* [PATCH] ext4: correct inline offset when handling xattrs in inode body
@ 2023-05-22 18:15 Eric Whitney
2023-07-13 14:55 ` Theodore Ts'o
0 siblings, 1 reply; 2+ messages in thread
From: Eric Whitney @ 2023-05-22 18:15 UTC (permalink / raw)
To: linux-ext4; +Cc: tytso, Eric Whitney
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.
Signed-off-by: Eric Whitney <enwlinux@gmail.com>
---
fs/ext4/xattr.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
index dfc2e223bd10..e1c7b65d8d52 100644
--- a/fs/ext4/xattr.c
+++ b/fs/ext4/xattr.c
@@ -1799,6 +1799,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);
--
2.30.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ext4: correct inline offset when handling xattrs in inode body
2023-05-22 18:15 [PATCH] ext4: correct inline offset when handling xattrs in inode body Eric Whitney
@ 2023-07-13 14:55 ` Theodore Ts'o
0 siblings, 0 replies; 2+ messages in thread
From: Theodore Ts'o @ 2023-07-13 14:55 UTC (permalink / raw)
To: linux-ext4, Eric Whitney; +Cc: Theodore Ts'o
On Mon, 22 May 2023 14:15:20 -0400, Eric Whitney wrote:
> 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.
>
> [...]
Applied, thanks!
[1/1] ext4: correct inline offset when handling xattrs in inode body
commit: 48ef88508c16866ec9641fdda38642aa1f776fd4
Best regards,
--
Theodore Ts'o <tytso@mit.edu>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-07-13 14:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-22 18:15 [PATCH] ext4: correct inline offset when handling xattrs in inode body Eric Whitney
2023-07-13 14:55 ` Theodore Ts'o
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).