]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
erofs: move erofs_xattr_handlers and xattr_handler_map to .rodata
authorWedson Almeida Filho <walmeida@microsoft.com>
Sat, 30 Sep 2023 05:00:12 +0000 (02:00 -0300)
committerChristian Brauner <brauner@kernel.org>
Mon, 9 Oct 2023 14:24:17 +0000 (16:24 +0200)
This makes it harder for accidental or malicious changes to
erofs_xattr_handlers or xattr_handler_map at runtime.

Cc: Gao Xiang <xiang@kernel.org>
Cc: Chao Yu <chao@kernel.org>
Cc: Yue Hu <huyue2@coolpad.com>
Cc: Jeffle Xu <jefflexu@linux.alibaba.com>
Cc: linux-erofs@lists.ozlabs.org
Signed-off-by: Wedson Almeida Filho <walmeida@microsoft.com>
Link: https://lore.kernel.org/r/20230930050033.41174-9-wedsonaf@gmail.com
Acked-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/erofs/xattr.c
fs/erofs/xattr.h

index 09d341675e890e6bc9a975cc0024bf5429b78ca6..b58316b49a43328ae37a5a64bfce6b2b9fc57ec4 100644 (file)
@@ -168,7 +168,7 @@ const struct xattr_handler __maybe_unused erofs_xattr_security_handler = {
 };
 #endif
 
-const struct xattr_handler *erofs_xattr_handlers[] = {
+const struct xattr_handler * const erofs_xattr_handlers[] = {
        &erofs_xattr_user_handler,
        &erofs_xattr_trusted_handler,
 #ifdef CONFIG_EROFS_FS_SECURITY
index f16283cb8c9301c1f0ce81d5bd321ca4c04d8c72..b246cd0e135ed448ff87c6d8c24959836e7e6e4f 100644 (file)
@@ -23,7 +23,7 @@ static inline const char *erofs_xattr_prefix(unsigned int idx,
 {
        const struct xattr_handler *handler = NULL;
 
-       static const struct xattr_handler *xattr_handler_map[] = {
+       static const struct xattr_handler * const xattr_handler_map[] = {
                [EROFS_XATTR_INDEX_USER] = &erofs_xattr_user_handler,
 #ifdef CONFIG_EROFS_FS_POSIX_ACL
                [EROFS_XATTR_INDEX_POSIX_ACL_ACCESS] = &nop_posix_acl_access,
@@ -44,7 +44,7 @@ static inline const char *erofs_xattr_prefix(unsigned int idx,
        return xattr_prefix(handler);
 }
 
-extern const struct xattr_handler *erofs_xattr_handlers[];
+extern const struct xattr_handler * const erofs_xattr_handlers[];
 
 int erofs_xattr_prefixes_init(struct super_block *sb);
 void erofs_xattr_prefixes_cleanup(struct super_block *sb);