Skip to content

Commit 6909cf5

Browse files
Eric Whitneytytso
authored andcommitted
ext4: correct inline offset when handling xattrs in inode body
When run on a file system where the inline_data feature has been enabled, xfstests generic/269, generic/270, and generic/476 cause ext4 to emit error messages indicating that inline directory entries are corrupted. This occurs because the inline offset used to locate inline directory entries in the inode body is not updated when an xattr in that shared region is deleted and the region is shifted in memory to recover the space it occupied. If the deleted xattr precedes the system.data attribute, which points to the inline directory entries, that attribute will be moved further up in the region. The inline offset continues to point to whatever is located in system.data's former location, with unfortunate effects when used to access directory entries or (presumably) inline data in the inode body. Cc: stable@kernel.org Signed-off-by: Eric Whitney <enwlinux@gmail.com> Link: https://lore.kernel.org/r/20230522181520.1570360-1-enwlinux@gmail.com Signed-off-by: Theodore Ts'o <tytso@mit.edu>
1 parent 3c55097 commit 6909cf5

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

fs/ext4/xattr.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1782,6 +1782,20 @@ static int ext4_xattr_set_entry(struct ext4_xattr_info *i,
17821782
memmove(here, (void *)here + size,
17831783
(void *)last - (void *)here + sizeof(__u32));
17841784
memset(last, 0, size);
1785+
1786+
/*
1787+
* Update i_inline_off - moved ibody region might contain
1788+
* system.data attribute. Handling a failure here won't
1789+
* cause other complications for setting an xattr.
1790+
*/
1791+
if (!is_block && ext4_has_inline_data(inode)) {
1792+
ret = ext4_find_inline_data_nolock(inode);
1793+
if (ret) {
1794+
ext4_warning_inode(inode,
1795+
"unable to update i_inline_off");
1796+
goto out;
1797+
}
1798+
}
17851799
} else if (s->not_found) {
17861800
/* Insert new name. */
17871801
size_t size = EXT4_XATTR_LEN(name_len);

0 commit comments

Comments
 (0)