diff options
author | Eric Biggers <[email protected]> | 2023-11-06 20:44:34 -0800 |
---|---|---|
committer | Greg Kroah-Hartman <[email protected]> | 2024-01-25 14:34:19 -0800 |
commit | 12cf91e23b126718a96b914f949f2cdfeadc7b2a (patch) | |
tree | ec798950b302172c202d8ff74052d244ff46f574 | |
parent | 9153fc9664959aa6bb35915b2bbd8fbc4c762962 (diff) | |
download | linux-12cf91e23b126718a96b914f949f2cdfeadc7b2a.tar.gz |
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 <[email protected]>
Reviewed-by: Chao Yu <[email protected]>
Signed-off-by: Jaegeuk Kim <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
-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 cf1bfed1e6621b..cef2825ff069b3 100644 --- a/fs/f2fs/xattr.c +++ b/fs/f2fs/xattr.c @@ -722,6 +722,12 @@ static int __f2fs_setxattr(struct inode *inode, int index, 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); |