Skip to content

Commit 2b08b1f

Browse files
committed
ext4: fix a potential fiemap/page fault deadlock w/ inline_data
The ext4_inline_data_fiemap() function calls fiemap_fill_next_extent() while still holding the xattr semaphore. This is not necessary and it triggers a circular lockdep warning. This is because fiemap_fill_next_extent() could trigger a page fault when it writes into page which triggers a page fault. If that page is mmaped from the inline file in question, this could very well result in a deadlock. This problem can be reproduced using generic/519 with a file system configuration which has the inline_data feature enabled. Signed-off-by: Theodore Ts'o <tytso@mit.edu> Cc: stable@kernel.org
1 parent 812c0ca commit 2b08b1f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

fs/ext4/inline.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1890,12 +1890,12 @@ int ext4_inline_data_fiemap(struct inode *inode,
18901890
physical += (char *)ext4_raw_inode(&iloc) - iloc.bh->b_data;
18911891
physical += offsetof(struct ext4_inode, i_block);
18921892

1893-
if (physical)
1894-
error = fiemap_fill_next_extent(fieinfo, start, physical,
1895-
inline_len, flags);
18961893
brelse(iloc.bh);
18971894
out:
18981895
up_read(&EXT4_I(inode)->xattr_sem);
1896+
if (physical)
1897+
error = fiemap_fill_next_extent(fieinfo, start, physical,
1898+
inline_len, flags);
18991899
return (error < 0 ? error : 0);
19001900
}
19011901

0 commit comments

Comments
 (0)