aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Biggers <[email protected]>2023-11-06 20:44:34 -0800
committerGreg Kroah-Hartman <[email protected]>2024-01-20 11:50:03 +0100
commit5de9e9dd1828db9b8b962f7ca42548bd596deb8a (patch)
tree1dd84a91c4341c1fae3b0ad48dc3c1e04c940359
parentfec3b1451d5febbc9e04250f879c10f8952e6bed (diff)
downloadlinux-5de9e9dd1828db9b8b962f7ca42548bd596deb8a.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.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/fs/f2fs/xattr.c b/fs/f2fs/xattr.c
index adaad16468d8a3..8816e13ca7c9e3 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);