Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1695431
| From | Arnd Bergmann <arnd@arndb.de> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH 2/2] platform/x86: alienware-wmi: fix format string overflow warning |
| Date | 2017-07-25 09:30 +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> |
| Organization | linux.* mail to news gateway |
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 | Next — Previous in thread | Next in thread | Find similar | Unroll 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