OSDN Git Service

libext2fs: don't overflow when punching indirect blocks with large blocks
authorDarrick J. Wong <darrick.wong@oracle.com>
Thu, 12 Dec 2013 17:06:03 +0000 (12:06 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 12 Dec 2013 17:06:07 +0000 (12:06 -0500)
commit341bc5e368f7a768482f041971fb3c4b156d6ed9
tree7f16ded837c8bbceed1df458e265c8987a69541c
parent487c9e3016aeccaf87fcc69bb1aa5eb43e8297fb
libext2fs: don't overflow when punching indirect blocks with large blocks

On a FS with a rather large blockize (> 4K), the old block map
structure can construct a fat enough "tree" (or whatever we call that
lopsided thing) that (at least in theory) one could create mappings
for logical blocks higher than 32 bits.  In practice this doesn't
happen, but the 'max' and 'iter' variables that the punch helpers use
will overflow because the BLOCK_SIZE_BITS shifts are too large to fit
a 32-bit variable.  The current variable declarations also cause punch
to fail on TIND-mapped blocks even if the file is < 16T.  So enlarge
the fields to fit.

Yes, this is an obscure corner case, but it seems a little silly if we
can't punch a file's block 300,000,000 on a 64k-block filesystem.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lib/ext2fs/punch.c