Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

9p: move xattr-related structs to .rodata

This makes it harder for accidental or malicious changes to
v9fs_xattr_user_handler, v9fs_xattr_trusted_handler,
v9fs_xattr_security_handler, or v9fs_xattr_handlers at runtime.

Cc: Eric Van Hensbergen <ericvh@kernel.org>
Cc: Latchesar Ionkov <lucho@ionkov.net>
Cc: Dominique Martinet <asmadeus@codewreck.org>
Cc: Christian Schoenebeck <linux_oss@crudebyte.com>
Cc: v9fs@lists.linux.dev
Signed-off-by: Wedson Almeida Filho <walmeida@microsoft.com>
Link: https://lore.kernel.org/r/20230930050033.41174-4-wedsonaf@gmail.com
Acked-by: Dominique Martinet <asmadeus@codewreck.org>
Reviewed-by: Christian Schoenebeck <linux_oss@crudebyte.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>

authored by

Wedson Almeida Filho and committed by
Christian Brauner
b6079dc9 e60ac128

+5 -5
+4 -4
fs/9p/xattr.c
··· 162 162 return v9fs_xattr_set(dentry, full_name, value, size, flags); 163 163 } 164 164 165 - static struct xattr_handler v9fs_xattr_user_handler = { 165 + static const struct xattr_handler v9fs_xattr_user_handler = { 166 166 .prefix = XATTR_USER_PREFIX, 167 167 .get = v9fs_xattr_handler_get, 168 168 .set = v9fs_xattr_handler_set, 169 169 }; 170 170 171 - static struct xattr_handler v9fs_xattr_trusted_handler = { 171 + static const struct xattr_handler v9fs_xattr_trusted_handler = { 172 172 .prefix = XATTR_TRUSTED_PREFIX, 173 173 .get = v9fs_xattr_handler_get, 174 174 .set = v9fs_xattr_handler_set, 175 175 }; 176 176 177 177 #ifdef CONFIG_9P_FS_SECURITY 178 - static struct xattr_handler v9fs_xattr_security_handler = { 178 + static const struct xattr_handler v9fs_xattr_security_handler = { 179 179 .prefix = XATTR_SECURITY_PREFIX, 180 180 .get = v9fs_xattr_handler_get, 181 181 .set = v9fs_xattr_handler_set, 182 182 }; 183 183 #endif 184 184 185 - const struct xattr_handler *v9fs_xattr_handlers[] = { 185 + const struct xattr_handler * const v9fs_xattr_handlers[] = { 186 186 &v9fs_xattr_user_handler, 187 187 &v9fs_xattr_trusted_handler, 188 188 #ifdef CONFIG_9P_FS_SECURITY
+1 -1
fs/9p/xattr.h
··· 10 10 #include <net/9p/9p.h> 11 11 #include <net/9p/client.h> 12 12 13 - extern const struct xattr_handler *v9fs_xattr_handlers[]; 13 + extern const struct xattr_handler * const v9fs_xattr_handlers[]; 14 14 15 15 ssize_t v9fs_fid_xattr_get(struct p9_fid *fid, const char *name, 16 16 void *buffer, size_t buffer_size);