All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wedson Almeida Filho <wedsonaf@gmail.com>
To: Alexander Viro <viro@zeniv.linux.org.uk>,
	Christian Brauner <brauner@kernel.org>,
	linux-fsdevel@vger.kernel.org
Cc: linux-kernel@vger.kernel.org,
	Wedson Almeida Filho <walmeida@microsoft.com>
Subject: [PATCH 01/29] xattr: make the xattr array itself const
Date: Sat, 30 Sep 2023 02:00:05 -0300	[thread overview]
Message-ID: <20230930050033.41174-2-wedsonaf@gmail.com> (raw)
In-Reply-To: <20230930050033.41174-1-wedsonaf@gmail.com>

From: Wedson Almeida Filho <walmeida@microsoft.com>

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.

Signed-off-by: Wedson Almeida Filho <walmeida@microsoft.com>
---
 fs/xattr.c         | 6 +++---
 include/linux/fs.h | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/xattr.c b/fs/xattr.c
index e7bbb7f57557..1905f8ede13d 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -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;
 
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 562f2623c9c9..4d8003f48216 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -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 */
-- 
2.34.1


  reply	other threads:[~2023-09-30  5:01 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-30  5:00 [PATCH 00/29] const xattr tables Wedson Almeida Filho
2023-09-30  5:00 ` Wedson Almeida Filho [this message]
2023-09-30  6:54   ` [PATCH 01/29] xattr: make the xattr array itself const kernel test robot
2023-10-02  9:58   ` Thomas Weißschuh
2023-09-30  5:00 ` [PATCH 02/29] ext4: move ext4_xattr_handlers to .rodata Wedson Almeida Filho
2023-09-30  5:00 ` [PATCH 03/29] 9p: move xattr-related structs " Wedson Almeida Filho
2023-09-30  8:12   ` Christian Schoenebeck
2023-09-30  9:03     ` Dominique Martinet
2023-10-03 13:55       ` Wedson Almeida Filho
2023-10-03 21:57         ` Dominique Martinet
2023-09-30  5:00 ` [PATCH 04/29] afs: move afs_xattr_handlers " Wedson Almeida Filho
2023-09-30  5:00 ` [PATCH 05/29] btrfs: move btrfs_xattr_handlers " Wedson Almeida Filho
2023-10-02 11:28   ` David Sterba
2023-10-02 11:37     ` David Sterba
2023-10-03 13:48       ` Wedson Almeida Filho
2023-09-30  5:00 ` [PATCH 06/29] ceph: move ceph_xattr_handlers " Wedson Almeida Filho
2023-10-03 14:30   ` Ilya Dryomov
2023-09-30  5:00 ` [PATCH 07/29] ecryptfs: move ecryptfs_xattr_handlers " Wedson Almeida Filho
2023-09-30  5:00 ` [PATCH 08/29] erofs: move erofs_xattr_handlers and xattr_handler_map " Wedson Almeida Filho
2023-09-30  5:00   ` Wedson Almeida Filho
2023-10-07  5:50   ` Gao Xiang
2023-10-07  5:50     ` Gao Xiang
2023-09-30  5:00 ` [PATCH 09/29] ext2: move ext2_xattr_handlers and ext2_xattr_handler_map " Wedson Almeida Filho
2023-10-02  9:49   ` Jan Kara
2023-09-30  5:00 ` [f2fs-dev] [PATCH 10/29] f2fs: move f2fs_xattr_handlers and f2fs_xattr_handler_map " Wedson Almeida Filho
2023-09-30  5:00   ` Wedson Almeida Filho
2023-10-07  6:37   ` Chao Yu
2023-10-07  6:37     ` [f2fs-dev] " Chao Yu
2023-09-30  5:00 ` [PATCH 11/29] fuse: move fuse_xattr_handlers " Wedson Almeida Filho
2023-09-30  5:00 ` [PATCH 12/29] gfs2: move gfs2_xattr_handlers_max " Wedson Almeida Filho
2023-09-30  5:00   ` [Cluster-devel] " Wedson Almeida Filho
2023-09-30  5:00 ` [PATCH 13/29] hfs: move hfs_xattr_handlers " Wedson Almeida Filho
2023-09-30  5:00 ` [PATCH 14/29] hfsplus: move hfsplus_xattr_handlers " Wedson Almeida Filho
2023-09-30  5:00 ` [PATCH 15/29] jffs2: move jffs2_xattr_handlers " Wedson Almeida Filho
2023-09-30  5:00   ` Wedson Almeida Filho
2023-10-07  1:39   ` Zhihao Cheng
2023-10-07  1:39     ` Zhihao Cheng
2023-09-30  5:00 ` [PATCH 16/29] jfs: move jfs_xattr_handlers " Wedson Almeida Filho
2023-10-03 14:54   ` Dave Kleikamp
2023-09-30  5:00 ` [PATCH 17/29] kernfs: move kernfs_xattr_handlers " Wedson Almeida Filho
2023-10-05 10:37   ` Greg Kroah-Hartman
2023-09-30  5:00 ` [PATCH 18/29] nfs: move nfs4_xattr_handlers " Wedson Almeida Filho
2023-09-30  5:00 ` [PATCH 19/29] ntfs3: move ntfs_xattr_handlers " Wedson Almeida Filho
2023-09-30  5:00 ` [PATCH 20/29] ocfs2: move ocfs2_xattr_handlers and ocfs2_xattr_handler_map " Wedson Almeida Filho
2023-09-30  5:00 ` [PATCH 21/29] orangefs: move orangefs_xattr_handlers " Wedson Almeida Filho
2023-09-30  5:00 ` [PATCH 22/29] reiserfs: move reiserfs_xattr_handlers " Wedson Almeida Filho
2023-09-30  5:00 ` [PATCH 23/29] smb: move cifs_xattr_handlers " Wedson Almeida Filho
2023-10-01 19:59   ` Steve French
2023-09-30  5:00 ` [PATCH 24/29] squashfs: move squashfs_xattr_handlers " Wedson Almeida Filho
2023-09-30  5:00 ` [PATCH 25/29] ubifs: move ubifs_xattr_handlers " Wedson Almeida Filho
2023-09-30  5:00   ` Wedson Almeida Filho
2023-10-07  1:39   ` Zhihao Cheng
2023-10-07  1:39     ` Zhihao Cheng
2023-09-30  5:00 ` [PATCH 26/29] xfs: move xfs_xattr_handlers " Wedson Almeida Filho
2023-10-01 16:18   ` Darrick J. Wong
2023-09-30  5:00 ` [PATCH 27/29] overlayfs: move xattr tables " Wedson Almeida Filho
2023-10-03 16:41   ` Amir Goldstein
2023-09-30  5:00 ` [PATCH 28/29] shmem: move shmem_xattr_handlers " Wedson Almeida Filho
2023-09-30  5:00 ` [PATCH 29/29] net: move sockfs_xattr_handlers " Wedson Almeida Filho
2023-10-04 21:24   ` Jakub Kicinski
2023-10-03 13:28 ` [PATCH 00/29] const xattr tables Christian Brauner
2023-10-09 14:43 ` Christian Brauner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230930050033.41174-2-wedsonaf@gmail.com \
    --to=wedsonaf@gmail.com \
    --cc=brauner@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    --cc=walmeida@microsoft.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.