From: Brian Foster <bfoster@redhat.com>
To: Eric Sandeen <sandeen@sandeen.net>
Cc: xfs@oss.sgi.com
Subject: Re: [PATCH 4/4] xfs_repair: fix left-shift overflows
Date: Fri, 9 Oct 2015 09:24:45 -0400 [thread overview]
Message-ID: <20151009132444.GE27982@bfoster.bfoster> (raw)
In-Reply-To: <561709E9.3000406@sandeen.net>
On Thu, Oct 08, 2015 at 07:27:21PM -0500, Eric Sandeen wrote:
> pmask in struct parent_list is a __uint64_t, but in some places
> we populated it with "1LL << shift" where shift could be up
> to 63; this really needs to be a 1ULL type for this to be correct.
>
> Also spotted by libubsan...
>
> The code in prefetch.c has another issue with large fs blocks
> (32 or 64k) because it shifts by up to 128 bits, but that's left
> for later...
>
> Signed-off-by: Eric Sandeen <sandeen@redhat.com>
> ---
Reviewed-by: Brian Foster <bfoster@redhat.com>
> repair/incore_ino.c | 14 +++++++-------
> repair/prefetch.c | 2 +-
> 2 files changed, 8 insertions(+), 8 deletions(-)
>
> diff --git a/repair/incore_ino.c b/repair/incore_ino.c
> index 32d7678..1898257 100644
> --- a/repair/incore_ino.c
> +++ b/repair/incore_ino.c
> @@ -625,7 +625,7 @@ set_inode_parent(
> else
> irec->ino_un.plist = ptbl;
>
> - ptbl->pmask = 1LL << offset;
> + ptbl->pmask = 1ULL << offset;
> ptbl->pentries = (xfs_ino_t*)memalign(sizeof(xfs_ino_t),
> sizeof(xfs_ino_t));
> if (!ptbl->pentries)
> @@ -638,8 +638,8 @@ set_inode_parent(
> return;
> }
>
> - if (ptbl->pmask & (1LL << offset)) {
> - bitmask = 1LL;
> + if (ptbl->pmask & (1ULL << offset)) {
> + bitmask = 1ULL;
> target = 0;
>
> for (i = 0; i < offset; i++) {
> @@ -655,7 +655,7 @@ set_inode_parent(
> return;
> }
>
> - bitmask = 1LL;
> + bitmask = 1ULL;
> cnt = target = 0;
>
> for (i = 0; i < XFS_INODES_PER_CHUNK; i++) {
> @@ -691,7 +691,7 @@ set_inode_parent(
> ptbl->cnt++;
> #endif
> ptbl->pentries[target] = parent;
> - ptbl->pmask |= (1LL << offset);
> + ptbl->pmask |= (1ULL << offset);
> }
>
> xfs_ino_t
> @@ -707,8 +707,8 @@ get_inode_parent(ino_tree_node_t *irec, int offset)
> else
> ptbl = irec->ino_un.plist;
>
> - if (ptbl->pmask & (1LL << offset)) {
> - bitmask = 1LL;
> + if (ptbl->pmask & (1ULL << offset)) {
> + bitmask = 1ULL;
> target = 0;
>
> for (i = 0; i < offset; i++) {
> diff --git a/repair/prefetch.c b/repair/prefetch.c
> index 52238ca..b11dcb3 100644
> --- a/repair/prefetch.c
> +++ b/repair/prefetch.c
> @@ -762,7 +762,7 @@ pf_queuing_worker(
> * sparse state in cluster sized chunks as cluster size
> * is the min. granularity of sparse irec regions.
> */
> - if ((sparse & ((1 << inodes_per_cluster) - 1)) == 0)
> + if ((sparse & ((1ULL << inodes_per_cluster) - 1)) == 0)
> pf_queue_io(args, &map, 1,
> (cur_irec->ino_isa_dir != 0) ?
> B_DIR_INODE : B_INODE);
> --
> 1.7.1
>
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
prev parent reply other threads:[~2015-10-09 13:24 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-09 0:23 [PATCH 0/4] fix (mostly) minor nits spotted by gcc sanitization Eric Sandeen
2015-10-09 0:24 ` [PATCH 1/4] libxfs: avoid negative (and full-width) shifts in radix-tree.c Eric Sandeen
2015-10-09 13:23 ` Brian Foster
2015-10-09 0:25 ` [PATCH 2/4] xfs_repair: fix unaligned accesses Eric Sandeen
2015-10-09 13:24 ` Brian Foster
2015-10-09 14:03 ` Eric Sandeen
2015-10-11 22:26 ` Dave Chinner
2015-10-12 1:33 ` Eric Sandeen
2015-10-12 21:31 ` Eric Sandeen
2015-10-12 21:45 ` Dave Chinner
2015-10-13 0:32 ` Dave Chinner
2015-10-09 0:25 ` [PATCH 3/4] xfs_logprint: fix some " Eric Sandeen
2015-10-09 13:24 ` Brian Foster
2015-10-09 13:48 ` Eric Sandeen
2015-10-09 0:27 ` [PATCH 4/4] xfs_repair: fix left-shift overflows Eric Sandeen
2015-10-09 13:24 ` Brian Foster [this message]
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=20151009132444.GE27982@bfoster.bfoster \
--to=bfoster@redhat.com \
--cc=sandeen@sandeen.net \
--cc=xfs@oss.sgi.com \
/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