From patchwork Fri Dec 16 21:51:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 9478555 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D0C7E607EE for ; Fri, 16 Dec 2016 21:51:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C15AD2857C for ; Fri, 16 Dec 2016 21:51:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B584A2863C; Fri, 16 Dec 2016 21:51:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DFF3A28615 for ; Fri, 16 Dec 2016 21:51:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756714AbcLPVvt (ORCPT ); Fri, 16 Dec 2016 16:51:49 -0500 Received: from mail-pf0-f169.google.com ([209.85.192.169]:33620 "EHLO mail-pf0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758813AbcLPVvk (ORCPT ); Fri, 16 Dec 2016 16:51:40 -0500 Received: by mail-pf0-f169.google.com with SMTP id d2so15907475pfd.0 for ; Fri, 16 Dec 2016 13:51:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:mime-version:content-disposition; bh=+qTiQ9UHsvjTCW3dG55ukziq1YwCRTL2I1QVpZD7a4s=; b=mtXUBbfzWrncHey8aULvmurUOFaFQrKVVrcfFZHwU+h+X17IEY1yU9roQ1SMoeOxwc OtNAQqCgaFdxoH6utVUasuZM7/V6W5H096adW3yBIrpsHzWhe+7GuLmw+uqYxX3bCn+B /iO/taEfzdCa6SGTWWDfwqE1qQtLsycpSHqx8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=+qTiQ9UHsvjTCW3dG55ukziq1YwCRTL2I1QVpZD7a4s=; b=TIbopCMI/gH15l8GBQ92b/1ebsQXdsXINKBlRis7LmXs+4jZsldvLPRidpEGjJ6RHY YxhD93y3mMSgmtFgQWnRFI3P/8/WE19XfyjzNs/fP5NcmdVC8Z/HMgOJl3cauxR/4c3f 5yRiZgyopJpQRWVD0JcFsbmTF2xnzHDITPSOXRyVRFGPyou5yAHa7GDG41FVYswneexC 4jQ2464Bzmj9vTyWfOyAXeuKR2ybuvE18iNASWTMi8TRoVAF+gbT6ie8KIxgDT/0zeU7 KlplZK2HDBaOxZpGUrxzFWfLf10YYjAmvh8ixKYKhcQzRj8NPDUbLn0CIxD0oREt9Gq4 czgg== X-Gm-Message-State: AKaTC00NlQv1XViy+gzn655+G31f1wD1obfJQt+jYEi0FSXx+0orvdHBiaNj1bfMOm/QTqk9 X-Received: by 10.84.210.46 with SMTP id z43mr11186101plh.175.1481925098764; Fri, 16 Dec 2016 13:51:38 -0800 (PST) Received: from www.outflux.net (173-164-112-133-Oregon.hfc.comcastbusiness.net. [173.164.112.133]) by smtp.gmail.com with ESMTPSA id p5sm181838pgk.23.2016.12.16.13.51.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Dec 2016 13:51:38 -0800 (PST) Date: Fri, 16 Dec 2016 13:51:37 -0800 From: Kees Cook To: Robert Moore Cc: linux-kernel@vger.kernel.org, Lv Zheng , "Rafael J. Wysocki" , Len Brown , linux-acpi@vger.kernel.org, Emese Revfy , devel@acpica.org Subject: [PATCH] acpi: Fix format string type mistakes Message-ID: <20161216215137.GA96800@beast> MIME-Version: 1.0 Content-Disposition: inline Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Emese Revfy This adds the missing __printf attribute which allows compile time format string checking (and will be used by the coming initify gcc plugin). Additionally, this fixes the warnings exposed by the attribute. Signed-off-by: Emese Revfy [kees: split scsi/acpi, merged attr and fix, new commit messages] Signed-off-by: Kees Cook --- drivers/acpi/acpica/dbhistry.c | 2 +- drivers/acpi/acpica/dbinput.c | 10 ++--- drivers/acpi/acpica/dbstats.c | 88 +++++++++++++++++++++--------------------- drivers/acpi/acpica/utdebug.c | 2 +- include/acpi/acpiosxf.h | 3 +- 5 files changed, 53 insertions(+), 52 deletions(-) diff --git a/drivers/acpi/acpica/dbhistry.c b/drivers/acpi/acpica/dbhistry.c index 46bd65d38df9..ec9da4830f6a 100644 --- a/drivers/acpi/acpica/dbhistry.c +++ b/drivers/acpi/acpica/dbhistry.c @@ -155,7 +155,7 @@ void acpi_db_display_history(void) for (i = 0; i < acpi_gbl_num_history; i++) { if (acpi_gbl_history_buffer[history_index].command) { - acpi_os_printf("%3ld %s\n", + acpi_os_printf("%3u %s\n", acpi_gbl_history_buffer[history_index]. cmd_num, acpi_gbl_history_buffer[history_index]. diff --git a/drivers/acpi/acpica/dbinput.c b/drivers/acpi/acpica/dbinput.c index 068214f9cc9d..43be06bdb790 100644 --- a/drivers/acpi/acpica/dbinput.c +++ b/drivers/acpi/acpica/dbinput.c @@ -608,7 +608,7 @@ static u32 acpi_db_get_line(char *input_buffer) (acpi_gbl_db_parsed_buf, sizeof(acpi_gbl_db_parsed_buf), input_buffer)) { acpi_os_printf - ("Buffer overflow while parsing input line (max %u characters)\n", + ("Buffer overflow while parsing input line (max %lu characters)\n", sizeof(acpi_gbl_db_parsed_buf)); return (0); } @@ -864,24 +864,24 @@ acpi_db_command_dispatch(char *input_buffer, if (param_count == 0) { acpi_os_printf - ("Current debug level for file output is: %8.8lX\n", + ("Current debug level for file output is: %8.8X\n", acpi_gbl_db_debug_level); acpi_os_printf - ("Current debug level for console output is: %8.8lX\n", + ("Current debug level for console output is: %8.8X\n", acpi_gbl_db_console_debug_level); } else if (param_count == 2) { temp = acpi_gbl_db_console_debug_level; acpi_gbl_db_console_debug_level = strtoul(acpi_gbl_db_args[1], NULL, 16); acpi_os_printf - ("Debug Level for console output was %8.8lX, now %8.8lX\n", + ("Debug Level for console output was %8.8X, now %8.8X\n", temp, acpi_gbl_db_console_debug_level); } else { temp = acpi_gbl_db_debug_level; acpi_gbl_db_debug_level = strtoul(acpi_gbl_db_args[1], NULL, 16); acpi_os_printf - ("Debug Level for file output was %8.8lX, now %8.8lX\n", + ("Debug Level for file output was %8.8X, now %8.8X\n", temp, acpi_gbl_db_debug_level); } break; diff --git a/drivers/acpi/acpica/dbstats.c b/drivers/acpi/acpica/dbstats.c index a414e1fa6f9d..de7023024b12 100644 --- a/drivers/acpi/acpica/dbstats.c +++ b/drivers/acpi/acpica/dbstats.c @@ -377,17 +377,17 @@ acpi_status acpi_db_display_statistics(char *type_arg) "ACPI_TYPE", "NODES", "OBJECTS"); for (i = 0; i < ACPI_TYPE_NS_NODE_MAX; i++) { - acpi_os_printf("%16.16s % 10ld% 10ld\n", + acpi_os_printf("%16.16s % 10d% 10d\n", acpi_ut_get_type_name(i), acpi_gbl_node_type_count[i], acpi_gbl_obj_type_count[i]); } - acpi_os_printf("%16.16s % 10ld% 10ld\n", "Misc/Unknown", + acpi_os_printf("%16.16s % 10d% 10d\n", "Misc/Unknown", acpi_gbl_node_type_count_misc, acpi_gbl_obj_type_count_misc); - acpi_os_printf("%16.16s % 10ld% 10ld\n", "TOTALS:", + acpi_os_printf("%16.16s % 10d% 10d\n", "TOTALS:", acpi_gbl_num_nodes, acpi_gbl_num_objects); break; @@ -415,16 +415,16 @@ acpi_status acpi_db_display_statistics(char *type_arg) case CMD_STAT_MISC: acpi_os_printf("\nMiscellaneous Statistics:\n\n"); - acpi_os_printf("Calls to AcpiPsFind:.. ........% 7ld\n", + acpi_os_printf("Calls to AcpiPsFind:.. ........% 7u\n", acpi_gbl_ps_find_count); - acpi_os_printf("Calls to AcpiNsLookup:..........% 7ld\n", + acpi_os_printf("Calls to AcpiNsLookup:..........% 7u\n", acpi_gbl_ns_lookup_count); acpi_os_printf("\n"); acpi_os_printf("Mutex usage:\n\n"); for (i = 0; i < ACPI_NUM_MUTEX; i++) { - acpi_os_printf("%-28s: % 7ld\n", + acpi_os_printf("%-28s: % 7u\n", acpi_ut_get_mutex_name(i), acpi_gbl_mutex_info[i].use_count); } @@ -434,87 +434,87 @@ acpi_status acpi_db_display_statistics(char *type_arg) acpi_os_printf("\nInternal object sizes:\n\n"); - acpi_os_printf("Common %3d\n", + acpi_os_printf("Common %3lu\n", sizeof(struct acpi_object_common)); - acpi_os_printf("Number %3d\n", + acpi_os_printf("Number %3lu\n", sizeof(struct acpi_object_integer)); - acpi_os_printf("String %3d\n", + acpi_os_printf("String %3lu\n", sizeof(struct acpi_object_string)); - acpi_os_printf("Buffer %3d\n", + acpi_os_printf("Buffer %3lu\n", sizeof(struct acpi_object_buffer)); - acpi_os_printf("Package %3d\n", + acpi_os_printf("Package %3lu\n", sizeof(struct acpi_object_package)); - acpi_os_printf("BufferField %3d\n", + acpi_os_printf("BufferField %3lu\n", sizeof(struct acpi_object_buffer_field)); - acpi_os_printf("Device %3d\n", + acpi_os_printf("Device %3lu\n", sizeof(struct acpi_object_device)); - acpi_os_printf("Event %3d\n", + acpi_os_printf("Event %3lu\n", sizeof(struct acpi_object_event)); - acpi_os_printf("Method %3d\n", + acpi_os_printf("Method %3lu\n", sizeof(struct acpi_object_method)); - acpi_os_printf("Mutex %3d\n", + acpi_os_printf("Mutex %3lu\n", sizeof(struct acpi_object_mutex)); - acpi_os_printf("Region %3d\n", + acpi_os_printf("Region %3lu\n", sizeof(struct acpi_object_region)); - acpi_os_printf("PowerResource %3d\n", + acpi_os_printf("PowerResource %3lu\n", sizeof(struct acpi_object_power_resource)); - acpi_os_printf("Processor %3d\n", + acpi_os_printf("Processor %3lu\n", sizeof(struct acpi_object_processor)); - acpi_os_printf("ThermalZone %3d\n", + acpi_os_printf("ThermalZone %3lu\n", sizeof(struct acpi_object_thermal_zone)); - acpi_os_printf("RegionField %3d\n", + acpi_os_printf("RegionField %3lu\n", sizeof(struct acpi_object_region_field)); - acpi_os_printf("BankField %3d\n", + acpi_os_printf("BankField %3lu\n", sizeof(struct acpi_object_bank_field)); - acpi_os_printf("IndexField %3d\n", + acpi_os_printf("IndexField %3lu\n", sizeof(struct acpi_object_index_field)); - acpi_os_printf("Reference %3d\n", + acpi_os_printf("Reference %3lu\n", sizeof(struct acpi_object_reference)); - acpi_os_printf("Notify %3d\n", + acpi_os_printf("Notify %3lu\n", sizeof(struct acpi_object_notify_handler)); - acpi_os_printf("AddressSpace %3d\n", + acpi_os_printf("AddressSpace %3lu\n", sizeof(struct acpi_object_addr_handler)); - acpi_os_printf("Extra %3d\n", + acpi_os_printf("Extra %3lu\n", sizeof(struct acpi_object_extra)); - acpi_os_printf("Data %3d\n", + acpi_os_printf("Data %3lu\n", sizeof(struct acpi_object_data)); acpi_os_printf("\n"); - acpi_os_printf("ParseObject %3d\n", + acpi_os_printf("ParseObject %3lu\n", sizeof(struct acpi_parse_obj_common)); - acpi_os_printf("ParseObjectNamed %3d\n", + acpi_os_printf("ParseObjectNamed %3lu\n", sizeof(struct acpi_parse_obj_named)); - acpi_os_printf("ParseObjectAsl %3d\n", + acpi_os_printf("ParseObjectAsl %3lu\n", sizeof(struct acpi_parse_obj_asl)); - acpi_os_printf("OperandObject %3d\n", + acpi_os_printf("OperandObject %3lu\n", sizeof(union acpi_operand_object)); - acpi_os_printf("NamespaceNode %3d\n", + acpi_os_printf("NamespaceNode %3lu\n", sizeof(struct acpi_namespace_node)); - acpi_os_printf("AcpiObject %3d\n", + acpi_os_printf("AcpiObject %3lu\n", sizeof(union acpi_object)); acpi_os_printf("\n"); - acpi_os_printf("Generic State %3d\n", + acpi_os_printf("Generic State %3lu\n", sizeof(union acpi_generic_state)); - acpi_os_printf("Common State %3d\n", + acpi_os_printf("Common State %3lu\n", sizeof(struct acpi_common_state)); - acpi_os_printf("Control State %3d\n", + acpi_os_printf("Control State %3lu\n", sizeof(struct acpi_control_state)); - acpi_os_printf("Update State %3d\n", + acpi_os_printf("Update State %3lu\n", sizeof(struct acpi_update_state)); - acpi_os_printf("Scope State %3d\n", + acpi_os_printf("Scope State %3lu\n", sizeof(struct acpi_scope_state)); - acpi_os_printf("Parse Scope %3d\n", + acpi_os_printf("Parse Scope %3lu\n", sizeof(struct acpi_pscope_state)); - acpi_os_printf("Package State %3d\n", + acpi_os_printf("Package State %3lu\n", sizeof(struct acpi_pkg_state)); - acpi_os_printf("Thread State %3d\n", + acpi_os_printf("Thread State %3lu\n", sizeof(struct acpi_thread_state)); - acpi_os_printf("Result Values %3d\n", + acpi_os_printf("Result Values %3lu\n", sizeof(struct acpi_result_values)); - acpi_os_printf("Notify Info %3d\n", + acpi_os_printf("Notify Info %3lu\n", sizeof(struct acpi_notify_info)); break; diff --git a/drivers/acpi/acpica/utdebug.c b/drivers/acpi/acpica/utdebug.c index 044df9b0356e..b4cdb9c14a87 100644 --- a/drivers/acpi/acpica/utdebug.c +++ b/drivers/acpi/acpica/utdebug.c @@ -189,7 +189,7 @@ acpi_debug_print(u32 requested_debug_level, * Display the module name, current line number, thread ID (if requested), * current procedure nesting level, and the current procedure name */ - acpi_os_printf("%9s-%04ld ", module_name, line_number); + acpi_os_printf("%9s-%04u ", module_name, line_number); #ifdef ACPI_APPLICATION /* diff --git a/include/acpi/acpiosxf.h b/include/acpi/acpiosxf.h index f3414c83abb1..48b21490bbeb 100644 --- a/include/acpi/acpiosxf.h +++ b/include/acpi/acpiosxf.h @@ -337,11 +337,12 @@ acpi_status acpi_os_signal(u32 function, void *info); * Debug print routines */ #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_printf +__printf(1, 2) void ACPI_INTERNAL_VAR_XFACE acpi_os_printf(const char *format, ...); #endif #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_vprintf -void acpi_os_vprintf(const char *format, va_list args); +__printf(1, 0) void acpi_os_vprintf(const char *format, va_list args); #endif #ifndef ACPI_USE_ALTERNATE_PROTOTYPE_acpi_os_redirect_output