mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-21 16:29:59 +00:00
ext4: correct inline offset when handling xattrs in inode body
commit 6909cf5c41
upstream.
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
4368f59a29
commit
8f07cd5926
1 changed files with 14 additions and 0 deletions
|
@ -1782,6 +1782,20 @@ static int ext4_xattr_set_entry(struct ext4_xattr_info *i,
|
|||
memmove(here, (void *)here + size,
|
||||
(void *)last - (void *)here + sizeof(__u32));
|
||||
memset(last, 0, size);
|
||||
|
||||
/*
|
||||
* Update i_inline_off - moved ibody region might contain
|
||||
* system.data attribute. Handling a failure here won't
|
||||
* cause other complications for setting an xattr.
|
||||
*/
|
||||
if (!is_block && ext4_has_inline_data(inode)) {
|
||||
ret = ext4_find_inline_data_nolock(inode);
|
||||
if (ret) {
|
||||
ext4_warning_inode(inode,
|
||||
"unable to update i_inline_off");
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
} else if (s->not_found) {
|
||||
/* Insert new name. */
|
||||
size_t size = EXT4_XATTR_LEN(name_len);
|
||||
|
|
Loading…
Reference in a new issue