From: Christian Brauner <brauner@kernel.org>
To: linux-fsdevel@vger.kernel.org
Cc: Alexander Viro <viro@zeniv.linux.org.uk>, Jan Kara <jack@suse.cz>,
Christoph Hellwig <hch@lst.de>,
Seth Forshee <sforshee@kernel.org>,
Paul Moore <paul@paul-moore.com>,
linux-security-module@vger.kernel.org,
Mimi Zohar <zohar@linux.ibm.com>,
linux-integrity@vger.kernel.org,
Ilya Dryomov <idryomov@gmail.com>,
ceph-devel@vger.kernel.org, Carlos Maiolino <cem@kernel.org>,
linux-xfs@vger.kernel.org, Miklos Szeredi <miklos@szeredi.hu>,
Amir Goldstein <amir73il@gmail.com>,
linux-unionfs@vger.kernel.org,
Namjae Jeon <linkinjeon@kernel.org>,
linux-cifs@vger.kernel.org, linux-kernel@vger.kernel.org,
"Christian Brauner (Amutable)" <brauner@kernel.org>
Subject: [PATCH 01/27] userns: pass const uid_gid_map in lookup helpers
Date: Tue, 01 Sep 2026 14:14:26 +0200 [thread overview]
Message-ID: <20260901-work-idmap-const-v1-1-54ccd48e100b@kernel.org> (raw)
In-Reply-To: <20260901-work-idmap-const-v1-0-54ccd48e100b@kernel.org>
map_id_down(), map_id_up() and map_id_range_up() search the extents
of an idmapping and never modify it. Let all relevant helpers pass a
const struct uid_gid_map. Callers can now pass pass struct mnt_idmap as
const and pass down &idmap->uid_map and &idmap->gid_map.
No functional changes.
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
---
include/linux/uidgid.h | 12 ++++++------
kernel/user_namespace.c | 28 ++++++++++++++--------------
2 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
index 2dc767e08f54..02403629b49f 100644
--- a/include/linux/uidgid.h
+++ b/include/linux/uidgid.h
@@ -130,9 +130,9 @@ static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
return from_kgid(ns, gid) != (gid_t) -1;
}
-u32 map_id_down(struct uid_gid_map *map, u32 id);
-u32 map_id_up(struct uid_gid_map *map, u32 id);
-u32 map_id_range_up(struct uid_gid_map *map, u32 id, u32 count);
+u32 map_id_down(const struct uid_gid_map *map, u32 id);
+u32 map_id_up(const struct uid_gid_map *map, u32 id);
+u32 map_id_range_up(const struct uid_gid_map *map, u32 id, u32 count);
#else
@@ -182,17 +182,17 @@ static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
return gid_valid(gid);
}
-static inline u32 map_id_down(struct uid_gid_map *map, u32 id)
+static inline u32 map_id_down(const struct uid_gid_map *map, u32 id)
{
return id;
}
-static inline u32 map_id_range_up(struct uid_gid_map *map, u32 id, u32 count)
+static inline u32 map_id_range_up(const struct uid_gid_map *map, u32 id, u32 count)
{
return id;
}
-static inline u32 map_id_up(struct uid_gid_map *map, u32 id)
+static inline u32 map_id_up(const struct uid_gid_map *map, u32 id)
{
return id;
}
diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
index 0bed462e9b2a..55b6bd75624b 100644
--- a/kernel/user_namespace.c
+++ b/kernel/user_namespace.c
@@ -278,8 +278,8 @@ static int cmp_map_id(const void *k, const void *e)
* map_id_range_down_max - Find idmap via binary search in ordered idmap array.
* Can only be called if number of mappings exceeds UID_GID_MAP_MAX_BASE_EXTENTS.
*/
-static struct uid_gid_extent *
-map_id_range_down_max(unsigned extents, struct uid_gid_map *map, u32 id, u32 count)
+static const struct uid_gid_extent *
+map_id_range_down_max(unsigned extents, const struct uid_gid_map *map, u32 id, u32 count)
{
struct idmap_key key;
@@ -296,8 +296,8 @@ map_id_range_down_max(unsigned extents, struct uid_gid_map *map, u32 id, u32 cou
* Can only be called if number of mappings is equal or less than
* UID_GID_MAP_MAX_BASE_EXTENTS.
*/
-static struct uid_gid_extent *
-map_id_range_down_base(unsigned extents, struct uid_gid_map *map, u32 id, u32 count)
+static const struct uid_gid_extent *
+map_id_range_down_base(unsigned extents, const struct uid_gid_map *map, u32 id, u32 count)
{
unsigned idx;
u32 first, last, id2;
@@ -315,9 +315,9 @@ map_id_range_down_base(unsigned extents, struct uid_gid_map *map, u32 id, u32 co
return NULL;
}
-static u32 map_id_range_down(struct uid_gid_map *map, u32 id, u32 count)
+static u32 map_id_range_down(const struct uid_gid_map *map, u32 id, u32 count)
{
- struct uid_gid_extent *extent;
+ const struct uid_gid_extent *extent;
unsigned extents = map->nr_extents;
smp_rmb();
@@ -335,7 +335,7 @@ static u32 map_id_range_down(struct uid_gid_map *map, u32 id, u32 count)
return id;
}
-u32 map_id_down(struct uid_gid_map *map, u32 id)
+u32 map_id_down(const struct uid_gid_map *map, u32 id)
{
return map_id_range_down(map, id, 1);
}
@@ -345,8 +345,8 @@ u32 map_id_down(struct uid_gid_map *map, u32 id)
* Can only be called if number of mappings is equal or less than
* UID_GID_MAP_MAX_BASE_EXTENTS.
*/
-static struct uid_gid_extent *
-map_id_range_up_base(unsigned extents, struct uid_gid_map *map, u32 id, u32 count)
+static const struct uid_gid_extent *
+map_id_range_up_base(unsigned extents, const struct uid_gid_map *map, u32 id, u32 count)
{
unsigned idx;
u32 first, last, id2;
@@ -368,8 +368,8 @@ map_id_range_up_base(unsigned extents, struct uid_gid_map *map, u32 id, u32 coun
* map_id_up_max - Find idmap via binary search in ordered idmap array.
* Can only be called if number of mappings exceeds UID_GID_MAP_MAX_BASE_EXTENTS.
*/
-static struct uid_gid_extent *
-map_id_range_up_max(unsigned extents, struct uid_gid_map *map, u32 id, u32 count)
+static const struct uid_gid_extent *
+map_id_range_up_max(unsigned extents, const struct uid_gid_map *map, u32 id, u32 count)
{
struct idmap_key key;
@@ -381,9 +381,9 @@ map_id_range_up_max(unsigned extents, struct uid_gid_map *map, u32 id, u32 count
sizeof(struct uid_gid_extent), cmp_map_id);
}
-u32 map_id_range_up(struct uid_gid_map *map, u32 id, u32 count)
+u32 map_id_range_up(const struct uid_gid_map *map, u32 id, u32 count)
{
- struct uid_gid_extent *extent;
+ const struct uid_gid_extent *extent;
unsigned extents = map->nr_extents;
smp_rmb();
@@ -401,7 +401,7 @@ u32 map_id_range_up(struct uid_gid_map *map, u32 id, u32 count)
return id;
}
-u32 map_id_up(struct uid_gid_map *map, u32 id)
+u32 map_id_up(const struct uid_gid_map *map, u32 id)
{
return map_id_range_up(map, id, 1);
}
--
2.53.0
next prev parent reply other threads:[~2026-09-01 12:14 UTC|newest]
Thread overview: 62+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-01 12:14 [PATCH 00/27] fs: port to const struct mnt_idmap Christian Brauner
2026-09-01 12:14 ` Christian Brauner [this message]
2026-09-02 14:06 ` [PATCH 01/27] userns: pass const uid_gid_map in lookup helpers Jan Kara
2026-09-01 12:14 ` [PATCH 02/27] fs: port mnt_idmap_{get,put}() to const mnt_idmap Christian Brauner
2026-09-02 14:08 ` Jan Kara
2026-09-01 12:14 ` [PATCH 03/27] fs: port vfs{g,u}id helpers " Christian Brauner
2026-09-02 14:11 ` Jan Kara
2026-09-01 12:14 ` [PATCH 04/27] fs: port fs{g,u}id " Christian Brauner
2026-09-02 14:13 ` Jan Kara
2026-09-01 12:14 ` [PATCH 05/27] fs: port i_{g,u}id_into_vfs{g,u}id() " Christian Brauner
2026-09-02 14:14 ` Jan Kara
2026-09-01 12:14 ` [PATCH 06/27] fs: port i_{g,u}id_{needs_}update() " Christian Brauner
2026-09-02 14:15 ` Jan Kara
2026-09-01 12:14 ` [PATCH 07/27] quota: port " Christian Brauner
2026-09-02 14:16 ` Jan Kara
2026-09-01 12:14 ` [PATCH 08/27] fs: port privilege checking helpers " Christian Brauner
2026-09-02 14:17 ` Jan Kara
2026-09-01 12:14 ` [PATCH 09/27] fs: port inode_owner_or_capable() " Christian Brauner
2026-09-02 14:18 ` Jan Kara
2026-09-01 12:14 ` [PATCH 10/27] fs: port inode_init_owner() " Christian Brauner
2026-09-02 14:20 ` Jan Kara
2026-09-01 12:14 ` [PATCH 11/27] fs: port acl " Christian Brauner
2026-09-02 14:22 ` Jan Kara
2026-09-02 19:34 ` Paul Moore
2026-09-01 12:14 ` [PATCH 12/27] fs: port ->permission() to pass " Christian Brauner
2026-09-02 15:38 ` Jan Kara
2026-09-02 19:34 ` Paul Moore
2026-09-01 12:14 ` [PATCH 13/27] fs: port xattr to " Christian Brauner
2026-09-02 15:42 ` Jan Kara
2026-09-02 19:34 ` Paul Moore
2026-09-01 12:14 ` [PATCH 14/27] fs: port ->fileattr_set() to pass " Christian Brauner
2026-09-02 15:43 ` Jan Kara
2026-09-01 12:14 ` [PATCH 15/27] fs: port ->set_acl() " Christian Brauner
2026-09-02 15:45 ` Jan Kara
2026-09-01 12:14 ` [PATCH 16/27] fs: port ->get_acl() " Christian Brauner
2026-09-02 15:45 ` Jan Kara
2026-09-01 12:14 ` [PATCH 17/27] fs: port ->tmpfile() " Christian Brauner
2026-09-02 15:47 ` Jan Kara
2026-09-02 19:34 ` Paul Moore
2026-09-01 12:14 ` [PATCH 18/27] fs: port ->mknod() " Christian Brauner
2026-09-02 15:49 ` Jan Kara
2026-09-02 19:34 ` Paul Moore
2026-09-01 12:14 ` [PATCH 19/27] fs: port ->rename() " Christian Brauner
2026-09-02 15:50 ` Jan Kara
2026-09-01 12:14 ` [PATCH 20/27] fs: port ->mkdir() " Christian Brauner
2026-09-02 15:52 ` Jan Kara
2026-09-01 12:14 ` [PATCH 21/27] fs: port ->symlink() " Christian Brauner
2026-09-02 15:53 ` Jan Kara
2026-09-01 12:14 ` [PATCH 22/27] fs: port ->create() " Christian Brauner
2026-09-02 15:55 ` Jan Kara
2026-09-01 12:14 ` [PATCH 23/27] fs: port ->getattr() " Christian Brauner
2026-09-02 15:58 ` Jan Kara
2026-09-01 12:14 ` [PATCH 24/27] fs: port ->setattr() " Christian Brauner
2026-09-01 15:53 ` Casey Schaufler
2026-09-02 16:01 ` Jan Kara
2026-09-02 19:34 ` Paul Moore
2026-09-01 12:14 ` [PATCH 25/27] fs: port vfs_*() helpers to " Christian Brauner
2026-09-02 16:02 ` Jan Kara
2026-09-01 12:14 ` [PATCH 26/27] fs: port mnt_idmap() and file_mnt_idmap() " Christian Brauner
2026-09-02 16:06 ` Jan Kara
2026-09-01 12:14 ` [PATCH 27/27] fs: make nop_mnt_idmap and invalid_mnt_idmap const Christian Brauner
2026-09-02 16:07 ` Jan Kara
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=20260901-work-idmap-const-v1-1-54ccd48e100b@kernel.org \
--to=brauner@kernel.org \
--cc=amir73il@gmail.com \
--cc=cem@kernel.org \
--cc=ceph-devel@vger.kernel.org \
--cc=hch@lst.de \
--cc=idryomov@gmail.com \
--cc=jack@suse.cz \
--cc=linkinjeon@kernel.org \
--cc=linux-cifs@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=linux-unionfs@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=paul@paul-moore.com \
--cc=sforshee@kernel.org \
--cc=viro@zeniv.linux.org.uk \
--cc=zohar@linux.ibm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox