All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/1] x86/boot: clear some fields explicitly
@ 2019-07-24 23:15 john.hubbard
  2019-07-24 23:15 ` [PATCH 1/1] " john.hubbard
  0 siblings, 1 reply; 16+ messages in thread
From: john.hubbard @ 2019-07-24 23:15 UTC (permalink / raw)
  To: H . Peter Anvin
  Cc: Thomas Gleixner, Ingo Molnar, Borislav Petkov, x86, LKML, John Hubbard

From: John Hubbard <jhubbard@nvidia.com>

Hi,

I just ran across this on the latest (well, any -rc1) linux.git, while
working on something else. It generates an ugly multiline warning:

In file included from arch/x86/kernel/head64.c:35:
In function ?sanitize_boot_params?,
    inlined from ?copy_bootdata? at arch/x86/kernel/head64.c:391:2:
./arch/x86/include/asm/bootparam_utils.h:40:3: warning:
?memset? offset [197, 448] from the object at ?boot_params? is out
of the bounds of referenced subobject ?ext_ramdisk_image? with type
?unsigned int? at offset 192 [-Warray-bounds]
   40 |   memset(&boot_params->ext_ramdisk_image, 0,
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   41 |          (char *)&boot_params->efi_info -
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   42 |    (char *)&boot_params->ext_ramdisk_image);
      |    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./arch/x86/include/asm/bootparam_utils.h:43:3: warning: ?memset?
offset [493, 497] from the object at ?boot_params? is out of the
bounds of referenced subobject ?kbd_status? with type
?unsigned char? at offset 491 [-Warray-bounds]
   43 |   memset(&boot_params->kbd_status, 0,
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   44 |          (char *)&boot_params->hdr -
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~
   45 |          (char *)&boot_params->kbd_status);
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

It looks like this hasn't been touched since 2013, so maybe gcc is
just getting more agressive about warnings. Well, we know it is, actually.

Because struct boot_params is __packed__, normal variable
variable assignment will work just as well as a memset here.
Change three u32 fields to be cleared to zero that way, and
just memset the _pad4 field.

This clears up the build warnings for me.

Testing: just did a basic boot test on my x86_64 machine, no problems
seen. Not that that tests much, but it's something.

John Hubbard (1):
  x86/boot: clear some fields explicitly

 arch/x86/include/asm/bootparam_utils.h | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

-- 
2.22.0


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2019-07-26  7:43 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-24 23:15 [PATCH 0/1] x86/boot: clear some fields explicitly john.hubbard
2019-07-24 23:15 ` [PATCH 1/1] " john.hubbard
2019-07-25  2:12   ` hpa
2019-07-25  6:49     ` John Hubbard
2019-07-25  7:22     ` Thomas Gleixner
2019-07-25 20:33       ` John Hubbard
2019-07-25 21:48         ` Thomas Gleixner
2019-07-25 21:57           ` hpa
2019-07-25 22:03             ` Thomas Gleixner
2019-07-25 22:28               ` H. Peter Anvin
2019-07-25 22:37                 ` Thomas Gleixner
2019-07-26  0:36                   ` John Hubbard
2019-07-25 22:42                 ` John Hubbard
2019-07-26  7:43                   ` Thomas Gleixner
2019-07-25 20:38       ` H. Peter Anvin
2019-07-25 20:44         ` John Hubbard

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.