Skip to contentSkip to conversation

const xattr tables

PATCH Applied Wedson Almeida Filho 18 participants 53 messages Sep 30, 2023 – Oct 9, 2023

Subsystems (34)
lore
Share & tools
lore
#38 lore raw

PATCH 22/29 reiserfs: move reiserfs_xattr_handlers to .rodata

In reply to Wedson Almeida Filho

From: Wedson Almeida Filho <[email protected]>

This makes it harder for accidental or malicious changes to reiserfs_xattr_handlers at runtime.

---
 fs/reiserfs/reiserfs.h | 2 +-
 fs/reiserfs/xattr.c    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
fs/reiserfs/reiserfs.h +1 -1
index 55e85256aae8..c18d0bc01725 100644
@@ -1165,7 +1165,7 @@ static inline int bmap_would_wrap(unsigned bmap_nr)
 	return bmap_nr > ((1LL << 16) - 1);
 }
 
-extern const struct xattr_handler *reiserfs_xattr_handlers[];
+extern const struct xattr_handler * const reiserfs_xattr_handlers[];
 
 /*
  * this says about version of key of all items (but stat data) the
fs/reiserfs/xattr.c +1 -1
index 651027967159..5a22a2bdaec7 100644
@@ -910,7 +910,7 @@ static int create_privroot(struct dentry *dentry) { return 0; }
 #endif
 
 /* Actual operations that are exported to VFS-land */
