Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1695431

Re: [PATCH 2/2] platform/x86: alienware-wmi: fix format string overflow warning

Path csiph.com!news.mixmin.net!news.unit0.net!news.panservice.it!bofh.it!news.nic.it!robomod
From Arnd Bergmann <arnd@arndb.de>
Newsgroups linux.kernel
Subject Re: [PATCH 2/2] platform/x86: alienware-wmi: fix format string overflow warning
Date Tue, 25 Jul 2017 09:30:02 +0200
Message-ID <u72s2-8ic-9@gated-at.bofh.it> (permalink)
References <u5mbv-1jG-5@gated-at.bofh.it> <u5mbv-1jG-17@gated-at.bofh.it> <u6HQB-2Si-7@gated-at.bofh.it>
X-Original-To Andy Shevchenko <andy.shevchenko@gmail.com>
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=vQ1EetGj/YAR4GsUFcRO9WEU90H+nVwltANpqr3w7rU=; b=hSMUqj1DllgIKZVDYUfaV/pdenLXhXFg4eu55WBPkS+G7+OQnTOuDNj0adngzQj+6I RNOawABUSTZ5WN70D4UUsRV2O3t9xipFKiCMxlkC+jjiZI9W38LvJXdSSGLeZcIrlWNO PfrImtmPo2b68A8slJRTkVsp5DXPmZMDRJ9sBzlPH7UoQd2O2hBdhbDIZvxSLabhKqKp KSn8ipcCdQOBUgFKbLh3WkcNsqoP9d3DGQ5PP5ZnKVFDXTskHq61RbWwgPfx2Kt1z7ro BdBTj2J8i3XHrJr4Mqpn6VFopXrm0O01OsX27rQoM4QmGsxR7WD2C4YPLukLnHTEk2uV wdpg==
X-Google-Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=vQ1EetGj/YAR4GsUFcRO9WEU90H+nVwltANpqr3w7rU=; b=LBIlHNwoI4GtiELatB3vAUwsSyuwqafGPFdHfYNb/T4oU+y5CQAw2CxrrL+LNAqRxN qWVEMEoIcIsJrY5Gje53ygVcTpUM74lhlm4P2QGx6QhMyZSTt30o7qm8Am5oNe5EHb7H QO3M9HUWGlJsOKdFrlCBAQZaq0G4/b71nDQq6YbU3uiH6Iz1Go91ugIYXhQS18yC/FXV ZUJDsibKWKmnfKvgboz4RIUOr410UfMJ/rUZ6foHxAf7cb+uzLDrd5/IpGAbnIZuPCXZ wkndWYU7r5rYBmop6qSoiQQMY9gRQDFz9YYMGip6tOvfbl/CZf4u952m1B/71styfrSX Z2SQ==
X-Gm-Message-State AIVw113dkDueNnjEPxGAo+eknR0O+Eo4aBB/Vv3AQ8X4EtywzNMWedC+ 78R7gWybknD7khjmqqXpmEIpGTU14KNE
X-Received by 10.202.216.3 with SMTP id p3mr9925241oig.55.1500967417151; Tue, 25 Jul 2017 00:23:37 -0700 (PDT)
MIME-Version 1.0
X-Google-Sender-Auth v0e1eCtZmbyu2_Bc63VPlF9v_o0
Content-Type text/plain; charset="UTF-8"
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 36
Organization linux.* mail to news gateway
X-Original-Cc Darren Hart <dvhart@infradead.org>, Andy Shevchenko <andy@infradead.org>, Platform Driver <platform-driver-x86@vger.kernel.org>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, gregkh <gregkh@linuxfoundation.org>
X-Original-Date Tue, 25 Jul 2017 09:23:36 +0200
X-Original-Message-ID <CAK8P3a3nHzpeRfKa3Ac9+qxEm1EdSUaUqAr_0G9+-NXZs4d34Q@mail.gmail.com>
X-Original-References <20170720160114.3261176-1-arnd@arndb.de> <20170720160114.3261176-2-arnd@arndb.de> <CAHp75VcEaqoESA_JPtV28E4emE5JTzd4t2SVLxYcn=spFzhBmA@mail.gmail.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1695431

Show key headers only | View raw


On Mon, Jul 24, 2017 at 11:22 AM, Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
> On Thu, Jul 20, 2017 at 7:00 PM, Arnd Bergmann <arnd@arndb.de> wrote:
>> gcc points out a possible format string overflow for a large value of 'zone':
>>
>> drivers/platform/x86/alienware-wmi.c: In function 'alienware_wmi_init':
>> drivers/platform/x86/alienware-wmi.c:461:24: error: '%02X' directive writing between 2 and 8 bytes into a region of size 6 [-Werror=format-overflow=]
>>    sprintf(buffer, "zone%02X", i);
>>                         ^~~~
>> drivers/platform/x86/alienware-wmi.c:461:19: note: directive argument in the range [0, 2147483646]
>>    sprintf(buffer, "zone%02X", i);
>>                    ^~~~~~~~~~
>> drivers/platform/x86/alienware-wmi.c:461:3: note: 'sprintf' output between 7 and 13 bytes into a destination of size 10
>>
>> This replaces the 'int' variable with an 'u8' to make sure
>> it always fits, renaming the variable to 'zone' for clarity.
>>
>> Unfortunately, gcc-7.1.1 still warns about it with that change, which
>> seems to be unintended by the gcc developers. I have opened a bug
>> against gcc with a reduced test case. As a workaround, I also
>> change the format string to use "%02hhX", which shuts up the
>> warning in that version.
>>
>
> Thanks, pushed to testing with slight change (+ empty lines after u8
> zone; where it's applicable).
> I'm not going to move this to fixes queue since it looks to me not
> critical at all. Drop me a message if you think otherwise.

Sounds good, thanks! This instance is harmless, and the warning is now
globally disabled in stable kernels (and in mainline). I plan to send a patch
to re-enable the warning in mainline once all the other instances are
addressed.  I don't think that Greg will backport that patch, but if he does,
then he may need some additional 30 patches besides this one.

          Arnd

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 1/2] platform/x86: peaq-wmi: select INPUT_POLLDEV Arnd Bergmann <arnd@arndb.de> - 2017-07-20 18:10 +0200
  [PATCH 2/2] platform/x86: alienware-wmi: fix format string overflow warning Arnd Bergmann <arnd@arndb.de> - 2017-07-20 18:10 +0200
    Re: [PATCH 2/2] platform/x86: alienware-wmi: fix format string  overflow warning Andy Shevchenko <andy.shevchenko@gmail.com> - 2017-07-24 11:30 +0200
      Re: [PATCH 2/2] platform/x86: alienware-wmi: fix format string  overflow warning Arnd Bergmann <arnd@arndb.de> - 2017-07-25 09:30 +0200
  Re: [PATCH 1/2] platform/x86: peaq-wmi: select INPUT_POLLDEV Darren Hart <dvhart@infradead.org> - 2017-07-21 02:10 +0200

csiph-web