Message ID | 20221116152258.28772-1-skhan@linuxfoundation.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp201173wru; Wed, 16 Nov 2022 07:24:35 -0800 (PST) X-Google-Smtp-Source: AA0mqf7sCTDp3zBtqtAruWpZYelNQht+2V7VqpRelvCIR++o9lnYVu3QbCdkJ1WAEDnwJqRX+1XQ X-Received: by 2002:a17:902:f549:b0:188:5c0c:7590 with SMTP id h9-20020a170902f54900b001885c0c7590mr9763115plf.65.1668612275014; Wed, 16 Nov 2022 07:24:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668612275; cv=none; d=google.com; s=arc-20160816; b=EhmeB+rXW/gHcGk/QehnZmUTOSQe7rzt7yp2SybqEha8HC4g6SFPFlHxzcVUPC+qgz t1XsEllXANwBvmW0vYWQlQ+Rc2hZKdJdNQPWnRGV4PoOxKMs2vp8pgwUp3+kpW3UxFwh g3KUKsXMt++DvN8yxqdeVMDBfCPSs3hBkEyHxI39tHX8YUIXjj6Puwz2tIXTyL0ryO4U TKCvFAwUCXeegFvpg6Ps7DQ/9AdkljcB1aT30TPyT787AzuMrT1cX27zAw22QnpdKoCQ UbiFC7/SQGnVg/hR6ofUME2X4xbUdwK1T/mI5WbVCik4GxcTdaFQDq9RPmkAEpwCFV2k xBjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=Ixv3Fmx1mnew0WeMfI1+VxxOz2mqpaE/UA185d2bGDg=; b=GdmvMUDSZf64QTUhSxW5J47/CwNqtgHfOO7QPkyb3zWS9gpPQyJ8yfcrniJaYtCyEl D4/sJBpECDTE/wh/tF8mNLJufpgsC+OkLpN5067pVEJEjhmwStzMT6X+oAAdyG4ucGC7 sYP6c+o44QOAf5tDO47laDy7i5dNVDgRIYPHBMynhAz4lZjCCMkKXiqaZVNvO+HxUsme mxhqFZWBY0ljdrKDxY9dC05zJqIiK8dpF14ZDLl9/c0ysL0BYiyjoagJsDhNXJzmporC ovh6+l5w86EwDNlbKsd1M3veI2H9c0Vr8Se+nMbRqhF5Fu3fjBRsLE04kZJjBLlK0xfY HQ0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=Wgmy6ylQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 189-20020a6301c6000000b00476caa56d0esi4329979pgb.739.2022.11.16.07.24.15; Wed, 16 Nov 2022 07:24:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=Wgmy6ylQ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234459AbiKPPXL (ORCPT <rfc822;just.gull.subs@gmail.com> + 99 others); Wed, 16 Nov 2022 10:23:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233489AbiKPPXC (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 16 Nov 2022 10:23:02 -0500 Received: from mail-il1-x129.google.com (mail-il1-x129.google.com [IPv6:2607:f8b0:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A3E14FF92 for <linux-kernel@vger.kernel.org>; Wed, 16 Nov 2022 07:23:01 -0800 (PST) Received: by mail-il1-x129.google.com with SMTP id q5so9274883ilt.13 for <linux-kernel@vger.kernel.org>; Wed, 16 Nov 2022 07:23:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Ixv3Fmx1mnew0WeMfI1+VxxOz2mqpaE/UA185d2bGDg=; b=Wgmy6ylQ7twJ7OvN1+vXvfWhy99X1ngOvzqefyA2DCYaaIKA6BBjvEYmD9H7qNLhCU m5lse8o672fAKzs5LjJzSE1O/zlon7XRT6St9bECgOhbBAeqhavtH/v5us4idJACpXO0 kSuLQDPwt2n2VfOozwNXpcuIQi7VBuTYD1kQY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Ixv3Fmx1mnew0WeMfI1+VxxOz2mqpaE/UA185d2bGDg=; b=OO92UFCuxPwwWvA8aLUM9PNGiMTdgmLloyLPWuOlq+T7DeNbLTiNF/xmmWQ6N6fl3/ C6HgHwL7vM3A9IXG7FU0XUvxwjO8ln48kZ2btAzzOrgsPPKy6eFAVmvALt1HiRrMq15F 9DGyBuUcmPwJErrlXS+uuvCttdJNODMi5+gfjUhU4/LRfSjjyWMS1xH0KVMFacgn/6Er WbHd6KcLLHBIH5stCLNUF2C/Tovpq6AmgbdqTSm04UQ2RLkll/GSaSaXjZt4NXg1fZYd Od7GgByunNk+h6Llq8yLtrMJnG7FRQ7gi1gS9MzXWAamPRzhI9qQjF3zB2UJhv8axyno RwQA== X-Gm-Message-State: ANoB5plBGfLderwutx9N9Xs4G/nEEpH6fiCDG30TJKs/a5DhGJGw+bYn c7k2qTBmr5hzbgoe1kXwo3+m8g== X-Received: by 2002:a92:c889:0:b0:2fd:1880:7f6e with SMTP id w9-20020a92c889000000b002fd18807f6emr10672589ilo.227.1668612180698; Wed, 16 Nov 2022 07:23:00 -0800 (PST) Received: from shuah-tx13.internal ([38.15.45.1]) by smtp.gmail.com with ESMTPSA id r4-20020a92c5a4000000b002fc681a6ad8sm6323228ilt.78.2022.11.16.07.22.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Nov 2022 07:23:00 -0800 (PST) From: Shuah Khan <skhan@linuxfoundation.org> To: robert.moore@intel.com, rafael.j.wysocki@intel.com, lenb@kernel.org Cc: Shuah Khan <skhan@linuxfoundation.org>, linux-acpi@vger.kernel.org, devel@acpica.org, linux-kernel@vger.kernel.org Subject: [PATCH] ACPICA: Fix sprintf() INT_MAX -Wformat-truncation= warn Date: Wed, 16 Nov 2022 08:22:58 -0700 Message-Id: <20221116152258.28772-1-skhan@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749666784821706183?= X-GMAIL-MSGID: =?utf-8?q?1749666784821706183?= |
Series |
ACPICA: Fix sprintf() INT_MAX -Wformat-truncation= warn
|
|
Commit Message
Shuah Khan
Nov. 16, 2022, 3:22 p.m. UTC
utprint module is included in tools/acpidump and when acpidump is built,
the following warning occurs.
CC tools/acpidump/utprint.o
/usr/include/x86_64-linux-gnu/bits/stdio2.h: In function ‘sprintf’:
../../../../../drivers/acpi/acpica/utprint.c:602:18: warning: specified bound 4294901760 exceeds ‘INT_MAX’ [-Wformat-truncation=]
602 | length = vsnprintf(string, ACPI_UINT32_MAX-ACPI_UINT16_MAX,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
603 | format, args);
| ~~~~~~~~~~~~~
Fix sprintf() to use ACPI_UINT32_MAX/2 to get rid of the truncate problem.
This change is inline other sprintf() implementations.
If using ACPI_UINT32_MAX is necessary in the kernel, acpidump might require
special case to get rid of this truncate problem.
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
---
drivers/acpi/acpica/utprint.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Wed, Nov 16, 2022 at 4:23 PM Shuah Khan <skhan@linuxfoundation.org> wrote: > > utprint module is included in tools/acpidump and when acpidump is built, > the following warning occurs. > > CC tools/acpidump/utprint.o > /usr/include/x86_64-linux-gnu/bits/stdio2.h: In function ‘sprintf’: > ../../../../../drivers/acpi/acpica/utprint.c:602:18: warning: specified bound 4294901760 exceeds ‘INT_MAX’ [-Wformat-truncation=] > 602 | length = vsnprintf(string, ACPI_UINT32_MAX-ACPI_UINT16_MAX, > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > 603 | format, args); > | ~~~~~~~~~~~~~ > > Fix sprintf() to use ACPI_UINT32_MAX/2 to get rid of the truncate problem. > This change is inline other sprintf() implementations. > > If using ACPI_UINT32_MAX is necessary in the kernel, acpidump might require > special case to get rid of this truncate problem. As ACPICA material, this should be submitted to the upstream project on GitHub and honestly I'm not sure if it is going to be resolved this way there. > Signed-off-by: Shuah Khan <skhan@linuxfoundation.org> > --- > drivers/acpi/acpica/utprint.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/acpi/acpica/utprint.c b/drivers/acpi/acpica/utprint.c > index d5aa2109847f..02cff16c8f77 100644 > --- a/drivers/acpi/acpica/utprint.c > +++ b/drivers/acpi/acpica/utprint.c > @@ -599,7 +599,7 @@ int sprintf(char *string, const char *format, ...) > int length; > > va_start(args, format); > - length = vsnprintf(string, ACPI_UINT32_MAX, format, args); > + length = vsnprintf(string, ACPI_UINT32_MAX/2, format, args); > va_end(args); > > return (length); > -- > 2.34.1 >
On 11/16/22 12:05, Rafael J. Wysocki wrote: > On Wed, Nov 16, 2022 at 4:23 PM Shuah Khan <skhan@linuxfoundation.org> wrote: >> >> utprint module is included in tools/acpidump and when acpidump is built, >> the following warning occurs. >> >> CC tools/acpidump/utprint.o >> /usr/include/x86_64-linux-gnu/bits/stdio2.h: In function ‘sprintf’: >> ../../../../../drivers/acpi/acpica/utprint.c:602:18: warning: specified bound 4294901760 exceeds ‘INT_MAX’ [-Wformat-truncation=] >> 602 | length = vsnprintf(string, ACPI_UINT32_MAX-ACPI_UINT16_MAX, >> | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ >> 603 | format, args); >> | ~~~~~~~~~~~~~ >> >> Fix sprintf() to use ACPI_UINT32_MAX/2 to get rid of the truncate problem. >> This change is inline other sprintf() implementations. >> >> If using ACPI_UINT32_MAX is necessary in the kernel, acpidump might require >> special case to get rid of this truncate problem. > > As ACPICA material, this should be submitted to the upstream project > on GitHub and honestly I'm not sure if it is going to be resolved this > way there. Thank you for your review. I will send this ACPICA upstream project. thanks, -- Shuah
diff --git a/drivers/acpi/acpica/utprint.c b/drivers/acpi/acpica/utprint.c index d5aa2109847f..02cff16c8f77 100644 --- a/drivers/acpi/acpica/utprint.c +++ b/drivers/acpi/acpica/utprint.c @@ -599,7 +599,7 @@ int sprintf(char *string, const char *format, ...) int length; va_start(args, format); - length = vsnprintf(string, ACPI_UINT32_MAX, format, args); + length = vsnprintf(string, ACPI_UINT32_MAX/2, format, args); va_end(args); return (length);