-const struct xattr_handler *reiserfs_xattr_handlers[] = {
+const struct xattr_handler * const reiserfs_xattr_handlers[] = {
 #ifdef CONFIG_REISERFS_FS_XATTR
 	&reiserfs_xattr_user_handler,
 	&reiserfs_xattr_trusted_handler,
Signature · 1 line
2.34.1
#0 lore raw

cover const xattr tables

From: Wedson Almeida Filho <[email protected]>

The 's_xattr' field of 'struct super_block' currently requires a mutable table of 'struct xattr_handler' entries (although each handler itself is const). However, no code in vfs actually modifies the tables.

So this series changes the type of 's_xattr' to allow const tables, and modifies existing file system to move their tables to .rodata. This is desirable because these tables contain entries with function pointers in them; moving them to .rodata makes it considerably less likely to be modified accidentally or maliciously at runtime.

I found this while writing Rust abstractions for vfs.

Wedson Almeida Filho (29):
xattr: make the xattr array itself const
ext4: move ext4_xattr_handlers to .rodata
9p: move xattr-related structs to .rodata
afs: move afs_xattr_handlers to .rodata
btrfs: move btrfs_xattr_handlers to .rodata
ceph: move ceph_xattr_handlers to .rodata
ecryptfs: move ecryptfs_xattr_handlers to .rodata
erofs: move erofs_xattr_handlers and xattr_handler_map to .rodata
ext2: move ext2_xattr_handlers and ext2_xattr_handler_map to .rodata
f2fs: move f2fs_xattr_handlers and f2fs_xattr_handler_map to .rodata
fuse: move fuse_xattr_handlers to .rodata
gfs2: move gfs2_xattr_handlers_max to .rodata
hfs: move hfs_xattr_handlers to .rodata
hfsplus: move hfsplus_xattr_handlers to .rodata
jffs2: move jffs2_xattr_handlers to .rodata
jfs: move jfs_xattr_handlers to .rodata
kernfs: move kernfs_xattr_handlers to .rodata
nfs: move nfs4_xattr_handlers to .rodata
ntfs3: move ntfs_xattr_handlers to .rodata
ocfs2: move ocfs2_xattr_handlers and ocfs2_xattr_handler_map to
.rodata
orangefs: move orangefs_xattr_handlers to .rodata
reiserfs: move reiserfs_xattr_handlers to .rodata
smb: move cifs_xattr_handlers to .rodata
squashfs: move squashfs_xattr_handlers to .rodata
ubifs: move ubifs_xattr_handlers to .rodata
xfs: move xfs_xattr_handlers to .rodata
overlayfs: move xattr tables to .rodata
shmem: move shmem_xattr_handlers to .rodata
net: move sockfs_xattr_handlers to .rodata

 fs/9p/xattr.c                 | 8 ++++----
 fs/9p/xattr.h                 | 2 +-
 fs/afs/internal.h             | 2 +-
 fs/afs/xattr.c                | 2 +-
 fs/btrfs/xattr.c              | 2 +-
 fs/btrfs/xattr.h              | 2 +-
 fs/ceph/super.h               | 2 +-
 fs/ceph/xattr.c               | 2 +-
 fs/ecryptfs/ecryptfs_kernel.h | 2 +-
 fs/ecryptfs/inode.c           | 2 +-
 fs/erofs/xattr.c              | 2 +-
 fs/erofs/xattr.h              | 4 ++--
 fs/ext2/xattr.c               | 4 ++--
 fs/ext2/xattr.h               | 2 +-
 fs/ext4/xattr.c               | 2 +-
 fs/ext4/xattr.h               | 2 +-
 fs/f2fs/xattr.c               | 4 ++--
 fs/f2fs/xattr.h               | 2 +-
 fs/fuse/fuse_i.h              | 2 +-
 fs/fuse/xattr.c               | 2 +-
 fs/gfs2/super.h               | 4 ++--
 fs/gfs2/xattr.c               | 4 ++--
 fs/hfs/attr.c                 | 2 +-
 fs/hfs/hfs_fs.h               | 2 +-
 fs/hfsplus/xattr.c            | 2 +-
 fs/hfsplus/xattr.h            | 2 +-
 fs/jffs2/xattr.c              | 2 +-
 fs/jffs2/xattr.h              | 2 +-
 fs/jfs/jfs_xattr.h            | 2 +-
 fs/jfs/xattr.c                | 2 +-
 fs/kernfs/inode.c             | 2 +-
 fs/kernfs/kernfs-internal.h   | 2 +-
 fs/nfs/nfs.h                  | 2 +-
 fs/nfs/nfs4_fs.h              | 2 +-
 fs/nfs/nfs4proc.c             | 2 +-
 fs/ntfs3/ntfs_fs.h            | 2 +-
 fs/ntfs3/xattr.c              | 2 +-
 fs/ocfs2/xattr.c              | 4 ++--
 fs/ocfs2/xattr.h              | 2 +-
 fs/orangefs/orangefs-kernel.h | 2 +-
 fs/orangefs/xattr.c           | 2 +-
 fs/overlayfs/super.c          | 4 ++--
 fs/reiserfs/reiserfs.h        | 2 +-
 fs/reiserfs/xattr.c           | 2 +-
 fs/smb/client/cifsfs.h        | 2 +-
 fs/smb/client/xattr.c         | 2 +-
 fs/squashfs/squashfs.h        | 2 +-
 fs/squashfs/xattr.c           | 2 +-
 fs/ubifs/ubifs.h              | 2 +-
 fs/ubifs/xattr.c              | 2 +-
 fs/xattr.c                    | 6 +++---
 fs/xfs/xfs_xattr.c            | 2 +-
 fs/xfs/xfs_xattr.h            | 2 +-
 include/linux/fs.h            | 2 +-
 include/linux/pseudo_fs.h     | 2 +-
 mm/shmem.c                    | 2 +-
 net/socket.c                  | 2 +-
 57 files changed, 69 insertions(+), 69 deletions(-)

base-commit: 2dde18cd1d8fac735875f2e4987f11817cc0bc2c

Signature · 1 line
2.34.1
#5 lore raw

PATCH 3/29 9p: move xattr-related structs to .rodata

From: Wedson Almeida Filho <[email protected]>

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 <[email protected]>
Cc Latchesar Ionkov <[email protected]>
Cc Dominique Martinet <[email protected]>
Cc Christian Schoenebeck <[email protected]>
---
 fs/9p/xattr.c | 8 ++++----
 fs/9p/xattr.h | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)
fs/9p/xattr.c +4 -4
index e00cf8109b3f..053d1cef6e13 100644
@@ -162,27 +162,27 @@ static int v9fs_xattr_handler_set(const struct xattr_handler *handler,
 	return v9fs_xattr_set(dentry, full_name, value, size, flags);
 }
 
-static struct xattr_handler v9fs_xattr_user_handler = {
+static const struct xattr_handler v9fs_xattr_user_handler = {
 	.prefix	= XATTR_USER_PREFIX,
 	.get	= v9fs_xattr_handler_get,
 	.set	= v9fs_xattr_handler_set,
 };
 
-static struct xattr_handler v9fs_xattr_trusted_handler = {
+static const struct xattr_handler v9fs_xattr_trusted_handler = {
 	.prefix	= XATTR_TRUSTED_PREFIX,
 	.get	= v9fs_xattr_handler_get,
 	.set	= v9fs_xattr_handler_set,
 };
 
 #ifdef CONFIG_9P_FS_SECURITY
-static struct xattr_handler v9fs_xattr_security_handler = {
+static const struct xattr_handler v9fs_xattr_security_handler = {
 	.prefix	= XATTR_SECURITY_PREFIX,
 	.get	= v9fs_xattr_handler_get,
 	.set	= v9fs_xattr_handler_set,
 };
 #endif
 
-const struct xattr_handler *v9fs_xattr_handlers[] = {
+const struct xattr_handler * const v9fs_xattr_handlers[] = {
 	&v9fs_xattr_user_handler,
 	&v9fs_xattr_trusted_handler,
 #ifdef CONFIG_9P_FS_SECURITY
fs/9p/xattr.h +1 -1
index b5636e544c8a..3ad5a802352a 100644
@@ -10,7 +10,7 @@
 #include <net/9p/9p.h>
 #include <net/9p/client.h>
 
-extern const struct xattr_handler *v9fs_xattr_handlers[];
+extern const struct xattr_handler * const v9fs_xattr_handlers[];
 
 ssize_t v9fs_fid_xattr_get(struct p9_fid *fid, const char *name,
 			   void *buffer, size_t buffer_size);
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/29 xattr: make the xattr array itself const

In reply to Wedson Almeida Filho

From: Wedson Almeida Filho <[email protected]>

As it is currently declared, the xattr_handler structs are const but the array containing their pointers is not. This patch makes it so that fs modules can place them in .rodata, which makes it harder for accidental/malicious modifications at runtime.

---
 fs/xattr.c         | 6 +++---
 include/linux/fs.h | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)
fs/xattr.c +3 -3
index e7bbb7f57557..1905f8ede13d 100644
@@ -56,7 +56,7 @@ strcmp_prefix(const char *a, const char *a_prefix)
 static const struct xattr_handler *
 xattr_resolve_name(struct inode *inode, const char **name)
 {
-	const struct xattr_handler **handlers = inode->i_sb->s_xattr;
+	const struct xattr_handler * const *handlers = inode->i_sb->s_xattr;
 	const struct xattr_handler *handler;
 
 	if (!(inode->i_opflags & IOP_XATTR)) {
@@ -162,7 +162,7 @@ xattr_permission(struct mnt_idmap *idmap, struct inode *inode,
 int
 xattr_supports_user_prefix(struct inode *inode)
 {
-	const struct xattr_handler **handlers = inode->i_sb->s_xattr;
+	const struct xattr_handler * const *handlers = inode->i_sb->s_xattr;
 	const struct xattr_handler *handler;
 
 	if (!(inode->i_opflags & IOP_XATTR)) {
@@ -999,7 +999,7 @@ int xattr_list_one(char **buffer, ssize_t *remaining_size, const char *name)
 ssize_t
 generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size)
 {
-	const struct xattr_handler *handler, **handlers = dentry->d_sb->s_xattr;
+	const struct xattr_handler *handler, * const *handlers = dentry->d_sb->s_xattr;
 	ssize_t remaining_size = buffer_size;
 	int err = 0;
 
include/linux/fs.h +1 -1
index 562f2623c9c9..4d8003f48216 100644
@@ -1172,7 +1172,7 @@ struct super_block {
 #ifdef CONFIG_SECURITY
 	void                    *s_security;
 #endif
-	const struct xattr_handler **s_xattr;
+	const struct xattr_handler * const *s_xattr;
 #ifdef CONFIG_FS_ENCRYPTION
 	const struct fscrypt_operations	*s_cop;
 	struct fscrypt_keyring	*s_master_keys; /* master crypto keys in use */
Signature · 1 line
2.34.1
#4 lore raw

PATCH 2/29 ext4: move ext4_xattr_handlers to .rodata

In reply to Wedson Almeida Filho

From: Wedson Almeida Filho <[email protected]>

This makes it harder for accidental or malicious changes to ext4_xattr_handlers at runtime.

---
 fs/ext4/xattr.c | 2 +-
 fs/ext4/xattr.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
fs/ext4/xattr.c +1 -1
index 05151d61b00b..5e8a7328fe4e 100644
@@ -98,7 +98,7 @@ static const struct xattr_handler * const ext4_xattr_handler_map[] = {
 	[EXT4_XATTR_INDEX_HURD]		     = &ext4_xattr_hurd_handler,
 };
 
-const struct xattr_handler *ext4_xattr_handlers[] = {
+const struct xattr_handler * const ext4_xattr_handlers[] = {
 	&ext4_xattr_user_handler,
 	&ext4_xattr_trusted_handler,
 #ifdef CONFIG_EXT4_FS_SECURITY
fs/ext4/xattr.h +1 -1
index 824faf0b15a8..bd97c4aa8177 100644
@@ -193,7 +193,7 @@ extern int ext4_expand_extra_isize_ea(struct inode *inode, int new_extra_isize,
 			    struct ext4_inode *raw_inode, handle_t *handle);
 extern void ext4_evict_ea_inode(struct inode *inode);
 
-extern const struct xattr_handler *ext4_xattr_handlers[];
+extern const struct xattr_handler * const ext4_xattr_handlers[];
 
 extern int ext4_xattr_ibody_find(struct inode *inode, struct ext4_xattr_info *i,
 				 struct ext4_xattr_ibody_find *is);
Signature · 1 line
2.34.1
#10 lore raw

PATCH 4/29 afs: move afs_xattr_handlers to .rodata

In reply to Wedson Almeida Filho

From: Wedson Almeida Filho <[email protected]>

This makes it harder for accidental or malicious changes to afs_xattr_handlers at runtime.

---
 fs/afs/internal.h | 2 +-
 fs/afs/xattr.c    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
fs/afs/internal.h +1 -1
index 9d3d64921106..a01d1f71ae8c 100644
@@ -1539,7 +1539,7 @@ int afs_launder_folio(struct folio *);
 /*
  * xattr.c
  */
-extern const struct xattr_handler *afs_xattr_handlers[];
+extern const struct xattr_handler * const afs_xattr_handlers[];
 
 /*
  * yfsclient.c
fs/afs/xattr.c +1 -1
index 9048d8ccc715..64b2c0224f62 100644
@@ -353,7 +353,7 @@ static const struct xattr_handler afs_xattr_afs_volume_handler = {
 	.get	= afs_xattr_get_volume,
 };
 
-const struct xattr_handler *afs_xattr_handlers[] = {
+const struct xattr_handler * const afs_xattr_handlers[] = {
 	&afs_xattr_afs_acl_handler,
 	&afs_xattr_afs_cell_handler,
 	&afs_xattr_afs_fid_handler,
Signature · 1 line
2.34.1
#11 lore raw

PATCH 5/29 btrfs: move btrfs_xattr_handlers to .rodata

In reply to Wedson Almeida Filho

From: Wedson Almeida Filho <[email protected]>

This makes it harder for accidental or malicious changes to btrfs_xattr_handlers at runtime.

---
 fs/btrfs/xattr.c | 2 +-
 fs/btrfs/xattr.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
fs/btrfs/xattr.c +1 -1
index fc4b20c2688a..d82d9545386a 100644
@@ -442,7 +442,7 @@ static const struct xattr_handler btrfs_btrfs_xattr_handler = {
 	.set = btrfs_xattr_handler_set_prop,
 };
 
-const struct xattr_handler *btrfs_xattr_handlers[] = {
+const struct xattr_handler * const btrfs_xattr_handlers[] = {
 	&btrfs_security_xattr_handler,
 	&btrfs_trusted_xattr_handler,
 	&btrfs_user_xattr_handler,
fs/btrfs/xattr.h +1 -1
index 1cd3fc0a8f17..118118ca3e1d 100644
@@ -8,7 +8,7 @@
 
 #include <linux/xattr.h>
 
-extern const struct xattr_handler *btrfs_xattr_handlers[];
+extern const struct xattr_handler * const btrfs_xattr_handlers[];
 
 int btrfs_getxattr(struct inode *inode, const char *name,
 		void *buffer, size_t size);
Signature · 1 line
2.34.1
#22 lore raw

PATCH 10/29 f2fs: move f2fs_xattr_handlers and f2fs_xattr_handler_map to .rodata

In reply to Wedson Almeida Filho

From: Wedson Almeida Filho <[email protected]>

This makes it harder for accidental or malicious changes to f2fs_xattr_handlers or f2fs_xattr_handler_map at runtime.

---
 fs/f2fs/xattr.c | 4 ++--
 fs/f2fs/xattr.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
fs/f2fs/xattr.c +2 -2
index 476b186b90a6..3895a066f36c 100644
@@ -189,7 +189,7 @@ const struct xattr_handler f2fs_xattr_security_handler = {
 	.set	= f2fs_xattr_generic_set,
 };
 
-static const struct xattr_handler *f2fs_xattr_handler_map[] = {
+static const struct xattr_handler * const f2fs_xattr_handler_map[] = {
 	[F2FS_XATTR_INDEX_USER] = &f2fs_xattr_user_handler,
 #ifdef CONFIG_F2FS_FS_POSIX_ACL
 	[F2FS_XATTR_INDEX_POSIX_ACL_ACCESS] = &nop_posix_acl_access,
@@ -202,7 +202,7 @@ static const struct xattr_handler *f2fs_xattr_handler_map[] = {
 	[F2FS_XATTR_INDEX_ADVISE] = &f2fs_xattr_advise_handler,
 };
 
-const struct xattr_handler *f2fs_xattr_handlers[] = {
+const struct xattr_handler * const f2fs_xattr_handlers[] = {
 	&f2fs_xattr_user_handler,
 	&f2fs_xattr_trusted_handler,
 #ifdef CONFIG_F2FS_FS_SECURITY
fs/f2fs/xattr.h +1 -1
index b1811c392e6f..a005ffdcf717 100644
@@ -125,7 +125,7 @@ extern const struct xattr_handler f2fs_xattr_trusted_handler;
 extern const struct xattr_handler f2fs_xattr_advise_handler;
 extern const struct xattr_handler f2fs_xattr_security_handler;
 
-extern const struct xattr_handler *f2fs_xattr_handlers[];
+extern const struct xattr_handler * const f2fs_xattr_handlers[];
 
 extern int f2fs_setxattr(struct inode *, int, const char *,
 				const void *, size_t, struct page *, int);
Signature · 8 lines
2.34.1



_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
#18 lore raw

PATCH 8/29 erofs: move erofs_xattr_handlers and xattr_handler_map to .rodata

In reply to Wedson Almeida Filho

From: Wedson Almeida Filho <[email protected]>

This makes it harder for accidental or malicious changes to erofs_xattr_handlers or xattr_handler_map at runtime.

---
 fs/erofs/xattr.c | 2 +-
 fs/erofs/xattr.h | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
fs/erofs/xattr.c +1 -1
index 40178b6e0688..a6dd68ea5df2 100644
@@ -166,7 +166,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
fs/erofs/xattr.h +2 -2
index f16283cb8c93..b246cd0e135e 100644
@@ -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);
Signature · 1 line
2.34.1
#17 lore raw

PATCH 7/29 ecryptfs: move ecryptfs_xattr_handlers to .rodata

In reply to Wedson Almeida Filho

From: Wedson Almeida Filho <[email protected]>

This makes it harder for accidental or malicious changes to ecryptfs_xattr_handlers at runtime.

---
 fs/ecryptfs/ecryptfs_kernel.h | 2 +-
 fs/ecryptfs/inode.c           | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
fs/ecryptfs/ecryptfs_kernel.h +1 -1
index f2ed0c0266cb..c586c5db18b5 100644
@@ -702,6 +702,6 @@ int ecryptfs_set_f_namelen(long *namelen, long lower_namelen,
 int ecryptfs_derive_iv(char *iv, struct ecryptfs_crypt_stat *crypt_stat,
 		       loff_t offset);
 
-extern const struct xattr_handler *ecryptfs_xattr_handlers[];
+extern const struct xattr_handler * const ecryptfs_xattr_handlers[];
 
 #endif /* #ifndef ECRYPTFS_KERNEL_H */
fs/ecryptfs/inode.c +1 -1
index 83274915ba6d..18fcec208d9d 100644
@@ -1209,7 +1209,7 @@ static const struct xattr_handler ecryptfs_xattr_handler = {
 	.set = ecryptfs_xattr_set,
 };
 
-const struct xattr_handler *ecryptfs_xattr_handlers[] = {
+const struct xattr_handler * const ecryptfs_xattr_handlers[] = {
 	&ecryptfs_xattr_handler,
 	NULL
 };
Signature · 1 line
2.34.1
#35 lore raw

PATCH 19/29 ntfs3: move ntfs_xattr_handlers to .rodata

In reply to Wedson Almeida Filho

From: Wedson Almeida Filho <[email protected]>

This makes it harder for accidental or malicious changes to ntfs_xattr_handlers at runtime.

---
 fs/ntfs3/ntfs_fs.h | 2 +-
 fs/ntfs3/xattr.c   | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
fs/ntfs3/ntfs_fs.h +1 -1
index 629403ede6e5..41c1538f8e51 100644
@@ -872,7 +872,7 @@ int ntfs_init_acl(struct mnt_idmap *idmap, struct inode *inode,
 
 int ntfs_acl_chmod(struct mnt_idmap *idmap, struct dentry *dentry);
 ssize_t ntfs_listxattr(struct dentry *dentry, char *buffer, size_t size);
-extern const struct xattr_handler *ntfs_xattr_handlers[];
+extern const struct xattr_handler * const ntfs_xattr_handlers[];
 
 int ntfs_save_wsl_perm(struct inode *inode, __le16 *ea_size);
 void ntfs_get_wsl_perm(struct inode *inode);
fs/ntfs3/xattr.c +1 -1
index 023f314e8950..a67ff036a251 100644
@@ -1016,7 +1016,7 @@ static const struct xattr_handler ntfs_other_xattr_handler = {
 	.list	= ntfs_xattr_user_list,
 };
 
-const struct xattr_handler *ntfs_xattr_handlers[] = {
+const struct xattr_handler * const ntfs_xattr_handlers[] = {
 	&ntfs_other_xattr_handler,
 	NULL,
 };
Signature · 1 line
2.34.1
#15 lore raw

PATCH 6/29 ceph: move ceph_xattr_handlers to .rodata

In reply to Wedson Almeida Filho

From: Wedson Almeida Filho <[email protected]>

This makes it harder for accidental or malicious changes to ceph_xattr_handlers at runtime.

---
 fs/ceph/super.h | 2 +-
 fs/ceph/xattr.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
fs/ceph/super.h +1 -1
index 3bfddf34d488..b40be1a0f778 100644
@@ -1089,7 +1089,7 @@ ssize_t __ceph_getxattr(struct inode *, const char *, void *, size_t);
 extern ssize_t ceph_listxattr(struct dentry *, char *, size_t);
 extern struct ceph_buffer *__ceph_build_xattrs_blob(struct ceph_inode_info *ci);
 extern void __ceph_destroy_xattrs(struct ceph_inode_info *ci);
-extern const struct xattr_handler *ceph_xattr_handlers[];
+extern const struct xattr_handler * const ceph_xattr_handlers[];
 
 struct ceph_acl_sec_ctx {
 #ifdef CONFIG_CEPH_FS_POSIX_ACL
fs/ceph/xattr.c +1 -1
index 806183959c47..0350d7465bbb 100644
@@ -1416,7 +1416,7 @@ void ceph_release_acl_sec_ctx(struct ceph_acl_sec_ctx *as_ctx)
  * List of handlers for synthetic system.* attributes. Other
  * attributes are handled directly.
  */
-const struct xattr_handler *ceph_xattr_handlers[] = {
+const struct xattr_handler * const ceph_xattr_handlers[] = {
 	&ceph_other_xattr_handler,
 	NULL,
 };
Signature · 1 line
2.34.1
#28 lore raw

PATCH 15/29 jffs2: move jffs2_xattr_handlers to .rodata

In reply to Wedson Almeida Filho

From: Wedson Almeida Filho <[email protected]>

This makes it harder for accidental or malicious changes to jffs2_xattr_handlers at runtime.

---
 fs/jffs2/xattr.c | 2 +-
 fs/jffs2/xattr.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
fs/jffs2/xattr.c +1 -1
index 3b6bdc9a49e1..00224f3a8d6e 100644
@@ -920,7 +920,7 @@ struct jffs2_xattr_datum *jffs2_setup_xattr_datum(struct jffs2_sb_info *c,
  * do_jffs2_setxattr(inode, xprefix, xname, buffer, size, flags)
  *   is an implementation of setxattr handler on jffs2.
  * -------------------------------------------------- */
-const struct xattr_handler *jffs2_xattr_handlers[] = {
+const struct xattr_handler * const jffs2_xattr_handlers[] = {
 	&jffs2_user_xattr_handler,
 #ifdef CONFIG_JFFS2_FS_SECURITY
 	&jffs2_security_xattr_handler,
fs/jffs2/xattr.h +1 -1
index 1b5030a3349d..7e7de093ec0a 100644
@@ -94,7 +94,7 @@ extern int do_jffs2_getxattr(struct inode *inode, int xprefix, const char *xname
 extern int do_jffs2_setxattr(struct inode *inode, int xprefix, const char *xname,
 			     const char *buffer, size_t size, int flags);
 
-extern const struct xattr_handler *jffs2_xattr_handlers[];
+extern const struct xattr_handler * const jffs2_xattr_handlers[];
 extern const struct xattr_handler jffs2_user_xattr_handler;
 extern const struct xattr_handler jffs2_trusted_xattr_handler;
 
Signature · 6 lines
2.34.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
#36 lore raw

PATCH 20/29 ocfs2: move ocfs2_xattr_handlers and ocfs2_xattr_handler_map to .rodata

In reply to Wedson Almeida Filho

From: Wedson Almeida Filho <[email protected]>

This makes it harder for accidental or malicious changes to ocfs2_xattr_handlers or ocfs2_xattr_handler_map at runtime.

---
 fs/ocfs2/xattr.c | 4 ++--
 fs/ocfs2/xattr.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
fs/ocfs2/xattr.c +2 -2
index 4ac77ff6e676..1c54adac1e50 100644
@@ -87,14 +87,14 @@ static struct ocfs2_xattr_def_value_root def_xv = {
 	.xv.xr_list.l_count = cpu_to_le16(1),
 };
 
-const struct xattr_handler *ocfs2_xattr_handlers[] = {
+const struct xattr_handler * const ocfs2_xattr_handlers[] = {
 	&ocfs2_xattr_user_handler,
 	&ocfs2_xattr_trusted_handler,
 	&ocfs2_xattr_security_handler,
 	NULL
 };
 
-static const struct xattr_handler *ocfs2_xattr_handler_map[OCFS2_XATTR_MAX] = {
+static const struct xattr_handler * const ocfs2_xattr_handler_map[OCFS2_XATTR_MAX] = {
 	[OCFS2_XATTR_INDEX_USER]		= &ocfs2_xattr_user_handler,
 	[OCFS2_XATTR_INDEX_POSIX_ACL_ACCESS]	= &nop_posix_acl_access,
 	[OCFS2_XATTR_INDEX_POSIX_ACL_DEFAULT]	= &nop_posix_acl_default,
fs/ocfs2/xattr.h +1 -1
index 00308b57f64f..65e9aa743919 100644
@@ -30,7 +30,7 @@ struct ocfs2_security_xattr_info {
 extern const struct xattr_handler ocfs2_xattr_user_handler;
 extern const struct xattr_handler ocfs2_xattr_trusted_handler;
 extern const struct xattr_handler ocfs2_xattr_security_handler;
-extern const struct xattr_handler *ocfs2_xattr_handlers[];
+extern const struct xattr_handler * const ocfs2_xattr_handlers[];
 
 ssize_t ocfs2_listxattr(struct dentry *, char *, size_t);
 int ocfs2_xattr_get_nolock(struct inode *, struct buffer_head *, int,
Signature · 1 line
2.34.1
#20 lore raw

PATCH 9/29 ext2: move ext2_xattr_handlers and ext2_xattr_handler_map to .rodata

In reply to Wedson Almeida Filho

From: Wedson Almeida Filho <[email protected]>

This makes it harder for accidental or malicious changes to ext2_xattr_handlers or ext2_xattr_handler_map at runtime.

---
 fs/ext2/xattr.c | 4 ++--
 fs/ext2/xattr.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
fs/ext2/xattr.c +2 -2
index 8906ba479aaf..cfbe376da612 100644
@@ -98,7 +98,7 @@ static struct buffer_head *ext2_xattr_cache_find(struct inode *,
 static void ext2_xattr_rehash(struct ext2_xattr_header *,
 			      struct ext2_xattr_entry *);
 
-static const struct xattr_handler *ext2_xattr_handler_map[] = {
+static const struct xattr_handler * const ext2_xattr_handler_map[] = {
 	[EXT2_XATTR_INDEX_USER]		     = &ext2_xattr_user_handler,
 #ifdef CONFIG_EXT2_FS_POSIX_ACL
 	[EXT2_XATTR_INDEX_POSIX_ACL_ACCESS]  = &nop_posix_acl_access,
@@ -110,7 +110,7 @@ static const struct xattr_handler *ext2_xattr_handler_map[] = {
 #endif
 };
 
-const struct xattr_handler *ext2_xattr_handlers[] = {
+const struct xattr_handler * const ext2_xattr_handlers[] = {
 	&ext2_xattr_user_handler,
 	&ext2_xattr_trusted_handler,
 #ifdef CONFIG_EXT2_FS_SECURITY
fs/ext2/xattr.h +1 -1
index 7925f596e8e2..6a4966949047 100644
@@ -72,7 +72,7 @@ extern void ext2_xattr_delete_inode(struct inode *);
 extern struct mb_cache *ext2_xattr_create_cache(void);
 extern void ext2_xattr_destroy_cache(struct mb_cache *cache);
 
-extern const struct xattr_handler *ext2_xattr_handlers[];
+extern const struct xattr_handler * const ext2_xattr_handlers[];
 
 # else  /* CONFIG_EXT2_FS_XATTR */
 
Signature · 1 line
2.34.1
#24 lore raw

PATCH 11/29 fuse: move fuse_xattr_handlers to .rodata

In reply to Wedson Almeida Filho

From: Wedson Almeida Filho <[email protected]>

This makes it harder for accidental or malicious changes to fuse_xattr_handlers at runtime.

---
 fs/fuse/fuse_i.h | 2 +-
 fs/fuse/xattr.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
fs/fuse/fuse_i.h +1 -1
index 9b7fc7d3c7f1..2e8c2e06cf78 100644
@@ -1268,7 +1268,7 @@ ssize_t fuse_getxattr(struct inode *inode, const char *name, void *value,
 		      size_t size);
 ssize_t fuse_listxattr(struct dentry *entry, char *list, size_t size);
 int fuse_removexattr(struct inode *inode, const char *name);
-extern const struct xattr_handler *fuse_xattr_handlers[];
+extern const struct xattr_handler * const fuse_xattr_handlers[];
 
 struct posix_acl;
 struct posix_acl *fuse_get_inode_acl(struct inode *inode, int type, bool rcu);
fs/fuse/xattr.c +1 -1
index 49c01559580f..5b423fdbb13f 100644
@@ -209,7 +209,7 @@ static const struct xattr_handler fuse_xattr_handler = {
 	.set    = fuse_xattr_set,
 };
 
-const struct xattr_handler *fuse_xattr_handlers[] = {
+const struct xattr_handler * const fuse_xattr_handlers[] = {
 	&fuse_xattr_handler,
 	NULL
 };
Signature · 1 line
2.34.1
#25 lore raw

PATCH 12/29 gfs2: move gfs2_xattr_handlers_max to .rodata

In reply to Wedson Almeida Filho

From: Wedson Almeida Filho <[email protected]>

This makes it harder for accidental or malicious changes to gfs2_xattr_handlers_max at runtime.

---
 fs/gfs2/super.h | 4 ++--
 fs/gfs2/xattr.c | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
fs/gfs2/super.h +2 -2
index bba58629bc45..3555dc69183a 100644
@@ -59,8 +59,8 @@ extern const struct export_operations gfs2_export_ops;
 extern const struct super_operations gfs2_super_ops;
 extern const struct dentry_operations gfs2_dops;
 
-extern const struct xattr_handler *gfs2_xattr_handlers_max[];
-extern const struct xattr_handler **gfs2_xattr_handlers_min;
+extern const struct xattr_handler * const gfs2_xattr_handlers_max[];
+extern const struct xattr_handler * const *gfs2_xattr_handlers_min;
 
 #endif /* __SUPER_DOT_H__ */
 
fs/gfs2/xattr.c +2 -2
index 93b36d026bb4..146c32d44bd1 100644
@@ -1494,7 +1494,7 @@ static const struct xattr_handler gfs2_xattr_trusted_handler = {
 	.set    = gfs2_xattr_set,
 };
 
-const struct xattr_handler *gfs2_xattr_handlers_max[] = {
+const struct xattr_handler * const gfs2_xattr_handlers_max[] = {
 	/* GFS2_FS_FORMAT_MAX */
 	&gfs2_xattr_trusted_handler,
 
@@ -1504,4 +1504,4 @@ const struct xattr_handler *gfs2_xattr_handlers_max[] = {
 	NULL,
 };
 
-const struct xattr_handler **gfs2_xattr_handlers_min = gfs2_xattr_handlers_max + 1;
+const struct xattr_handler * const *gfs2_xattr_handlers_min = gfs2_xattr_handlers_max + 1;
Signature · 1 line
2.34.1
#42 lore raw

PATCH 25/29 ubifs: move ubifs_xattr_handlers to .rodata

In reply to Wedson Almeida Filho

From: Wedson Almeida Filho <[email protected]>

This makes it harder for accidental or malicious changes to ubifs_xattr_handlers at runtime.

---
 fs/ubifs/ubifs.h | 2 +-
 fs/ubifs/xattr.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
fs/ubifs/ubifs.h +1 -1
index 4c36044140e7..8a9a66255e7e 100644
@@ -2043,7 +2043,7 @@ ssize_t ubifs_xattr_get(struct inode *host, const char *name, void *buf,
 			size_t size);
 
 #ifdef CONFIG_UBIFS_FS_XATTR
-extern const struct xattr_handler *ubifs_xattr_handlers[];
+extern const struct xattr_handler * const ubifs_xattr_handlers[];
 ssize_t ubifs_listxattr(struct dentry *dentry, char *buffer, size_t size);
 void ubifs_evict_xattr_inode(struct ubifs_info *c, ino_t xattr_inum);
 int ubifs_purge_xattrs(struct inode *host);
fs/ubifs/xattr.c +1 -1
index 349228dd1191..5e17e9591e6e 100644
@@ -735,7 +735,7 @@ static const struct xattr_handler ubifs_security_xattr_handler = {
 };
 #endif
 
-const struct xattr_handler *ubifs_xattr_handlers[] = {
+const struct xattr_handler * const ubifs_xattr_handlers[] = {
 	&ubifs_user_xattr_handler,
 	&ubifs_trusted_xattr_handler,
 #ifdef CONFIG_UBIFS_FS_SECURITY
Signature · 6 lines
2.34.1


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
#48 lore raw

PATCH 28/29 shmem: move shmem_xattr_handlers to .rodata

In reply to Wedson Almeida Filho

From: Wedson Almeida Filho <[email protected]>

This makes it harder for accidental or malicious changes to shmem_xattr_handlers at runtime.

---
 mm/shmem.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
mm/shmem.c +1 -1
index d963c747dabc..683c84d667c1 100644
@@ -3487,7 +3487,7 @@ static const struct xattr_handler shmem_trusted_xattr_handler = {
 	.set = shmem_xattr_handler_set,
 };
 
-static const struct xattr_handler *shmem_xattr_handlers[] = {
+static const struct xattr_handler * const shmem_xattr_handlers[] = {
 	&shmem_security_xattr_handler,
 	&shmem_trusted_xattr_handler,
 	NULL
Signature · 1 line
2.34.1
#49 lore raw

PATCH 29/29 net: move sockfs_xattr_handlers to .rodata

In reply to Wedson Almeida Filho

From: Wedson Almeida Filho <[email protected]>

This makes it harder for accidental or malicious changes to sockfs_xattr_handlers at runtime.

Cc "David S. Miller" <[email protected]>
Cc Eric Dumazet <[email protected]>
Cc Jakub Kicinski <[email protected]>
Cc Paolo Abeni <[email protected]>
Cc Richard Cochran <[email protected]>
---
 include/linux/pseudo_fs.h | 2 +-
 net/socket.c              | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
include/linux/pseudo_fs.h +1 -1
index eceda1d1407a..730f77381d55 100644
@@ -5,7 +5,7 @@
 
 struct pseudo_fs_context {
 	const struct super_operations *ops;
-	const struct xattr_handler **xattr;
+	const struct xattr_handler * const *xattr;
 	const struct dentry_operations *dops;
 	unsigned long magic;
 };
net/socket.c +1 -1
index 2b0e54b2405c..0a99fc22641e 100644
@@ -400,7 +400,7 @@ static const struct xattr_handler sockfs_security_xattr_handler = {
 	.set = sockfs_security_xattr_set,
 };
 
-static const struct xattr_handler *sockfs_xattr_handlers[] = {
+static const struct xattr_handler * const sockfs_xattr_handlers[] = {
 	&sockfs_xattr_handler,
 	&sockfs_security_xattr_handler,
 	NULL
Signature · 1 line
2.34.1
#26 lore raw

PATCH 13/29 hfs: move hfs_xattr_handlers to .rodata

In reply to Wedson Almeida Filho

From: Wedson Almeida Filho <[email protected]>

This makes it harder for accidental or malicious changes to hfs_xattr_handlers at runtime.

---
 fs/hfs/attr.c   | 2 +-
 fs/hfs/hfs_fs.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
fs/hfs/attr.c +1 -1
index 6341bb248247..f8395cdd1adf 100644
@@ -146,7 +146,7 @@ static const struct xattr_handler hfs_type_handler = {
 	.set = hfs_xattr_set,
 };
 
-const struct xattr_handler *hfs_xattr_handlers[] = {
+const struct xattr_handler * const hfs_xattr_handlers[] = {
 	&hfs_creator_handler,
 	&hfs_type_handler,
 	NULL
fs/hfs/hfs_fs.h +1 -1
index 49d02524e667..b5a6ad5df357 100644
@@ -215,7 +215,7 @@ extern void hfs_evict_inode(struct inode *);
 extern void hfs_delete_inode(struct inode *);
 
 /* attr.c */
-extern const struct xattr_handler *hfs_xattr_handlers[];
+extern const struct xattr_handler * const hfs_xattr_handlers[];
 
 /* mdb.c */
 extern int hfs_mdb_get(struct super_block *);
Signature · 1 line
2.34.1
#27 lore raw

PATCH 14/29 hfsplus: move hfsplus_xattr_handlers to .rodata

In reply to Wedson Almeida Filho

From: Wedson Almeida Filho <[email protected]>

This makes it harder for accidental or malicious changes to hfsplus_xattr_handlers at runtime.

---
 fs/hfsplus/xattr.c | 2 +-
 fs/hfsplus/xattr.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
fs/hfsplus/xattr.c +1 -1
index 58021e73c00b..9c9ff6b8c6f7 100644
@@ -13,7 +13,7 @@
 
 static int hfsplus_removexattr(struct inode *inode, const char *name);
 
-const struct xattr_handler *hfsplus_xattr_handlers[] = {
+const struct xattr_handler * const hfsplus_xattr_handlers[] = {
 	&hfsplus_xattr_osx_handler,
 	&hfsplus_xattr_user_handler,
 	&hfsplus_xattr_trusted_handler,
fs/hfsplus/xattr.h +1 -1
index d14e362b3eba..15cc55e41410 100644
@@ -17,7 +17,7 @@ extern const struct xattr_handler hfsplus_xattr_user_handler;
 extern const struct xattr_handler hfsplus_xattr_trusted_handler;
 extern const struct xattr_handler hfsplus_xattr_security_handler;
 
-extern const struct xattr_handler *hfsplus_xattr_handlers[];
+extern const struct xattr_handler * const hfsplus_xattr_handlers[];
 
 int __hfsplus_setxattr(struct inode *inode, const char *name,
 			const void *value, size_t size, int flags);
Signature · 1 line
2.34.1
#30 lore raw

PATCH 16/29 jfs: move jfs_xattr_handlers to .rodata

In reply to Wedson Almeida Filho

From: Wedson Almeida Filho <[email protected]>

This makes it harder for accidental or malicious changes to jfs_xattr_handlers at runtime.

---
 fs/jfs/jfs_xattr.h | 2 +-
 fs/jfs/xattr.c     | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
fs/jfs/jfs_xattr.h +1 -1
index 0d33816d251d..ec67d8554d2c 100644
@@ -46,7 +46,7 @@ extern int __jfs_setxattr(tid_t, struct inode *, const char *, const void *,
 extern ssize_t __jfs_getxattr(struct inode *, const char *, void *, size_t);
 extern ssize_t jfs_listxattr(struct dentry *, char *, size_t);
 
-extern const struct xattr_handler *jfs_xattr_handlers[];
+extern const struct xattr_handler * const jfs_xattr_handlers[];
 
 #ifdef CONFIG_JFS_SECURITY
 extern int jfs_init_security(tid_t, struct inode *, struct inode *,
fs/jfs/xattr.c +1 -1
index 931e50018f88..001c900a2b4d 100644
@@ -985,7 +985,7 @@ static const struct xattr_handler jfs_trusted_xattr_handler = {
 	.set = jfs_xattr_set,
 };
 
-const struct xattr_handler *jfs_xattr_handlers[] = {
+const struct xattr_handler * const jfs_xattr_handlers[] = {
 	&jfs_os2_xattr_handler,
 	&jfs_user_xattr_handler,
 	&jfs_security_xattr_handler,
Signature · 1 line
2.34.1
#32 lore raw

PATCH 17/29 kernfs: move kernfs_xattr_handlers to .rodata

In reply to Wedson Almeida Filho

From: Wedson Almeida Filho <[email protected]>

This makes it harder for accidental or malicious changes to kernfs_xattr_handlers at runtime.

Cc Greg Kroah-Hartman <[email protected]>
Cc Tejun Heo <[email protected]>
---
 fs/kernfs/inode.c           | 2 +-
 fs/kernfs/kernfs-internal.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
fs/kernfs/inode.c +1 -1
index b22b74d1a115..45a63c4e5e4e 100644
@@ -434,7 +434,7 @@ static const struct xattr_handler kernfs_user_xattr_handler = {
 	.set = kernfs_vfs_user_xattr_set,
 };
 
-const struct xattr_handler *kernfs_xattr_handlers[] = {
+const struct xattr_handler * const kernfs_xattr_handlers[] = {
 	&kernfs_trusted_xattr_handler,
 	&kernfs_security_xattr_handler,
 	&kernfs_user_xattr_handler,
fs/kernfs/kernfs-internal.h +1 -1
index a9b854cdfdb5..237f2764b941 100644
@@ -127,7 +127,7 @@ extern struct kmem_cache *kernfs_node_cache, *kernfs_iattrs_cache;
 /*
  * inode.c
  */
-extern const struct xattr_handler *kernfs_xattr_handlers[];
+extern const struct xattr_handler * const kernfs_xattr_handlers[];
 void kernfs_evict_inode(struct inode *inode);
 int kernfs_iop_permission(struct mnt_idmap *idmap,
 			  struct inode *inode, int mask);
Signature · 1 line
2.34.1
#34 lore raw

PATCH 18/29 nfs: move nfs4_xattr_handlers to .rodata

In reply to Wedson Almeida Filho

From: Wedson Almeida Filho <[email protected]>

This makes it harder for accidental or malicious changes to nfs4_xattr_handlers at runtime.

---
 fs/nfs/nfs.h      | 2 +-
 fs/nfs/nfs4_fs.h  | 2 +-
 fs/nfs/nfs4proc.c | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
fs/nfs/nfs.h +1 -1
index 5ba00610aede..0d3ce0460e35 100644
@@ -18,7 +18,7 @@ struct nfs_subversion {
 	const struct rpc_version *rpc_vers;	/* NFS version information */
 	const struct nfs_rpc_ops *rpc_ops;	/* NFS operations */
 	const struct super_operations *sops;	/* NFS Super operations */
-	const struct xattr_handler **xattr;	/* NFS xattr handlers */
+	const struct xattr_handler * const *xattr;	/* NFS xattr handlers */
 	struct list_head list;		/* List of NFS versions */
 };
 
fs/nfs/nfs4_fs.h +1 -1
index 4c9f8bd866ab..28499a0da4c3 100644
@@ -315,7 +315,7 @@ extern struct rpc_clnt *nfs4_proc_lookup_mountpoint(struct inode *,
 						    struct nfs_fh *,
 						    struct nfs_fattr *);
 extern int nfs4_proc_secinfo(struct inode *, const struct qstr *, struct nfs4_secinfo_flavors *);
-extern const struct xattr_handler *nfs4_xattr_handlers[];
+extern const struct xattr_handler * const nfs4_xattr_handlers[];
 extern int nfs4_set_rw_stateid(nfs4_stateid *stateid,
 		const struct nfs_open_context *ctx,
 		const struct nfs_lock_context *l_ctx,
fs/nfs/nfs4proc.c +1 -1
index 832fa226b8f2..4557a14a596c 100644
@@ -10740,7 +10740,7 @@ static const struct xattr_handler nfs4_xattr_nfs4_user_handler = {
 };
 #endif
 
-const struct xattr_handler *nfs4_xattr_handlers[] = {
+const struct xattr_handler * const nfs4_xattr_handlers[] = {
 	&nfs4_xattr_nfs4_acl_handler,
 #if defined(CONFIG_NFS_V4_1)
 	&nfs4_xattr_nfs4_dacl_handler,
Signature · 1 line
2.34.1
#37 lore raw

PATCH 21/29 orangefs: move orangefs_xattr_handlers to .rodata

In reply to Wedson Almeida Filho

From: Wedson Almeida Filho <[email protected]>

This makes it harder for accidental or malicious changes to orangefs_xattr_handlers at runtime.

---
 fs/orangefs/orangefs-kernel.h | 2 +-
 fs/orangefs/xattr.c           | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
fs/orangefs/orangefs-kernel.h +1 -1
index ce20d3443869..e211f29544e5 100644
@@ -103,7 +103,7 @@ enum orangefs_vfs_op_states {
 #define ORANGEFS_CACHE_CREATE_FLAGS 0
 #endif
 
-extern const struct xattr_handler *orangefs_xattr_handlers[];
+extern const struct xattr_handler * const orangefs_xattr_handlers[];
 
 extern struct posix_acl *orangefs_get_acl(struct inode *inode, int type, bool rcu);
 extern int orangefs_set_acl(struct mnt_idmap *idmap,
fs/orangefs/xattr.c +1 -1
index 68b62689a63e..74ef75586f38 100644
@@ -554,7 +554,7 @@ static const struct xattr_handler orangefs_xattr_default_handler = {
 	.set = orangefs_xattr_set_default,
 };
 
-const struct xattr_handler *orangefs_xattr_handlers[] = {
+const struct xattr_handler * const orangefs_xattr_handlers[] = {
 	&orangefs_xattr_default_handler,
 	NULL
 };
Signature · 1 line
2.34.1
#39 lore raw

PATCH 23/29 smb: move cifs_xattr_handlers to .rodata

In reply to Wedson Almeida Filho

From: Wedson Almeida Filho <[email protected]>

This makes it harder for accidental or malicious changes to cifs_xattr_handlers at runtime.

Cc Steve French <[email protected]>
Cc Paulo Alcantara <[email protected]>
Cc Ronnie Sahlberg <[email protected]>
Cc Shyam Prasad N <[email protected]>
Cc Tom Talpey <[email protected]>
---
 fs/smb/client/cifsfs.h | 2 +-
 fs/smb/client/xattr.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
fs/smb/client/cifsfs.h +1 -1
index 15c8cc4b6680..a0472b539567 100644
@@ -134,7 +134,7 @@ extern int cifs_symlink(struct mnt_idmap *idmap, struct inode *inode,
 			struct dentry *direntry, const char *symname);
 
 #ifdef CONFIG_CIFS_XATTR
-extern const struct xattr_handler *cifs_xattr_handlers[];
+extern const struct xattr_handler * const cifs_xattr_handlers[];
 extern ssize_t	cifs_listxattr(struct dentry *, char *, size_t);
 #else
 # define cifs_xattr_handlers NULL
fs/smb/client/xattr.c +1 -1
index 4ad5531686d8..ac199160bce6 100644
@@ -478,7 +478,7 @@ static const struct xattr_handler smb3_ntsd_full_xattr_handler = {
 	.set = cifs_xattr_set,
 };
 
-const struct xattr_handler *cifs_xattr_handlers[] = {
+const struct xattr_handler * const cifs_xattr_handlers[] = {
 	&cifs_user_xattr_handler,
 	&cifs_os2_xattr_handler,
 	&cifs_cifs_acl_xattr_handler,
Signature · 1 line
2.34.1
#41 lore raw

PATCH 24/29 squashfs: move squashfs_xattr_handlers to .rodata

In reply to Wedson Almeida Filho

From: Wedson Almeida Filho <[email protected]>

This makes it harder for accidental or malicious changes to squashfs_xattr_handlers at runtime.

---
 fs/squashfs/squashfs.h | 2 +-
 fs/squashfs/xattr.c    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
fs/squashfs/squashfs.h +1 -1
index a6164fdf9435..5a756e6790b5 100644
@@ -111,4 +111,4 @@ extern const struct address_space_operations squashfs_symlink_aops;
 extern const struct inode_operations squashfs_symlink_inode_ops;
 
 /* xattr.c */
-extern const struct xattr_handler *squashfs_xattr_handlers[];
+extern const struct xattr_handler * const squashfs_xattr_handlers[];
fs/squashfs/xattr.c +1 -1
index e1e3f3dd5a06..ce6608cabd49 100644
@@ -262,7 +262,7 @@ static const struct xattr_handler *squashfs_xattr_handler(int type)
 	}
 }
 
-const struct xattr_handler *squashfs_xattr_handlers[] = {
+const struct xattr_handler * const squashfs_xattr_handlers[] = {
 	&squashfs_xattr_user_handler,
 	&squashfs_xattr_trusted_handler,
 	&squashfs_xattr_security_handler,
Signature · 1 line
2.34.1
#44 lore raw

PATCH 26/29 xfs: move xfs_xattr_handlers to .rodata

In reply to Wedson Almeida Filho

From: Wedson Almeida Filho <[email protected]>

This makes it harder for accidental or malicious changes to xfs_xattr_handlers at runtime.

---
 fs/xfs/xfs_xattr.c | 2 +-
 fs/xfs/xfs_xattr.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
fs/xfs/xfs_xattr.c +1 -1
index 43e5c219aaed..77418bcd6f3a 100644
@@ -175,7 +175,7 @@ static const struct xattr_handler xfs_xattr_security_handler = {
 	.set	= xfs_xattr_set,
 };
 
-const struct xattr_handler *xfs_xattr_handlers[] = {
+const struct xattr_handler * const xfs_xattr_handlers[] = {
 	&xfs_xattr_user_handler,
 	&xfs_xattr_trusted_handler,
 	&xfs_xattr_security_handler,
fs/xfs/xfs_xattr.h +1 -1
index 2b09133b1b9b..cec766cad26c 100644
@@ -8,6 +8,6 @@
 
 int xfs_attr_change(struct xfs_da_args *args);
 
-extern const struct xattr_handler *xfs_xattr_handlers[];
+extern const struct xattr_handler * const xfs_xattr_handlers[];
 
 #endif /* __XFS_XATTR_H__ */
Signature · 1 line
2.34.1
#46 lore raw

PATCH 27/29 overlayfs: move xattr tables to .rodata

In reply to Wedson Almeida Filho

From: Wedson Almeida Filho <[email protected]>

This makes it harder for accidental or malicious changes to ovl_trusted_xattr_handlers or ovl_user_xattr_handlers at runtime.

---
 fs/overlayfs/super.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/overlayfs/super.c +2 -2
index cc8977498c48..fe7af47be621 100644
@@ -477,13 +477,13 @@ static const struct xattr_handler ovl_other_xattr_handler = {
 	.set = ovl_other_xattr_set,
 };
 
-static const struct xattr_handler *ovl_trusted_xattr_handlers[] = {
+static const struct xattr_handler * const ovl_trusted_xattr_handlers[] = {
 	&ovl_own_trusted_xattr_handler,
 	&ovl_other_xattr_handler,
 	NULL
 };
 
-static const struct xattr_handler *ovl_user_xattr_handlers[] = {
+static const struct xattr_handler * const ovl_user_xattr_handlers[] = {
 	&ovl_own_user_xattr_handler,
 	&ovl_other_xattr_handler,
 	NULL
Signature · 1 line
2.34.1
#2 lore raw

Re: [PATCH 01/29] xattr: make the xattr array itself const

In reply to Wedson Almeida Filho
kernel test robot noticed the following build warnings:

Hi Wedson,

kernel test robot noticed the following build warnings:

[auto build test WARNING on 2dde18cd1d8fac735875f2e4987f11817cc0bc2c]

url:    https://github.com/intel-lab-lkp/linux/commits/Wedson-Almeida-Filho/xattr-make-the-xattr-array-itself-const/20230930-130453
base:   2dde18cd1d8fac735875f2e4987f11817cc0bc2c
patch link:    https://lore.kernel.org/r/20230930050033.41174-2-wedsonaf%40gmail.com
patch subject: [PATCH 01/29] xattr: make the xattr array itself const
config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20230930/[email protected]/config)
compiler: m68k-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230930/[email protected]/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All warnings (new ones prefixed by >>):

fs/reiserfs/xattr.c: In function 'listxattr_filler':

>> fs/reiserfs/xattr.c:822:57: warning: passing argument 1 of 'reiserfs_xattr_list' discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]
     822 |                 if (!reiserfs_xattr_list(b->dentry->d_sb->s_xattr, name,
         |                                          ~~~~~~~~~~~~~~~^~~~~~~~~

fs/reiserfs/xattr.c:782:69: note: expected 'const struct xattr_handler **' but argument is of type 'const struct xattr_handler * const*'
782 | static inline bool reiserfs_xattr_list(const struct xattr_handler **handlers,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~

vim +822 fs/reiserfs/xattr.c

^1da177e4c3f41 Linus Torvalds      2005-04-16  811  
25885a35a72007 Al Viro             2022-08-16  812  static bool listxattr_filler(struct dir_context *ctx, const char *name,
ac7576f4b1da8c Miklos Szeredi      2014-10-30  813  			    int namelen, loff_t offset, u64 ino,
ac7576f4b1da8c Miklos Szeredi      2014-10-30  814  			    unsigned int d_type)
^1da177e4c3f41 Linus Torvalds      2005-04-16  815  {
ac7576f4b1da8c Miklos Szeredi      2014-10-30  816  	struct listxattr_buf *b =
ac7576f4b1da8c Miklos Szeredi      2014-10-30  817  		container_of(ctx, struct listxattr_buf, ctx);
48b32a3553a547 Jeff Mahoney        2009-03-30  818  	size_t size;
f3fb9e27325c4e Fabian Frederick    2014-08-08  819  
48b32a3553a547 Jeff Mahoney        2009-03-30  820  	if (name[0] != '.' ||
48b32a3553a547 Jeff Mahoney        2009-03-30  821  	    (namelen != 1 && (name[1] != '.' || namelen != 2))) {
387b96a5891c07 Christian Brauner   2023-02-01 @822  		if (!reiserfs_xattr_list(b->dentry->d_sb->s_xattr, name,
387b96a5891c07 Christian Brauner   2023-02-01  823  					 b->dentry))
25885a35a72007 Al Viro             2022-08-16  824  			return true;
764a5c6b1fa430 Andreas Gruenbacher 2015-12-02  825  		size = namelen + 1;
48b32a3553a547 Jeff Mahoney        2009-03-30  826  		if (b->buf) {
a13f085d111e90 Jann Horn           2018-08-21  827  			if (b->pos + size > b->size) {
a13f085d111e90 Jann Horn           2018-08-21  828  				b->pos = -ERANGE;
25885a35a72007 Al Viro             2022-08-16  829  				return false;
a13f085d111e90 Jann Horn           2018-08-21  830  			}
764a5c6b1fa430 Andreas Gruenbacher 2015-12-02  831  			memcpy(b->buf + b->pos, name, namelen);
764a5c6b1fa430 Andreas Gruenbacher 2015-12-02  832  			b->buf[b->pos + namelen] = 0;
^1da177e4c3f41 Linus Torvalds      2005-04-16  833  		}
48b32a3553a547 Jeff Mahoney        2009-03-30  834  		b->pos += size;
48b32a3553a547 Jeff Mahoney        2009-03-30  835  	}
25885a35a72007 Al Viro             2022-08-16  836  	return true;
^1da177e4c3f41 Linus Torvalds      2005-04-16  837  }
bd4c625c061c2a Linus Torvalds      2005-07-12  838  
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
reviewer Reviewed-by on v1 3/29
#6 lore raw

Re: [PATCH 03/29] 9p: move xattr-related structs to .rodata

In reply to Wedson Almeida Filho
Quoted 6 lines · CEST Wedson Almeida Filho

From: Wedson Almeida Filho <[email protected]>

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.

Quoted 6 lines
Cc Eric Van Hensbergen <[email protected]>
Cc Latchesar Ionkov <[email protected]>
Cc Dominique Martinet <[email protected]>
Cc Christian Schoenebeck <[email protected]>
Quoted 55 lines
---
 fs/9p/xattr.c | 8 ++++----
 fs/9p/xattr.h | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)
fs/9p/xattr.c +4 -4
index e00cf8109b3f..053d1cef6e13 100644
@@ -162,27 +162,27 @@ static int v9fs_xattr_handler_set(const struct xattr_handler *handler,
 	return v9fs_xattr_set(dentry, full_name, value, size, flags);
 }
 
-static struct xattr_handler v9fs_xattr_user_handler = {
+static const struct xattr_handler v9fs_xattr_user_handler = {
 	.prefix	= XATTR_USER_PREFIX,
 	.get	= v9fs_xattr_handler_get,
 	.set	= v9fs_xattr_handler_set,
 };
 
-static struct xattr_handler v9fs_xattr_trusted_handler = {
+static const struct xattr_handler v9fs_xattr_trusted_handler = {
 	.prefix	= XATTR_TRUSTED_PREFIX,
 	.get	= v9fs_xattr_handler_get,
 	.set	= v9fs_xattr_handler_set,
 };
 
 #ifdef CONFIG_9P_FS_SECURITY
-static struct xattr_handler v9fs_xattr_security_handler = {
+static const struct xattr_handler v9fs_xattr_security_handler = {
 	.prefix	= XATTR_SECURITY_PREFIX,
 	.get	= v9fs_xattr_handler_get,
 	.set	= v9fs_xattr_handler_set,
 };
 #endif
 
-const struct xattr_handler *v9fs_xattr_handlers[] = {
+const struct xattr_handler * const v9fs_xattr_handlers[] = {
 	&v9fs_xattr_user_handler,
 	&v9fs_xattr_trusted_handler,
 #ifdef CONFIG_9P_FS_SECURITY
fs/9p/xattr.h +1 -1
index b5636e544c8a..3ad5a802352a 100644
@@ -10,7 +10,7 @@
 #include <net/9p/9p.h>
 #include <net/9p/client.h>
 
-extern const struct xattr_handler *v9fs_xattr_handlers[];
+extern const struct xattr_handler * const v9fs_xattr_handlers[];
 
 ssize_t v9fs_fid_xattr_get(struct p9_fid *fid, const char *name,
 			   void *buffer, size_t buffer_size);
#7 lore raw

Re: [PATCH 03/29] 9p: move xattr-related structs to .rodata

Christian Schoenebeck wrote on Sat, Sep 30, 2023 at 10:12:25AM +0200:

Quoted 7 lines · CEST Wedson Almeida Filho
Quoted 6 lines

From: Wedson Almeida Filho <[email protected]>

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.

Quoted 8 lines
Quoted 6 lines
Cc Eric Van Hensbergen <[email protected]>
Cc Latchesar Ionkov <[email protected]>
Cc Dominique Martinet <[email protected]>
Cc Christian Schoenebeck <[email protected]>

Looks good to me on principle as well (and it should blow up immediately on testing in the unlikely case there's a problem...)

Eric, I don't think you have anything planned for this round? There's another data race patch laying around that we didn't submit for 6.6, shall I take these two for now?

(Assuming this patch series is meant to be taken up by individual fs maintainers independantly, it's never really clear with such large swatches of patchs and we weren't in Cc of a cover letter if there was any... In the future it'd help if either there's a clear cover letter everyone is in Cc at (some would say keep everyone in cc of all patches!), or just send these in a loop so they don't appear to be part of a series and each maintainer deals with it as they see fit)

Signature · 1 line
Dominique
Reviewed-by on v1 26/29
#45 lore raw

Re: [PATCH 26/29] xfs: move xfs_xattr_handlers to .rodata

In reply to Wedson Almeida Filho
Quoted 8 lines · Wedson Almeida Filho

From: Wedson Almeida Filho <[email protected]>

This makes it harder for accidental or malicious changes to xfs_xattr_handlers at runtime.

--D

Quoted 33 lines
---
 fs/xfs/xfs_xattr.c | 2 +-
 fs/xfs/xfs_xattr.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
fs/xfs/xfs_xattr.c +1 -1
index 43e5c219aaed..77418bcd6f3a 100644
@@ -175,7 +175,7 @@ static const struct xattr_handler xfs_xattr_security_handler = {
 	.set	= xfs_xattr_set,
 };
 
-const struct xattr_handler *xfs_xattr_handlers[] = {
+const struct xattr_handler * const xfs_xattr_handlers[] = {
 	&xfs_xattr_user_handler,
 	&xfs_xattr_trusted_handler,
 	&xfs_xattr_security_handler,
fs/xfs/xfs_xattr.h +1 -1
index 2b09133b1b9b..cec766cad26c 100644
@@ -8,6 +8,6 @@
 
 int xfs_attr_change(struct xfs_da_args *args);
 
-extern const struct xattr_handler *xfs_xattr_handlers[];
+extern const struct xattr_handler * const xfs_xattr_handlers[];
 
 #endif /* __XFS_XATTR_H__ */
Signature · 1 line
2.34.1
Reviewed-by on v1 23/29
#40 lore raw

Re: [PATCH 23/29] smb: move cifs_xattr_handlers to .rodata

In reply to Wedson Almeida Filho
Quoted 47 lines · Wedson Almeida Filho

From: Wedson Almeida Filho <[email protected]>

This makes it harder for accidental or malicious changes to cifs_xattr_handlers at runtime.

Cc Steve French <[email protected]>
Cc Paulo Alcantara <[email protected]>
Cc Ronnie Sahlberg <[email protected]>
Cc Shyam Prasad N <[email protected]>
Cc Tom Talpey <[email protected]>
---
 fs/smb/client/cifsfs.h | 2 +-
 fs/smb/client/xattr.c  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
fs/smb/client/cifsfs.h +1 -1
index 15c8cc4b6680..a0472b539567 100644
@@ -134,7 +134,7 @@ extern int cifs_symlink(struct mnt_idmap *idmap, struct inode *inode,
                        struct dentry *direntry, const char *symname);
 
 #ifdef CONFIG_CIFS_XATTR
-extern const struct xattr_handler *cifs_xattr_handlers[];
+extern const struct xattr_handler * const cifs_xattr_handlers[];
 extern ssize_t cifs_listxattr(struct dentry *, char *, size_t);
 #else
 # define cifs_xattr_handlers NULL
fs/smb/client/xattr.c +1 -2
index 4ad5531686d8..ac199160bce6 100644
@@ -478,7 +478,7 @@ static const struct xattr_handler smb3_ntsd_full_xattr_handler = {
        .set = cifs_xattr_set,
 };
 
-const struct xattr_handler *cifs_xattr_handlers[] = {
+const struct xattr_handler * const cifs_xattr_handlers[] = {
        &cifs_user_xattr_handler,
        &cifs_os2_xattr_handler,
        &cifs_cifs_acl_xattr_handler,
--

2.34.1

Signature · 3 lines
Thanks,

Steve
reviewer Acked-by on v1 9/29
#21 lore raw

Re: [PATCH 09/29] ext2: move ext2_xattr_handlers and ext2_xattr_handler_map to .rodata

In reply to Wedson Almeida Filho
Quoted 8 lines · Wedson Almeida Filho

From: Wedson Almeida Filho <[email protected]>

This makes it harder for accidental or malicious changes to ext2_xattr_handlers or ext2_xattr_handler_map at runtime.

Looks good to me. Feel free to add:

Honza

Quoted 43 lines
---
 fs/ext2/xattr.c | 4 ++--
 fs/ext2/xattr.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
fs/ext2/xattr.c +2 -2
index 8906ba479aaf..cfbe376da612 100644
@@ -98,7 +98,7 @@ static struct buffer_head *ext2_xattr_cache_find(struct inode *,
 static void ext2_xattr_rehash(struct ext2_xattr_header *,
 			      struct ext2_xattr_entry *);
 
-static const struct xattr_handler *ext2_xattr_handler_map[] = {
+static const struct xattr_handler * const ext2_xattr_handler_map[] = {
 	[EXT2_XATTR_INDEX_USER]		     = &ext2_xattr_user_handler,
 #ifdef CONFIG_EXT2_FS_POSIX_ACL
 	[EXT2_XATTR_INDEX_POSIX_ACL_ACCESS]  = &nop_posix_acl_access,
@@ -110,7 +110,7 @@ static const struct xattr_handler *ext2_xattr_handler_map[] = {
 #endif
 };
 
-const struct xattr_handler *ext2_xattr_handlers[] = {
+const struct xattr_handler * const ext2_xattr_handlers[] = {
 	&ext2_xattr_user_handler,
 	&ext2_xattr_trusted_handler,
 #ifdef CONFIG_EXT2_FS_SECURITY
fs/ext2/xattr.h +1 -1
index 7925f596e8e2..6a4966949047 100644
@@ -72,7 +72,7 @@ extern void ext2_xattr_delete_inode(struct inode *);
 extern struct mb_cache *ext2_xattr_create_cache(void);
 extern void ext2_xattr_destroy_cache(struct mb_cache *cache);
 
-extern const struct xattr_handler *ext2_xattr_handlers[];
+extern const struct xattr_handler * const ext2_xattr_handlers[];
 
 # else  /* CONFIG_EXT2_FS_XATTR */
 
Signature · 1 line
2.34.1
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
#3 lore raw

Re: [PATCH 01/29] xattr: make the xattr array itself const

In reply to Wedson Almeida Filho
Quoted 6 lines · Wedson Almeida Filho

From: Wedson Almeida Filho <[email protected]>

As it is currently declared, the xattr_handler structs are const but the array containing their pointers is not. This patch makes it so that fs modules can place them in .rodata, which makes it harder for accidental/malicious modifications at runtime.

You could also add an entry to scripts/const_structs.checkpatch to make sure newly introduced usages of the struct are const.

Could be a single dedicated patch after this patch has been applied.

Quoted 53 lines
---
 fs/xattr.c         | 6 +++---
 include/linux/fs.h | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)
fs/xattr.c +3 -3
index e7bbb7f57557..1905f8ede13d 100644
@@ -56,7 +56,7 @@ strcmp_prefix(const char *a, const char *a_prefix)
 static const struct xattr_handler *
 xattr_resolve_name(struct inode *inode, const char **name)
 {
-	const struct xattr_handler **handlers = inode->i_sb->s_xattr;
+	const struct xattr_handler * const *handlers = inode->i_sb->s_xattr;
 	const struct xattr_handler *handler;
 
 	if (!(inode->i_opflags & IOP_XATTR)) {
@@ -162,7 +162,7 @@ xattr_permission(struct mnt_idmap *idmap, struct inode *inode,
 int
 xattr_supports_user_prefix(struct inode *inode)
 {
-	const struct xattr_handler **handlers = inode->i_sb->s_xattr;
+	const struct xattr_handler * const *handlers = inode->i_sb->s_xattr;
 	const struct xattr_handler *handler;
 
 	if (!(inode->i_opflags & IOP_XATTR)) {
@@ -999,7 +999,7 @@ int xattr_list_one(char **buffer, ssize_t *remaining_size, const char *name)
 ssize_t
 generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size)
 {
-	const struct xattr_handler *handler, **handlers = dentry->d_sb->s_xattr;
+	const struct xattr_handler *handler, * const *handlers = dentry->d_sb->s_xattr;
 	ssize_t remaining_size = buffer_size;
 	int err = 0;
 
include/linux/fs.h +1 -1
index 562f2623c9c9..4d8003f48216 100644
@@ -1172,7 +1172,7 @@ struct super_block {
 #ifdef CONFIG_SECURITY
 	void                    *s_security;
 #endif
-	const struct xattr_handler **s_xattr;
+	const struct xattr_handler * const *s_xattr;
 #ifdef CONFIG_FS_ENCRYPTION
 	const struct fscrypt_operations	*s_cop;
 	struct fscrypt_keyring	*s_master_keys; /* master crypto keys in use */
Signature · 1 line
2.34.1
#12 lore raw

Re: [PATCH 05/29] btrfs: move btrfs_xattr_handlers to .rodata

In reply to Wedson Almeida Filho
Quoted 10 lines · Wedson Almeida Filho

From: Wedson Almeida Filho <[email protected]>

This makes it harder for accidental or malicious changes to btrfs_xattr_handlers at runtime.

With slightly updated changelog added to misc-next, thanks.

#13 lore raw

Re: [PATCH 05/29] btrfs: move btrfs_xattr_handlers to .rodata

Quoted 6 lines · David Sterba
Quoted 5 lines · Wedson Almeida Filho

From: Wedson Almeida Filho <[email protected]>

This makes it harder for accidental or malicious changes to btrfs_xattr_handlers at runtime.

Quoted 7 lines
Quoted 5 lines

With slightly updated changelog added to misc-next, thanks.

Removed again. I did not notice first that this is part of a larger series, please also CC the [PATCH 0/N] patch.

There's a warning:

fs/btrfs/super.c: In function ‘btrfs_fill_super’:
fs/btrfs/super.c:1107:21: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
1107 | sb->s_xattr = btrfs_xattr_handlers;
| ^

but the patch changing the type is present in the series.

Please update the changelog of btrfs patch with:

Add const specifier also to the pointed array members of btrfs_xattr_handlers. This moves the whole structure to the .rodata section which makes it harder for accidental or malicious changes to btrfs_xattr_handlers at runtime.

or use it for others patches too.

#51 lore raw
In reply to Wedson Almeida Filho
Quoted 11 lines · Wedson Almeida Filho

From: Wedson Almeida Filho <[email protected]>

The 's_xattr' field of 'struct super_block' currently requires a mutable table of 'struct xattr_handler' entries (although each handler itself is const). However, no code in vfs actually modifies the tables.

So this series changes the type of 's_xattr' to allow const tables, and modifies existing file system to move their tables to .rodata. This is desirable because these tables contain entries with function pointers in them; moving them to .rodata makes it considerably less likely to be modified accidentally or maliciously at runtime.

Fine by me and good idea. On vacation this week but I'll wait for individual fs maintainers to ack their portions anyway and then pick up next week.

#14 lore raw

Re: [PATCH 05/29] btrfs: move btrfs_xattr_handlers to .rodata

In reply to David Sterba
Quoted 14 lines · David Sterba
Quoted 12 lines · David Sterba
Quoted 10 lines · Wedson Almeida Filho

From: Wedson Almeida Filho <[email protected]>

This makes it harder for accidental or malicious changes to btrfs_xattr_handlers at runtime.

Quoted 4 lines
Quoted 1 line

With slightly updated changelog added to misc-next, thanks.

Removed again. I did not notice first that this is part of a larger series, please also CC the [PATCH 0/N] patch.

Sorry for the confusion, I will CC you there too.

Quoted 7 lines

There's a warning:

fs/btrfs/super.c: In function ‘btrfs_fill_super’:
fs/btrfs/super.c:1107:21: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
1107 | sb->s_xattr = btrfs_xattr_handlers;
| ^

Quoted 8 lines

but the patch changing the type is present in the series.

Please update the changelog of btrfs patch with:

Add const specifier also to the pointed array members of btrfs_xattr_handlers. This moves the whole structure to the .rodata section which makes it harder for accidental or malicious changes to btrfs_xattr_handlers at runtime.

Will do. Thanks!

Quoted 1 line

or use it for others patches too.

#8 lore raw

Re: [PATCH 03/29] 9p: move xattr-related structs to .rodata

In reply to Dominique Martinet
Quoted 17 lines · Dominique Martinet

Christian Schoenebeck wrote on Sat, Sep 30, 2023 at 10:12:25AM +0200:

Quoted 15 lines · CEST Wedson Almeida Filho
Quoted 6 lines

From: Wedson Almeida Filho <[email protected]>

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.

Quoted 6 lines
Cc Eric Van Hensbergen <[email protected]>
Cc Latchesar Ionkov <[email protected]>
Cc Dominique Martinet <[email protected]>
Cc Christian Schoenebeck <[email protected]>

Thanks for the review, Christian!

Quoted 7 lines

Looks good to me on principle as well (and it should blow up immediately on testing in the unlikely case there's a problem...)

Eric, I don't think you have anything planned for this round? There's another data race patch laying around that we didn't submit for 6.6, shall I take these two for now?

Quoted 7 lines

(Assuming this patch series is meant to be taken up by individual fs maintainers independantly, it's never really clear with such large swatches of patchs and we weren't in Cc of a cover letter if there was any... In the future it'd help if either there's a clear cover letter everyone is in Cc at (some would say keep everyone in cc of all patches!), or just send these in a loop so they don't appear to be part of a series and each maintainer deals with it as they see fit)

There is a cover letter
(https://lore.kernel.org/all/[email protected]/),
apologies for not CCing you there. I was trying to avoid spamming maintainers with unrelated changes.

We need changes in fs/xattr.c (which are in the first patch of the series) to avoid warnings, so unfortunately this can't be taken individually. My thought was that individual fs maintainers would review/ack the patches and this would be taken through the fs tree.

Quoted 3 lines

--
Dominique

maintainer Acked-by on v1 6/29
#16 lore raw

Re: [PATCH 06/29] ceph: move ceph_xattr_handlers to .rodata

In reply to Wedson Almeida Filho
Quoted 43 lines · Wedson Almeida Filho

From: Wedson Almeida Filho <[email protected]>

This makes it harder for accidental or malicious changes to ceph_xattr_handlers at runtime.

---
 fs/ceph/super.h | 2 +-
 fs/ceph/xattr.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
fs/ceph/super.h +1 -1
index 3bfddf34d488..b40be1a0f778 100644
@@ -1089,7 +1089,7 @@ ssize_t __ceph_getxattr(struct inode *, const char *, void *, size_t);
 extern ssize_t ceph_listxattr(struct dentry *, char *, size_t);
 extern struct ceph_buffer *__ceph_build_xattrs_blob(struct ceph_inode_info *ci);
 extern void __ceph_destroy_xattrs(struct ceph_inode_info *ci);
-extern const struct xattr_handler *ceph_xattr_handlers[];
+extern const struct xattr_handler * const ceph_xattr_handlers[];
 
 struct ceph_acl_sec_ctx {
 #ifdef CONFIG_CEPH_FS_POSIX_ACL
fs/ceph/xattr.c +1 -2
index 806183959c47..0350d7465bbb 100644
@@ -1416,7 +1416,7 @@ void ceph_release_acl_sec_ctx(struct ceph_acl_sec_ctx *as_ctx)
  * List of handlers for synthetic system.* attributes. Other
  * attributes are handled directly.
  */
-const struct xattr_handler *ceph_xattr_handlers[] = {
+const struct xattr_handler * const ceph_xattr_handlers[] = {
        &ceph_other_xattr_handler,
        NULL,
 };
--
Quoted 2 lines

2.34.1

Thanks,

Ilya

Reviewed-by on v1 16/29
#31 lore raw

Re: [PATCH 16/29] jfs: move jfs_xattr_handlers to .rodata

In reply to Wedson Almeida Filho
Quoted 8 lines · Wedson Almeida Filho

From: Wedson Almeida Filho <[email protected]>

This makes it harder for accidental or malicious changes to jfs_xattr_handlers at runtime.

Quoted 31 lines
---
  fs/jfs/jfs_xattr.h | 2 +-
  fs/jfs/xattr.c     | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)
fs/jfs/jfs_xattr.h +1 -1
index 0d33816d251d..ec67d8554d2c 100644
@@ -46,7 +46,7 @@ extern int __jfs_setxattr(tid_t, struct inode *, const char *, const void *,
  extern ssize_t __jfs_getxattr(struct inode *, const char *, void *, size_t);
  extern ssize_t jfs_listxattr(struct dentry *, char *, size_t);
 
-extern const struct xattr_handler *jfs_xattr_handlers[];
+extern const struct xattr_handler * const jfs_xattr_handlers[];
 
  #ifdef CONFIG_JFS_SECURITY
  extern int jfs_init_security(tid_t, struct inode *, struct inode *,
fs/jfs/xattr.c +1 -1
index 931e50018f88..001c900a2b4d 100644
@@ -985,7 +985,7 @@ static const struct xattr_handler jfs_trusted_xattr_handler = {
  	.set = jfs_xattr_set,
  };
 
-const struct xattr_handler *jfs_xattr_handlers[] = {
+const struct xattr_handler * const jfs_xattr_handlers[] = {
  	&jfs_os2_xattr_handler,
  	&jfs_user_xattr_handler,
  	&jfs_security_xattr_handler,
maintainer Acked-by on v1 27/29
#47 lore raw

Re: [PATCH 27/29] overlayfs: move xattr tables to .rodata

In reply to Wedson Almeida Filho
Quoted 10 lines · Wedson Almeida Filho

From: Wedson Almeida Filho <[email protected]>

This makes it harder for accidental or malicious changes to ovl_trusted_xattr_handlers or ovl_user_xattr_handlers at runtime.

Quoted 27 lines
---
 fs/overlayfs/super.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/overlayfs/super.c +2 -3
index cc8977498c48..fe7af47be621 100644
@@ -477,13 +477,13 @@ static const struct xattr_handler ovl_other_xattr_handler = {
        .set = ovl_other_xattr_set,
 };
 
-static const struct xattr_handler *ovl_trusted_xattr_handlers[] = {
+static const struct xattr_handler * const ovl_trusted_xattr_handlers[] = {
        &ovl_own_trusted_xattr_handler,
        &ovl_other_xattr_handler,
        NULL
 };
 
-static const struct xattr_handler *ovl_user_xattr_handlers[] = {
+static const struct xattr_handler * const ovl_user_xattr_handlers[] = {
        &ovl_own_user_xattr_handler,
        &ovl_other_xattr_handler,
        NULL
--

2.34.1

maintainer Acked-by
#9 lore raw

Re: [PATCH 03/29] 9p: move xattr-related structs to .rodata

In reply to Wedson Almeida Filho

Wedson Almeida Filho wrote on Tue, Oct 03, 2023 at 10:55:44AM -0300:

Quoted 20 lines
Quoted 7 lines

Looks good to me on principle as well (and it should blow up immediately on testing in the unlikely case there's a problem...)

Eric, I don't think you have anything planned for this round? There's another data race patch laying around that we didn't submit for 6.6, shall I take these two for now?

Quoted 7 lines

(Assuming this patch series is meant to be taken up by individual fs maintainers independantly, it's never really clear with such large swatches of patchs and we weren't in Cc of a cover letter if there was any... In the future it'd help if either there's a clear cover letter everyone is in Cc at (some would say keep everyone in cc of all patches!), or just send these in a loop so they don't appear to be part of a series and each maintainer deals with it as they see fit)

There is a cover letter
(https://lore.kernel.org/all/[email protected]/),
apologies for not CCing you there. I was trying to avoid spamming maintainers with unrelated changes.

Quoted 4 lines

We need changes in fs/xattr.c (which are in the first patch of the series) to avoid warnings, so unfortunately this can't be taken individually. My thought was that individual fs maintainers would review/ack the patches and this would be taken through the fs tree.

Please include all related maintainers in cover letter and any "common"
patch: I'd have complained about the warning if I had taken the time to try it out :)

(b4 made it easy to download a whole thread, but it was't obvious this was required -- I honestly prefer receiving the whole thread than too little patch but I know some maintainers are split on this... At least I think we'll all agree cover letter and required dependencies are useful though -- I now see David Sterba told you something similar, but only after having written that so leaving it in)

By the way the shmem patch failed to apply to 6.6-rc4 and will need rebasing.

With all that said, I've taken a few minutes to check it didn't blow up, so:

Signature · 1 line
Dominique Martinet | Asmadeus
maintainer Acked-by on v1 17/29
#33 lore raw

Re: [PATCH 17/29] kernfs: move kernfs_xattr_handlers to .rodata

In reply to Wedson Almeida Filho
Quoted 8 lines · Wedson Almeida Filho

From: Wedson Almeida Filho <[email protected]>

This makes it harder for accidental or malicious changes to kernfs_xattr_handlers at runtime.

Cc Greg Kroah-Hartman <[email protected]>
Cc Tejun Heo <[email protected]>
reviewer Reviewed-by on v1 25/29
#43 lore raw

Re: [PATCH 25/29] ubifs: move ubifs_xattr_handlers to .rodata

In reply to Wedson Almeida Filho
Quoted 5 lines · Wedson Almeida Filho

From: Wedson Almeida Filho <[email protected]>

This makes it harder for accidental or malicious changes to ubifs_xattr_handlers at runtime.

Quoted 7 lines
---
  fs/ubifs/ubifs.h | 2 +-
  fs/ubifs/xattr.c | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)
Quoted 28 lines
fs/ubifs/ubifs.h +1 -1
index 4c36044140e7..8a9a66255e7e 100644
@@ -2043,7 +2043,7 @@ ssize_t ubifs_xattr_get(struct inode *host, const char *name, void *buf,
  			size_t size);
 
  #ifdef CONFIG_UBIFS_FS_XATTR
-extern const struct xattr_handler *ubifs_xattr_handlers[];
+extern const struct xattr_handler * const ubifs_xattr_handlers[];
  ssize_t ubifs_listxattr(struct dentry *dentry, char *buffer, size_t size);
  void ubifs_evict_xattr_inode(struct ubifs_info *c, ino_t xattr_inum);
  int ubifs_purge_xattrs(struct inode *host);
fs/ubifs/xattr.c +1 -1
index 349228dd1191..5e17e9591e6e 100644
@@ -735,7 +735,7 @@ static const struct xattr_handler ubifs_security_xattr_handler = {
  };
  #endif
 
-const struct xattr_handler *ubifs_xattr_handlers[] = {
+const struct xattr_handler * const ubifs_xattr_handlers[] = {
  	&ubifs_user_xattr_handler,
  	&ubifs_trusted_xattr_handler,
  #ifdef CONFIG_UBIFS_FS_SECURITY
reviewer Reviewed-by on v1 15/29
#29 lore raw

Re: [PATCH 15/29] jffs2: move jffs2_xattr_handlers to .rodata

In reply to Wedson Almeida Filho
Quoted 5 lines · Wedson Almeida Filho

From: Wedson Almeida Filho <[email protected]>

This makes it harder for accidental or malicious changes to jffs2_xattr_handlers at runtime.

Quoted 9 lines
---
  fs/jffs2/xattr.c | 2 +-
  fs/jffs2/xattr.h | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)
Quoted 27 lines
fs/jffs2/xattr.c +1 -1
index 3b6bdc9a49e1..00224f3a8d6e 100644
@@ -920,7 +920,7 @@ struct jffs2_xattr_datum *jffs2_setup_xattr_datum(struct jffs2_sb_info *c,
   * do_jffs2_setxattr(inode, xprefix, xname, buffer, size, flags)
   *   is an implementation of setxattr handler on jffs2.
   * -------------------------------------------------- */
-const struct xattr_handler *jffs2_xattr_handlers[] = {
+const struct xattr_handler * const jffs2_xattr_handlers[] = {
  	&jffs2_user_xattr_handler,
  #ifdef CONFIG_JFFS2_FS_SECURITY
  	&jffs2_security_xattr_handler,
fs/jffs2/xattr.h +1 -1
index 1b5030a3349d..7e7de093ec0a 100644
@@ -94,7 +94,7 @@ extern int do_jffs2_getxattr(struct inode *inode, int xprefix, const char *xname
  extern int do_jffs2_setxattr(struct inode *inode, int xprefix, const char *xname,
  			     const char *buffer, size_t size, int flags);
 
-extern const struct xattr_handler *jffs2_xattr_handlers[];
+extern const struct xattr_handler * const jffs2_xattr_handlers[];
  extern const struct xattr_handler jffs2_user_xattr_handler;
  extern const struct xattr_handler jffs2_trusted_xattr_handler;
 
Acked-by on v1 8/29
#19 lore raw

Re: [PATCH 08/29] erofs: move erofs_xattr_handlers and xattr_handler_map to .rodata

In reply to Wedson Almeida Filho
Quoted 11 lines · Wedson Almeida Filho

From: Wedson Almeida Filho <[email protected]>

This makes it harder for accidental or malicious changes to erofs_xattr_handlers or xattr_handler_map at runtime.

Thanks,
Gao Xiang

maintainer Reviewed-by on v1 10/29
#23 lore raw

Re: [PATCH 10/29] f2fs: move f2fs_xattr_handlers and f2fs_xattr_handler_map to .rodata

In reply to Wedson Almeida Filho
Quoted 9 lines · Wedson Almeida Filho

From: Wedson Almeida Filho <[email protected]>

This makes it harder for accidental or malicious changes to f2fs_xattr_handlers or f2fs_xattr_handler_map at runtime.

Thanks,

maintainer Applied
#52 lore raw
In reply to Wedson Almeida Filho
Quoted 6 lines · Wedson Almeida Filho

From: Wedson Almeida Filho <[email protected]>

The 's_xattr' field of 'struct super_block' currently requires a mutable table of 'struct xattr_handler' entries (although each handler itself is const). However, no code in vfs actually modifies the tables.

Quoted 7 lines

So this series changes the type of 's_xattr' to allow const tables, and modifies existing file system to move their tables to .rodata. This is desirable because these tables contain entries with function pointers in them; moving them to .rodata makes it considerably less likely to be modified accidentally or maliciously at runtime.

I found this while writing Rust abstractions for vfs.

Applied to the vfs.xattr branch of the vfs/vfs.git tree. Patches in the vfs.xattr branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the patch has now been applied. If possible patch trailers will be updated.

Note that commit hashes shown below are subject to change due to rebase, trailer updates or similar. If in doubt, please check the listed branch.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs.xattr

[01/29] xattr: make the xattr array itself const

        https://git.kernel.org/vfs/vfs/c/e346fb6d774a
[02/29] ext4: move ext4_xattr_handlers to .rodata
        https://git.kernel.org/vfs/vfs/c/e60ac1283340
[03/29] 9p: move xattr-related structs to .rodata
        https://git.kernel.org/vfs/vfs/c/b6079dc9cb51
[04/29] afs: move afs_xattr_handlers to .rodata
        https://git.kernel.org/vfs/vfs/c/f710c2e48135
[05/29] btrfs: move btrfs_xattr_handlers to .rodata
        https://git.kernel.org/vfs/vfs/c/8a25b4189896
[06/29] ceph: move ceph_xattr_handlers to .rodata
        https://git.kernel.org/vfs/vfs/c/10f9fbe9f25a
[07/29] ecryptfs: move ecryptfs_xattr_handlers to .rodata
        https://git.kernel.org/vfs/vfs/c/f354ed981066
[08/29] erofs: move erofs_xattr_handlers and xattr_handler_map to .rodata
        https://git.kernel.org/vfs/vfs/c/3591f40e223c
[09/29] ext2: move ext2_xattr_handlers and ext2_xattr_handler_map to .rodata
        https://git.kernel.org/vfs/vfs/c/ce78a1ec1c3b
[10/29] f2fs: move f2fs_xattr_handlers and f2fs_xattr_handler_map to .rodata
        https://git.kernel.org/vfs/vfs/c/a1c0752c33d2
[11/29] fuse: move fuse_xattr_handlers to .rodata
        https://git.kernel.org/vfs/vfs/c/34271edb1878
[12/29] gfs2: move gfs2_xattr_handlers_max to .rodata
        https://git.kernel.org/vfs/vfs/c/89491fafa81c
[13/29] hfs: move hfs_xattr_handlers to .rodata
        https://git.kernel.org/vfs/vfs/c/e27a45b65070
[14/29] hfsplus: move hfsplus_xattr_handlers to .rodata
        https://git.kernel.org/vfs/vfs/c/2c323f2c5650
[15/29] jffs2: move jffs2_xattr_handlers to .rodata
        https://git.kernel.org/vfs/vfs/c/13a75c3abcbe
[16/29] jfs: move jfs_xattr_handlers to .rodata
        https://git.kernel.org/vfs/vfs/c/ea780283e2c0
[17/29] kernfs: move kernfs_xattr_handlers to .rodata
        https://git.kernel.org/vfs/vfs/c/ffb2e0650827
[18/29] nfs: move nfs4_xattr_handlers to .rodata
        https://git.kernel.org/vfs/vfs/c/f496647e3b09
[19/29] ntfs3: move ntfs_xattr_handlers to .rodata
        https://git.kernel.org/vfs/vfs/c/5bf1dd9441da
[20/29] ocfs2: move ocfs2_xattr_handlers and ocfs2_xattr_handler_map to .rodata
        https://git.kernel.org/vfs/vfs/c/2cba9af99b3f
[21/29] orangefs: move orangefs_xattr_handlers to .rodata
        https://git.kernel.org/vfs/vfs/c/2e9440ac0716
[22/29] reiserfs: move reiserfs_xattr_handlers to .rodata
        https://git.kernel.org/vfs/vfs/c/c063254b7de8
[23/29] smb: move cifs_xattr_handlers to .rodata
        https://git.kernel.org/vfs/vfs/c/e45679b0d2e4
[24/29] squashfs: move squashfs_xattr_handlers to .rodata
        https://git.kernel.org/vfs/vfs/c/8a2ae79c7db0
[25/29] ubifs: move ubifs_xattr_handlers to .rodata
        https://git.kernel.org/vfs/vfs/c/582f1ebe32a9
[26/29] xfs: move xfs_xattr_handlers to .rodata
        https://git.kernel.org/vfs/vfs/c/6fca42a3b168
[27/29] overlayfs: move xattr tables to .rodata
        https://git.kernel.org/vfs/vfs/c/3f644c1cd7b5
[28/29] shmem: move shmem_xattr_handlers to .rodata
        https://git.kernel.org/vfs/vfs/c/2f8e5f98045e
[29/29] net: move sockfs_xattr_handlers to .rodata
        https://git.kernel.org/vfs/vfs/c/dcff22588d9a