mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Scotty Bauer <sbauer@eng.utah.edu>
Cc: linux-kernel@vger.kernel.org, clemens@ladisch.de
Subject: Re: [PATCH] kern/sys: Compat sysinfo syscall fix undefined behavior
Date: Thu, 4 Sep 2014 13:14:08 -0700	[thread overview]
Message-ID: <20140904131408.5b50c44315263c497ac7d818@linux-foundation.org> (raw)
In-Reply-To: <5408B39D.4030400@eng.utah.edu>

On Thu, 04 Sep 2014 12:46:53 -0600 Scotty Bauer <sbauer@eng.utah.edu> wrote:

> Fix undefined behavior and compiler warning by replacing right
> shift 32 with upper_32_bits macro
> 
> Signed-off-by: Scotty Bauer <sbauer@eng.utah.edu>
> ---
>  kernel/sys.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/sys.c b/kernel/sys.c
> index ce81291..c78530b 100644
> --- a/kernel/sys.c
> +++ b/kernel/sys.c
> @@ -2135,7 +2135,7 @@ COMPAT_SYSCALL_DEFINE1(sysinfo, struct compat_sysinfo __user *, info)
>  	/* Check to see if any memory value is too large for 32-bit and scale
>  	 *  down if needed
>  	 */
> -	if ((s.totalram >> 32) || (s.totalswap >> 32)) {
> +	if (upper_32_bits(s.totalram) || upper_32_bits(s.totalswap)) {
>  		int bitcount = 0;
>  
>  		while (s.mem_unit < PAGE_SIZE) {

Fair enough.

If I'm reading it correctly, this is all dead code because si_meminfo()
unconditionally sets sysinfo.mem_unit to PAGE_SIZE.

It could all do with a bit of a cleanup, I suspect.

  reply	other threads:[~2014-09-04 20:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-04 18:46 Scotty Bauer
2014-09-04 20:14 ` Andrew Morton [this message]
2014-09-04 20:35   ` Scotty Bauer

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=20140904131408.5b50c44315263c497ac7d818@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=clemens@ladisch.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sbauer@eng.utah.edu \
    /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

all inboxes | Powered by JetHome®