Skip to content
Snippets Groups Projects
Commit 948ca5f3 authored by Eric Whitney's avatar Eric Whitney Committed by Theodore Ts'o
Browse files

ext4: enforce buffer head state assertion in ext4_da_map_blocks


Remove the code that re-initializes a buffer head with an invalid block
number and BH_New and BH_Delay bits when a matching delayed and
unwritten block has been found in the extent status cache. Replace it
with assertions that verify the buffer head already has this state
correctly set.  The current code masked an inline data truncation bug
that left stale entries in the extent status cache.  With this change,
generic/130 can be used to reproduce and detect that bug.

Signed-off-by: default avatarEric Whitney <enwlinux@gmail.com>
Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
Link: https://lore.kernel.org/r/20210819144927.25163-3-enwlinux@gmail.com


Signed-off-by: default avatarTheodore Ts'o <tytso@mit.edu>
parent 0add491d
Branches
Tags
No related merge requests found
...@@ -1706,13 +1706,16 @@ static int ext4_da_map_blocks(struct inode *inode, sector_t iblock, ...@@ -1706,13 +1706,16 @@ static int ext4_da_map_blocks(struct inode *inode, sector_t iblock,
} }
/* /*
* Delayed extent could be allocated by fallocate. * the buffer head associated with a delayed and not unwritten
* So we need to check it. * block found in the extent status cache must contain an
*/ * invalid block number and have its BH_New and BH_Delay bits
if (ext4_es_is_delayed(&es) && !ext4_es_is_unwritten(&es)) { * set, reflecting the state assigned when the block was
map_bh(bh, inode->i_sb, invalid_block); * initially delayed allocated
set_buffer_new(bh); */
set_buffer_delay(bh); if (ext4_es_is_delonly(&es)) {
BUG_ON(bh->b_blocknr != invalid_block);
BUG_ON(!buffer_new(bh));
BUG_ON(!buffer_delay(bh));
return 0; return 0;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment