[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <1945505398.1250534.1343730754291.JavaMail.root@redhat.com>
Date: Tue, 31 Jul 2012 06:32:34 -0400 (EDT)
From: Tomas Racek <tracek@...hat.com>
To: Dave Chinner <david@...morbit.com>
Cc: Alex Elder <elder@...nel.org>,
open list <linux-kernel@...r.kernel.org>,
"supporter:XFS FILESYSTEM" <xfs@....sgi.com>,
linux-xfs@...r.kernel.org, Ben Myers <bpm@....com>,
lczerner@...hat.com
Subject: Re: [PATCH 1/1] xfs: check for possible overflow in xfs_ioc_trim
> > +
> > + if (range.start > ULLONG_MAX - BBSIZE)
> > + return -XFS_ERROR(EINVAL);
> > +
>
> There's no point checking for overflow on the range start - what we
> need to check is whether it is larger than the size of the
> filesystem. We do that after the conversion of range.start to basic
> blocks, so that check needs to be promoted to before this. i.e.
>
> if (range.start >= XFS_FSB_TO_B(mp, mp->m_sb.sb_dblocks))
> return -XFS_ERROR(EINVAL);
>
> > start = BTOBB(range.start);
> > end = start + BTOBBT(range.len) - 1;
> > minlen = BTOBB(max_t(u64, granularity, range.minlen));
>
> And that will prevent the overflow in BTOBB() just as effectively...
You're right, that's a far better way, I'll change it so.
Thanks!
Tomas
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists