diff options
author | Jan Kara <jack@suse.cz> | 2024-06-13 18:02:34 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2024-08-19 06:40:50 +0300 |
commit | 3d096f2a99eb88148ef84ee0370699054a87f7d6 (patch) | |
tree | ea80f0c6b5162ac81183eb6762f333b735568956 /fs/ext4 | |
parent | 91c22df7013847f3f88d1e3f79637c4074548c90 (diff) | |
download | linux-3d096f2a99eb88148ef84ee0370699054a87f7d6.tar.xz |
ext4: avoid writing unitialized memory to disk in EA inodes
[ Upstream commit 65121eff3e4c8c90f8126debf3c369228691c591 ]
If the extended attribute size is not a multiple of block size, the last
block in the EA inode will have uninitialized tail which will get
written to disk. We will never expose the data to userspace but still
this is not a good practice so just zero out the tail of the block as it
isn't going to cause a noticeable performance overhead.
Fixes: e50e5129f384 ("ext4: xattr-in-inode support")
Reported-by: syzbot+9c1fe13fcb51574b249b@syzkaller.appspotmail.com
Reported-by: Hugh Dickins <hughd@google.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Link: https://patch.msgid.link/20240613150234.25176-1-jack@suse.cz
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'fs/ext4')
-rw-r--r-- | fs/ext4/xattr.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c index 2dcb7d2bb85e..b91a1d1099d5 100644 --- a/fs/ext4/xattr.c +++ b/fs/ext4/xattr.c @@ -1377,6 +1377,12 @@ retry: goto out; memcpy(bh->b_data, buf, csize); + /* + * Zero out block tail to avoid writing uninitialized memory + * to disk. + */ + if (csize < blocksize) + memset(bh->b_data + csize, 0, blocksize - csize); set_buffer_uptodate(bh); ext4_handle_dirty_metadata(handle, ea_inode, bh); |