From: Dave Kleikamp <dave.kleikamp@oracle.com>
To: Nickolai Zeldovich <nickolai@csail.mit.edu>
Cc: linux-kernel@vger.kernel.org, jfs-discussion@lists.sourceforge.net
Subject: Re: [PATCH] jfs: avoid undefined behavior from left-shifting by 32 bits
Date: Mon, 07 Jan 2013 08:33:36 -0600 [thread overview]
Message-ID: <50EADCC0.4070704@oracle.com> (raw)
In-Reply-To: <1357413561-42508-1-git-send-email-nickolai@csail.mit.edu>
On 01/05/2013 01:19 PM, Nickolai Zeldovich wrote:
> Shifting a 32-bit int by 32 bits is undefined behavior in C, and
> results in different behavior on different architectures (e.g., x86
> and PowerPC). diAlloc() in fs/jfs/jfs_imap.c computes a mask using
> 0xffffffffu<<(32-bitno), which can left-shift by 32 bits. To avoid
> unexpected behavior, explicitly check for bitno==0 and use a 0 mask.
Thanks. Pushed to
git://github.com/kleikamp/linux-shaggy.git jfs-next
Shaggy
>
> Signed-off-by: Nickolai Zeldovich <nickolai@csail.mit.edu>
> ---
> fs/jfs/jfs_imap.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/jfs/jfs_imap.c b/fs/jfs/jfs_imap.c
> index 6ba4006..f7e042b 100644
> --- a/fs/jfs/jfs_imap.c
> +++ b/fs/jfs/jfs_imap.c
> @@ -1493,7 +1493,7 @@ int diAlloc(struct inode *pip, bool dir, struct inode *ip)
> /* mask any prior bits for the starting words of the
> * summary map.
> */
> - mask = ONES << (EXTSPERSUM - bitno);
> + mask = (bitno == 0) ? 0 : (ONES << (EXTSPERSUM - bitno));
> inosmap = le32_to_cpu(iagp->inosmap[sword]) | mask;
> extsmap = le32_to_cpu(iagp->extsmap[sword]) | mask;
>
>
parent reply other threads:[~2013-01-07 14:33 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <1357413561-42508-1-git-send-email-nickolai@csail.mit.edu>]
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=50EADCC0.4070704@oracle.com \
--to=dave.kleikamp@oracle.com \
--cc=jfs-discussion@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=nickolai@csail.mit.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 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.