linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: john.hubbard@gmail.com
To: "H . Peter Anvin" <hpa@zytor.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	x86@kernel.org, LKML <linux-kernel@vger.kernel.org>,
	John Hubbard <jhubbard@nvidia.com>
Subject: [PATCH 0/1] x86/boot: clear some fields explicitly
Date: Wed, 24 Jul 2019 16:15:27 -0700	[thread overview]
Message-ID: <20190724231528.32381-1-jhubbard@nvidia.com> (raw)

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


             reply	other threads:[~2019-07-24 23:15 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-24 23:15 john.hubbard [this message]
2019-07-24 23:15 ` [PATCH 1/1] x86/boot: clear some fields explicitly 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190724231528.32381-1-jhubbard@nvidia.com \
    --to=john.hubbard@gmail.com \
    --cc=bp@alien8.de \
    --cc=hpa@zytor.com \
    --cc=jhubbard@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).