diff options
author | Eric Biggers <ebiggers@google.com> | 2023-11-06 20:44:34 -0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2024-01-20 11:51:37 +0100 |
commit | 2525d1ba225b5c167162fa344013c408e8b4de36 (patch) | |
tree | e34163200f26af277d3a8188f21421f59dc8b273 | |
parent | 47345b4264bc394a8d16bb16e8e7744965fa3934 (diff) | |
download | linux-2525d1ba225b5c167162fa344013c408e8b4de36.tar.gz linux-2525d1ba225b5c167162fa344013c408e8b4de36.tar.bz2 linux-2525d1ba225b5c167162fa344013c408e8b4de36.zip |
f2fs: explicitly null-terminate the xattr list
commit e26b6d39270f5eab0087453d9b544189a38c8564 upstream.
When setting an xattr, explicitly null-terminate the xattr list. This
eliminates the fragile assumption that the unused xattr space is always
zeroed.
Signed-off-by: Eric Biggers <ebiggers@google.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | fs/f2fs/xattr.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/fs/f2fs/xattr.c b/fs/f2fs/xattr.c index 465d145360de..e197657db36b 100644 --- a/fs/f2fs/xattr.c +++ b/fs/f2fs/xattr.c @@ -754,6 +754,12 @@ retry: memcpy(pval, value, size); last->e_value_size = cpu_to_le16(size); new_hsize += newsize; + /* + * Explicitly add the null terminator. The unused xattr space + * is supposed to always be zeroed, which would make this + * unnecessary, but don't depend on that. + */ + *(u32 *)((u8 *)last + newsize) = 0; } error = write_all_xattrs(inode, new_hsize, base_addr, ipage); |