* [PATCH 01/27] userns: pass const uid_gid_map in lookup helpers
2026-09-01 12:14 [PATCH 00/27] fs: port to const struct mnt_idmap Christian Brauner
@ 2026-09-01 12:14 ` Christian Brauner
2026-09-02 14:06 ` Jan Kara
2026-09-01 12:14 ` [PATCH 02/27] fs: port mnt_idmap_{get,put}() to const mnt_idmap Christian Brauner
` (25 subsequent siblings)
26 siblings, 1 reply; 62+ messages in thread
From: Christian Brauner @ 2026-09-01 12:14 UTC (permalink / raw)
To: linux-fsdevel
Cc: Alexander Viro, Jan Kara, Christoph Hellwig, Seth Forshee,
Paul Moore, linux-security-module, Mimi Zohar, linux-integrity,
Ilya Dryomov, ceph-devel, Carlos Maiolino, linux-xfs,
Miklos Szeredi, Amir Goldstein, linux-unionfs, Namjae Jeon,
linux-cifs, linux-kernel, Christian Brauner (Amutable)
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
^ permalink raw reply related [flat|nested] 62+ messages in thread* Re: [PATCH 01/27] userns: pass const uid_gid_map in lookup helpers
2026-09-01 12:14 ` [PATCH 01/27] userns: pass const uid_gid_map in lookup helpers Christian Brauner
@ 2026-09-02 14:06 ` Jan Kara
0 siblings, 0 replies; 62+ messages in thread
From: Jan Kara @ 2026-09-02 14:06 UTC (permalink / raw)
To: Christian Brauner
Cc: linux-fsdevel, Alexander Viro, Jan Kara, Christoph Hellwig,
Seth Forshee, Paul Moore, linux-security-module, Mimi Zohar,
linux-integrity, Ilya Dryomov, ceph-devel, Carlos Maiolino,
linux-xfs, Miklos Szeredi, Amir Goldstein, linux-unionfs,
Namjae Jeon, linux-cifs, linux-kernel
On Tue 01-09-26 14:14:26, Christian Brauner wrote:
> 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>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> 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
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 62+ messages in thread
* [PATCH 02/27] fs: port mnt_idmap_{get,put}() to const mnt_idmap
2026-09-01 12:14 [PATCH 00/27] fs: port to const struct mnt_idmap Christian Brauner
2026-09-01 12:14 ` [PATCH 01/27] userns: pass const uid_gid_map in lookup helpers Christian Brauner
@ 2026-09-01 12:14 ` 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
` (24 subsequent siblings)
26 siblings, 1 reply; 62+ messages in thread
From: Christian Brauner @ 2026-09-01 12:14 UTC (permalink / raw)
To: linux-fsdevel
Cc: Alexander Viro, Jan Kara, Christoph Hellwig, Seth Forshee,
Paul Moore, linux-security-module, Mimi Zohar, linux-integrity,
Ilya Dryomov, ceph-devel, Carlos Maiolino, linux-xfs,
Miklos Szeredi, Amir Goldstein, linux-unionfs, Namjae Jeon,
linux-cifs, linux-kernel, Christian Brauner (Amutable)
struct mnt_idmap is immutable once alloc_mnt_idmap() has set it up. The
only thing that changes afterwards is the reference count. Model
mnt_idmap_{get,put}() after struct cred's reference count handling and
take a const pointer.
This model is forced upon us because ceph stores the idmapping in mds
requests and need to be able to take and put references.
mnt_idmap_get() keeps returning a non-const pointer for now because
struct vfsmount still stores a non-const pointer. We can only change
that at the end of the series once every user of mnt_idmap() has been
ported.
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
---
fs/internal.h | 4 ++--
fs/mnt_idmapping.c | 16 ++++++++++------
include/linux/mnt_idmapping.h | 4 ++--
3 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/fs/internal.h b/fs/internal.h
index c658c8a5ebd5..581aaa2d6510 100644
--- a/fs/internal.h
+++ b/fs/internal.h
@@ -327,8 +327,8 @@ ssize_t __kernel_write_iter(struct file *file, struct iov_iter *from, loff_t *po
* fs/attr.c
*/
struct mnt_idmap *alloc_mnt_idmap(struct user_namespace *mnt_userns);
-struct mnt_idmap *mnt_idmap_get(struct mnt_idmap *idmap);
-void mnt_idmap_put(struct mnt_idmap *idmap);
+struct mnt_idmap *mnt_idmap_get(const struct mnt_idmap *idmap);
+void mnt_idmap_put(const struct mnt_idmap *idmap);
struct stashed_operations {
struct dentry *(*stash_dentry)(struct dentry **stashed,
struct dentry *dentry);
diff --git a/fs/mnt_idmapping.c b/fs/mnt_idmapping.c
index cb61fbdb52e9..cc6c5f1cfba8 100644
--- a/fs/mnt_idmapping.c
+++ b/fs/mnt_idmapping.c
@@ -312,12 +312,14 @@ struct mnt_idmap *alloc_mnt_idmap(struct user_namespace *mnt_userns)
*
* Return: @idmap with reference count bumped if @not_mnt_idmap isn't passed.
*/
-struct mnt_idmap *mnt_idmap_get(struct mnt_idmap *idmap)
+struct mnt_idmap *mnt_idmap_get(const struct mnt_idmap *idmap)
{
+ struct mnt_idmap *nonconst_idmap = (struct mnt_idmap *)idmap;
+
if (idmap != &nop_mnt_idmap && idmap != &invalid_mnt_idmap)
- refcount_inc(&idmap->count);
+ refcount_inc(&nonconst_idmap->count);
- return idmap;
+ return nonconst_idmap;
}
EXPORT_SYMBOL_GPL(mnt_idmap_get);
@@ -328,11 +330,13 @@ EXPORT_SYMBOL_GPL(mnt_idmap_get);
* If this is a non-initial idmapping, put the reference count when a mount is
* released and free it if we're the last user.
*/
-void mnt_idmap_put(struct mnt_idmap *idmap)
+void mnt_idmap_put(const struct mnt_idmap *idmap)
{
+ struct mnt_idmap *nonconst_idmap = (struct mnt_idmap *)idmap;
+
if (idmap != &nop_mnt_idmap && idmap != &invalid_mnt_idmap &&
- refcount_dec_and_test(&idmap->count))
- free_mnt_idmap(idmap);
+ refcount_dec_and_test(&nonconst_idmap->count))
+ free_mnt_idmap(nonconst_idmap);
}
EXPORT_SYMBOL_GPL(mnt_idmap_put);
diff --git a/include/linux/mnt_idmapping.h b/include/linux/mnt_idmapping.h
index e71a6070a8f8..e5bee8b41094 100644
--- a/include/linux/mnt_idmapping.h
+++ b/include/linux/mnt_idmapping.h
@@ -121,8 +121,8 @@ static inline bool vfsgid_eq_kgid(vfsgid_t vfsgid, kgid_t kgid)
int vfsgid_in_group_p(vfsgid_t vfsgid);
-struct mnt_idmap *mnt_idmap_get(struct mnt_idmap *idmap);
-void mnt_idmap_put(struct mnt_idmap *idmap);
+struct mnt_idmap *mnt_idmap_get(const struct mnt_idmap *idmap);
+void mnt_idmap_put(const struct mnt_idmap *idmap);
vfsuid_t make_vfsuid(struct mnt_idmap *idmap,
struct user_namespace *fs_userns, kuid_t kuid);
--
2.53.0
^ permalink raw reply related [flat|nested] 62+ messages in thread* Re: [PATCH 02/27] fs: port mnt_idmap_{get,put}() to const mnt_idmap
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
0 siblings, 0 replies; 62+ messages in thread
From: Jan Kara @ 2026-09-02 14:08 UTC (permalink / raw)
To: Christian Brauner
Cc: linux-fsdevel, Alexander Viro, Jan Kara, Christoph Hellwig,
Seth Forshee, Paul Moore, linux-security-module, Mimi Zohar,
linux-integrity, Ilya Dryomov, ceph-devel, Carlos Maiolino,
linux-xfs, Miklos Szeredi, Amir Goldstein, linux-unionfs,
Namjae Jeon, linux-cifs, linux-kernel
On Tue 01-09-26 14:14:27, Christian Brauner wrote:
> struct mnt_idmap is immutable once alloc_mnt_idmap() has set it up. The
> only thing that changes afterwards is the reference count. Model
> mnt_idmap_{get,put}() after struct cred's reference count handling and
> take a const pointer.
>
> This model is forced upon us because ceph stores the idmapping in mds
> requests and need to be able to take and put references.
>
> mnt_idmap_get() keeps returning a non-const pointer for now because
> struct vfsmount still stores a non-const pointer. We can only change
> that at the end of the series once every user of mnt_idmap() has been
> ported.
>
> Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Yeah, this is a bit ugly but it's convenient :) and in the great scheme of
things I think it's a win. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> fs/internal.h | 4 ++--
> fs/mnt_idmapping.c | 16 ++++++++++------
> include/linux/mnt_idmapping.h | 4 ++--
> 3 files changed, 14 insertions(+), 10 deletions(-)
>
> diff --git a/fs/internal.h b/fs/internal.h
> index c658c8a5ebd5..581aaa2d6510 100644
> --- a/fs/internal.h
> +++ b/fs/internal.h
> @@ -327,8 +327,8 @@ ssize_t __kernel_write_iter(struct file *file, struct iov_iter *from, loff_t *po
> * fs/attr.c
> */
> struct mnt_idmap *alloc_mnt_idmap(struct user_namespace *mnt_userns);
> -struct mnt_idmap *mnt_idmap_get(struct mnt_idmap *idmap);
> -void mnt_idmap_put(struct mnt_idmap *idmap);
> +struct mnt_idmap *mnt_idmap_get(const struct mnt_idmap *idmap);
> +void mnt_idmap_put(const struct mnt_idmap *idmap);
> struct stashed_operations {
> struct dentry *(*stash_dentry)(struct dentry **stashed,
> struct dentry *dentry);
> diff --git a/fs/mnt_idmapping.c b/fs/mnt_idmapping.c
> index cb61fbdb52e9..cc6c5f1cfba8 100644
> --- a/fs/mnt_idmapping.c
> +++ b/fs/mnt_idmapping.c
> @@ -312,12 +312,14 @@ struct mnt_idmap *alloc_mnt_idmap(struct user_namespace *mnt_userns)
> *
> * Return: @idmap with reference count bumped if @not_mnt_idmap isn't passed.
> */
> -struct mnt_idmap *mnt_idmap_get(struct mnt_idmap *idmap)
> +struct mnt_idmap *mnt_idmap_get(const struct mnt_idmap *idmap)
> {
> + struct mnt_idmap *nonconst_idmap = (struct mnt_idmap *)idmap;
> +
> if (idmap != &nop_mnt_idmap && idmap != &invalid_mnt_idmap)
> - refcount_inc(&idmap->count);
> + refcount_inc(&nonconst_idmap->count);
>
> - return idmap;
> + return nonconst_idmap;
> }
> EXPORT_SYMBOL_GPL(mnt_idmap_get);
>
> @@ -328,11 +330,13 @@ EXPORT_SYMBOL_GPL(mnt_idmap_get);
> * If this is a non-initial idmapping, put the reference count when a mount is
> * released and free it if we're the last user.
> */
> -void mnt_idmap_put(struct mnt_idmap *idmap)
> +void mnt_idmap_put(const struct mnt_idmap *idmap)
> {
> + struct mnt_idmap *nonconst_idmap = (struct mnt_idmap *)idmap;
> +
> if (idmap != &nop_mnt_idmap && idmap != &invalid_mnt_idmap &&
> - refcount_dec_and_test(&idmap->count))
> - free_mnt_idmap(idmap);
> + refcount_dec_and_test(&nonconst_idmap->count))
> + free_mnt_idmap(nonconst_idmap);
> }
> EXPORT_SYMBOL_GPL(mnt_idmap_put);
>
> diff --git a/include/linux/mnt_idmapping.h b/include/linux/mnt_idmapping.h
> index e71a6070a8f8..e5bee8b41094 100644
> --- a/include/linux/mnt_idmapping.h
> +++ b/include/linux/mnt_idmapping.h
> @@ -121,8 +121,8 @@ static inline bool vfsgid_eq_kgid(vfsgid_t vfsgid, kgid_t kgid)
>
> int vfsgid_in_group_p(vfsgid_t vfsgid);
>
> -struct mnt_idmap *mnt_idmap_get(struct mnt_idmap *idmap);
> -void mnt_idmap_put(struct mnt_idmap *idmap);
> +struct mnt_idmap *mnt_idmap_get(const struct mnt_idmap *idmap);
> +void mnt_idmap_put(const struct mnt_idmap *idmap);
>
> vfsuid_t make_vfsuid(struct mnt_idmap *idmap,
> struct user_namespace *fs_userns, kuid_t kuid);
>
> --
> 2.53.0
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 62+ messages in thread
* [PATCH 03/27] fs: port vfs{g,u}id helpers to const mnt_idmap
2026-09-01 12:14 [PATCH 00/27] fs: port to const struct mnt_idmap Christian Brauner
2026-09-01 12:14 ` [PATCH 01/27] userns: pass const uid_gid_map in lookup helpers Christian Brauner
2026-09-01 12:14 ` [PATCH 02/27] fs: port mnt_idmap_{get,put}() to const mnt_idmap Christian Brauner
@ 2026-09-01 12:14 ` 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
` (23 subsequent siblings)
26 siblings, 1 reply; 62+ messages in thread
From: Christian Brauner @ 2026-09-01 12:14 UTC (permalink / raw)
To: linux-fsdevel
Cc: Alexander Viro, Jan Kara, Christoph Hellwig, Seth Forshee,
Paul Moore, linux-security-module, Mimi Zohar, linux-integrity,
Ilya Dryomov, ceph-devel, Carlos Maiolino, linux-xfs,
Miklos Szeredi, Amir Goldstein, linux-unionfs, Namjae Jeon,
linux-cifs, linux-kernel, Christian Brauner (Amutable)
Convert to const struct mnt_idmap.
A mount's idmapping is immutable. The only thing that is allowed to be
modified afterwards is the reference count and that is hidden behind
mnt_idmap_get() and mnt_idmap_put(). Everything else only ever reads
from the idmapping. This is the same model that struct cred uses and the
idmapping is also rather sensitive.
So make the idmap argument const wherever we can. The conversion is done
from the bottom up so callers can continue to pass a non-const pointer
to a const parameter until the conversion is finished.
No functional changes.
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
---
fs/ceph/inode.c | 2 +-
fs/ceph/super.h | 2 +-
fs/fuse/dir.c | 12 ++++++------
fs/internal.h | 2 +-
fs/mnt_idmapping.c | 15 ++++++++-------
fs/overlayfs/inode.c | 4 ++--
fs/overlayfs/overlayfs.h | 2 +-
fs/posix_acl.c | 2 +-
fs/smb/server/smbacl.c | 14 +++++++-------
fs/smb/server/smbacl.h | 8 ++++----
fs/smb/server/vfs.c | 4 ++--
fs/smb/server/vfs.h | 2 +-
include/linux/mnt_idmapping.h | 12 ++++++------
security/integrity/evm/evm_main.c | 4 ++--
14 files changed, 43 insertions(+), 42 deletions(-)
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index d52e2b389e0b..3921b601ad59 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -2568,7 +2568,7 @@ static int fill_fscrypt_truncate(struct inode *inode,
return ret;
}
-int __ceph_setattr(struct mnt_idmap *idmap, struct inode *inode,
+int __ceph_setattr(const struct mnt_idmap *idmap, struct inode *inode,
struct iattr *attr, struct ceph_iattr *cia)
{
struct ceph_inode_info *ci = ceph_inode(inode);
diff --git a/fs/ceph/super.h b/fs/ceph/super.h
index 72d4e30304dc..e9a9d5737c80 100644
--- a/fs/ceph/super.h
+++ b/fs/ceph/super.h
@@ -1173,7 +1173,7 @@ struct ceph_iattr {
struct ceph_fscrypt_auth *fscrypt_auth;
};
-extern int __ceph_setattr(struct mnt_idmap *idmap, struct inode *inode,
+extern int __ceph_setattr(const struct mnt_idmap *idmap, struct inode *inode,
struct iattr *attr, struct ceph_iattr *cia);
extern int ceph_setattr(struct mnt_idmap *idmap,
struct dentry *dentry, struct iattr *attr);
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index e49b4e874b15..0d297f74c663 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -751,7 +751,7 @@ static u32 fuse_ext_size(size_t size)
/*
* This adds just a single supplementary group that matches the parent's group.
*/
-static int get_create_supp_group(struct mnt_idmap *idmap,
+static int get_create_supp_group(const struct mnt_idmap *idmap,
struct inode *dir,
struct fuse_in_arg *ext)
{
@@ -782,7 +782,7 @@ static int get_create_supp_group(struct mnt_idmap *idmap,
return 0;
}
-static int get_create_ext(struct mnt_idmap *idmap,
+static int get_create_ext(const struct mnt_idmap *idmap,
struct fuse_args *args,
struct inode *dir, struct dentry *dentry,
umode_t mode)
@@ -1375,7 +1375,7 @@ static int fuse_link(struct dentry *entry, struct inode *newdir,
return err;
}
-static void fuse_fillattr(struct mnt_idmap *idmap, struct inode *inode,
+static void fuse_fillattr(const struct mnt_idmap *idmap, struct inode *inode,
struct fuse_attr *attr, struct kstat *stat)
{
unsigned int blkbits;
@@ -1429,7 +1429,7 @@ static void fuse_statx_to_attr(struct fuse_statx *sx, struct fuse_attr *attr)
attr->blksize = sx->blksize;
}
-static int fuse_do_statx(struct mnt_idmap *idmap, struct inode *inode,
+static int fuse_do_statx(const struct mnt_idmap *idmap, struct inode *inode,
struct file *file, struct kstat *stat)
{
int err;
@@ -1490,7 +1490,7 @@ static int fuse_do_statx(struct mnt_idmap *idmap, struct inode *inode,
return 0;
}
-static int fuse_do_getattr(struct mnt_idmap *idmap, struct inode *inode,
+static int fuse_do_getattr(const struct mnt_idmap *idmap, struct inode *inode,
struct kstat *stat, struct file *file)
{
int err;
@@ -2000,7 +2000,7 @@ static bool update_mtime(unsigned ivalid, bool trust_local_mtime)
return true;
}
-static void iattr_to_fattr(struct mnt_idmap *idmap, struct fuse_conn *fc,
+static void iattr_to_fattr(const struct mnt_idmap *idmap, struct fuse_conn *fc,
struct iattr *iattr, struct fuse_setattr_in *arg,
bool trust_local_cmtime)
{
diff --git a/fs/internal.h b/fs/internal.h
index 581aaa2d6510..87ac96c3e29e 100644
--- a/fs/internal.h
+++ b/fs/internal.h
@@ -354,7 +354,7 @@ static inline bool path_mounted(const struct path *path)
}
void file_f_owner_release(struct file *file);
bool file_seek_cur_needs_f_lock(struct file *file);
-int statmount_mnt_idmap(struct mnt_idmap *idmap, struct seq_file *seq, bool uid_map);
+int statmount_mnt_idmap(const struct mnt_idmap *idmap, struct seq_file *seq, bool uid_map);
struct dentry *find_next_child(struct dentry *parent, struct dentry *prev);
int anon_inode_getattr(struct mnt_idmap *idmap, const struct path *path,
struct kstat *stat, u32 request_mask,
diff --git a/fs/mnt_idmapping.c b/fs/mnt_idmapping.c
index cc6c5f1cfba8..4d5fbf185608 100644
--- a/fs/mnt_idmapping.c
+++ b/fs/mnt_idmapping.c
@@ -77,7 +77,7 @@ static inline bool initial_idmapping(const struct user_namespace *ns)
* returned.
*/
-vfsuid_t make_vfsuid(struct mnt_idmap *idmap,
+vfsuid_t make_vfsuid(const struct mnt_idmap *idmap,
struct user_namespace *fs_userns,
kuid_t kuid)
{
@@ -117,7 +117,7 @@ EXPORT_SYMBOL_GPL(make_vfsuid);
* If @kgid has no mapping in either @idmap or @fs_userns INVALID_GID is
* returned.
*/
-vfsgid_t make_vfsgid(struct mnt_idmap *idmap,
+vfsgid_t make_vfsgid(const struct mnt_idmap *idmap,
struct user_namespace *fs_userns, kgid_t kgid)
{
gid_t gid;
@@ -147,7 +147,7 @@ EXPORT_SYMBOL_GPL(make_vfsgid);
*
* Return: @vfsuid mapped into the filesystem idmapping
*/
-kuid_t from_vfsuid(struct mnt_idmap *idmap,
+kuid_t from_vfsuid(const struct mnt_idmap *idmap,
struct user_namespace *fs_userns, vfsuid_t vfsuid)
{
uid_t uid;
@@ -176,7 +176,7 @@ EXPORT_SYMBOL_GPL(from_vfsuid);
*
* Return: @vfsgid mapped into the filesystem idmapping
*/
-kgid_t from_vfsgid(struct mnt_idmap *idmap,
+kgid_t from_vfsgid(const struct mnt_idmap *idmap,
struct user_namespace *fs_userns, vfsgid_t vfsgid)
{
gid_t gid;
@@ -340,9 +340,10 @@ void mnt_idmap_put(const struct mnt_idmap *idmap)
}
EXPORT_SYMBOL_GPL(mnt_idmap_put);
-int statmount_mnt_idmap(struct mnt_idmap *idmap, struct seq_file *seq, bool uid_map)
+int statmount_mnt_idmap(const struct mnt_idmap *idmap, struct seq_file *seq, bool uid_map)
{
- struct uid_gid_map *map, *map_up;
+ const struct uid_gid_map *map;
+ struct uid_gid_map *map_up;
u32 idx, nr_mappings;
if (!is_valid_mnt_idmap(idmap))
@@ -362,7 +363,7 @@ int statmount_mnt_idmap(struct mnt_idmap *idmap, struct seq_file *seq, bool uid_
for (idx = 0, nr_mappings = 0; idx < map->nr_extents; idx++) {
uid_t lower;
- struct uid_gid_extent *extent;
+ const struct uid_gid_extent *extent;
if (map->nr_extents <= UID_GID_MAP_MAX_BASE_EXTENTS)
extent = &map->extent[idx];
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
index 401cb8c75520..0364e7d08ad7 100644
--- a/fs/overlayfs/inode.c
+++ b/fs/overlayfs/inode.c
@@ -355,7 +355,7 @@ static const char *ovl_get_link(struct dentry *dentry,
* alter the POSIX ACLs for the underlying filesystem.
*/
static void ovl_idmap_posix_acl(const struct inode *realinode,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct posix_acl *acl)
{
struct user_namespace *fs_userns = i_user_ns(realinode);
@@ -447,7 +447,7 @@ struct posix_acl *ovl_get_acl_path(const struct path *path,
*
* This is obviously only relevant when idmapped layers are used.
*/
-struct posix_acl *do_ovl_get_acl(struct mnt_idmap *idmap,
+struct posix_acl *do_ovl_get_acl(const struct mnt_idmap *idmap,
struct inode *inode, int type,
bool rcu, bool noperm)
{
diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h
index e0d8c6152e9f..6508f30aaaca 100644
--- a/fs/overlayfs/overlayfs.h
+++ b/fs/overlayfs/overlayfs.h
@@ -806,7 +806,7 @@ int ovl_permission(struct mnt_idmap *idmap, struct inode *inode,
int mask);
#ifdef CONFIG_FS_POSIX_ACL
-struct posix_acl *do_ovl_get_acl(struct mnt_idmap *idmap,
+struct posix_acl *do_ovl_get_acl(const struct mnt_idmap *idmap,
struct inode *inode, int type,
bool rcu, bool noperm);
static inline struct posix_acl *ovl_get_inode_acl(struct inode *inode, int type,
diff --git a/fs/posix_acl.c b/fs/posix_acl.c
index 18b302f94174..f9c55a59c6c6 100644
--- a/fs/posix_acl.c
+++ b/fs/posix_acl.c
@@ -1057,7 +1057,7 @@ int simple_acl_create(struct inode *dir, struct inode *inode)
return 0;
}
-static int vfs_set_acl_idmapped_mnt(struct mnt_idmap *idmap,
+static int vfs_set_acl_idmapped_mnt(const struct mnt_idmap *idmap,
struct user_namespace *fs_userns,
struct posix_acl *acl)
{
diff --git a/fs/smb/server/smbacl.c b/fs/smb/server/smbacl.c
index 8ad2e5a5cca8..915dbfab62ea 100644
--- a/fs/smb/server/smbacl.c
+++ b/fs/smb/server/smbacl.c
@@ -257,7 +257,7 @@ void id_to_sid(unsigned int cid, uint sidtype, struct smb_sid *ssid)
ssid->num_subauth++;
}
-static int sid_to_id(struct mnt_idmap *idmap,
+static int sid_to_id(const struct mnt_idmap *idmap,
struct smb_sid *psid, uint sidtype,
struct smb_fattr *fattr)
{
@@ -383,7 +383,7 @@ void free_acl_state(struct posix_acl_state *state)
kfree(state->groups);
}
-static void parse_dacl(struct mnt_idmap *idmap,
+static void parse_dacl(const struct mnt_idmap *idmap,
struct smb_acl *pdacl, char *end_of_acl,
struct smb_sid *pownersid, struct smb_sid *pgrpsid,
struct smb_fattr *fattr)
@@ -608,7 +608,7 @@ static void parse_dacl(struct mnt_idmap *idmap,
free_acl_state(&default_acl_state);
}
-static void set_posix_acl_entries_dacl(struct mnt_idmap *idmap,
+static void set_posix_acl_entries_dacl(const struct mnt_idmap *idmap,
struct smb_ace *pndace,
struct smb_fattr *fattr, u16 *num_aces,
u16 *size, u16 existing_nt_aces,
@@ -739,7 +739,7 @@ static void set_posix_acl_entries_dacl(struct mnt_idmap *idmap,
}
}
-static void set_ntacl_dacl(struct mnt_idmap *idmap,
+static void set_ntacl_dacl(const struct mnt_idmap *idmap,
struct smb_acl *pndacl,
struct smb_acl *nt_dacl,
unsigned int aces_size,
@@ -798,7 +798,7 @@ static void set_ntacl_dacl(struct mnt_idmap *idmap,
pndacl->size = cpu_to_le16(le16_to_cpu(pndacl->size) + size);
}
-static void set_mode_dacl(struct mnt_idmap *idmap,
+static void set_mode_dacl(const struct mnt_idmap *idmap,
struct smb_acl *pndacl, struct smb_fattr *fattr)
{
struct smb_ace *pace, *pndace;
@@ -884,7 +884,7 @@ static int parse_sid(struct smb_sid *psid, char *end_of_acl)
}
/* Convert CIFS ACL to POSIX form */
-int parse_sec_desc(struct mnt_idmap *idmap, struct smb_ntsd *pntsd,
+int parse_sec_desc(const struct mnt_idmap *idmap, struct smb_ntsd *pntsd,
int acl_len, struct smb_fattr *fattr)
{
int rc = 0;
@@ -1017,7 +1017,7 @@ size_t smb_acl_sec_desc_scratch_len(struct smb_fattr *fattr,
}
/* Convert permission bits from mode to equivalent CIFS ACL */
-int build_sec_desc(struct mnt_idmap *idmap,
+int build_sec_desc(const struct mnt_idmap *idmap,
struct smb_ntsd *pntsd, struct smb_ntsd *ppntsd,
int ppntsd_size, int addition_info, __u32 *secdesclen,
struct smb_fattr *fattr)
diff --git a/fs/smb/server/smbacl.h b/fs/smb/server/smbacl.h
index 01810c16cc04..28d215807faa 100644
--- a/fs/smb/server/smbacl.h
+++ b/fs/smb/server/smbacl.h
@@ -81,9 +81,9 @@ struct posix_acl_state {
struct posix_ace_state_array *groups;
};
-int parse_sec_desc(struct mnt_idmap *idmap, struct smb_ntsd *pntsd,
+int parse_sec_desc(const struct mnt_idmap *idmap, struct smb_ntsd *pntsd,
int acl_len, struct smb_fattr *fattr);
-int build_sec_desc(struct mnt_idmap *idmap, struct smb_ntsd *pntsd,
+int build_sec_desc(const struct mnt_idmap *idmap, struct smb_ntsd *pntsd,
struct smb_ntsd *ppntsd, int ppntsd_size, int addition_info,
__u32 *secdesclen, struct smb_fattr *fattr);
int init_acl_state(struct posix_acl_state *state, u16 cnt);
@@ -105,7 +105,7 @@ void ksmbd_init_domain(u32 *sub_auth);
size_t smb_acl_sec_desc_scratch_len(struct smb_fattr *fattr,
struct smb_ntsd *ppntsd, int ppntsd_size, int addition_info);
-static inline uid_t posix_acl_uid_translate(struct mnt_idmap *idmap,
+static inline uid_t posix_acl_uid_translate(const struct mnt_idmap *idmap,
struct posix_acl_entry *pace)
{
vfsuid_t vfsuid;
@@ -117,7 +117,7 @@ static inline uid_t posix_acl_uid_translate(struct mnt_idmap *idmap,
return from_kuid(&init_user_ns, vfsuid_into_kuid(vfsuid));
}
-static inline gid_t posix_acl_gid_translate(struct mnt_idmap *idmap,
+static inline gid_t posix_acl_gid_translate(const struct mnt_idmap *idmap,
struct posix_acl_entry *pace)
{
vfsgid_t vfsgid;
diff --git a/fs/smb/server/vfs.c b/fs/smb/server/vfs.c
index d2b524f79cbe..cb52dce113b9 100644
--- a/fs/smb/server/vfs.c
+++ b/fs/smb/server/vfs.c
@@ -1540,7 +1540,7 @@ int ksmbd_vfs_remove_sd_xattrs(struct mnt_idmap *idmap, const struct path *path)
return err;
}
-static struct xattr_smb_acl *ksmbd_vfs_make_xattr_posix_acl(struct mnt_idmap *idmap,
+static struct xattr_smb_acl *ksmbd_vfs_make_xattr_posix_acl(const struct mnt_idmap *idmap,
struct inode *inode,
int acl_type)
{
@@ -2253,7 +2253,7 @@ int ksmbd_vfs_set_init_posix_acl(struct mnt_idmap *idmap,
return rc;
}
-int ksmbd_vfs_inherit_posix_acl(struct mnt_idmap *idmap,
+int ksmbd_vfs_inherit_posix_acl(const struct mnt_idmap *idmap,
const struct path *path, struct inode *parent_inode)
{
struct posix_acl *acls;
diff --git a/fs/smb/server/vfs.h b/fs/smb/server/vfs.h
index 55d099de71f5..9f4b003166e5 100644
--- a/fs/smb/server/vfs.h
+++ b/fs/smb/server/vfs.h
@@ -173,7 +173,7 @@ int ksmbd_vfs_get_dos_attrib_xattr(struct mnt_idmap *idmap,
struct xattr_dos_attrib *da);
int ksmbd_vfs_set_init_posix_acl(struct mnt_idmap *idmap,
const struct path *path);
-int ksmbd_vfs_inherit_posix_acl(struct mnt_idmap *idmap,
+int ksmbd_vfs_inherit_posix_acl(const struct mnt_idmap *idmap,
const struct path *path,
struct inode *parent_inode);
void ksmbd_vfs_update_compressed_fattr(struct dentry *dentry, __le32 *fattr);
diff --git a/include/linux/mnt_idmapping.h b/include/linux/mnt_idmapping.h
index e5bee8b41094..b16f52d27ba0 100644
--- a/include/linux/mnt_idmapping.h
+++ b/include/linux/mnt_idmapping.h
@@ -124,16 +124,16 @@ int vfsgid_in_group_p(vfsgid_t vfsgid);
struct mnt_idmap *mnt_idmap_get(const struct mnt_idmap *idmap);
void mnt_idmap_put(const struct mnt_idmap *idmap);
-vfsuid_t make_vfsuid(struct mnt_idmap *idmap,
+vfsuid_t make_vfsuid(const struct mnt_idmap *idmap,
struct user_namespace *fs_userns, kuid_t kuid);
-vfsgid_t make_vfsgid(struct mnt_idmap *idmap,
+vfsgid_t make_vfsgid(const struct mnt_idmap *idmap,
struct user_namespace *fs_userns, kgid_t kgid);
-kuid_t from_vfsuid(struct mnt_idmap *idmap,
+kuid_t from_vfsuid(const struct mnt_idmap *idmap,
struct user_namespace *fs_userns, vfsuid_t vfsuid);
-kgid_t from_vfsgid(struct mnt_idmap *idmap,
+kgid_t from_vfsgid(const struct mnt_idmap *idmap,
struct user_namespace *fs_userns, vfsgid_t vfsgid);
/**
@@ -148,7 +148,7 @@ kgid_t from_vfsgid(struct mnt_idmap *idmap,
*
* Return: true if @vfsuid has a mapping in the filesystem, false if not.
*/
-static inline bool vfsuid_has_fsmapping(struct mnt_idmap *idmap,
+static inline bool vfsuid_has_fsmapping(const struct mnt_idmap *idmap,
struct user_namespace *fs_userns,
vfsuid_t vfsuid)
{
@@ -186,7 +186,7 @@ static inline kuid_t vfsuid_into_kuid(vfsuid_t vfsuid)
*
* Return: true if @vfsgid has a mapping in the filesystem, false if not.
*/
-static inline bool vfsgid_has_fsmapping(struct mnt_idmap *idmap,
+static inline bool vfsgid_has_fsmapping(const struct mnt_idmap *idmap,
struct user_namespace *fs_userns,
vfsgid_t vfsgid)
{
diff --git a/security/integrity/evm/evm_main.c b/security/integrity/evm/evm_main.c
index b59e3f121b8a..66f27653cdac 100644
--- a/security/integrity/evm/evm_main.c
+++ b/security/integrity/evm/evm_main.c
@@ -481,7 +481,7 @@ static enum integrity_status evm_verify_current_integrity(struct dentry *dentry)
*
* Returns 1 if passed xattr value differs from current value, 0 otherwise.
*/
-static int evm_xattr_change(struct mnt_idmap *idmap,
+static int evm_xattr_change(const struct mnt_idmap *idmap,
struct dentry *dentry, const char *xattr_name,
const void *xattr_value, size_t xattr_value_len)
{
@@ -517,7 +517,7 @@ static int evm_xattr_change(struct mnt_idmap *idmap,
* For posix xattr acls only, permit security.evm, even if it currently
* doesn't exist, to be updated unless the EVM signature is immutable.
*/
-static int evm_protect_xattr(struct mnt_idmap *idmap,
+static int evm_protect_xattr(const struct mnt_idmap *idmap,
struct dentry *dentry, const char *xattr_name,
const void *xattr_value, size_t xattr_value_len)
{
--
2.53.0
^ permalink raw reply related [flat|nested] 62+ messages in thread* Re: [PATCH 03/27] fs: port vfs{g,u}id helpers to const mnt_idmap
2026-09-01 12:14 ` [PATCH 03/27] fs: port vfs{g,u}id helpers " Christian Brauner
@ 2026-09-02 14:11 ` Jan Kara
0 siblings, 0 replies; 62+ messages in thread
From: Jan Kara @ 2026-09-02 14:11 UTC (permalink / raw)
To: Christian Brauner
Cc: linux-fsdevel, Alexander Viro, Jan Kara, Christoph Hellwig,
Seth Forshee, Paul Moore, linux-security-module, Mimi Zohar,
linux-integrity, Ilya Dryomov, ceph-devel, Carlos Maiolino,
linux-xfs, Miklos Szeredi, Amir Goldstein, linux-unionfs,
Namjae Jeon, linux-cifs, linux-kernel
On Tue 01-09-26 14:14:28, Christian Brauner wrote:
> Convert to const struct mnt_idmap.
>
> A mount's idmapping is immutable. The only thing that is allowed to be
> modified afterwards is the reference count and that is hidden behind
> mnt_idmap_get() and mnt_idmap_put(). Everything else only ever reads
> from the idmapping. This is the same model that struct cred uses and the
> idmapping is also rather sensitive.
>
> So make the idmap argument const wherever we can. The conversion is done
> from the bottom up so callers can continue to pass a non-const pointer
> to a const parameter until the conversion is finished.
>
> No functional changes.
>
> Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> fs/ceph/inode.c | 2 +-
> fs/ceph/super.h | 2 +-
> fs/fuse/dir.c | 12 ++++++------
> fs/internal.h | 2 +-
> fs/mnt_idmapping.c | 15 ++++++++-------
> fs/overlayfs/inode.c | 4 ++--
> fs/overlayfs/overlayfs.h | 2 +-
> fs/posix_acl.c | 2 +-
> fs/smb/server/smbacl.c | 14 +++++++-------
> fs/smb/server/smbacl.h | 8 ++++----
> fs/smb/server/vfs.c | 4 ++--
> fs/smb/server/vfs.h | 2 +-
> include/linux/mnt_idmapping.h | 12 ++++++------
> security/integrity/evm/evm_main.c | 4 ++--
> 14 files changed, 43 insertions(+), 42 deletions(-)
>
> diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
> index d52e2b389e0b..3921b601ad59 100644
> --- a/fs/ceph/inode.c
> +++ b/fs/ceph/inode.c
> @@ -2568,7 +2568,7 @@ static int fill_fscrypt_truncate(struct inode *inode,
> return ret;
> }
>
> -int __ceph_setattr(struct mnt_idmap *idmap, struct inode *inode,
> +int __ceph_setattr(const struct mnt_idmap *idmap, struct inode *inode,
> struct iattr *attr, struct ceph_iattr *cia)
> {
> struct ceph_inode_info *ci = ceph_inode(inode);
> diff --git a/fs/ceph/super.h b/fs/ceph/super.h
> index 72d4e30304dc..e9a9d5737c80 100644
> --- a/fs/ceph/super.h
> +++ b/fs/ceph/super.h
> @@ -1173,7 +1173,7 @@ struct ceph_iattr {
> struct ceph_fscrypt_auth *fscrypt_auth;
> };
>
> -extern int __ceph_setattr(struct mnt_idmap *idmap, struct inode *inode,
> +extern int __ceph_setattr(const struct mnt_idmap *idmap, struct inode *inode,
> struct iattr *attr, struct ceph_iattr *cia);
> extern int ceph_setattr(struct mnt_idmap *idmap,
> struct dentry *dentry, struct iattr *attr);
> diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
> index e49b4e874b15..0d297f74c663 100644
> --- a/fs/fuse/dir.c
> +++ b/fs/fuse/dir.c
> @@ -751,7 +751,7 @@ static u32 fuse_ext_size(size_t size)
> /*
> * This adds just a single supplementary group that matches the parent's group.
> */
> -static int get_create_supp_group(struct mnt_idmap *idmap,
> +static int get_create_supp_group(const struct mnt_idmap *idmap,
> struct inode *dir,
> struct fuse_in_arg *ext)
> {
> @@ -782,7 +782,7 @@ static int get_create_supp_group(struct mnt_idmap *idmap,
> return 0;
> }
>
> -static int get_create_ext(struct mnt_idmap *idmap,
> +static int get_create_ext(const struct mnt_idmap *idmap,
> struct fuse_args *args,
> struct inode *dir, struct dentry *dentry,
> umode_t mode)
> @@ -1375,7 +1375,7 @@ static int fuse_link(struct dentry *entry, struct inode *newdir,
> return err;
> }
>
> -static void fuse_fillattr(struct mnt_idmap *idmap, struct inode *inode,
> +static void fuse_fillattr(const struct mnt_idmap *idmap, struct inode *inode,
> struct fuse_attr *attr, struct kstat *stat)
> {
> unsigned int blkbits;
> @@ -1429,7 +1429,7 @@ static void fuse_statx_to_attr(struct fuse_statx *sx, struct fuse_attr *attr)
> attr->blksize = sx->blksize;
> }
>
> -static int fuse_do_statx(struct mnt_idmap *idmap, struct inode *inode,
> +static int fuse_do_statx(const struct mnt_idmap *idmap, struct inode *inode,
> struct file *file, struct kstat *stat)
> {
> int err;
> @@ -1490,7 +1490,7 @@ static int fuse_do_statx(struct mnt_idmap *idmap, struct inode *inode,
> return 0;
> }
>
> -static int fuse_do_getattr(struct mnt_idmap *idmap, struct inode *inode,
> +static int fuse_do_getattr(const struct mnt_idmap *idmap, struct inode *inode,
> struct kstat *stat, struct file *file)
> {
> int err;
> @@ -2000,7 +2000,7 @@ static bool update_mtime(unsigned ivalid, bool trust_local_mtime)
> return true;
> }
>
> -static void iattr_to_fattr(struct mnt_idmap *idmap, struct fuse_conn *fc,
> +static void iattr_to_fattr(const struct mnt_idmap *idmap, struct fuse_conn *fc,
> struct iattr *iattr, struct fuse_setattr_in *arg,
> bool trust_local_cmtime)
> {
> diff --git a/fs/internal.h b/fs/internal.h
> index 581aaa2d6510..87ac96c3e29e 100644
> --- a/fs/internal.h
> +++ b/fs/internal.h
> @@ -354,7 +354,7 @@ static inline bool path_mounted(const struct path *path)
> }
> void file_f_owner_release(struct file *file);
> bool file_seek_cur_needs_f_lock(struct file *file);
> -int statmount_mnt_idmap(struct mnt_idmap *idmap, struct seq_file *seq, bool uid_map);
> +int statmount_mnt_idmap(const struct mnt_idmap *idmap, struct seq_file *seq, bool uid_map);
> struct dentry *find_next_child(struct dentry *parent, struct dentry *prev);
> int anon_inode_getattr(struct mnt_idmap *idmap, const struct path *path,
> struct kstat *stat, u32 request_mask,
> diff --git a/fs/mnt_idmapping.c b/fs/mnt_idmapping.c
> index cc6c5f1cfba8..4d5fbf185608 100644
> --- a/fs/mnt_idmapping.c
> +++ b/fs/mnt_idmapping.c
> @@ -77,7 +77,7 @@ static inline bool initial_idmapping(const struct user_namespace *ns)
> * returned.
> */
>
> -vfsuid_t make_vfsuid(struct mnt_idmap *idmap,
> +vfsuid_t make_vfsuid(const struct mnt_idmap *idmap,
> struct user_namespace *fs_userns,
> kuid_t kuid)
> {
> @@ -117,7 +117,7 @@ EXPORT_SYMBOL_GPL(make_vfsuid);
> * If @kgid has no mapping in either @idmap or @fs_userns INVALID_GID is
> * returned.
> */
> -vfsgid_t make_vfsgid(struct mnt_idmap *idmap,
> +vfsgid_t make_vfsgid(const struct mnt_idmap *idmap,
> struct user_namespace *fs_userns, kgid_t kgid)
> {
> gid_t gid;
> @@ -147,7 +147,7 @@ EXPORT_SYMBOL_GPL(make_vfsgid);
> *
> * Return: @vfsuid mapped into the filesystem idmapping
> */
> -kuid_t from_vfsuid(struct mnt_idmap *idmap,
> +kuid_t from_vfsuid(const struct mnt_idmap *idmap,
> struct user_namespace *fs_userns, vfsuid_t vfsuid)
> {
> uid_t uid;
> @@ -176,7 +176,7 @@ EXPORT_SYMBOL_GPL(from_vfsuid);
> *
> * Return: @vfsgid mapped into the filesystem idmapping
> */
> -kgid_t from_vfsgid(struct mnt_idmap *idmap,
> +kgid_t from_vfsgid(const struct mnt_idmap *idmap,
> struct user_namespace *fs_userns, vfsgid_t vfsgid)
> {
> gid_t gid;
> @@ -340,9 +340,10 @@ void mnt_idmap_put(const struct mnt_idmap *idmap)
> }
> EXPORT_SYMBOL_GPL(mnt_idmap_put);
>
> -int statmount_mnt_idmap(struct mnt_idmap *idmap, struct seq_file *seq, bool uid_map)
> +int statmount_mnt_idmap(const struct mnt_idmap *idmap, struct seq_file *seq, bool uid_map)
> {
> - struct uid_gid_map *map, *map_up;
> + const struct uid_gid_map *map;
> + struct uid_gid_map *map_up;
> u32 idx, nr_mappings;
>
> if (!is_valid_mnt_idmap(idmap))
> @@ -362,7 +363,7 @@ int statmount_mnt_idmap(struct mnt_idmap *idmap, struct seq_file *seq, bool uid_
>
> for (idx = 0, nr_mappings = 0; idx < map->nr_extents; idx++) {
> uid_t lower;
> - struct uid_gid_extent *extent;
> + const struct uid_gid_extent *extent;
>
> if (map->nr_extents <= UID_GID_MAP_MAX_BASE_EXTENTS)
> extent = &map->extent[idx];
> diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
> index 401cb8c75520..0364e7d08ad7 100644
> --- a/fs/overlayfs/inode.c
> +++ b/fs/overlayfs/inode.c
> @@ -355,7 +355,7 @@ static const char *ovl_get_link(struct dentry *dentry,
> * alter the POSIX ACLs for the underlying filesystem.
> */
> static void ovl_idmap_posix_acl(const struct inode *realinode,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct posix_acl *acl)
> {
> struct user_namespace *fs_userns = i_user_ns(realinode);
> @@ -447,7 +447,7 @@ struct posix_acl *ovl_get_acl_path(const struct path *path,
> *
> * This is obviously only relevant when idmapped layers are used.
> */
> -struct posix_acl *do_ovl_get_acl(struct mnt_idmap *idmap,
> +struct posix_acl *do_ovl_get_acl(const struct mnt_idmap *idmap,
> struct inode *inode, int type,
> bool rcu, bool noperm)
> {
> diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h
> index e0d8c6152e9f..6508f30aaaca 100644
> --- a/fs/overlayfs/overlayfs.h
> +++ b/fs/overlayfs/overlayfs.h
> @@ -806,7 +806,7 @@ int ovl_permission(struct mnt_idmap *idmap, struct inode *inode,
> int mask);
>
> #ifdef CONFIG_FS_POSIX_ACL
> -struct posix_acl *do_ovl_get_acl(struct mnt_idmap *idmap,
> +struct posix_acl *do_ovl_get_acl(const struct mnt_idmap *idmap,
> struct inode *inode, int type,
> bool rcu, bool noperm);
> static inline struct posix_acl *ovl_get_inode_acl(struct inode *inode, int type,
> diff --git a/fs/posix_acl.c b/fs/posix_acl.c
> index 18b302f94174..f9c55a59c6c6 100644
> --- a/fs/posix_acl.c
> +++ b/fs/posix_acl.c
> @@ -1057,7 +1057,7 @@ int simple_acl_create(struct inode *dir, struct inode *inode)
> return 0;
> }
>
> -static int vfs_set_acl_idmapped_mnt(struct mnt_idmap *idmap,
> +static int vfs_set_acl_idmapped_mnt(const struct mnt_idmap *idmap,
> struct user_namespace *fs_userns,
> struct posix_acl *acl)
> {
> diff --git a/fs/smb/server/smbacl.c b/fs/smb/server/smbacl.c
> index 8ad2e5a5cca8..915dbfab62ea 100644
> --- a/fs/smb/server/smbacl.c
> +++ b/fs/smb/server/smbacl.c
> @@ -257,7 +257,7 @@ void id_to_sid(unsigned int cid, uint sidtype, struct smb_sid *ssid)
> ssid->num_subauth++;
> }
>
> -static int sid_to_id(struct mnt_idmap *idmap,
> +static int sid_to_id(const struct mnt_idmap *idmap,
> struct smb_sid *psid, uint sidtype,
> struct smb_fattr *fattr)
> {
> @@ -383,7 +383,7 @@ void free_acl_state(struct posix_acl_state *state)
> kfree(state->groups);
> }
>
> -static void parse_dacl(struct mnt_idmap *idmap,
> +static void parse_dacl(const struct mnt_idmap *idmap,
> struct smb_acl *pdacl, char *end_of_acl,
> struct smb_sid *pownersid, struct smb_sid *pgrpsid,
> struct smb_fattr *fattr)
> @@ -608,7 +608,7 @@ static void parse_dacl(struct mnt_idmap *idmap,
> free_acl_state(&default_acl_state);
> }
>
> -static void set_posix_acl_entries_dacl(struct mnt_idmap *idmap,
> +static void set_posix_acl_entries_dacl(const struct mnt_idmap *idmap,
> struct smb_ace *pndace,
> struct smb_fattr *fattr, u16 *num_aces,
> u16 *size, u16 existing_nt_aces,
> @@ -739,7 +739,7 @@ static void set_posix_acl_entries_dacl(struct mnt_idmap *idmap,
> }
> }
>
> -static void set_ntacl_dacl(struct mnt_idmap *idmap,
> +static void set_ntacl_dacl(const struct mnt_idmap *idmap,
> struct smb_acl *pndacl,
> struct smb_acl *nt_dacl,
> unsigned int aces_size,
> @@ -798,7 +798,7 @@ static void set_ntacl_dacl(struct mnt_idmap *idmap,
> pndacl->size = cpu_to_le16(le16_to_cpu(pndacl->size) + size);
> }
>
> -static void set_mode_dacl(struct mnt_idmap *idmap,
> +static void set_mode_dacl(const struct mnt_idmap *idmap,
> struct smb_acl *pndacl, struct smb_fattr *fattr)
> {
> struct smb_ace *pace, *pndace;
> @@ -884,7 +884,7 @@ static int parse_sid(struct smb_sid *psid, char *end_of_acl)
> }
>
> /* Convert CIFS ACL to POSIX form */
> -int parse_sec_desc(struct mnt_idmap *idmap, struct smb_ntsd *pntsd,
> +int parse_sec_desc(const struct mnt_idmap *idmap, struct smb_ntsd *pntsd,
> int acl_len, struct smb_fattr *fattr)
> {
> int rc = 0;
> @@ -1017,7 +1017,7 @@ size_t smb_acl_sec_desc_scratch_len(struct smb_fattr *fattr,
> }
>
> /* Convert permission bits from mode to equivalent CIFS ACL */
> -int build_sec_desc(struct mnt_idmap *idmap,
> +int build_sec_desc(const struct mnt_idmap *idmap,
> struct smb_ntsd *pntsd, struct smb_ntsd *ppntsd,
> int ppntsd_size, int addition_info, __u32 *secdesclen,
> struct smb_fattr *fattr)
> diff --git a/fs/smb/server/smbacl.h b/fs/smb/server/smbacl.h
> index 01810c16cc04..28d215807faa 100644
> --- a/fs/smb/server/smbacl.h
> +++ b/fs/smb/server/smbacl.h
> @@ -81,9 +81,9 @@ struct posix_acl_state {
> struct posix_ace_state_array *groups;
> };
>
> -int parse_sec_desc(struct mnt_idmap *idmap, struct smb_ntsd *pntsd,
> +int parse_sec_desc(const struct mnt_idmap *idmap, struct smb_ntsd *pntsd,
> int acl_len, struct smb_fattr *fattr);
> -int build_sec_desc(struct mnt_idmap *idmap, struct smb_ntsd *pntsd,
> +int build_sec_desc(const struct mnt_idmap *idmap, struct smb_ntsd *pntsd,
> struct smb_ntsd *ppntsd, int ppntsd_size, int addition_info,
> __u32 *secdesclen, struct smb_fattr *fattr);
> int init_acl_state(struct posix_acl_state *state, u16 cnt);
> @@ -105,7 +105,7 @@ void ksmbd_init_domain(u32 *sub_auth);
> size_t smb_acl_sec_desc_scratch_len(struct smb_fattr *fattr,
> struct smb_ntsd *ppntsd, int ppntsd_size, int addition_info);
>
> -static inline uid_t posix_acl_uid_translate(struct mnt_idmap *idmap,
> +static inline uid_t posix_acl_uid_translate(const struct mnt_idmap *idmap,
> struct posix_acl_entry *pace)
> {
> vfsuid_t vfsuid;
> @@ -117,7 +117,7 @@ static inline uid_t posix_acl_uid_translate(struct mnt_idmap *idmap,
> return from_kuid(&init_user_ns, vfsuid_into_kuid(vfsuid));
> }
>
> -static inline gid_t posix_acl_gid_translate(struct mnt_idmap *idmap,
> +static inline gid_t posix_acl_gid_translate(const struct mnt_idmap *idmap,
> struct posix_acl_entry *pace)
> {
> vfsgid_t vfsgid;
> diff --git a/fs/smb/server/vfs.c b/fs/smb/server/vfs.c
> index d2b524f79cbe..cb52dce113b9 100644
> --- a/fs/smb/server/vfs.c
> +++ b/fs/smb/server/vfs.c
> @@ -1540,7 +1540,7 @@ int ksmbd_vfs_remove_sd_xattrs(struct mnt_idmap *idmap, const struct path *path)
> return err;
> }
>
> -static struct xattr_smb_acl *ksmbd_vfs_make_xattr_posix_acl(struct mnt_idmap *idmap,
> +static struct xattr_smb_acl *ksmbd_vfs_make_xattr_posix_acl(const struct mnt_idmap *idmap,
> struct inode *inode,
> int acl_type)
> {
> @@ -2253,7 +2253,7 @@ int ksmbd_vfs_set_init_posix_acl(struct mnt_idmap *idmap,
> return rc;
> }
>
> -int ksmbd_vfs_inherit_posix_acl(struct mnt_idmap *idmap,
> +int ksmbd_vfs_inherit_posix_acl(const struct mnt_idmap *idmap,
> const struct path *path, struct inode *parent_inode)
> {
> struct posix_acl *acls;
> diff --git a/fs/smb/server/vfs.h b/fs/smb/server/vfs.h
> index 55d099de71f5..9f4b003166e5 100644
> --- a/fs/smb/server/vfs.h
> +++ b/fs/smb/server/vfs.h
> @@ -173,7 +173,7 @@ int ksmbd_vfs_get_dos_attrib_xattr(struct mnt_idmap *idmap,
> struct xattr_dos_attrib *da);
> int ksmbd_vfs_set_init_posix_acl(struct mnt_idmap *idmap,
> const struct path *path);
> -int ksmbd_vfs_inherit_posix_acl(struct mnt_idmap *idmap,
> +int ksmbd_vfs_inherit_posix_acl(const struct mnt_idmap *idmap,
> const struct path *path,
> struct inode *parent_inode);
> void ksmbd_vfs_update_compressed_fattr(struct dentry *dentry, __le32 *fattr);
> diff --git a/include/linux/mnt_idmapping.h b/include/linux/mnt_idmapping.h
> index e5bee8b41094..b16f52d27ba0 100644
> --- a/include/linux/mnt_idmapping.h
> +++ b/include/linux/mnt_idmapping.h
> @@ -124,16 +124,16 @@ int vfsgid_in_group_p(vfsgid_t vfsgid);
> struct mnt_idmap *mnt_idmap_get(const struct mnt_idmap *idmap);
> void mnt_idmap_put(const struct mnt_idmap *idmap);
>
> -vfsuid_t make_vfsuid(struct mnt_idmap *idmap,
> +vfsuid_t make_vfsuid(const struct mnt_idmap *idmap,
> struct user_namespace *fs_userns, kuid_t kuid);
>
> -vfsgid_t make_vfsgid(struct mnt_idmap *idmap,
> +vfsgid_t make_vfsgid(const struct mnt_idmap *idmap,
> struct user_namespace *fs_userns, kgid_t kgid);
>
> -kuid_t from_vfsuid(struct mnt_idmap *idmap,
> +kuid_t from_vfsuid(const struct mnt_idmap *idmap,
> struct user_namespace *fs_userns, vfsuid_t vfsuid);
>
> -kgid_t from_vfsgid(struct mnt_idmap *idmap,
> +kgid_t from_vfsgid(const struct mnt_idmap *idmap,
> struct user_namespace *fs_userns, vfsgid_t vfsgid);
>
> /**
> @@ -148,7 +148,7 @@ kgid_t from_vfsgid(struct mnt_idmap *idmap,
> *
> * Return: true if @vfsuid has a mapping in the filesystem, false if not.
> */
> -static inline bool vfsuid_has_fsmapping(struct mnt_idmap *idmap,
> +static inline bool vfsuid_has_fsmapping(const struct mnt_idmap *idmap,
> struct user_namespace *fs_userns,
> vfsuid_t vfsuid)
> {
> @@ -186,7 +186,7 @@ static inline kuid_t vfsuid_into_kuid(vfsuid_t vfsuid)
> *
> * Return: true if @vfsgid has a mapping in the filesystem, false if not.
> */
> -static inline bool vfsgid_has_fsmapping(struct mnt_idmap *idmap,
> +static inline bool vfsgid_has_fsmapping(const struct mnt_idmap *idmap,
> struct user_namespace *fs_userns,
> vfsgid_t vfsgid)
> {
> diff --git a/security/integrity/evm/evm_main.c b/security/integrity/evm/evm_main.c
> index b59e3f121b8a..66f27653cdac 100644
> --- a/security/integrity/evm/evm_main.c
> +++ b/security/integrity/evm/evm_main.c
> @@ -481,7 +481,7 @@ static enum integrity_status evm_verify_current_integrity(struct dentry *dentry)
> *
> * Returns 1 if passed xattr value differs from current value, 0 otherwise.
> */
> -static int evm_xattr_change(struct mnt_idmap *idmap,
> +static int evm_xattr_change(const struct mnt_idmap *idmap,
> struct dentry *dentry, const char *xattr_name,
> const void *xattr_value, size_t xattr_value_len)
> {
> @@ -517,7 +517,7 @@ static int evm_xattr_change(struct mnt_idmap *idmap,
> * For posix xattr acls only, permit security.evm, even if it currently
> * doesn't exist, to be updated unless the EVM signature is immutable.
> */
> -static int evm_protect_xattr(struct mnt_idmap *idmap,
> +static int evm_protect_xattr(const struct mnt_idmap *idmap,
> struct dentry *dentry, const char *xattr_name,
> const void *xattr_value, size_t xattr_value_len)
> {
>
> --
> 2.53.0
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 62+ messages in thread
* [PATCH 04/27] fs: port fs{g,u}id helpers to const mnt_idmap
2026-09-01 12:14 [PATCH 00/27] fs: port to const struct mnt_idmap Christian Brauner
` (2 preceding siblings ...)
2026-09-01 12:14 ` [PATCH 03/27] fs: port vfs{g,u}id helpers " Christian Brauner
@ 2026-09-01 12:14 ` 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
` (22 subsequent siblings)
26 siblings, 1 reply; 62+ messages in thread
From: Christian Brauner @ 2026-09-01 12:14 UTC (permalink / raw)
To: linux-fsdevel
Cc: Alexander Viro, Jan Kara, Christoph Hellwig, Seth Forshee,
Paul Moore, linux-security-module, Mimi Zohar, linux-integrity,
Ilya Dryomov, ceph-devel, Carlos Maiolino, linux-xfs,
Miklos Szeredi, Amir Goldstein, linux-unionfs, Namjae Jeon,
linux-cifs, linux-kernel, Christian Brauner (Amutable)
Convert to const struct mnt_idmap.
A mount's idmapping is immutable. The only thing that is allowed to be
modified afterwards is the reference count and that is hidden behind
mnt_idmap_get() and mnt_idmap_put(). Everything else only ever reads
from the idmapping. This is the same model that struct cred uses and the
idmapping is also rather sensitive.
So make the idmap argument const wherever we can. The conversion is done
from the bottom up so callers can continue to pass a non-const pointer
to a const parameter until the conversion is finished.
No functional changes.
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
---
fs/ceph/mds_client.h | 2 +-
fs/fuse/dir.c | 13 +++++++------
fs/fuse/fuse_i.h | 4 ++--
fs/fuse/req.c | 8 +++++---
include/linux/fs.h | 6 +++---
include/linux/mnt_idmapping.h | 4 ++--
6 files changed, 20 insertions(+), 17 deletions(-)
diff --git a/fs/ceph/mds_client.h b/fs/ceph/mds_client.h
index 3c62e3c3530b..1ac8a7e08e5c 100644
--- a/fs/ceph/mds_client.h
+++ b/fs/ceph/mds_client.h
@@ -375,7 +375,7 @@ struct ceph_mds_request {
int r_fmode; /* file mode, if expecting cap */
int r_request_release_offset;
const struct cred *r_cred;
- struct mnt_idmap *r_mnt_idmap;
+ const struct mnt_idmap *r_mnt_idmap;
struct timespec64 r_stamp;
/* for choosing which mds to send this request to */
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 0d297f74c663..7a204f55ca84 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -820,7 +820,7 @@ static void free_ext_value(struct fuse_args *args)
* If the filesystem doesn't support this, then fall back to separate
* 'mknod' + 'open' requests.
*/
-static int fuse_create_open(struct mnt_idmap *idmap, struct inode *dir,
+static int fuse_create_open(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *entry, struct file *file,
unsigned int flags, umode_t mode, u32 opcode)
{
@@ -980,7 +980,7 @@ static int fuse_atomic_open(struct inode *dir, struct dentry *entry,
/*
* Code shared between mknod, mkdir, symlink and link
*/
-static struct dentry *create_new_entry(struct mnt_idmap *idmap, struct fuse_mount *fm,
+static struct dentry *create_new_entry(const struct mnt_idmap *idmap, struct fuse_mount *fm,
struct fuse_args *args, struct inode *dir,
struct dentry *entry, umode_t mode)
{
@@ -1053,7 +1053,7 @@ static struct dentry *create_new_entry(struct mnt_idmap *idmap, struct fuse_moun
return ERR_PTR(err);
}
-static int create_new_nondir(struct mnt_idmap *idmap, struct fuse_mount *fm,
+static int create_new_nondir(const struct mnt_idmap *idmap, struct fuse_mount *fm,
struct fuse_args *args, struct inode *dir,
struct dentry *entry, umode_t mode)
{
@@ -1256,9 +1256,10 @@ static int fuse_rmdir(struct inode *dir, struct dentry *entry)
return err;
}
-static int fuse_rename_common(struct mnt_idmap *idmap, struct inode *olddir, struct dentry *oldent,
- struct inode *newdir, struct dentry *newent,
- unsigned int flags, int opcode, size_t argsize)
+static int fuse_rename_common(const struct mnt_idmap *idmap, struct inode *olddir,
+ struct dentry *oldent, struct inode *newdir,
+ struct dentry *newent, unsigned int flags,
+ int opcode, size_t argsize)
{
int err;
struct fuse_rename2_in inarg;
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index c8d4c5f3af7e..a07c75377a30 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -1003,7 +1003,7 @@ void __exit fuse_ctl_cleanup(void);
/*
* Simple request sending that does request allocation and freeing
*/
-ssize_t __fuse_simple_request(struct mnt_idmap *idmap,
+ssize_t __fuse_simple_request(const struct mnt_idmap *idmap,
struct fuse_mount *fm,
struct fuse_args *args);
@@ -1012,7 +1012,7 @@ static inline ssize_t fuse_simple_request(struct fuse_mount *fm, struct fuse_arg
return __fuse_simple_request(&invalid_mnt_idmap, fm, args);
}
-static inline ssize_t fuse_simple_idmap_request(struct mnt_idmap *idmap,
+static inline ssize_t fuse_simple_idmap_request(const struct mnt_idmap *idmap,
struct fuse_mount *fm,
struct fuse_args *args)
{
diff --git a/fs/fuse/req.c b/fs/fuse/req.c
index a01ee743d31e..a133b012d041 100644
--- a/fs/fuse/req.c
+++ b/fs/fuse/req.c
@@ -3,7 +3,8 @@
#include "dev.h"
#include "fuse_i.h"
-static int fuse_fill_creds(struct fuse_mount *fm, struct fuse_args *args, struct mnt_idmap *idmap)
+static int fuse_fill_creds(struct fuse_mount *fm, struct fuse_args *args,
+ const struct mnt_idmap *idmap)
{
struct fuse_conn *fc = fm->fc;
bool no_idmap = !fm->sb || (fm->sb->s_iflags & SB_I_NOIDMAP);
@@ -49,7 +50,8 @@ static int fuse_fill_creds(struct fuse_mount *fm, struct fuse_args *args, struct
return 0;
}
-static int fuse_req_prep(struct fuse_mount *fm, struct fuse_args *args, struct mnt_idmap *idmap)
+static int fuse_req_prep(struct fuse_mount *fm, struct fuse_args *args,
+ const struct mnt_idmap *idmap)
{
if (!args->force && fm->fc->conn_error)
return -ECONNREFUSED;
@@ -57,7 +59,7 @@ static int fuse_req_prep(struct fuse_mount *fm, struct fuse_args *args, struct m
return fuse_fill_creds(fm, args, idmap);
}
-ssize_t __fuse_simple_request(struct mnt_idmap *idmap, struct fuse_mount *fm,
+ssize_t __fuse_simple_request(const struct mnt_idmap *idmap, struct fuse_mount *fm,
struct fuse_args *args)
{
struct fuse_conn *fc = fm->fc;
diff --git a/include/linux/fs.h b/include/linux/fs.h
index f9d1e05e8ae6..959c747ef75a 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1544,7 +1544,7 @@ static inline void i_gid_update(struct mnt_idmap *idmap,
* an idmapped mount map the caller's fsuid according to @idmap.
*/
static inline void inode_fsuid_set(struct inode *inode,
- struct mnt_idmap *idmap)
+ const struct mnt_idmap *idmap)
{
inode->i_uid = mapped_fsuid(idmap, i_user_ns(inode));
}
@@ -1558,7 +1558,7 @@ static inline void inode_fsuid_set(struct inode *inode,
* an idmapped mount map the caller's fsgid according to @idmap.
*/
static inline void inode_fsgid_set(struct inode *inode,
- struct mnt_idmap *idmap)
+ const struct mnt_idmap *idmap)
{
inode->i_gid = mapped_fsgid(idmap, i_user_ns(inode));
}
@@ -1575,7 +1575,7 @@ static inline void inode_fsgid_set(struct inode *inode,
* Return: true if fsuid and fsgid is mapped, false if not.
*/
static inline bool fsuidgid_has_mapping(struct super_block *sb,
- struct mnt_idmap *idmap)
+ const struct mnt_idmap *idmap)
{
struct user_namespace *fs_userns = sb->s_user_ns;
kuid_t kuid;
diff --git a/include/linux/mnt_idmapping.h b/include/linux/mnt_idmapping.h
index b16f52d27ba0..6656aea23be2 100644
--- a/include/linux/mnt_idmapping.h
+++ b/include/linux/mnt_idmapping.h
@@ -225,7 +225,7 @@ static inline kgid_t vfsgid_into_kgid(vfsgid_t vfsgid)
*
* Return: the caller's current fsuid mapped up according to @idmap.
*/
-static inline kuid_t mapped_fsuid(struct mnt_idmap *idmap,
+static inline kuid_t mapped_fsuid(const struct mnt_idmap *idmap,
struct user_namespace *fs_userns)
{
return from_vfsuid(idmap, fs_userns, VFSUIDT_INIT(current_fsuid()));
@@ -244,7 +244,7 @@ static inline kuid_t mapped_fsuid(struct mnt_idmap *idmap,
*
* Return: the caller's current fsgid mapped up according to @idmap.
*/
-static inline kgid_t mapped_fsgid(struct mnt_idmap *idmap,
+static inline kgid_t mapped_fsgid(const struct mnt_idmap *idmap,
struct user_namespace *fs_userns)
{
return from_vfsgid(idmap, fs_userns, VFSGIDT_INIT(current_fsgid()));
--
2.53.0
^ permalink raw reply related [flat|nested] 62+ messages in thread* Re: [PATCH 04/27] fs: port fs{g,u}id helpers to const mnt_idmap
2026-09-01 12:14 ` [PATCH 04/27] fs: port fs{g,u}id " Christian Brauner
@ 2026-09-02 14:13 ` Jan Kara
0 siblings, 0 replies; 62+ messages in thread
From: Jan Kara @ 2026-09-02 14:13 UTC (permalink / raw)
To: Christian Brauner
Cc: linux-fsdevel, Alexander Viro, Jan Kara, Christoph Hellwig,
Seth Forshee, Paul Moore, linux-security-module, Mimi Zohar,
linux-integrity, Ilya Dryomov, ceph-devel, Carlos Maiolino,
linux-xfs, Miklos Szeredi, Amir Goldstein, linux-unionfs,
Namjae Jeon, linux-cifs, linux-kernel
On Tue 01-09-26 14:14:29, Christian Brauner wrote:
> Convert to const struct mnt_idmap.
>
> A mount's idmapping is immutable. The only thing that is allowed to be
> modified afterwards is the reference count and that is hidden behind
> mnt_idmap_get() and mnt_idmap_put(). Everything else only ever reads
> from the idmapping. This is the same model that struct cred uses and the
> idmapping is also rather sensitive.
>
> So make the idmap argument const wherever we can. The conversion is done
> from the bottom up so callers can continue to pass a non-const pointer
> to a const parameter until the conversion is finished.
>
> No functional changes.
>
> Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> fs/ceph/mds_client.h | 2 +-
> fs/fuse/dir.c | 13 +++++++------
> fs/fuse/fuse_i.h | 4 ++--
> fs/fuse/req.c | 8 +++++---
> include/linux/fs.h | 6 +++---
> include/linux/mnt_idmapping.h | 4 ++--
> 6 files changed, 20 insertions(+), 17 deletions(-)
>
> diff --git a/fs/ceph/mds_client.h b/fs/ceph/mds_client.h
> index 3c62e3c3530b..1ac8a7e08e5c 100644
> --- a/fs/ceph/mds_client.h
> +++ b/fs/ceph/mds_client.h
> @@ -375,7 +375,7 @@ struct ceph_mds_request {
> int r_fmode; /* file mode, if expecting cap */
> int r_request_release_offset;
> const struct cred *r_cred;
> - struct mnt_idmap *r_mnt_idmap;
> + const struct mnt_idmap *r_mnt_idmap;
> struct timespec64 r_stamp;
>
> /* for choosing which mds to send this request to */
> diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
> index 0d297f74c663..7a204f55ca84 100644
> --- a/fs/fuse/dir.c
> +++ b/fs/fuse/dir.c
> @@ -820,7 +820,7 @@ static void free_ext_value(struct fuse_args *args)
> * If the filesystem doesn't support this, then fall back to separate
> * 'mknod' + 'open' requests.
> */
> -static int fuse_create_open(struct mnt_idmap *idmap, struct inode *dir,
> +static int fuse_create_open(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *entry, struct file *file,
> unsigned int flags, umode_t mode, u32 opcode)
> {
> @@ -980,7 +980,7 @@ static int fuse_atomic_open(struct inode *dir, struct dentry *entry,
> /*
> * Code shared between mknod, mkdir, symlink and link
> */
> -static struct dentry *create_new_entry(struct mnt_idmap *idmap, struct fuse_mount *fm,
> +static struct dentry *create_new_entry(const struct mnt_idmap *idmap, struct fuse_mount *fm,
> struct fuse_args *args, struct inode *dir,
> struct dentry *entry, umode_t mode)
> {
> @@ -1053,7 +1053,7 @@ static struct dentry *create_new_entry(struct mnt_idmap *idmap, struct fuse_moun
> return ERR_PTR(err);
> }
>
> -static int create_new_nondir(struct mnt_idmap *idmap, struct fuse_mount *fm,
> +static int create_new_nondir(const struct mnt_idmap *idmap, struct fuse_mount *fm,
> struct fuse_args *args, struct inode *dir,
> struct dentry *entry, umode_t mode)
> {
> @@ -1256,9 +1256,10 @@ static int fuse_rmdir(struct inode *dir, struct dentry *entry)
> return err;
> }
>
> -static int fuse_rename_common(struct mnt_idmap *idmap, struct inode *olddir, struct dentry *oldent,
> - struct inode *newdir, struct dentry *newent,
> - unsigned int flags, int opcode, size_t argsize)
> +static int fuse_rename_common(const struct mnt_idmap *idmap, struct inode *olddir,
> + struct dentry *oldent, struct inode *newdir,
> + struct dentry *newent, unsigned int flags,
> + int opcode, size_t argsize)
> {
> int err;
> struct fuse_rename2_in inarg;
> diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
> index c8d4c5f3af7e..a07c75377a30 100644
> --- a/fs/fuse/fuse_i.h
> +++ b/fs/fuse/fuse_i.h
> @@ -1003,7 +1003,7 @@ void __exit fuse_ctl_cleanup(void);
> /*
> * Simple request sending that does request allocation and freeing
> */
> -ssize_t __fuse_simple_request(struct mnt_idmap *idmap,
> +ssize_t __fuse_simple_request(const struct mnt_idmap *idmap,
> struct fuse_mount *fm,
> struct fuse_args *args);
>
> @@ -1012,7 +1012,7 @@ static inline ssize_t fuse_simple_request(struct fuse_mount *fm, struct fuse_arg
> return __fuse_simple_request(&invalid_mnt_idmap, fm, args);
> }
>
> -static inline ssize_t fuse_simple_idmap_request(struct mnt_idmap *idmap,
> +static inline ssize_t fuse_simple_idmap_request(const struct mnt_idmap *idmap,
> struct fuse_mount *fm,
> struct fuse_args *args)
> {
> diff --git a/fs/fuse/req.c b/fs/fuse/req.c
> index a01ee743d31e..a133b012d041 100644
> --- a/fs/fuse/req.c
> +++ b/fs/fuse/req.c
> @@ -3,7 +3,8 @@
> #include "dev.h"
> #include "fuse_i.h"
>
> -static int fuse_fill_creds(struct fuse_mount *fm, struct fuse_args *args, struct mnt_idmap *idmap)
> +static int fuse_fill_creds(struct fuse_mount *fm, struct fuse_args *args,
> + const struct mnt_idmap *idmap)
> {
> struct fuse_conn *fc = fm->fc;
> bool no_idmap = !fm->sb || (fm->sb->s_iflags & SB_I_NOIDMAP);
> @@ -49,7 +50,8 @@ static int fuse_fill_creds(struct fuse_mount *fm, struct fuse_args *args, struct
> return 0;
> }
>
> -static int fuse_req_prep(struct fuse_mount *fm, struct fuse_args *args, struct mnt_idmap *idmap)
> +static int fuse_req_prep(struct fuse_mount *fm, struct fuse_args *args,
> + const struct mnt_idmap *idmap)
> {
> if (!args->force && fm->fc->conn_error)
> return -ECONNREFUSED;
> @@ -57,7 +59,7 @@ static int fuse_req_prep(struct fuse_mount *fm, struct fuse_args *args, struct m
> return fuse_fill_creds(fm, args, idmap);
> }
>
> -ssize_t __fuse_simple_request(struct mnt_idmap *idmap, struct fuse_mount *fm,
> +ssize_t __fuse_simple_request(const struct mnt_idmap *idmap, struct fuse_mount *fm,
> struct fuse_args *args)
> {
> struct fuse_conn *fc = fm->fc;
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index f9d1e05e8ae6..959c747ef75a 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -1544,7 +1544,7 @@ static inline void i_gid_update(struct mnt_idmap *idmap,
> * an idmapped mount map the caller's fsuid according to @idmap.
> */
> static inline void inode_fsuid_set(struct inode *inode,
> - struct mnt_idmap *idmap)
> + const struct mnt_idmap *idmap)
> {
> inode->i_uid = mapped_fsuid(idmap, i_user_ns(inode));
> }
> @@ -1558,7 +1558,7 @@ static inline void inode_fsuid_set(struct inode *inode,
> * an idmapped mount map the caller's fsgid according to @idmap.
> */
> static inline void inode_fsgid_set(struct inode *inode,
> - struct mnt_idmap *idmap)
> + const struct mnt_idmap *idmap)
> {
> inode->i_gid = mapped_fsgid(idmap, i_user_ns(inode));
> }
> @@ -1575,7 +1575,7 @@ static inline void inode_fsgid_set(struct inode *inode,
> * Return: true if fsuid and fsgid is mapped, false if not.
> */
> static inline bool fsuidgid_has_mapping(struct super_block *sb,
> - struct mnt_idmap *idmap)
> + const struct mnt_idmap *idmap)
> {
> struct user_namespace *fs_userns = sb->s_user_ns;
> kuid_t kuid;
> diff --git a/include/linux/mnt_idmapping.h b/include/linux/mnt_idmapping.h
> index b16f52d27ba0..6656aea23be2 100644
> --- a/include/linux/mnt_idmapping.h
> +++ b/include/linux/mnt_idmapping.h
> @@ -225,7 +225,7 @@ static inline kgid_t vfsgid_into_kgid(vfsgid_t vfsgid)
> *
> * Return: the caller's current fsuid mapped up according to @idmap.
> */
> -static inline kuid_t mapped_fsuid(struct mnt_idmap *idmap,
> +static inline kuid_t mapped_fsuid(const struct mnt_idmap *idmap,
> struct user_namespace *fs_userns)
> {
> return from_vfsuid(idmap, fs_userns, VFSUIDT_INIT(current_fsuid()));
> @@ -244,7 +244,7 @@ static inline kuid_t mapped_fsuid(struct mnt_idmap *idmap,
> *
> * Return: the caller's current fsgid mapped up according to @idmap.
> */
> -static inline kgid_t mapped_fsgid(struct mnt_idmap *idmap,
> +static inline kgid_t mapped_fsgid(const struct mnt_idmap *idmap,
> struct user_namespace *fs_userns)
> {
> return from_vfsgid(idmap, fs_userns, VFSGIDT_INIT(current_fsgid()));
>
> --
> 2.53.0
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 62+ messages in thread
* [PATCH 05/27] fs: port i_{g,u}id_into_vfs{g,u}id() to const mnt_idmap
2026-09-01 12:14 [PATCH 00/27] fs: port to const struct mnt_idmap Christian Brauner
` (3 preceding siblings ...)
2026-09-01 12:14 ` [PATCH 04/27] fs: port fs{g,u}id " Christian Brauner
@ 2026-09-01 12:14 ` 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
` (21 subsequent siblings)
26 siblings, 1 reply; 62+ messages in thread
From: Christian Brauner @ 2026-09-01 12:14 UTC (permalink / raw)
To: linux-fsdevel
Cc: Alexander Viro, Jan Kara, Christoph Hellwig, Seth Forshee,
Paul Moore, linux-security-module, Mimi Zohar, linux-integrity,
Ilya Dryomov, ceph-devel, Carlos Maiolino, linux-xfs,
Miklos Szeredi, Amir Goldstein, linux-unionfs, Namjae Jeon,
linux-cifs, linux-kernel, Christian Brauner (Amutable)
Convert to const struct mnt_idmap.
A mount's idmapping is immutable. The only thing that is allowed to be
modified afterwards is the reference count and that is hidden behind
mnt_idmap_get() and mnt_idmap_put(). Everything else only ever reads
from the idmapping. This is the same model that struct cred uses and the
idmapping is also rather sensitive.
So make the idmap argument const wherever we can. The conversion is done
from the bottom up so callers can continue to pass a non-const pointer
to a const parameter until the conversion is finished.
No functional changes.
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
---
fs/exfat/file.c | 2 +-
fs/fat/file.c | 2 +-
fs/internal.h | 2 +-
fs/namei.c | 2 +-
fs/smb/server/ndr.c | 2 +-
fs/smb/server/ndr.h | 2 +-
fs/smb/server/smb2pdu.c | 2 +-
fs/xattr.c | 2 +-
fs/xfs/xfs_itable.c | 2 +-
fs/xfs/xfs_itable.h | 2 +-
include/linux/fs.h | 6 +++---
security/integrity/ima/ima.h | 10 +++++-----
security/integrity/ima/ima_api.c | 2 +-
security/integrity/ima/ima_appraise.c | 2 +-
security/integrity/ima/ima_main.c | 2 +-
security/integrity/ima/ima_policy.c | 4 ++--
16 files changed, 23 insertions(+), 23 deletions(-)
diff --git a/fs/exfat/file.c b/fs/exfat/file.c
index a2a9ee1a2004..0530803f71e8 100644
--- a/fs/exfat/file.c
+++ b/fs/exfat/file.c
@@ -143,7 +143,7 @@ static long exfat_fallocate(struct file *file, int mode,
return err;
}
-static bool exfat_allow_set_time(struct mnt_idmap *idmap,
+static bool exfat_allow_set_time(const struct mnt_idmap *idmap,
struct exfat_sb_info *sbi, struct inode *inode)
{
mode_t allow_utime = sbi->options.allow_utime;
diff --git a/fs/fat/file.c b/fs/fat/file.c
index 1c835ca5f21a..0b8b493d06e4 100644
--- a/fs/fat/file.c
+++ b/fs/fat/file.c
@@ -493,7 +493,7 @@ static int fat_sanitize_mode(const struct msdos_sb_info *sbi,
return 0;
}
-static int fat_allow_set_time(struct mnt_idmap *idmap,
+static int fat_allow_set_time(const struct mnt_idmap *idmap,
struct msdos_sb_info *sbi, struct inode *inode)
{
umode_t allow_utime = sbi->options.allow_utime;
diff --git a/fs/internal.h b/fs/internal.h
index 87ac96c3e29e..72244e5f4e57 100644
--- a/fs/internal.h
+++ b/fs/internal.h
@@ -299,7 +299,7 @@ int filename_setxattr(int dfd, struct filename *filename,
int setxattr_copy(const char __user *name, struct kernel_xattr_ctx *ctx);
int import_xattr_name(struct xattr_name *kname, const char __user *name);
-int may_write_xattr(struct mnt_idmap *idmap, struct inode *inode);
+int may_write_xattr(const struct mnt_idmap *idmap, struct inode *inode);
#ifdef CONFIG_FS_POSIX_ACL
int do_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
diff --git a/fs/namei.c b/fs/namei.c
index 20a6534ea3ef..603d43e4a961 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1407,7 +1407,7 @@ int may_linkat(struct mnt_idmap *idmap, const struct path *link)
*
* Returns 0 if the open is allowed, -ve on error.
*/
-static int may_create_in_sticky(struct mnt_idmap *idmap, struct nameidata *nd,
+static int may_create_in_sticky(const struct mnt_idmap *idmap, struct nameidata *nd,
struct inode *const inode)
{
umode_t dir_mode = nd->dir_mode;
diff --git a/fs/smb/server/ndr.c b/fs/smb/server/ndr.c
index 58d71560f626..7e546c22e284 100644
--- a/fs/smb/server/ndr.c
+++ b/fs/smb/server/ndr.c
@@ -338,7 +338,7 @@ static int ndr_encode_posix_acl_entry(struct ndr *n, struct xattr_smb_acl *acl)
}
int ndr_encode_posix_acl(struct ndr *n,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct inode *inode,
struct xattr_smb_acl *acl,
struct xattr_smb_acl *def_acl)
diff --git a/fs/smb/server/ndr.h b/fs/smb/server/ndr.h
index f3c108c8cf4d..646568c42e4d 100644
--- a/fs/smb/server/ndr.h
+++ b/fs/smb/server/ndr.h
@@ -14,7 +14,7 @@ struct ndr {
int ndr_encode_dos_attr(struct ndr *n, struct xattr_dos_attrib *da);
int ndr_decode_dos_attr(struct ndr *n, struct xattr_dos_attrib *da);
-int ndr_encode_posix_acl(struct ndr *n, struct mnt_idmap *idmap,
+int ndr_encode_posix_acl(struct ndr *n, const struct mnt_idmap *idmap,
struct inode *inode, struct xattr_smb_acl *acl,
struct xattr_smb_acl *def_acl);
int ndr_encode_v4_ntacl(struct ndr *n, struct xattr_ntacl *acl);
diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index a8046f477d54..0789200d602f 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -3604,7 +3604,7 @@ static int smb2_create_sd_buffer(struct ksmbd_work *work,
}
static void ksmbd_acls_fattr(struct smb_fattr *fattr,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct inode *inode)
{
vfsuid_t vfsuid = i_uid_into_vfsuid(idmap, inode);
diff --git a/fs/xattr.c b/fs/xattr.c
index d58979115200..c08f188748a9 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -100,7 +100,7 @@ xattr_resolve_name(struct inode *inode, const char **name)
*
* Return: On success zero is returned. On error a negative errno is returned.
*/
-int may_write_xattr(struct mnt_idmap *idmap, struct inode *inode)
+int may_write_xattr(const struct mnt_idmap *idmap, struct inode *inode)
{
if (IS_IMMUTABLE(inode))
return -EPERM;
diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
index 159295c63e8f..a4cf1effa5e6 100644
--- a/fs/xfs/xfs_itable.c
+++ b/fs/xfs/xfs_itable.c
@@ -63,7 +63,7 @@ want_metadir_file(
STATIC int
xfs_bulkstat_one_int(
struct xfs_mount *mp,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct xfs_trans *tp,
xfs_ino_t ino,
struct xfs_bstat_chunk *bc)
diff --git a/fs/xfs/xfs_itable.h b/fs/xfs/xfs_itable.h
index 2d0612f14d6e..c0567bfc30fb 100644
--- a/fs/xfs/xfs_itable.h
+++ b/fs/xfs/xfs_itable.h
@@ -8,7 +8,7 @@
/* In-memory representation of a userspace request for batch inode data. */
struct xfs_ibulk {
struct xfs_mount *mp;
- struct mnt_idmap *idmap;
+ const struct mnt_idmap *idmap;
void __user *ubuffer; /* user output buffer */
xfs_ino_t startino; /* start with this inode */
unsigned int icount; /* number of elements in ubuffer */
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 959c747ef75a..cec5de83d882 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1439,7 +1439,7 @@ static inline void i_gid_write(struct inode *inode, gid_t gid)
* Return: whe inode's i_uid mapped down according to @idmap.
* If the inode's i_uid has no mapping INVALID_VFSUID is returned.
*/
-static inline vfsuid_t i_uid_into_vfsuid(struct mnt_idmap *idmap,
+static inline vfsuid_t i_uid_into_vfsuid(const struct mnt_idmap *idmap,
const struct inode *inode)
{
return make_vfsuid(idmap, i_user_ns(inode), inode->i_uid);
@@ -1491,7 +1491,7 @@ static inline void i_uid_update(struct mnt_idmap *idmap,
* Return: the inode's i_gid mapped down according to @idmap.
* If the inode's i_gid has no mapping INVALID_VFSGID is returned.
*/
-static inline vfsgid_t i_gid_into_vfsgid(struct mnt_idmap *idmap,
+static inline vfsgid_t i_gid_into_vfsgid(const struct mnt_idmap *idmap,
const struct inode *inode)
{
return make_vfsgid(idmap, i_user_ns(inode), inode->i_gid);
@@ -2173,7 +2173,7 @@ extern loff_t vfs_dedupe_file_range_one(struct file *src_file, loff_t src_pos,
(inode)->i_rdev == WHITEOUT_DEV)
#define IS_ANON_FILE(inode) ((inode)->i_flags & S_ANON_INODE)
-static inline bool HAS_UNMAPPED_ID(struct mnt_idmap *idmap,
+static inline bool HAS_UNMAPPED_ID(const struct mnt_idmap *idmap,
struct inode *inode)
{
return !vfsuid_valid(i_uid_into_vfsuid(idmap, inode)) ||
diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
index 10214f73ca1e..b502854f28ee 100644
--- a/security/integrity/ima/ima.h
+++ b/security/integrity/ima/ima.h
@@ -423,7 +423,7 @@ static inline void ima_process_queued_keys(void) {}
#endif /* CONFIG_IMA_QUEUE_EARLY_BOOT_KEYS */
/* LIM API function definitions */
-int ima_get_action(struct mnt_idmap *idmap, struct inode *inode,
+int ima_get_action(const struct mnt_idmap *idmap, struct inode *inode,
const struct cred *cred, struct lsm_prop *prop, int mask,
enum ima_hooks func, int *pcr,
struct ima_template_desc **template_desc,
@@ -437,7 +437,7 @@ void ima_store_measurement(struct ima_iint_cache *iint, struct file *file,
struct evm_ima_xattr_data *xattr_value,
int xattr_len, const struct modsig *modsig, int pcr,
struct ima_template_desc *template_desc);
-int process_buffer_measurement(struct mnt_idmap *idmap,
+int process_buffer_measurement(const struct mnt_idmap *idmap,
struct inode *inode, const void *buf, int size,
const char *eventname, enum ima_hooks func,
int pcr, const char *func_data,
@@ -454,7 +454,7 @@ void ima_free_template_entry(struct ima_template_entry *entry);
const char *ima_d_path(const struct path *path, char **pathbuf, char *filename);
/* IMA policy related functions */
-int ima_match_policy(struct mnt_idmap *idmap, struct inode *inode,
+int ima_match_policy(const struct mnt_idmap *idmap, struct inode *inode,
const struct cred *cred, struct lsm_prop *prop,
enum ima_hooks func, int mask, int flags, int *pcr,
struct ima_template_desc **template_desc,
@@ -489,7 +489,7 @@ int ima_appraise_measurement(enum ima_hooks func, struct ima_iint_cache *iint,
struct evm_ima_xattr_data *xattr_value,
int xattr_len, const struct modsig *modsig,
bool bprm_is_check);
-int ima_must_appraise(struct mnt_idmap *idmap, struct inode *inode,
+int ima_must_appraise(const struct mnt_idmap *idmap, struct inode *inode,
int mask, enum ima_hooks func);
void ima_update_xattr(struct ima_iint_cache *iint, struct file *file);
enum integrity_status ima_get_cache_status(struct ima_iint_cache *iint,
@@ -519,7 +519,7 @@ static inline int ima_appraise_measurement(enum ima_hooks func,
return INTEGRITY_UNKNOWN;
}
-static inline int ima_must_appraise(struct mnt_idmap *idmap,
+static inline int ima_must_appraise(const struct mnt_idmap *idmap,
struct inode *inode, int mask,
enum ima_hooks func)
{
diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
index 122d127e108d..3c5a23b4a2ff 100644
--- a/security/integrity/ima/ima_api.c
+++ b/security/integrity/ima/ima_api.c
@@ -188,7 +188,7 @@ void ima_add_violation(struct file *file, const unsigned char *filename,
* Returns IMA_MEASURE, IMA_APPRAISE mask.
*
*/
-int ima_get_action(struct mnt_idmap *idmap, struct inode *inode,
+int ima_get_action(const struct mnt_idmap *idmap, struct inode *inode,
const struct cred *cred, struct lsm_prop *prop, int mask,
enum ima_hooks func, int *pcr,
struct ima_template_desc **template_desc,
diff --git a/security/integrity/ima/ima_appraise.c b/security/integrity/ima/ima_appraise.c
index ced2e131b061..6b21db789ef1 100644
--- a/security/integrity/ima/ima_appraise.c
+++ b/security/integrity/ima/ima_appraise.c
@@ -71,7 +71,7 @@ bool is_ima_appraise_enabled(void)
*
* Return 1 to appraise or hash
*/
-int ima_must_appraise(struct mnt_idmap *idmap, struct inode *inode,
+int ima_must_appraise(const struct mnt_idmap *idmap, struct inode *inode,
int mask, enum ima_hooks func)
{
struct lsm_prop prop;
diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c
index ab1e53b3210d..8d9c92dc8825 100644
--- a/security/integrity/ima/ima_main.c
+++ b/security/integrity/ima/ima_main.c
@@ -1095,7 +1095,7 @@ static int ima_post_load_data(char *buf, loff_t size,
* has been written to the passed location but not added to a measurement entry,
* a negative value otherwise.
*/
-int process_buffer_measurement(struct mnt_idmap *idmap,
+int process_buffer_measurement(const struct mnt_idmap *idmap,
struct inode *inode, const void *buf, int size,
const char *eventname, enum ima_hooks func,
int pcr, const char *func_data,
diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c
index f79d07bb63c6..89d197d99383 100644
--- a/security/integrity/ima/ima_policy.c
+++ b/security/integrity/ima/ima_policy.c
@@ -575,7 +575,7 @@ static bool ima_match_rule_data(struct ima_rule_entry *rule,
* Returns true on rule match, false on failure.
*/
static bool ima_match_rules(struct ima_rule_entry *rule,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct inode *inode, const struct cred *cred,
struct lsm_prop *prop, enum ima_hooks func, int mask,
const char *func_data)
@@ -757,7 +757,7 @@ static int get_subaction(struct ima_rule_entry *rule, enum ima_hooks func)
* list when walking it. Reads are many orders of magnitude more numerous
* than writes so ima_match_policy() is classical RCU candidate.
*/
-int ima_match_policy(struct mnt_idmap *idmap, struct inode *inode,
+int ima_match_policy(const struct mnt_idmap *idmap, struct inode *inode,
const struct cred *cred, struct lsm_prop *prop,
enum ima_hooks func, int mask, int flags, int *pcr,
struct ima_template_desc **template_desc,
--
2.53.0
^ permalink raw reply related [flat|nested] 62+ messages in thread* Re: [PATCH 05/27] fs: port i_{g,u}id_into_vfs{g,u}id() to const mnt_idmap
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
0 siblings, 0 replies; 62+ messages in thread
From: Jan Kara @ 2026-09-02 14:14 UTC (permalink / raw)
To: Christian Brauner
Cc: linux-fsdevel, Alexander Viro, Jan Kara, Christoph Hellwig,
Seth Forshee, Paul Moore, linux-security-module, Mimi Zohar,
linux-integrity, Ilya Dryomov, ceph-devel, Carlos Maiolino,
linux-xfs, Miklos Szeredi, Amir Goldstein, linux-unionfs,
Namjae Jeon, linux-cifs, linux-kernel
On Tue 01-09-26 14:14:30, Christian Brauner wrote:
> Convert to const struct mnt_idmap.
>
> A mount's idmapping is immutable. The only thing that is allowed to be
> modified afterwards is the reference count and that is hidden behind
> mnt_idmap_get() and mnt_idmap_put(). Everything else only ever reads
> from the idmapping. This is the same model that struct cred uses and the
> idmapping is also rather sensitive.
>
> So make the idmap argument const wherever we can. The conversion is done
> from the bottom up so callers can continue to pass a non-const pointer
> to a const parameter until the conversion is finished.
>
> No functional changes.
>
> Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> fs/exfat/file.c | 2 +-
> fs/fat/file.c | 2 +-
> fs/internal.h | 2 +-
> fs/namei.c | 2 +-
> fs/smb/server/ndr.c | 2 +-
> fs/smb/server/ndr.h | 2 +-
> fs/smb/server/smb2pdu.c | 2 +-
> fs/xattr.c | 2 +-
> fs/xfs/xfs_itable.c | 2 +-
> fs/xfs/xfs_itable.h | 2 +-
> include/linux/fs.h | 6 +++---
> security/integrity/ima/ima.h | 10 +++++-----
> security/integrity/ima/ima_api.c | 2 +-
> security/integrity/ima/ima_appraise.c | 2 +-
> security/integrity/ima/ima_main.c | 2 +-
> security/integrity/ima/ima_policy.c | 4 ++--
> 16 files changed, 23 insertions(+), 23 deletions(-)
>
> diff --git a/fs/exfat/file.c b/fs/exfat/file.c
> index a2a9ee1a2004..0530803f71e8 100644
> --- a/fs/exfat/file.c
> +++ b/fs/exfat/file.c
> @@ -143,7 +143,7 @@ static long exfat_fallocate(struct file *file, int mode,
> return err;
> }
>
> -static bool exfat_allow_set_time(struct mnt_idmap *idmap,
> +static bool exfat_allow_set_time(const struct mnt_idmap *idmap,
> struct exfat_sb_info *sbi, struct inode *inode)
> {
> mode_t allow_utime = sbi->options.allow_utime;
> diff --git a/fs/fat/file.c b/fs/fat/file.c
> index 1c835ca5f21a..0b8b493d06e4 100644
> --- a/fs/fat/file.c
> +++ b/fs/fat/file.c
> @@ -493,7 +493,7 @@ static int fat_sanitize_mode(const struct msdos_sb_info *sbi,
> return 0;
> }
>
> -static int fat_allow_set_time(struct mnt_idmap *idmap,
> +static int fat_allow_set_time(const struct mnt_idmap *idmap,
> struct msdos_sb_info *sbi, struct inode *inode)
> {
> umode_t allow_utime = sbi->options.allow_utime;
> diff --git a/fs/internal.h b/fs/internal.h
> index 87ac96c3e29e..72244e5f4e57 100644
> --- a/fs/internal.h
> +++ b/fs/internal.h
> @@ -299,7 +299,7 @@ int filename_setxattr(int dfd, struct filename *filename,
> int setxattr_copy(const char __user *name, struct kernel_xattr_ctx *ctx);
> int import_xattr_name(struct xattr_name *kname, const char __user *name);
>
> -int may_write_xattr(struct mnt_idmap *idmap, struct inode *inode);
> +int may_write_xattr(const struct mnt_idmap *idmap, struct inode *inode);
>
> #ifdef CONFIG_FS_POSIX_ACL
> int do_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> diff --git a/fs/namei.c b/fs/namei.c
> index 20a6534ea3ef..603d43e4a961 100644
> --- a/fs/namei.c
> +++ b/fs/namei.c
> @@ -1407,7 +1407,7 @@ int may_linkat(struct mnt_idmap *idmap, const struct path *link)
> *
> * Returns 0 if the open is allowed, -ve on error.
> */
> -static int may_create_in_sticky(struct mnt_idmap *idmap, struct nameidata *nd,
> +static int may_create_in_sticky(const struct mnt_idmap *idmap, struct nameidata *nd,
> struct inode *const inode)
> {
> umode_t dir_mode = nd->dir_mode;
> diff --git a/fs/smb/server/ndr.c b/fs/smb/server/ndr.c
> index 58d71560f626..7e546c22e284 100644
> --- a/fs/smb/server/ndr.c
> +++ b/fs/smb/server/ndr.c
> @@ -338,7 +338,7 @@ static int ndr_encode_posix_acl_entry(struct ndr *n, struct xattr_smb_acl *acl)
> }
>
> int ndr_encode_posix_acl(struct ndr *n,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct inode *inode,
> struct xattr_smb_acl *acl,
> struct xattr_smb_acl *def_acl)
> diff --git a/fs/smb/server/ndr.h b/fs/smb/server/ndr.h
> index f3c108c8cf4d..646568c42e4d 100644
> --- a/fs/smb/server/ndr.h
> +++ b/fs/smb/server/ndr.h
> @@ -14,7 +14,7 @@ struct ndr {
>
> int ndr_encode_dos_attr(struct ndr *n, struct xattr_dos_attrib *da);
> int ndr_decode_dos_attr(struct ndr *n, struct xattr_dos_attrib *da);
> -int ndr_encode_posix_acl(struct ndr *n, struct mnt_idmap *idmap,
> +int ndr_encode_posix_acl(struct ndr *n, const struct mnt_idmap *idmap,
> struct inode *inode, struct xattr_smb_acl *acl,
> struct xattr_smb_acl *def_acl);
> int ndr_encode_v4_ntacl(struct ndr *n, struct xattr_ntacl *acl);
> diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
> index a8046f477d54..0789200d602f 100644
> --- a/fs/smb/server/smb2pdu.c
> +++ b/fs/smb/server/smb2pdu.c
> @@ -3604,7 +3604,7 @@ static int smb2_create_sd_buffer(struct ksmbd_work *work,
> }
>
> static void ksmbd_acls_fattr(struct smb_fattr *fattr,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct inode *inode)
> {
> vfsuid_t vfsuid = i_uid_into_vfsuid(idmap, inode);
> diff --git a/fs/xattr.c b/fs/xattr.c
> index d58979115200..c08f188748a9 100644
> --- a/fs/xattr.c
> +++ b/fs/xattr.c
> @@ -100,7 +100,7 @@ xattr_resolve_name(struct inode *inode, const char **name)
> *
> * Return: On success zero is returned. On error a negative errno is returned.
> */
> -int may_write_xattr(struct mnt_idmap *idmap, struct inode *inode)
> +int may_write_xattr(const struct mnt_idmap *idmap, struct inode *inode)
> {
> if (IS_IMMUTABLE(inode))
> return -EPERM;
> diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
> index 159295c63e8f..a4cf1effa5e6 100644
> --- a/fs/xfs/xfs_itable.c
> +++ b/fs/xfs/xfs_itable.c
> @@ -63,7 +63,7 @@ want_metadir_file(
> STATIC int
> xfs_bulkstat_one_int(
> struct xfs_mount *mp,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct xfs_trans *tp,
> xfs_ino_t ino,
> struct xfs_bstat_chunk *bc)
> diff --git a/fs/xfs/xfs_itable.h b/fs/xfs/xfs_itable.h
> index 2d0612f14d6e..c0567bfc30fb 100644
> --- a/fs/xfs/xfs_itable.h
> +++ b/fs/xfs/xfs_itable.h
> @@ -8,7 +8,7 @@
> /* In-memory representation of a userspace request for batch inode data. */
> struct xfs_ibulk {
> struct xfs_mount *mp;
> - struct mnt_idmap *idmap;
> + const struct mnt_idmap *idmap;
> void __user *ubuffer; /* user output buffer */
> xfs_ino_t startino; /* start with this inode */
> unsigned int icount; /* number of elements in ubuffer */
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 959c747ef75a..cec5de83d882 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -1439,7 +1439,7 @@ static inline void i_gid_write(struct inode *inode, gid_t gid)
> * Return: whe inode's i_uid mapped down according to @idmap.
> * If the inode's i_uid has no mapping INVALID_VFSUID is returned.
> */
> -static inline vfsuid_t i_uid_into_vfsuid(struct mnt_idmap *idmap,
> +static inline vfsuid_t i_uid_into_vfsuid(const struct mnt_idmap *idmap,
> const struct inode *inode)
> {
> return make_vfsuid(idmap, i_user_ns(inode), inode->i_uid);
> @@ -1491,7 +1491,7 @@ static inline void i_uid_update(struct mnt_idmap *idmap,
> * Return: the inode's i_gid mapped down according to @idmap.
> * If the inode's i_gid has no mapping INVALID_VFSGID is returned.
> */
> -static inline vfsgid_t i_gid_into_vfsgid(struct mnt_idmap *idmap,
> +static inline vfsgid_t i_gid_into_vfsgid(const struct mnt_idmap *idmap,
> const struct inode *inode)
> {
> return make_vfsgid(idmap, i_user_ns(inode), inode->i_gid);
> @@ -2173,7 +2173,7 @@ extern loff_t vfs_dedupe_file_range_one(struct file *src_file, loff_t src_pos,
> (inode)->i_rdev == WHITEOUT_DEV)
> #define IS_ANON_FILE(inode) ((inode)->i_flags & S_ANON_INODE)
>
> -static inline bool HAS_UNMAPPED_ID(struct mnt_idmap *idmap,
> +static inline bool HAS_UNMAPPED_ID(const struct mnt_idmap *idmap,
> struct inode *inode)
> {
> return !vfsuid_valid(i_uid_into_vfsuid(idmap, inode)) ||
> diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
> index 10214f73ca1e..b502854f28ee 100644
> --- a/security/integrity/ima/ima.h
> +++ b/security/integrity/ima/ima.h
> @@ -423,7 +423,7 @@ static inline void ima_process_queued_keys(void) {}
> #endif /* CONFIG_IMA_QUEUE_EARLY_BOOT_KEYS */
>
> /* LIM API function definitions */
> -int ima_get_action(struct mnt_idmap *idmap, struct inode *inode,
> +int ima_get_action(const struct mnt_idmap *idmap, struct inode *inode,
> const struct cred *cred, struct lsm_prop *prop, int mask,
> enum ima_hooks func, int *pcr,
> struct ima_template_desc **template_desc,
> @@ -437,7 +437,7 @@ void ima_store_measurement(struct ima_iint_cache *iint, struct file *file,
> struct evm_ima_xattr_data *xattr_value,
> int xattr_len, const struct modsig *modsig, int pcr,
> struct ima_template_desc *template_desc);
> -int process_buffer_measurement(struct mnt_idmap *idmap,
> +int process_buffer_measurement(const struct mnt_idmap *idmap,
> struct inode *inode, const void *buf, int size,
> const char *eventname, enum ima_hooks func,
> int pcr, const char *func_data,
> @@ -454,7 +454,7 @@ void ima_free_template_entry(struct ima_template_entry *entry);
> const char *ima_d_path(const struct path *path, char **pathbuf, char *filename);
>
> /* IMA policy related functions */
> -int ima_match_policy(struct mnt_idmap *idmap, struct inode *inode,
> +int ima_match_policy(const struct mnt_idmap *idmap, struct inode *inode,
> const struct cred *cred, struct lsm_prop *prop,
> enum ima_hooks func, int mask, int flags, int *pcr,
> struct ima_template_desc **template_desc,
> @@ -489,7 +489,7 @@ int ima_appraise_measurement(enum ima_hooks func, struct ima_iint_cache *iint,
> struct evm_ima_xattr_data *xattr_value,
> int xattr_len, const struct modsig *modsig,
> bool bprm_is_check);
> -int ima_must_appraise(struct mnt_idmap *idmap, struct inode *inode,
> +int ima_must_appraise(const struct mnt_idmap *idmap, struct inode *inode,
> int mask, enum ima_hooks func);
> void ima_update_xattr(struct ima_iint_cache *iint, struct file *file);
> enum integrity_status ima_get_cache_status(struct ima_iint_cache *iint,
> @@ -519,7 +519,7 @@ static inline int ima_appraise_measurement(enum ima_hooks func,
> return INTEGRITY_UNKNOWN;
> }
>
> -static inline int ima_must_appraise(struct mnt_idmap *idmap,
> +static inline int ima_must_appraise(const struct mnt_idmap *idmap,
> struct inode *inode, int mask,
> enum ima_hooks func)
> {
> diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
> index 122d127e108d..3c5a23b4a2ff 100644
> --- a/security/integrity/ima/ima_api.c
> +++ b/security/integrity/ima/ima_api.c
> @@ -188,7 +188,7 @@ void ima_add_violation(struct file *file, const unsigned char *filename,
> * Returns IMA_MEASURE, IMA_APPRAISE mask.
> *
> */
> -int ima_get_action(struct mnt_idmap *idmap, struct inode *inode,
> +int ima_get_action(const struct mnt_idmap *idmap, struct inode *inode,
> const struct cred *cred, struct lsm_prop *prop, int mask,
> enum ima_hooks func, int *pcr,
> struct ima_template_desc **template_desc,
> diff --git a/security/integrity/ima/ima_appraise.c b/security/integrity/ima/ima_appraise.c
> index ced2e131b061..6b21db789ef1 100644
> --- a/security/integrity/ima/ima_appraise.c
> +++ b/security/integrity/ima/ima_appraise.c
> @@ -71,7 +71,7 @@ bool is_ima_appraise_enabled(void)
> *
> * Return 1 to appraise or hash
> */
> -int ima_must_appraise(struct mnt_idmap *idmap, struct inode *inode,
> +int ima_must_appraise(const struct mnt_idmap *idmap, struct inode *inode,
> int mask, enum ima_hooks func)
> {
> struct lsm_prop prop;
> diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c
> index ab1e53b3210d..8d9c92dc8825 100644
> --- a/security/integrity/ima/ima_main.c
> +++ b/security/integrity/ima/ima_main.c
> @@ -1095,7 +1095,7 @@ static int ima_post_load_data(char *buf, loff_t size,
> * has been written to the passed location but not added to a measurement entry,
> * a negative value otherwise.
> */
> -int process_buffer_measurement(struct mnt_idmap *idmap,
> +int process_buffer_measurement(const struct mnt_idmap *idmap,
> struct inode *inode, const void *buf, int size,
> const char *eventname, enum ima_hooks func,
> int pcr, const char *func_data,
> diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c
> index f79d07bb63c6..89d197d99383 100644
> --- a/security/integrity/ima/ima_policy.c
> +++ b/security/integrity/ima/ima_policy.c
> @@ -575,7 +575,7 @@ static bool ima_match_rule_data(struct ima_rule_entry *rule,
> * Returns true on rule match, false on failure.
> */
> static bool ima_match_rules(struct ima_rule_entry *rule,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct inode *inode, const struct cred *cred,
> struct lsm_prop *prop, enum ima_hooks func, int mask,
> const char *func_data)
> @@ -757,7 +757,7 @@ static int get_subaction(struct ima_rule_entry *rule, enum ima_hooks func)
> * list when walking it. Reads are many orders of magnitude more numerous
> * than writes so ima_match_policy() is classical RCU candidate.
> */
> -int ima_match_policy(struct mnt_idmap *idmap, struct inode *inode,
> +int ima_match_policy(const struct mnt_idmap *idmap, struct inode *inode,
> const struct cred *cred, struct lsm_prop *prop,
> enum ima_hooks func, int mask, int flags, int *pcr,
> struct ima_template_desc **template_desc,
>
> --
> 2.53.0
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 62+ messages in thread
* [PATCH 06/27] fs: port i_{g,u}id_{needs_}update() to const mnt_idmap
2026-09-01 12:14 [PATCH 00/27] fs: port to const struct mnt_idmap Christian Brauner
` (4 preceding siblings ...)
2026-09-01 12:14 ` [PATCH 05/27] fs: port i_{g,u}id_into_vfs{g,u}id() " Christian Brauner
@ 2026-09-01 12:14 ` Christian Brauner
2026-09-02 14:15 ` Jan Kara
2026-09-01 12:14 ` [PATCH 07/27] quota: port " Christian Brauner
` (20 subsequent siblings)
26 siblings, 1 reply; 62+ messages in thread
From: Christian Brauner @ 2026-09-01 12:14 UTC (permalink / raw)
To: linux-fsdevel
Cc: Alexander Viro, Jan Kara, Christoph Hellwig, Seth Forshee,
Paul Moore, linux-security-module, Mimi Zohar, linux-integrity,
Ilya Dryomov, ceph-devel, Carlos Maiolino, linux-xfs,
Miklos Szeredi, Amir Goldstein, linux-unionfs, Namjae Jeon,
linux-cifs, linux-kernel, Christian Brauner (Amutable)
Convert to const struct mnt_idmap.
A mount's idmapping is immutable. The only thing that is allowed to be
modified afterwards is the reference count and that is hidden behind
mnt_idmap_get() and mnt_idmap_put(). Everything else only ever reads
from the idmapping. This is the same model that struct cred uses and the
idmapping is also rather sensitive.
So make the idmap argument const wherever we can. The conversion is done
from the bottom up so callers can continue to pass a non-const pointer
to a const parameter until the conversion is finished.
No functional changes.
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
---
include/linux/fs.h | 8 ++++----
security/integrity/evm/evm_main.c | 2 +-
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/include/linux/fs.h b/include/linux/fs.h
index cec5de83d882..154f2c976a0a 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1456,7 +1456,7 @@ static inline vfsuid_t i_uid_into_vfsuid(const struct mnt_idmap *idmap,
*
* Return: true if @inode's i_uid field needs to be updated, false if not.
*/
-static inline bool i_uid_needs_update(struct mnt_idmap *idmap,
+static inline bool i_uid_needs_update(const struct mnt_idmap *idmap,
const struct iattr *attr,
const struct inode *inode)
{
@@ -1474,7 +1474,7 @@ static inline bool i_uid_needs_update(struct mnt_idmap *idmap,
* Safely update @inode's i_uid field translating the vfsuid of any idmapped
* mount into the filesystem kuid.
*/
-static inline void i_uid_update(struct mnt_idmap *idmap,
+static inline void i_uid_update(const struct mnt_idmap *idmap,
const struct iattr *attr,
struct inode *inode)
{
@@ -1508,7 +1508,7 @@ static inline vfsgid_t i_gid_into_vfsgid(const struct mnt_idmap *idmap,
*
* Return: true if @inode's i_gid field needs to be updated, false if not.
*/
-static inline bool i_gid_needs_update(struct mnt_idmap *idmap,
+static inline bool i_gid_needs_update(const struct mnt_idmap *idmap,
const struct iattr *attr,
const struct inode *inode)
{
@@ -1526,7 +1526,7 @@ static inline bool i_gid_needs_update(struct mnt_idmap *idmap,
* Safely update @inode's i_gid field translating the vfsgid of any idmapped
* mount into the filesystem kgid.
*/
-static inline void i_gid_update(struct mnt_idmap *idmap,
+static inline void i_gid_update(const struct mnt_idmap *idmap,
const struct iattr *attr,
struct inode *inode)
{
diff --git a/security/integrity/evm/evm_main.c b/security/integrity/evm/evm_main.c
index 66f27653cdac..06e187c9912d 100644
--- a/security/integrity/evm/evm_main.c
+++ b/security/integrity/evm/evm_main.c
@@ -933,7 +933,7 @@ static inline void evm_inode_post_remove_acl(struct mnt_idmap *idmap,
evm_inode_post_removexattr(dentry, acl_name);
}
-static int evm_attr_change(struct mnt_idmap *idmap,
+static int evm_attr_change(const struct mnt_idmap *idmap,
struct dentry *dentry, struct iattr *attr)
{
struct inode *inode = d_backing_inode(dentry);
--
2.53.0
^ permalink raw reply related [flat|nested] 62+ messages in thread* Re: [PATCH 06/27] fs: port i_{g,u}id_{needs_}update() to const mnt_idmap
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
0 siblings, 0 replies; 62+ messages in thread
From: Jan Kara @ 2026-09-02 14:15 UTC (permalink / raw)
To: Christian Brauner
Cc: linux-fsdevel, Alexander Viro, Jan Kara, Christoph Hellwig,
Seth Forshee, Paul Moore, linux-security-module, Mimi Zohar,
linux-integrity, Ilya Dryomov, ceph-devel, Carlos Maiolino,
linux-xfs, Miklos Szeredi, Amir Goldstein, linux-unionfs,
Namjae Jeon, linux-cifs, linux-kernel
On Tue 01-09-26 14:14:31, Christian Brauner wrote:
> Convert to const struct mnt_idmap.
>
> A mount's idmapping is immutable. The only thing that is allowed to be
> modified afterwards is the reference count and that is hidden behind
> mnt_idmap_get() and mnt_idmap_put(). Everything else only ever reads
> from the idmapping. This is the same model that struct cred uses and the
> idmapping is also rather sensitive.
>
> So make the idmap argument const wherever we can. The conversion is done
> from the bottom up so callers can continue to pass a non-const pointer
> to a const parameter until the conversion is finished.
>
> No functional changes.
>
> Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> include/linux/fs.h | 8 ++++----
> security/integrity/evm/evm_main.c | 2 +-
> 2 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index cec5de83d882..154f2c976a0a 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -1456,7 +1456,7 @@ static inline vfsuid_t i_uid_into_vfsuid(const struct mnt_idmap *idmap,
> *
> * Return: true if @inode's i_uid field needs to be updated, false if not.
> */
> -static inline bool i_uid_needs_update(struct mnt_idmap *idmap,
> +static inline bool i_uid_needs_update(const struct mnt_idmap *idmap,
> const struct iattr *attr,
> const struct inode *inode)
> {
> @@ -1474,7 +1474,7 @@ static inline bool i_uid_needs_update(struct mnt_idmap *idmap,
> * Safely update @inode's i_uid field translating the vfsuid of any idmapped
> * mount into the filesystem kuid.
> */
> -static inline void i_uid_update(struct mnt_idmap *idmap,
> +static inline void i_uid_update(const struct mnt_idmap *idmap,
> const struct iattr *attr,
> struct inode *inode)
> {
> @@ -1508,7 +1508,7 @@ static inline vfsgid_t i_gid_into_vfsgid(const struct mnt_idmap *idmap,
> *
> * Return: true if @inode's i_gid field needs to be updated, false if not.
> */
> -static inline bool i_gid_needs_update(struct mnt_idmap *idmap,
> +static inline bool i_gid_needs_update(const struct mnt_idmap *idmap,
> const struct iattr *attr,
> const struct inode *inode)
> {
> @@ -1526,7 +1526,7 @@ static inline bool i_gid_needs_update(struct mnt_idmap *idmap,
> * Safely update @inode's i_gid field translating the vfsgid of any idmapped
> * mount into the filesystem kgid.
> */
> -static inline void i_gid_update(struct mnt_idmap *idmap,
> +static inline void i_gid_update(const struct mnt_idmap *idmap,
> const struct iattr *attr,
> struct inode *inode)
> {
> diff --git a/security/integrity/evm/evm_main.c b/security/integrity/evm/evm_main.c
> index 66f27653cdac..06e187c9912d 100644
> --- a/security/integrity/evm/evm_main.c
> +++ b/security/integrity/evm/evm_main.c
> @@ -933,7 +933,7 @@ static inline void evm_inode_post_remove_acl(struct mnt_idmap *idmap,
> evm_inode_post_removexattr(dentry, acl_name);
> }
>
> -static int evm_attr_change(struct mnt_idmap *idmap,
> +static int evm_attr_change(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct iattr *attr)
> {
> struct inode *inode = d_backing_inode(dentry);
>
> --
> 2.53.0
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 62+ messages in thread
* [PATCH 07/27] quota: port to const mnt_idmap
2026-09-01 12:14 [PATCH 00/27] fs: port to const struct mnt_idmap Christian Brauner
` (5 preceding siblings ...)
2026-09-01 12:14 ` [PATCH 06/27] fs: port i_{g,u}id_{needs_}update() " Christian Brauner
@ 2026-09-01 12:14 ` Christian Brauner
2026-09-02 14:16 ` Jan Kara
2026-09-01 12:14 ` [PATCH 08/27] fs: port privilege checking helpers " Christian Brauner
` (19 subsequent siblings)
26 siblings, 1 reply; 62+ messages in thread
From: Christian Brauner @ 2026-09-01 12:14 UTC (permalink / raw)
To: linux-fsdevel
Cc: Alexander Viro, Jan Kara, Christoph Hellwig, Seth Forshee,
Paul Moore, linux-security-module, Mimi Zohar, linux-integrity,
Ilya Dryomov, ceph-devel, Carlos Maiolino, linux-xfs,
Miklos Szeredi, Amir Goldstein, linux-unionfs, Namjae Jeon,
linux-cifs, linux-kernel, Christian Brauner (Amutable)
Convert to const struct mnt_idmap.
A mount's idmapping is immutable. The only thing that is allowed to be
modified afterwards is the reference count and that is hidden behind
mnt_idmap_get() and mnt_idmap_put(). Everything else only ever reads
from the idmapping. This is the same model that struct cred uses and the
idmapping is also rather sensitive.
So make the idmap argument const wherever we can. The conversion is done
from the bottom up so callers can continue to pass a non-const pointer
to a const parameter until the conversion is finished.
No functional changes.
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
---
fs/quota/dquot.c | 2 +-
include/linux/quotaops.h | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
index 204afc5e984b..c5e9c4e24d68 100644
--- a/fs/quota/dquot.c
+++ b/fs/quota/dquot.c
@@ -2079,7 +2079,7 @@ EXPORT_SYMBOL(__dquot_transfer);
/* Wrapper for transferring ownership of an inode for uid/gid only
* Called from FSXXX_setattr()
*/
-int dquot_transfer(struct mnt_idmap *idmap, struct inode *inode,
+int dquot_transfer(const struct mnt_idmap *idmap, struct inode *inode,
struct iattr *iattr)
{
struct dquot *transfer_to[MAXQUOTAS] = {};
diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h
index f9c0f9d7c9d9..0c64ca674e77 100644
--- a/include/linux/quotaops.h
+++ b/include/linux/quotaops.h
@@ -20,7 +20,7 @@ static inline struct quota_info *sb_dqopt(struct super_block *sb)
}
/* i_rwsem must being held */
-static inline bool is_quota_modification(struct mnt_idmap *idmap,
+static inline bool is_quota_modification(const struct mnt_idmap *idmap,
struct inode *inode, struct iattr *ia)
{
return ((ia->ia_valid & ATTR_SIZE) ||
@@ -109,7 +109,7 @@ int dquot_set_dqblk(struct super_block *sb, struct kqid id,
struct qc_dqblk *di);
int __dquot_transfer(struct inode *inode, struct dquot **transfer_to);
-int dquot_transfer(struct mnt_idmap *idmap, struct inode *inode,
+int dquot_transfer(const struct mnt_idmap *idmap, struct inode *inode,
struct iattr *iattr);
static inline struct mem_dqinfo *sb_dqinfo(struct super_block *sb, int type)
@@ -229,7 +229,7 @@ static inline void dquot_free_inode(struct inode *inode)
{
}
-static inline int dquot_transfer(struct mnt_idmap *idmap,
+static inline int dquot_transfer(const struct mnt_idmap *idmap,
struct inode *inode, struct iattr *iattr)
{
return 0;
--
2.53.0
^ permalink raw reply related [flat|nested] 62+ messages in thread* Re: [PATCH 07/27] quota: port to const mnt_idmap
2026-09-01 12:14 ` [PATCH 07/27] quota: port " Christian Brauner
@ 2026-09-02 14:16 ` Jan Kara
0 siblings, 0 replies; 62+ messages in thread
From: Jan Kara @ 2026-09-02 14:16 UTC (permalink / raw)
To: Christian Brauner
Cc: linux-fsdevel, Alexander Viro, Jan Kara, Christoph Hellwig,
Seth Forshee, Paul Moore, linux-security-module, Mimi Zohar,
linux-integrity, Ilya Dryomov, ceph-devel, Carlos Maiolino,
linux-xfs, Miklos Szeredi, Amir Goldstein, linux-unionfs,
Namjae Jeon, linux-cifs, linux-kernel
On Tue 01-09-26 14:14:32, Christian Brauner wrote:
> Convert to const struct mnt_idmap.
>
> A mount's idmapping is immutable. The only thing that is allowed to be
> modified afterwards is the reference count and that is hidden behind
> mnt_idmap_get() and mnt_idmap_put(). Everything else only ever reads
> from the idmapping. This is the same model that struct cred uses and the
> idmapping is also rather sensitive.
>
> So make the idmap argument const wherever we can. The conversion is done
> from the bottom up so callers can continue to pass a non-const pointer
> to a const parameter until the conversion is finished.
>
> No functional changes.
>
> Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> fs/quota/dquot.c | 2 +-
> include/linux/quotaops.h | 6 +++---
> 2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
> index 204afc5e984b..c5e9c4e24d68 100644
> --- a/fs/quota/dquot.c
> +++ b/fs/quota/dquot.c
> @@ -2079,7 +2079,7 @@ EXPORT_SYMBOL(__dquot_transfer);
> /* Wrapper for transferring ownership of an inode for uid/gid only
> * Called from FSXXX_setattr()
> */
> -int dquot_transfer(struct mnt_idmap *idmap, struct inode *inode,
> +int dquot_transfer(const struct mnt_idmap *idmap, struct inode *inode,
> struct iattr *iattr)
> {
> struct dquot *transfer_to[MAXQUOTAS] = {};
> diff --git a/include/linux/quotaops.h b/include/linux/quotaops.h
> index f9c0f9d7c9d9..0c64ca674e77 100644
> --- a/include/linux/quotaops.h
> +++ b/include/linux/quotaops.h
> @@ -20,7 +20,7 @@ static inline struct quota_info *sb_dqopt(struct super_block *sb)
> }
>
> /* i_rwsem must being held */
> -static inline bool is_quota_modification(struct mnt_idmap *idmap,
> +static inline bool is_quota_modification(const struct mnt_idmap *idmap,
> struct inode *inode, struct iattr *ia)
> {
> return ((ia->ia_valid & ATTR_SIZE) ||
> @@ -109,7 +109,7 @@ int dquot_set_dqblk(struct super_block *sb, struct kqid id,
> struct qc_dqblk *di);
>
> int __dquot_transfer(struct inode *inode, struct dquot **transfer_to);
> -int dquot_transfer(struct mnt_idmap *idmap, struct inode *inode,
> +int dquot_transfer(const struct mnt_idmap *idmap, struct inode *inode,
> struct iattr *iattr);
>
> static inline struct mem_dqinfo *sb_dqinfo(struct super_block *sb, int type)
> @@ -229,7 +229,7 @@ static inline void dquot_free_inode(struct inode *inode)
> {
> }
>
> -static inline int dquot_transfer(struct mnt_idmap *idmap,
> +static inline int dquot_transfer(const struct mnt_idmap *idmap,
> struct inode *inode, struct iattr *iattr)
> {
> return 0;
>
> --
> 2.53.0
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 62+ messages in thread
* [PATCH 08/27] fs: port privilege checking helpers to const mnt_idmap
2026-09-01 12:14 [PATCH 00/27] fs: port to const struct mnt_idmap Christian Brauner
` (6 preceding siblings ...)
2026-09-01 12:14 ` [PATCH 07/27] quota: port " Christian Brauner
@ 2026-09-01 12:14 ` 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
` (18 subsequent siblings)
26 siblings, 1 reply; 62+ messages in thread
From: Christian Brauner @ 2026-09-01 12:14 UTC (permalink / raw)
To: linux-fsdevel
Cc: Alexander Viro, Jan Kara, Christoph Hellwig, Seth Forshee,
Paul Moore, linux-security-module, Mimi Zohar, linux-integrity,
Ilya Dryomov, ceph-devel, Carlos Maiolino, linux-xfs,
Miklos Szeredi, Amir Goldstein, linux-unionfs, Namjae Jeon,
linux-cifs, linux-kernel, Christian Brauner (Amutable)
Convert to const struct mnt_idmap.
A mount's idmapping is immutable. The only thing that is allowed to be
modified afterwards is the reference count and that is hidden behind
mnt_idmap_get() and mnt_idmap_put(). Everything else only ever reads
from the idmapping. This is the same model that struct cred uses and the
idmapping is also rather sensitive.
So make the idmap argument const wherever we can. The conversion is done
from the bottom up so callers can continue to pass a non-const pointer
to a const parameter until the conversion is finished.
No functional changes.
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
---
fs/attr.c | 10 +++++-----
fs/f2fs/acl.c | 4 ++--
fs/f2fs/file.c | 2 +-
fs/inode.c | 4 ++--
fs/internal.h | 4 ++--
include/linux/capability.h | 4 ++--
include/linux/fs.h | 8 ++++----
include/linux/security.h | 2 +-
kernel/capability.c | 4 ++--
security/commoncap.c | 2 +-
10 files changed, 22 insertions(+), 22 deletions(-)
diff --git a/fs/attr.c b/fs/attr.c
index 71888ac903c2..23f1347ff240 100644
--- a/fs/attr.c
+++ b/fs/attr.c
@@ -30,7 +30,7 @@
*
* Return: ATTR_KILL_SGID if setgid bit needs to be removed, 0 otherwise.
*/
-int setattr_should_drop_sgid(struct mnt_idmap *idmap,
+int setattr_should_drop_sgid(const struct mnt_idmap *idmap,
const struct inode *inode)
{
umode_t mode = inode->i_mode;
@@ -60,7 +60,7 @@ EXPORT_SYMBOL(setattr_should_drop_sgid);
* Return: A mask of ATTR_KILL_S{G,U}ID indicating which - if any - setid bits
* to remove, 0 otherwise.
*/
-int setattr_should_drop_suidgid(struct mnt_idmap *idmap,
+int setattr_should_drop_suidgid(const struct mnt_idmap *idmap,
struct inode *inode)
{
umode_t mode = inode->i_mode;
@@ -91,7 +91,7 @@ EXPORT_SYMBOL(setattr_should_drop_suidgid);
* permissions. On non-idmapped mounts or if permission checking is to be
* performed on the raw inode simply pass @nop_mnt_idmap.
*/
-static bool chown_ok(struct mnt_idmap *idmap,
+static bool chown_ok(const struct mnt_idmap *idmap,
const struct inode *inode, vfsuid_t ia_vfsuid)
{
vfsuid_t vfsuid = i_uid_into_vfsuid(idmap, inode);
@@ -118,7 +118,7 @@ static bool chown_ok(struct mnt_idmap *idmap,
* permissions. On non-idmapped mounts or if permission checking is to be
* performed on the raw inode simply pass @nop_mnt_idmap.
*/
-static bool chgrp_ok(struct mnt_idmap *idmap,
+static bool chgrp_ok(const struct mnt_idmap *idmap,
const struct inode *inode, vfsgid_t ia_vfsgid)
{
vfsgid_t vfsgid = i_gid_into_vfsgid(idmap, inode);
@@ -339,7 +339,7 @@ static void setattr_copy_mgtime(struct inode *inode, const struct iattr *attr)
* that for "simple" filesystems, the struct inode is the inode storage.
* The caller is free to mark the inode dirty afterwards if needed.
*/
-void setattr_copy(struct mnt_idmap *idmap, struct inode *inode,
+void setattr_copy(const struct mnt_idmap *idmap, struct inode *inode,
const struct iattr *attr)
{
unsigned int ia_valid = attr->ia_valid;
diff --git a/fs/f2fs/acl.c b/fs/f2fs/acl.c
index d3253549173e..e7e0084d0a5f 100644
--- a/fs/f2fs/acl.c
+++ b/fs/f2fs/acl.c
@@ -219,7 +219,7 @@ struct posix_acl *f2fs_get_acl(struct inode *inode, int type, bool rcu)
return __f2fs_get_acl(inode, type, NULL);
}
-static int f2fs_acl_update_mode(struct mnt_idmap *idmap,
+static int f2fs_acl_update_mode(const struct mnt_idmap *idmap,
struct inode *inode, umode_t *mode_p,
struct posix_acl **acl)
{
@@ -240,7 +240,7 @@ static int f2fs_acl_update_mode(struct mnt_idmap *idmap,
return 0;
}
-static int __f2fs_set_acl(struct mnt_idmap *idmap,
+static int __f2fs_set_acl(const struct mnt_idmap *idmap,
struct inode *inode, int type,
struct posix_acl *acl, struct folio *ifolio)
{
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index edc352569e87..03bb3a9a449f 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -1096,7 +1096,7 @@ int f2fs_getattr(struct mnt_idmap *idmap, const struct path *path,
}
#ifdef CONFIG_F2FS_FS_POSIX_ACL
-static void __setattr_copy(struct mnt_idmap *idmap,
+static void __setattr_copy(const struct mnt_idmap *idmap,
struct inode *inode, const struct iattr *attr)
{
unsigned int ia_valid = attr->ia_valid;
diff --git a/fs/inode.c b/fs/inode.c
index ba7da39be4a3..72a8bbe38d62 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -2337,7 +2337,7 @@ EXPORT_SYMBOL(touch_atime);
* response to write or truncate. Return 0 if nothing has to be changed.
* Negative value on error (change should be denied).
*/
-int dentry_needs_remove_privs(struct mnt_idmap *idmap,
+int dentry_needs_remove_privs(const struct mnt_idmap *idmap,
struct dentry *dentry)
{
struct inode *inode = d_inode(dentry);
@@ -3033,7 +3033,7 @@ EXPORT_SYMBOL(inode_set_ctime_deleg);
*
* Return: true if the caller is sufficiently privileged, false if not.
*/
-bool in_group_or_capable(struct mnt_idmap *idmap,
+bool in_group_or_capable(const struct mnt_idmap *idmap,
const struct inode *inode, vfsgid_t vfsgid)
{
if (vfsgid_in_group_p(vfsgid))
diff --git a/fs/internal.h b/fs/internal.h
index 72244e5f4e57..161b0cafe17f 100644
--- a/fs/internal.h
+++ b/fs/internal.h
@@ -210,8 +210,8 @@ extern int vfs_open(const struct path *, struct file *);
* inode.c
*/
extern long prune_icache_sb(struct super_block *sb, struct shrink_control *sc);
-int dentry_needs_remove_privs(struct mnt_idmap *, struct dentry *dentry);
-bool in_group_or_capable(struct mnt_idmap *idmap,
+int dentry_needs_remove_privs(const struct mnt_idmap *, struct dentry *dentry);
+bool in_group_or_capable(const struct mnt_idmap *idmap,
const struct inode *inode, vfsgid_t vfsgid);
/*
diff --git a/include/linux/capability.h b/include/linux/capability.h
index 37db92b3d6f8..c39a2bbefc47 100644
--- a/include/linux/capability.h
+++ b/include/linux/capability.h
@@ -181,9 +181,9 @@ static inline bool ns_capable_setid(struct user_namespace *ns, int cap)
}
#endif /* CONFIG_MULTIUSER */
bool privileged_wrt_inode_uidgid(struct user_namespace *ns,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
const struct inode *inode);
-bool capable_wrt_inode_uidgid(struct mnt_idmap *idmap,
+bool capable_wrt_inode_uidgid(const struct mnt_idmap *idmap,
const struct inode *inode, int cap);
extern bool file_ns_capable(const struct file *file, struct user_namespace *ns, int cap);
extern bool ptracer_capable(struct task_struct *tsk, struct user_namespace *ns);
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 154f2c976a0a..7c82d7aaa775 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1835,7 +1835,7 @@ void inode_init_owner(struct mnt_idmap *idmap, struct inode *inode,
extern bool may_open_dev(const struct path *path);
umode_t mode_strip_sgid(struct mnt_idmap *idmap,
const struct inode *dir, umode_t mode);
-bool in_group_or_capable(struct mnt_idmap *idmap,
+bool in_group_or_capable(const struct mnt_idmap *idmap,
const struct inode *inode, vfsgid_t vfsgid);
/*
@@ -3045,9 +3045,9 @@ static inline struct inode *new_inode_pseudo(struct super_block *sb)
}
extern struct inode *new_inode(struct super_block *sb);
extern void free_inode_nonrcu(struct inode *inode);
-extern int setattr_should_drop_suidgid(struct mnt_idmap *, struct inode *);
+extern int setattr_should_drop_suidgid(const struct mnt_idmap *, struct inode *);
extern int file_remove_privs(struct file *);
-int setattr_should_drop_sgid(struct mnt_idmap *idmap,
+int setattr_should_drop_sgid(const struct mnt_idmap *idmap,
const struct inode *inode);
/*
@@ -3401,7 +3401,7 @@ int may_setattr(struct mnt_idmap *idmap, struct inode *inode,
unsigned int ia_valid);
int setattr_prepare(struct mnt_idmap *, struct dentry *, struct iattr *);
extern int inode_newsize_ok(const struct inode *, loff_t offset);
-void setattr_copy(struct mnt_idmap *, struct inode *inode,
+void setattr_copy(const struct mnt_idmap *, struct inode *inode,
const struct iattr *attr);
extern int file_update_time(struct file *file);
diff --git a/include/linux/security.h b/include/linux/security.h
index 153e9043058f..4598a13657ee 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -185,7 +185,7 @@ extern int cap_capset(struct cred *new, const struct cred *old,
extern int cap_bprm_creds_from_file(struct linux_binprm *bprm, const struct file *file);
int cap_inode_setxattr(struct dentry *dentry, const char *name,
const void *value, size_t size, int flags);
-int cap_inode_removexattr(struct mnt_idmap *idmap,
+int cap_inode_removexattr(const struct mnt_idmap *idmap,
struct dentry *dentry, const char *name);
int cap_inode_need_killpriv(struct dentry *dentry);
int cap_inode_killpriv(struct mnt_idmap *idmap, struct dentry *dentry);
diff --git a/kernel/capability.c b/kernel/capability.c
index 829f49ae07b9..ae3b03703148 100644
--- a/kernel/capability.c
+++ b/kernel/capability.c
@@ -453,7 +453,7 @@ EXPORT_SYMBOL(file_ns_capable);
* Return true if the inode uid and gid are within the namespace.
*/
bool privileged_wrt_inode_uidgid(struct user_namespace *ns,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
const struct inode *inode)
{
return vfsuid_has_mapping(ns, i_uid_into_vfsuid(idmap, inode)) &&
@@ -470,7 +470,7 @@ bool privileged_wrt_inode_uidgid(struct user_namespace *ns,
* its own user namespace and that the given inode's uid and gid are
* mapped into the current user namespace.
*/
-bool capable_wrt_inode_uidgid(struct mnt_idmap *idmap,
+bool capable_wrt_inode_uidgid(const struct mnt_idmap *idmap,
const struct inode *inode, int cap)
{
struct user_namespace *ns = current_user_ns();
diff --git a/security/commoncap.c b/security/commoncap.c
index 3399535808fe..9361393fd756 100644
--- a/security/commoncap.c
+++ b/security/commoncap.c
@@ -1063,7 +1063,7 @@ int cap_inode_setxattr(struct dentry *dentry, const char *name,
* This is used to make sure security xattrs don't get removed by those who
* aren't privileged to remove them.
*/
-int cap_inode_removexattr(struct mnt_idmap *idmap,
+int cap_inode_removexattr(const struct mnt_idmap *idmap,
struct dentry *dentry, const char *name)
{
struct user_namespace *user_ns = dentry->d_sb->s_user_ns;
--
2.53.0
^ permalink raw reply related [flat|nested] 62+ messages in thread* Re: [PATCH 08/27] fs: port privilege checking helpers to const mnt_idmap
2026-09-01 12:14 ` [PATCH 08/27] fs: port privilege checking helpers " Christian Brauner
@ 2026-09-02 14:17 ` Jan Kara
0 siblings, 0 replies; 62+ messages in thread
From: Jan Kara @ 2026-09-02 14:17 UTC (permalink / raw)
To: Christian Brauner
Cc: linux-fsdevel, Alexander Viro, Jan Kara, Christoph Hellwig,
Seth Forshee, Paul Moore, linux-security-module, Mimi Zohar,
linux-integrity, Ilya Dryomov, ceph-devel, Carlos Maiolino,
linux-xfs, Miklos Szeredi, Amir Goldstein, linux-unionfs,
Namjae Jeon, linux-cifs, linux-kernel
On Tue 01-09-26 14:14:33, Christian Brauner wrote:
> Convert to const struct mnt_idmap.
>
> A mount's idmapping is immutable. The only thing that is allowed to be
> modified afterwards is the reference count and that is hidden behind
> mnt_idmap_get() and mnt_idmap_put(). Everything else only ever reads
> from the idmapping. This is the same model that struct cred uses and the
> idmapping is also rather sensitive.
>
> So make the idmap argument const wherever we can. The conversion is done
> from the bottom up so callers can continue to pass a non-const pointer
> to a const parameter until the conversion is finished.
>
> No functional changes.
>
> Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> fs/attr.c | 10 +++++-----
> fs/f2fs/acl.c | 4 ++--
> fs/f2fs/file.c | 2 +-
> fs/inode.c | 4 ++--
> fs/internal.h | 4 ++--
> include/linux/capability.h | 4 ++--
> include/linux/fs.h | 8 ++++----
> include/linux/security.h | 2 +-
> kernel/capability.c | 4 ++--
> security/commoncap.c | 2 +-
> 10 files changed, 22 insertions(+), 22 deletions(-)
>
> diff --git a/fs/attr.c b/fs/attr.c
> index 71888ac903c2..23f1347ff240 100644
> --- a/fs/attr.c
> +++ b/fs/attr.c
> @@ -30,7 +30,7 @@
> *
> * Return: ATTR_KILL_SGID if setgid bit needs to be removed, 0 otherwise.
> */
> -int setattr_should_drop_sgid(struct mnt_idmap *idmap,
> +int setattr_should_drop_sgid(const struct mnt_idmap *idmap,
> const struct inode *inode)
> {
> umode_t mode = inode->i_mode;
> @@ -60,7 +60,7 @@ EXPORT_SYMBOL(setattr_should_drop_sgid);
> * Return: A mask of ATTR_KILL_S{G,U}ID indicating which - if any - setid bits
> * to remove, 0 otherwise.
> */
> -int setattr_should_drop_suidgid(struct mnt_idmap *idmap,
> +int setattr_should_drop_suidgid(const struct mnt_idmap *idmap,
> struct inode *inode)
> {
> umode_t mode = inode->i_mode;
> @@ -91,7 +91,7 @@ EXPORT_SYMBOL(setattr_should_drop_suidgid);
> * permissions. On non-idmapped mounts or if permission checking is to be
> * performed on the raw inode simply pass @nop_mnt_idmap.
> */
> -static bool chown_ok(struct mnt_idmap *idmap,
> +static bool chown_ok(const struct mnt_idmap *idmap,
> const struct inode *inode, vfsuid_t ia_vfsuid)
> {
> vfsuid_t vfsuid = i_uid_into_vfsuid(idmap, inode);
> @@ -118,7 +118,7 @@ static bool chown_ok(struct mnt_idmap *idmap,
> * permissions. On non-idmapped mounts or if permission checking is to be
> * performed on the raw inode simply pass @nop_mnt_idmap.
> */
> -static bool chgrp_ok(struct mnt_idmap *idmap,
> +static bool chgrp_ok(const struct mnt_idmap *idmap,
> const struct inode *inode, vfsgid_t ia_vfsgid)
> {
> vfsgid_t vfsgid = i_gid_into_vfsgid(idmap, inode);
> @@ -339,7 +339,7 @@ static void setattr_copy_mgtime(struct inode *inode, const struct iattr *attr)
> * that for "simple" filesystems, the struct inode is the inode storage.
> * The caller is free to mark the inode dirty afterwards if needed.
> */
> -void setattr_copy(struct mnt_idmap *idmap, struct inode *inode,
> +void setattr_copy(const struct mnt_idmap *idmap, struct inode *inode,
> const struct iattr *attr)
> {
> unsigned int ia_valid = attr->ia_valid;
> diff --git a/fs/f2fs/acl.c b/fs/f2fs/acl.c
> index d3253549173e..e7e0084d0a5f 100644
> --- a/fs/f2fs/acl.c
> +++ b/fs/f2fs/acl.c
> @@ -219,7 +219,7 @@ struct posix_acl *f2fs_get_acl(struct inode *inode, int type, bool rcu)
> return __f2fs_get_acl(inode, type, NULL);
> }
>
> -static int f2fs_acl_update_mode(struct mnt_idmap *idmap,
> +static int f2fs_acl_update_mode(const struct mnt_idmap *idmap,
> struct inode *inode, umode_t *mode_p,
> struct posix_acl **acl)
> {
> @@ -240,7 +240,7 @@ static int f2fs_acl_update_mode(struct mnt_idmap *idmap,
> return 0;
> }
>
> -static int __f2fs_set_acl(struct mnt_idmap *idmap,
> +static int __f2fs_set_acl(const struct mnt_idmap *idmap,
> struct inode *inode, int type,
> struct posix_acl *acl, struct folio *ifolio)
> {
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index edc352569e87..03bb3a9a449f 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -1096,7 +1096,7 @@ int f2fs_getattr(struct mnt_idmap *idmap, const struct path *path,
> }
>
> #ifdef CONFIG_F2FS_FS_POSIX_ACL
> -static void __setattr_copy(struct mnt_idmap *idmap,
> +static void __setattr_copy(const struct mnt_idmap *idmap,
> struct inode *inode, const struct iattr *attr)
> {
> unsigned int ia_valid = attr->ia_valid;
> diff --git a/fs/inode.c b/fs/inode.c
> index ba7da39be4a3..72a8bbe38d62 100644
> --- a/fs/inode.c
> +++ b/fs/inode.c
> @@ -2337,7 +2337,7 @@ EXPORT_SYMBOL(touch_atime);
> * response to write or truncate. Return 0 if nothing has to be changed.
> * Negative value on error (change should be denied).
> */
> -int dentry_needs_remove_privs(struct mnt_idmap *idmap,
> +int dentry_needs_remove_privs(const struct mnt_idmap *idmap,
> struct dentry *dentry)
> {
> struct inode *inode = d_inode(dentry);
> @@ -3033,7 +3033,7 @@ EXPORT_SYMBOL(inode_set_ctime_deleg);
> *
> * Return: true if the caller is sufficiently privileged, false if not.
> */
> -bool in_group_or_capable(struct mnt_idmap *idmap,
> +bool in_group_or_capable(const struct mnt_idmap *idmap,
> const struct inode *inode, vfsgid_t vfsgid)
> {
> if (vfsgid_in_group_p(vfsgid))
> diff --git a/fs/internal.h b/fs/internal.h
> index 72244e5f4e57..161b0cafe17f 100644
> --- a/fs/internal.h
> +++ b/fs/internal.h
> @@ -210,8 +210,8 @@ extern int vfs_open(const struct path *, struct file *);
> * inode.c
> */
> extern long prune_icache_sb(struct super_block *sb, struct shrink_control *sc);
> -int dentry_needs_remove_privs(struct mnt_idmap *, struct dentry *dentry);
> -bool in_group_or_capable(struct mnt_idmap *idmap,
> +int dentry_needs_remove_privs(const struct mnt_idmap *, struct dentry *dentry);
> +bool in_group_or_capable(const struct mnt_idmap *idmap,
> const struct inode *inode, vfsgid_t vfsgid);
>
> /*
> diff --git a/include/linux/capability.h b/include/linux/capability.h
> index 37db92b3d6f8..c39a2bbefc47 100644
> --- a/include/linux/capability.h
> +++ b/include/linux/capability.h
> @@ -181,9 +181,9 @@ static inline bool ns_capable_setid(struct user_namespace *ns, int cap)
> }
> #endif /* CONFIG_MULTIUSER */
> bool privileged_wrt_inode_uidgid(struct user_namespace *ns,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> const struct inode *inode);
> -bool capable_wrt_inode_uidgid(struct mnt_idmap *idmap,
> +bool capable_wrt_inode_uidgid(const struct mnt_idmap *idmap,
> const struct inode *inode, int cap);
> extern bool file_ns_capable(const struct file *file, struct user_namespace *ns, int cap);
> extern bool ptracer_capable(struct task_struct *tsk, struct user_namespace *ns);
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 154f2c976a0a..7c82d7aaa775 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -1835,7 +1835,7 @@ void inode_init_owner(struct mnt_idmap *idmap, struct inode *inode,
> extern bool may_open_dev(const struct path *path);
> umode_t mode_strip_sgid(struct mnt_idmap *idmap,
> const struct inode *dir, umode_t mode);
> -bool in_group_or_capable(struct mnt_idmap *idmap,
> +bool in_group_or_capable(const struct mnt_idmap *idmap,
> const struct inode *inode, vfsgid_t vfsgid);
>
> /*
> @@ -3045,9 +3045,9 @@ static inline struct inode *new_inode_pseudo(struct super_block *sb)
> }
> extern struct inode *new_inode(struct super_block *sb);
> extern void free_inode_nonrcu(struct inode *inode);
> -extern int setattr_should_drop_suidgid(struct mnt_idmap *, struct inode *);
> +extern int setattr_should_drop_suidgid(const struct mnt_idmap *, struct inode *);
> extern int file_remove_privs(struct file *);
> -int setattr_should_drop_sgid(struct mnt_idmap *idmap,
> +int setattr_should_drop_sgid(const struct mnt_idmap *idmap,
> const struct inode *inode);
>
> /*
> @@ -3401,7 +3401,7 @@ int may_setattr(struct mnt_idmap *idmap, struct inode *inode,
> unsigned int ia_valid);
> int setattr_prepare(struct mnt_idmap *, struct dentry *, struct iattr *);
> extern int inode_newsize_ok(const struct inode *, loff_t offset);
> -void setattr_copy(struct mnt_idmap *, struct inode *inode,
> +void setattr_copy(const struct mnt_idmap *, struct inode *inode,
> const struct iattr *attr);
>
> extern int file_update_time(struct file *file);
> diff --git a/include/linux/security.h b/include/linux/security.h
> index 153e9043058f..4598a13657ee 100644
> --- a/include/linux/security.h
> +++ b/include/linux/security.h
> @@ -185,7 +185,7 @@ extern int cap_capset(struct cred *new, const struct cred *old,
> extern int cap_bprm_creds_from_file(struct linux_binprm *bprm, const struct file *file);
> int cap_inode_setxattr(struct dentry *dentry, const char *name,
> const void *value, size_t size, int flags);
> -int cap_inode_removexattr(struct mnt_idmap *idmap,
> +int cap_inode_removexattr(const struct mnt_idmap *idmap,
> struct dentry *dentry, const char *name);
> int cap_inode_need_killpriv(struct dentry *dentry);
> int cap_inode_killpriv(struct mnt_idmap *idmap, struct dentry *dentry);
> diff --git a/kernel/capability.c b/kernel/capability.c
> index 829f49ae07b9..ae3b03703148 100644
> --- a/kernel/capability.c
> +++ b/kernel/capability.c
> @@ -453,7 +453,7 @@ EXPORT_SYMBOL(file_ns_capable);
> * Return true if the inode uid and gid are within the namespace.
> */
> bool privileged_wrt_inode_uidgid(struct user_namespace *ns,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> const struct inode *inode)
> {
> return vfsuid_has_mapping(ns, i_uid_into_vfsuid(idmap, inode)) &&
> @@ -470,7 +470,7 @@ bool privileged_wrt_inode_uidgid(struct user_namespace *ns,
> * its own user namespace and that the given inode's uid and gid are
> * mapped into the current user namespace.
> */
> -bool capable_wrt_inode_uidgid(struct mnt_idmap *idmap,
> +bool capable_wrt_inode_uidgid(const struct mnt_idmap *idmap,
> const struct inode *inode, int cap)
> {
> struct user_namespace *ns = current_user_ns();
> diff --git a/security/commoncap.c b/security/commoncap.c
> index 3399535808fe..9361393fd756 100644
> --- a/security/commoncap.c
> +++ b/security/commoncap.c
> @@ -1063,7 +1063,7 @@ int cap_inode_setxattr(struct dentry *dentry, const char *name,
> * This is used to make sure security xattrs don't get removed by those who
> * aren't privileged to remove them.
> */
> -int cap_inode_removexattr(struct mnt_idmap *idmap,
> +int cap_inode_removexattr(const struct mnt_idmap *idmap,
> struct dentry *dentry, const char *name)
> {
> struct user_namespace *user_ns = dentry->d_sb->s_user_ns;
>
> --
> 2.53.0
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 62+ messages in thread
* [PATCH 09/27] fs: port inode_owner_or_capable() to const mnt_idmap
2026-09-01 12:14 [PATCH 00/27] fs: port to const struct mnt_idmap Christian Brauner
` (7 preceding siblings ...)
2026-09-01 12:14 ` [PATCH 08/27] fs: port privilege checking helpers " Christian Brauner
@ 2026-09-01 12:14 ` Christian Brauner
2026-09-02 14:18 ` Jan Kara
2026-09-01 12:14 ` [PATCH 10/27] fs: port inode_init_owner() " Christian Brauner
` (17 subsequent siblings)
26 siblings, 1 reply; 62+ messages in thread
From: Christian Brauner @ 2026-09-01 12:14 UTC (permalink / raw)
To: linux-fsdevel
Cc: Alexander Viro, Jan Kara, Christoph Hellwig, Seth Forshee,
Paul Moore, linux-security-module, Mimi Zohar, linux-integrity,
Ilya Dryomov, ceph-devel, Carlos Maiolino, linux-xfs,
Miklos Szeredi, Amir Goldstein, linux-unionfs, Namjae Jeon,
linux-cifs, linux-kernel, Christian Brauner (Amutable)
Convert to const struct mnt_idmap.
A mount's idmapping is immutable. The only thing that is allowed to be
modified afterwards is the reference count and that is hidden behind
mnt_idmap_get() and mnt_idmap_put(). Everything else only ever reads
from the idmapping. This is the same model that struct cred uses and the
idmapping is also rather sensitive.
So make the idmap argument const wherever we can. The conversion is done
from the bottom up so callers can continue to pass a non-const pointer
to a const parameter until the conversion is finished.
No functional changes.
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
---
fs/btrfs/ioctl.c | 2 +-
fs/ext4/ioctl.c | 2 +-
fs/inode.c | 2 +-
include/linux/fs.h | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 72bc9d4f7708..b34c6a8247e4 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -3886,7 +3886,7 @@ static long btrfs_ioctl_quota_rescan_wait(struct btrfs_fs_info *fs_info)
}
static long _btrfs_ioctl_set_received_subvol(struct file *file,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct btrfs_ioctl_received_subvol_args *sa)
{
struct inode *inode = file_inode(file);
diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index c8387e6a2c6e..6de77da4203c 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -373,7 +373,7 @@ void ext4_reset_inode_seed(struct inode *inode)
*
*/
static long swap_inode_boot_loader(struct super_block *sb,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct inode *inode)
{
handle_t *handle;
diff --git a/fs/inode.c b/fs/inode.c
index 72a8bbe38d62..4313e9735c5c 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -2746,7 +2746,7 @@ EXPORT_SYMBOL(inode_init_owner);
* On non-idmapped mounts or if permission checking is to be performed on the
* raw inode simply pass @nop_mnt_idmap.
*/
-bool inode_owner_or_capable(struct mnt_idmap *idmap,
+bool inode_owner_or_capable(const struct mnt_idmap *idmap,
const struct inode *inode)
{
vfsuid_t vfsuid;
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 7c82d7aaa775..e2babddf755d 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1755,7 +1755,7 @@ static inline bool file_write_not_started(const struct file *file)
return sb_write_not_started(file_inode(file)->i_sb);
}
-bool inode_owner_or_capable(struct mnt_idmap *idmap,
+bool inode_owner_or_capable(const struct mnt_idmap *idmap,
const struct inode *inode);
/*
--
2.53.0
^ permalink raw reply related [flat|nested] 62+ messages in thread* Re: [PATCH 09/27] fs: port inode_owner_or_capable() to const mnt_idmap
2026-09-01 12:14 ` [PATCH 09/27] fs: port inode_owner_or_capable() " Christian Brauner
@ 2026-09-02 14:18 ` Jan Kara
0 siblings, 0 replies; 62+ messages in thread
From: Jan Kara @ 2026-09-02 14:18 UTC (permalink / raw)
To: Christian Brauner
Cc: linux-fsdevel, Alexander Viro, Jan Kara, Christoph Hellwig,
Seth Forshee, Paul Moore, linux-security-module, Mimi Zohar,
linux-integrity, Ilya Dryomov, ceph-devel, Carlos Maiolino,
linux-xfs, Miklos Szeredi, Amir Goldstein, linux-unionfs,
Namjae Jeon, linux-cifs, linux-kernel
On Tue 01-09-26 14:14:34, Christian Brauner wrote:
> Convert to const struct mnt_idmap.
>
> A mount's idmapping is immutable. The only thing that is allowed to be
> modified afterwards is the reference count and that is hidden behind
> mnt_idmap_get() and mnt_idmap_put(). Everything else only ever reads
> from the idmapping. This is the same model that struct cred uses and the
> idmapping is also rather sensitive.
>
> So make the idmap argument const wherever we can. The conversion is done
> from the bottom up so callers can continue to pass a non-const pointer
> to a const parameter until the conversion is finished.
>
> No functional changes.
>
> Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> fs/btrfs/ioctl.c | 2 +-
> fs/ext4/ioctl.c | 2 +-
> fs/inode.c | 2 +-
> include/linux/fs.h | 2 +-
> 4 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
> index 72bc9d4f7708..b34c6a8247e4 100644
> --- a/fs/btrfs/ioctl.c
> +++ b/fs/btrfs/ioctl.c
> @@ -3886,7 +3886,7 @@ static long btrfs_ioctl_quota_rescan_wait(struct btrfs_fs_info *fs_info)
> }
>
> static long _btrfs_ioctl_set_received_subvol(struct file *file,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct btrfs_ioctl_received_subvol_args *sa)
> {
> struct inode *inode = file_inode(file);
> diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
> index c8387e6a2c6e..6de77da4203c 100644
> --- a/fs/ext4/ioctl.c
> +++ b/fs/ext4/ioctl.c
> @@ -373,7 +373,7 @@ void ext4_reset_inode_seed(struct inode *inode)
> *
> */
> static long swap_inode_boot_loader(struct super_block *sb,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct inode *inode)
> {
> handle_t *handle;
> diff --git a/fs/inode.c b/fs/inode.c
> index 72a8bbe38d62..4313e9735c5c 100644
> --- a/fs/inode.c
> +++ b/fs/inode.c
> @@ -2746,7 +2746,7 @@ EXPORT_SYMBOL(inode_init_owner);
> * On non-idmapped mounts or if permission checking is to be performed on the
> * raw inode simply pass @nop_mnt_idmap.
> */
> -bool inode_owner_or_capable(struct mnt_idmap *idmap,
> +bool inode_owner_or_capable(const struct mnt_idmap *idmap,
> const struct inode *inode)
> {
> vfsuid_t vfsuid;
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 7c82d7aaa775..e2babddf755d 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -1755,7 +1755,7 @@ static inline bool file_write_not_started(const struct file *file)
> return sb_write_not_started(file_inode(file)->i_sb);
> }
>
> -bool inode_owner_or_capable(struct mnt_idmap *idmap,
> +bool inode_owner_or_capable(const struct mnt_idmap *idmap,
> const struct inode *inode);
>
> /*
>
> --
> 2.53.0
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 62+ messages in thread
* [PATCH 10/27] fs: port inode_init_owner() to const mnt_idmap
2026-09-01 12:14 [PATCH 00/27] fs: port to const struct mnt_idmap Christian Brauner
` (8 preceding siblings ...)
2026-09-01 12:14 ` [PATCH 09/27] fs: port inode_owner_or_capable() " Christian Brauner
@ 2026-09-01 12:14 ` Christian Brauner
2026-09-02 14:20 ` Jan Kara
2026-09-01 12:14 ` [PATCH 11/27] fs: port acl " Christian Brauner
` (16 subsequent siblings)
26 siblings, 1 reply; 62+ messages in thread
From: Christian Brauner @ 2026-09-01 12:14 UTC (permalink / raw)
To: linux-fsdevel
Cc: Alexander Viro, Jan Kara, Christoph Hellwig, Seth Forshee,
Paul Moore, linux-security-module, Mimi Zohar, linux-integrity,
Ilya Dryomov, ceph-devel, Carlos Maiolino, linux-xfs,
Miklos Szeredi, Amir Goldstein, linux-unionfs, Namjae Jeon,
linux-cifs, linux-kernel, Christian Brauner (Amutable)
Convert to const struct mnt_idmap.
A mount's idmapping is immutable. The only thing that is allowed to be
modified afterwards is the reference count and that is hidden behind
mnt_idmap_get() and mnt_idmap_put(). Everything else only ever reads
from the idmapping. This is the same model that struct cred uses and the
idmapping is also rather sensitive.
So make the idmap argument const wherever we can. The conversion is done
from the bottom up so callers can continue to pass a non-const pointer
to a const parameter until the conversion is finished.
No functional changes.
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
---
fs/btrfs/btrfs_inode.h | 2 +-
fs/btrfs/inode.c | 6 +++---
fs/btrfs/ioctl.c | 2 +-
fs/ext4/ext4.h | 2 +-
fs/ext4/ialloc.c | 2 +-
fs/ext4/namei.c | 4 ++--
fs/f2fs/f2fs.h | 2 +-
fs/f2fs/namei.c | 10 +++++-----
fs/hugetlbfs/inode.c | 2 +-
fs/inode.c | 4 ++--
fs/namei.c | 2 +-
fs/overlayfs/dir.c | 2 +-
fs/xfs/libxfs/xfs_inode_util.h | 2 +-
fs/xfs/xfs_inode.c | 4 ++--
fs/xfs/xfs_inode.h | 2 +-
fs/xfs/xfs_iops.c | 2 +-
fs/xfs/xfs_symlink.c | 2 +-
fs/xfs/xfs_symlink.h | 2 +-
include/linux/fs.h | 4 ++--
mm/shmem.c | 8 ++++----
20 files changed, 33 insertions(+), 33 deletions(-)
diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h
index 1082fa92c145..26ce5319c7fc 100644
--- a/fs/btrfs/btrfs_inode.h
+++ b/fs/btrfs/btrfs_inode.h
@@ -559,7 +559,7 @@ int btrfs_new_inode_prepare(struct btrfs_new_inode_args *args,
int btrfs_create_new_inode(struct btrfs_trans_handle *trans,
struct btrfs_new_inode_args *args);
void btrfs_new_inode_args_destroy(struct btrfs_new_inode_args *args);
-struct inode *btrfs_new_subvol_inode(struct mnt_idmap *idmap,
+struct inode *btrfs_new_subvol_inode(const struct mnt_idmap *idmap,
struct inode *dir);
void btrfs_set_delalloc_extent(struct btrfs_inode *inode, struct extent_state *state,
u32 bits);
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 3c10a0ef0002..d5a78d9027e2 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -8022,7 +8022,7 @@ static int btrfs_truncate(struct btrfs_inode *inode, bool skip_writeback)
return ret;
}
-struct inode *btrfs_new_subvol_inode(struct mnt_idmap *idmap,
+struct inode *btrfs_new_subvol_inode(const struct mnt_idmap *idmap,
struct inode *dir)
{
struct inode *inode;
@@ -8540,7 +8540,7 @@ static int btrfs_rename_exchange(struct inode *old_dir,
return ret;
}
-static struct inode *new_whiteout_inode(struct mnt_idmap *idmap,
+static struct inode *new_whiteout_inode(const struct mnt_idmap *idmap,
struct inode *dir)
{
struct inode *inode;
@@ -8555,7 +8555,7 @@ static struct inode *new_whiteout_inode(struct mnt_idmap *idmap,
return inode;
}
-static int btrfs_rename(struct mnt_idmap *idmap,
+static int btrfs_rename(const struct mnt_idmap *idmap,
struct inode *old_dir, struct dentry *old_dentry,
struct inode *new_dir, struct dentry *new_dentry,
unsigned int flags)
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index b34c6a8247e4..8eacdc2ee4de 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -534,7 +534,7 @@ static unsigned int create_subvol_num_items(const struct btrfs_qgroup_inherit *i
return num_items;
}
-static noinline int create_subvol(struct mnt_idmap *idmap,
+static noinline int create_subvol(const struct mnt_idmap *idmap,
struct inode *dir, struct dentry *dentry,
struct btrfs_qgroup_inherit *inherit)
{
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 724a27e8be61..aef86b1d10fa 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -3044,7 +3044,7 @@ extern int ext4fs_dirhash(const struct inode *dir, const char *name, int len,
/* ialloc.c */
extern int ext4_mark_inode_used(struct super_block *sb, int ino);
-extern struct inode *__ext4_new_inode(struct mnt_idmap *, handle_t *,
+extern struct inode *__ext4_new_inode(const struct mnt_idmap *, handle_t *,
struct inode *, umode_t,
const struct qstr *qstr, __u32 goal,
uid_t *owner, __u32 i_flags,
diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
index a5831fc536db..529623103ae7 100644
--- a/fs/ext4/ialloc.c
+++ b/fs/ext4/ialloc.c
@@ -930,7 +930,7 @@ static int ext4_xattr_credits_for_new_inode(struct inode *dir, mode_t mode,
* For other inodes, search forward from the parent directory's block
* group to find a free inode.
*/
-struct inode *__ext4_new_inode(struct mnt_idmap *idmap,
+struct inode *__ext4_new_inode(const struct mnt_idmap *idmap,
handle_t *handle, struct inode *dir,
umode_t mode, const struct qstr *qstr,
__u32 goal, uid_t *owner, __u32 i_flags,
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index a6386c1d237f..edc12599e64d 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -3753,7 +3753,7 @@ static void ext4_update_dir_count(handle_t *handle, struct ext4_renament *ent)
}
}
-static struct inode *ext4_whiteout_for_rename(struct mnt_idmap *idmap,
+static struct inode *ext4_whiteout_for_rename(const struct mnt_idmap *idmap,
struct ext4_renament *ent,
int credits, handle_t **h)
{
@@ -3796,7 +3796,7 @@ static struct inode *ext4_whiteout_for_rename(struct mnt_idmap *idmap,
* while new_{dentry,inode) refers to the destination dentry/inode
* This comes from rename(const char *oldpath, const char *newpath)
*/
-static int ext4_rename(struct mnt_idmap *idmap, struct inode *old_dir,
+static int ext4_rename(const struct mnt_idmap *idmap, struct inode *old_dir,
struct dentry *old_dentry, struct inode *new_dir,
struct dentry *new_dentry, unsigned int flags)
{
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 9940a6cecf1a..eefc886e3ffc 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -3890,7 +3890,7 @@ void f2fs_destroy_evict_inode_work(void);
int f2fs_update_extension_list(struct f2fs_sb_info *sbi, const char *name,
bool hot, bool set);
struct dentry *f2fs_get_parent(struct dentry *child);
-int f2fs_get_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
+int f2fs_get_tmpfile(const struct mnt_idmap *idmap, struct inode *dir,
struct inode **new_inode);
/*
diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
index ff86ee07290d..e33780294713 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -231,7 +231,7 @@ static void set_file_temperature(struct f2fs_sb_info *sbi, struct inode *inode,
file_set_hot(inode);
}
-static struct inode *f2fs_new_inode(struct mnt_idmap *idmap,
+static struct inode *f2fs_new_inode(const struct mnt_idmap *idmap,
struct inode *dir, umode_t mode,
const char *name)
{
@@ -857,7 +857,7 @@ static int f2fs_mknod(struct mnt_idmap *idmap, struct inode *dir,
return err;
}
-static int __f2fs_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
+static int __f2fs_tmpfile(const struct mnt_idmap *idmap, struct inode *dir,
struct file *file, umode_t mode, bool is_whiteout,
struct inode **new_inode, struct f2fs_filename *fname)
{
@@ -944,7 +944,7 @@ static int f2fs_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
return finish_open_simple(file, err);
}
-static int f2fs_create_whiteout(struct mnt_idmap *idmap,
+static int f2fs_create_whiteout(const struct mnt_idmap *idmap,
struct inode *dir, struct inode **whiteout,
struct f2fs_filename *fname)
{
@@ -952,14 +952,14 @@ static int f2fs_create_whiteout(struct mnt_idmap *idmap,
true, whiteout, fname);
}
-int f2fs_get_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
+int f2fs_get_tmpfile(const struct mnt_idmap *idmap, struct inode *dir,
struct inode **new_inode)
{
return __f2fs_tmpfile(idmap, dir, NULL, S_IFREG,
false, new_inode, NULL);
}
-static int f2fs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
+static int f2fs_rename(const struct mnt_idmap *idmap, struct inode *old_dir,
struct dentry *old_dentry, struct inode *new_dir,
struct dentry *new_dentry, unsigned int flags)
{
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 7611a8470ea2..4bd3adc20a47 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -892,7 +892,7 @@ static struct inode *hugetlbfs_get_root(struct super_block *sb,
static struct lock_class_key hugetlbfs_i_mmap_rwsem_key;
static struct inode *hugetlbfs_get_inode(struct super_block *sb,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct inode *dir,
umode_t mode, dev_t dev)
{
diff --git a/fs/inode.c b/fs/inode.c
index 4313e9735c5c..99f1aab89eae 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -2716,7 +2716,7 @@ EXPORT_SYMBOL(init_special_inode);
* and initializing i_uid and i_gid. On non-idmapped mounts or if permission
* checking is to be performed on the raw inode simply pass @nop_mnt_idmap.
*/
-void inode_init_owner(struct mnt_idmap *idmap, struct inode *inode,
+void inode_init_owner(const struct mnt_idmap *idmap, struct inode *inode,
const struct inode *dir, umode_t mode)
{
inode_fsuid_set(inode, idmap);
@@ -3058,7 +3058,7 @@ EXPORT_SYMBOL(in_group_or_capable);
*
* Return: the new mode to use for the file
*/
-umode_t mode_strip_sgid(struct mnt_idmap *idmap,
+umode_t mode_strip_sgid(const struct mnt_idmap *idmap,
const struct inode *dir, umode_t mode)
{
if ((mode & (S_ISGID | S_IXGRP)) != (S_ISGID | S_IXGRP))
diff --git a/fs/namei.c b/fs/namei.c
index 603d43e4a961..db82daec3646 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -4142,7 +4142,7 @@ EXPORT_SYMBOL(end_renaming);
*
* Returns: mode to be passed to the filesystem
*/
-static inline umode_t vfs_prepare_mode(struct mnt_idmap *idmap,
+static inline umode_t vfs_prepare_mode(const struct mnt_idmap *idmap,
const struct inode *dir, umode_t mode,
umode_t mask_perms, umode_t type)
{
diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
index 7beb0af26498..a022dc7781bf 100644
--- a/fs/overlayfs/dir.c
+++ b/fs/overlayfs/dir.c
@@ -688,7 +688,7 @@ static int ovl_create_or_link(struct dentry *dentry, struct inode *inode,
return err;
}
-static int ovl_create_object(struct mnt_idmap *idmap, struct dentry *dentry,
+static int ovl_create_object(const struct mnt_idmap *idmap, struct dentry *dentry,
int mode, dev_t rdev, const char *link)
{
int err;
diff --git a/fs/xfs/libxfs/xfs_inode_util.h b/fs/xfs/libxfs/xfs_inode_util.h
index 060242998a23..e9eac35159c3 100644
--- a/fs/xfs/libxfs/xfs_inode_util.h
+++ b/fs/xfs/libxfs/xfs_inode_util.h
@@ -27,7 +27,7 @@ prid_t xfs_get_initial_prid(struct xfs_inode *dp);
* idmap to NULL. To create a tree root, set pip to NULL.
*/
struct xfs_icreate_args {
- struct mnt_idmap *idmap;
+ const struct mnt_idmap *idmap;
struct xfs_inode *pip; /* parent inode or null */
dev_t rdev;
umode_t mode;
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 030a7c8f2c12..6fcd1c5928f8 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -2084,7 +2084,7 @@ xfs_sort_inodes(
*/
static int
xfs_rename_alloc_whiteout(
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct xfs_name *src_name,
struct xfs_inode *dp,
struct xfs_inode **wip)
@@ -2130,7 +2130,7 @@ xfs_rename_alloc_whiteout(
*/
int
xfs_rename(
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct xfs_inode *src_dp,
struct xfs_name *src_name,
struct xfs_inode *src_ip,
diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
index 34c1038ebfcd..12bc4573c52d 100644
--- a/fs/xfs/xfs_inode.h
+++ b/fs/xfs/xfs_inode.h
@@ -568,7 +568,7 @@ int xfs_remove(struct xfs_inode *dp, struct xfs_name *name,
struct xfs_inode *ip);
int xfs_link(struct xfs_inode *tdp, struct xfs_inode *sip,
struct xfs_name *target_name);
-int xfs_rename(struct mnt_idmap *idmap,
+int xfs_rename(const struct mnt_idmap *idmap,
struct xfs_inode *src_dp, struct xfs_name *src_name,
struct xfs_inode *src_ip, struct xfs_inode *target_dp,
struct xfs_name *target_name,
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index 4a3299abf774..df5e7c1b2334 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -169,7 +169,7 @@ xfs_create_need_xattr(
STATIC int
xfs_generic_create(
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct inode *dir,
struct dentry *dentry,
umode_t mode,
diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c
index 5585ac7f4d16..40a9bb1703b5 100644
--- a/fs/xfs/xfs_symlink.c
+++ b/fs/xfs/xfs_symlink.c
@@ -82,7 +82,7 @@ xfs_readlink(
int
xfs_symlink(
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct xfs_inode *dp,
struct xfs_name *link_name,
const char *target_path,
diff --git a/fs/xfs/xfs_symlink.h b/fs/xfs/xfs_symlink.h
index 0d29a50e66fd..3c5a969f9fc5 100644
--- a/fs/xfs/xfs_symlink.h
+++ b/fs/xfs/xfs_symlink.h
@@ -7,7 +7,7 @@
/* Kernel only symlink definitions */
-int xfs_symlink(struct mnt_idmap *idmap, struct xfs_inode *dp,
+int xfs_symlink(const struct mnt_idmap *idmap, struct xfs_inode *dp,
struct xfs_name *link_name, const char *target_path,
umode_t mode, struct xfs_inode **ipp);
int xfs_readlink(struct xfs_inode *ip, char *link);
diff --git a/include/linux/fs.h b/include/linux/fs.h
index e2babddf755d..91a23c8dbbf6 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1830,10 +1830,10 @@ extern long compat_ptr_ioctl(struct file *file, unsigned int cmd,
/*
* VFS file helper functions.
*/
-void inode_init_owner(struct mnt_idmap *idmap, struct inode *inode,
+void inode_init_owner(const struct mnt_idmap *idmap, struct inode *inode,
const struct inode *dir, umode_t mode);
extern bool may_open_dev(const struct path *path);
-umode_t mode_strip_sgid(struct mnt_idmap *idmap,
+umode_t mode_strip_sgid(const struct mnt_idmap *idmap,
const struct inode *dir, umode_t mode);
bool in_group_or_capable(const struct mnt_idmap *idmap,
const struct inode *inode, vfsgid_t vfsgid);
diff --git a/mm/shmem.c b/mm/shmem.c
index 897fa2b61346..9ab5231c4dfe 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -3022,7 +3022,7 @@ static struct offset_ctx *shmem_get_offset_ctx(struct inode *inode)
return &SHMEM_I(inode)->dir_offsets;
}
-static struct inode *__shmem_get_inode(struct mnt_idmap *idmap,
+static struct inode *__shmem_get_inode(const struct mnt_idmap *idmap,
struct super_block *sb,
struct inode *dir, umode_t mode,
dev_t dev, vma_flags_t flags)
@@ -3102,7 +3102,7 @@ static struct inode *__shmem_get_inode(struct mnt_idmap *idmap,
}
#ifdef CONFIG_TMPFS_QUOTA
-static struct inode *shmem_get_inode(struct mnt_idmap *idmap,
+static struct inode *shmem_get_inode(const struct mnt_idmap *idmap,
struct super_block *sb, struct inode *dir,
umode_t mode, dev_t dev, vma_flags_t flags)
{
@@ -3130,7 +3130,7 @@ static struct inode *shmem_get_inode(struct mnt_idmap *idmap,
return ERR_PTR(err);
}
#else
-static struct inode *shmem_get_inode(struct mnt_idmap *idmap,
+static struct inode *shmem_get_inode(const struct mnt_idmap *idmap,
struct super_block *sb, struct inode *dir,
umode_t mode, dev_t dev, vma_flags_t flags)
{
@@ -5792,7 +5792,7 @@ static inline void shmem_unacct_size(unsigned long flags, loff_t size)
{
}
-static inline struct inode *shmem_get_inode(struct mnt_idmap *idmap,
+static inline struct inode *shmem_get_inode(const struct mnt_idmap *idmap,
struct super_block *sb, struct inode *dir,
umode_t mode, dev_t dev, vma_flags_t flags)
{
--
2.53.0
^ permalink raw reply related [flat|nested] 62+ messages in thread* Re: [PATCH 10/27] fs: port inode_init_owner() to const mnt_idmap
2026-09-01 12:14 ` [PATCH 10/27] fs: port inode_init_owner() " Christian Brauner
@ 2026-09-02 14:20 ` Jan Kara
0 siblings, 0 replies; 62+ messages in thread
From: Jan Kara @ 2026-09-02 14:20 UTC (permalink / raw)
To: Christian Brauner
Cc: linux-fsdevel, Alexander Viro, Jan Kara, Christoph Hellwig,
Seth Forshee, Paul Moore, linux-security-module, Mimi Zohar,
linux-integrity, Ilya Dryomov, ceph-devel, Carlos Maiolino,
linux-xfs, Miklos Szeredi, Amir Goldstein, linux-unionfs,
Namjae Jeon, linux-cifs, linux-kernel
On Tue 01-09-26 14:14:35, Christian Brauner wrote:
> Convert to const struct mnt_idmap.
>
> A mount's idmapping is immutable. The only thing that is allowed to be
> modified afterwards is the reference count and that is hidden behind
> mnt_idmap_get() and mnt_idmap_put(). Everything else only ever reads
> from the idmapping. This is the same model that struct cred uses and the
> idmapping is also rather sensitive.
>
> So make the idmap argument const wherever we can. The conversion is done
> from the bottom up so callers can continue to pass a non-const pointer
> to a const parameter until the conversion is finished.
>
> No functional changes.
>
> Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> fs/btrfs/btrfs_inode.h | 2 +-
> fs/btrfs/inode.c | 6 +++---
> fs/btrfs/ioctl.c | 2 +-
> fs/ext4/ext4.h | 2 +-
> fs/ext4/ialloc.c | 2 +-
> fs/ext4/namei.c | 4 ++--
> fs/f2fs/f2fs.h | 2 +-
> fs/f2fs/namei.c | 10 +++++-----
> fs/hugetlbfs/inode.c | 2 +-
> fs/inode.c | 4 ++--
> fs/namei.c | 2 +-
> fs/overlayfs/dir.c | 2 +-
> fs/xfs/libxfs/xfs_inode_util.h | 2 +-
> fs/xfs/xfs_inode.c | 4 ++--
> fs/xfs/xfs_inode.h | 2 +-
> fs/xfs/xfs_iops.c | 2 +-
> fs/xfs/xfs_symlink.c | 2 +-
> fs/xfs/xfs_symlink.h | 2 +-
> include/linux/fs.h | 4 ++--
> mm/shmem.c | 8 ++++----
> 20 files changed, 33 insertions(+), 33 deletions(-)
>
> diff --git a/fs/btrfs/btrfs_inode.h b/fs/btrfs/btrfs_inode.h
> index 1082fa92c145..26ce5319c7fc 100644
> --- a/fs/btrfs/btrfs_inode.h
> +++ b/fs/btrfs/btrfs_inode.h
> @@ -559,7 +559,7 @@ int btrfs_new_inode_prepare(struct btrfs_new_inode_args *args,
> int btrfs_create_new_inode(struct btrfs_trans_handle *trans,
> struct btrfs_new_inode_args *args);
> void btrfs_new_inode_args_destroy(struct btrfs_new_inode_args *args);
> -struct inode *btrfs_new_subvol_inode(struct mnt_idmap *idmap,
> +struct inode *btrfs_new_subvol_inode(const struct mnt_idmap *idmap,
> struct inode *dir);
> void btrfs_set_delalloc_extent(struct btrfs_inode *inode, struct extent_state *state,
> u32 bits);
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index 3c10a0ef0002..d5a78d9027e2 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -8022,7 +8022,7 @@ static int btrfs_truncate(struct btrfs_inode *inode, bool skip_writeback)
> return ret;
> }
>
> -struct inode *btrfs_new_subvol_inode(struct mnt_idmap *idmap,
> +struct inode *btrfs_new_subvol_inode(const struct mnt_idmap *idmap,
> struct inode *dir)
> {
> struct inode *inode;
> @@ -8540,7 +8540,7 @@ static int btrfs_rename_exchange(struct inode *old_dir,
> return ret;
> }
>
> -static struct inode *new_whiteout_inode(struct mnt_idmap *idmap,
> +static struct inode *new_whiteout_inode(const struct mnt_idmap *idmap,
> struct inode *dir)
> {
> struct inode *inode;
> @@ -8555,7 +8555,7 @@ static struct inode *new_whiteout_inode(struct mnt_idmap *idmap,
> return inode;
> }
>
> -static int btrfs_rename(struct mnt_idmap *idmap,
> +static int btrfs_rename(const struct mnt_idmap *idmap,
> struct inode *old_dir, struct dentry *old_dentry,
> struct inode *new_dir, struct dentry *new_dentry,
> unsigned int flags)
> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
> index b34c6a8247e4..8eacdc2ee4de 100644
> --- a/fs/btrfs/ioctl.c
> +++ b/fs/btrfs/ioctl.c
> @@ -534,7 +534,7 @@ static unsigned int create_subvol_num_items(const struct btrfs_qgroup_inherit *i
> return num_items;
> }
>
> -static noinline int create_subvol(struct mnt_idmap *idmap,
> +static noinline int create_subvol(const struct mnt_idmap *idmap,
> struct inode *dir, struct dentry *dentry,
> struct btrfs_qgroup_inherit *inherit)
> {
> diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
> index 724a27e8be61..aef86b1d10fa 100644
> --- a/fs/ext4/ext4.h
> +++ b/fs/ext4/ext4.h
> @@ -3044,7 +3044,7 @@ extern int ext4fs_dirhash(const struct inode *dir, const char *name, int len,
>
> /* ialloc.c */
> extern int ext4_mark_inode_used(struct super_block *sb, int ino);
> -extern struct inode *__ext4_new_inode(struct mnt_idmap *, handle_t *,
> +extern struct inode *__ext4_new_inode(const struct mnt_idmap *, handle_t *,
> struct inode *, umode_t,
> const struct qstr *qstr, __u32 goal,
> uid_t *owner, __u32 i_flags,
> diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
> index a5831fc536db..529623103ae7 100644
> --- a/fs/ext4/ialloc.c
> +++ b/fs/ext4/ialloc.c
> @@ -930,7 +930,7 @@ static int ext4_xattr_credits_for_new_inode(struct inode *dir, mode_t mode,
> * For other inodes, search forward from the parent directory's block
> * group to find a free inode.
> */
> -struct inode *__ext4_new_inode(struct mnt_idmap *idmap,
> +struct inode *__ext4_new_inode(const struct mnt_idmap *idmap,
> handle_t *handle, struct inode *dir,
> umode_t mode, const struct qstr *qstr,
> __u32 goal, uid_t *owner, __u32 i_flags,
> diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
> index a6386c1d237f..edc12599e64d 100644
> --- a/fs/ext4/namei.c
> +++ b/fs/ext4/namei.c
> @@ -3753,7 +3753,7 @@ static void ext4_update_dir_count(handle_t *handle, struct ext4_renament *ent)
> }
> }
>
> -static struct inode *ext4_whiteout_for_rename(struct mnt_idmap *idmap,
> +static struct inode *ext4_whiteout_for_rename(const struct mnt_idmap *idmap,
> struct ext4_renament *ent,
> int credits, handle_t **h)
> {
> @@ -3796,7 +3796,7 @@ static struct inode *ext4_whiteout_for_rename(struct mnt_idmap *idmap,
> * while new_{dentry,inode) refers to the destination dentry/inode
> * This comes from rename(const char *oldpath, const char *newpath)
> */
> -static int ext4_rename(struct mnt_idmap *idmap, struct inode *old_dir,
> +static int ext4_rename(const struct mnt_idmap *idmap, struct inode *old_dir,
> struct dentry *old_dentry, struct inode *new_dir,
> struct dentry *new_dentry, unsigned int flags)
> {
> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> index 9940a6cecf1a..eefc886e3ffc 100644
> --- a/fs/f2fs/f2fs.h
> +++ b/fs/f2fs/f2fs.h
> @@ -3890,7 +3890,7 @@ void f2fs_destroy_evict_inode_work(void);
> int f2fs_update_extension_list(struct f2fs_sb_info *sbi, const char *name,
> bool hot, bool set);
> struct dentry *f2fs_get_parent(struct dentry *child);
> -int f2fs_get_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
> +int f2fs_get_tmpfile(const struct mnt_idmap *idmap, struct inode *dir,
> struct inode **new_inode);
>
> /*
> diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
> index ff86ee07290d..e33780294713 100644
> --- a/fs/f2fs/namei.c
> +++ b/fs/f2fs/namei.c
> @@ -231,7 +231,7 @@ static void set_file_temperature(struct f2fs_sb_info *sbi, struct inode *inode,
> file_set_hot(inode);
> }
>
> -static struct inode *f2fs_new_inode(struct mnt_idmap *idmap,
> +static struct inode *f2fs_new_inode(const struct mnt_idmap *idmap,
> struct inode *dir, umode_t mode,
> const char *name)
> {
> @@ -857,7 +857,7 @@ static int f2fs_mknod(struct mnt_idmap *idmap, struct inode *dir,
> return err;
> }
>
> -static int __f2fs_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
> +static int __f2fs_tmpfile(const struct mnt_idmap *idmap, struct inode *dir,
> struct file *file, umode_t mode, bool is_whiteout,
> struct inode **new_inode, struct f2fs_filename *fname)
> {
> @@ -944,7 +944,7 @@ static int f2fs_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
> return finish_open_simple(file, err);
> }
>
> -static int f2fs_create_whiteout(struct mnt_idmap *idmap,
> +static int f2fs_create_whiteout(const struct mnt_idmap *idmap,
> struct inode *dir, struct inode **whiteout,
> struct f2fs_filename *fname)
> {
> @@ -952,14 +952,14 @@ static int f2fs_create_whiteout(struct mnt_idmap *idmap,
> true, whiteout, fname);
> }
>
> -int f2fs_get_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
> +int f2fs_get_tmpfile(const struct mnt_idmap *idmap, struct inode *dir,
> struct inode **new_inode)
> {
> return __f2fs_tmpfile(idmap, dir, NULL, S_IFREG,
> false, new_inode, NULL);
> }
>
> -static int f2fs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
> +static int f2fs_rename(const struct mnt_idmap *idmap, struct inode *old_dir,
> struct dentry *old_dentry, struct inode *new_dir,
> struct dentry *new_dentry, unsigned int flags)
> {
> diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
> index 7611a8470ea2..4bd3adc20a47 100644
> --- a/fs/hugetlbfs/inode.c
> +++ b/fs/hugetlbfs/inode.c
> @@ -892,7 +892,7 @@ static struct inode *hugetlbfs_get_root(struct super_block *sb,
> static struct lock_class_key hugetlbfs_i_mmap_rwsem_key;
>
> static struct inode *hugetlbfs_get_inode(struct super_block *sb,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct inode *dir,
> umode_t mode, dev_t dev)
> {
> diff --git a/fs/inode.c b/fs/inode.c
> index 4313e9735c5c..99f1aab89eae 100644
> --- a/fs/inode.c
> +++ b/fs/inode.c
> @@ -2716,7 +2716,7 @@ EXPORT_SYMBOL(init_special_inode);
> * and initializing i_uid and i_gid. On non-idmapped mounts or if permission
> * checking is to be performed on the raw inode simply pass @nop_mnt_idmap.
> */
> -void inode_init_owner(struct mnt_idmap *idmap, struct inode *inode,
> +void inode_init_owner(const struct mnt_idmap *idmap, struct inode *inode,
> const struct inode *dir, umode_t mode)
> {
> inode_fsuid_set(inode, idmap);
> @@ -3058,7 +3058,7 @@ EXPORT_SYMBOL(in_group_or_capable);
> *
> * Return: the new mode to use for the file
> */
> -umode_t mode_strip_sgid(struct mnt_idmap *idmap,
> +umode_t mode_strip_sgid(const struct mnt_idmap *idmap,
> const struct inode *dir, umode_t mode)
> {
> if ((mode & (S_ISGID | S_IXGRP)) != (S_ISGID | S_IXGRP))
> diff --git a/fs/namei.c b/fs/namei.c
> index 603d43e4a961..db82daec3646 100644
> --- a/fs/namei.c
> +++ b/fs/namei.c
> @@ -4142,7 +4142,7 @@ EXPORT_SYMBOL(end_renaming);
> *
> * Returns: mode to be passed to the filesystem
> */
> -static inline umode_t vfs_prepare_mode(struct mnt_idmap *idmap,
> +static inline umode_t vfs_prepare_mode(const struct mnt_idmap *idmap,
> const struct inode *dir, umode_t mode,
> umode_t mask_perms, umode_t type)
> {
> diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
> index 7beb0af26498..a022dc7781bf 100644
> --- a/fs/overlayfs/dir.c
> +++ b/fs/overlayfs/dir.c
> @@ -688,7 +688,7 @@ static int ovl_create_or_link(struct dentry *dentry, struct inode *inode,
> return err;
> }
>
> -static int ovl_create_object(struct mnt_idmap *idmap, struct dentry *dentry,
> +static int ovl_create_object(const struct mnt_idmap *idmap, struct dentry *dentry,
> int mode, dev_t rdev, const char *link)
> {
> int err;
> diff --git a/fs/xfs/libxfs/xfs_inode_util.h b/fs/xfs/libxfs/xfs_inode_util.h
> index 060242998a23..e9eac35159c3 100644
> --- a/fs/xfs/libxfs/xfs_inode_util.h
> +++ b/fs/xfs/libxfs/xfs_inode_util.h
> @@ -27,7 +27,7 @@ prid_t xfs_get_initial_prid(struct xfs_inode *dp);
> * idmap to NULL. To create a tree root, set pip to NULL.
> */
> struct xfs_icreate_args {
> - struct mnt_idmap *idmap;
> + const struct mnt_idmap *idmap;
> struct xfs_inode *pip; /* parent inode or null */
> dev_t rdev;
> umode_t mode;
> diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
> index 030a7c8f2c12..6fcd1c5928f8 100644
> --- a/fs/xfs/xfs_inode.c
> +++ b/fs/xfs/xfs_inode.c
> @@ -2084,7 +2084,7 @@ xfs_sort_inodes(
> */
> static int
> xfs_rename_alloc_whiteout(
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct xfs_name *src_name,
> struct xfs_inode *dp,
> struct xfs_inode **wip)
> @@ -2130,7 +2130,7 @@ xfs_rename_alloc_whiteout(
> */
> int
> xfs_rename(
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct xfs_inode *src_dp,
> struct xfs_name *src_name,
> struct xfs_inode *src_ip,
> diff --git a/fs/xfs/xfs_inode.h b/fs/xfs/xfs_inode.h
> index 34c1038ebfcd..12bc4573c52d 100644
> --- a/fs/xfs/xfs_inode.h
> +++ b/fs/xfs/xfs_inode.h
> @@ -568,7 +568,7 @@ int xfs_remove(struct xfs_inode *dp, struct xfs_name *name,
> struct xfs_inode *ip);
> int xfs_link(struct xfs_inode *tdp, struct xfs_inode *sip,
> struct xfs_name *target_name);
> -int xfs_rename(struct mnt_idmap *idmap,
> +int xfs_rename(const struct mnt_idmap *idmap,
> struct xfs_inode *src_dp, struct xfs_name *src_name,
> struct xfs_inode *src_ip, struct xfs_inode *target_dp,
> struct xfs_name *target_name,
> diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
> index 4a3299abf774..df5e7c1b2334 100644
> --- a/fs/xfs/xfs_iops.c
> +++ b/fs/xfs/xfs_iops.c
> @@ -169,7 +169,7 @@ xfs_create_need_xattr(
>
> STATIC int
> xfs_generic_create(
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct inode *dir,
> struct dentry *dentry,
> umode_t mode,
> diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c
> index 5585ac7f4d16..40a9bb1703b5 100644
> --- a/fs/xfs/xfs_symlink.c
> +++ b/fs/xfs/xfs_symlink.c
> @@ -82,7 +82,7 @@ xfs_readlink(
>
> int
> xfs_symlink(
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct xfs_inode *dp,
> struct xfs_name *link_name,
> const char *target_path,
> diff --git a/fs/xfs/xfs_symlink.h b/fs/xfs/xfs_symlink.h
> index 0d29a50e66fd..3c5a969f9fc5 100644
> --- a/fs/xfs/xfs_symlink.h
> +++ b/fs/xfs/xfs_symlink.h
> @@ -7,7 +7,7 @@
>
> /* Kernel only symlink definitions */
>
> -int xfs_symlink(struct mnt_idmap *idmap, struct xfs_inode *dp,
> +int xfs_symlink(const struct mnt_idmap *idmap, struct xfs_inode *dp,
> struct xfs_name *link_name, const char *target_path,
> umode_t mode, struct xfs_inode **ipp);
> int xfs_readlink(struct xfs_inode *ip, char *link);
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index e2babddf755d..91a23c8dbbf6 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -1830,10 +1830,10 @@ extern long compat_ptr_ioctl(struct file *file, unsigned int cmd,
> /*
> * VFS file helper functions.
> */
> -void inode_init_owner(struct mnt_idmap *idmap, struct inode *inode,
> +void inode_init_owner(const struct mnt_idmap *idmap, struct inode *inode,
> const struct inode *dir, umode_t mode);
> extern bool may_open_dev(const struct path *path);
> -umode_t mode_strip_sgid(struct mnt_idmap *idmap,
> +umode_t mode_strip_sgid(const struct mnt_idmap *idmap,
> const struct inode *dir, umode_t mode);
> bool in_group_or_capable(const struct mnt_idmap *idmap,
> const struct inode *inode, vfsgid_t vfsgid);
> diff --git a/mm/shmem.c b/mm/shmem.c
> index 897fa2b61346..9ab5231c4dfe 100644
> --- a/mm/shmem.c
> +++ b/mm/shmem.c
> @@ -3022,7 +3022,7 @@ static struct offset_ctx *shmem_get_offset_ctx(struct inode *inode)
> return &SHMEM_I(inode)->dir_offsets;
> }
>
> -static struct inode *__shmem_get_inode(struct mnt_idmap *idmap,
> +static struct inode *__shmem_get_inode(const struct mnt_idmap *idmap,
> struct super_block *sb,
> struct inode *dir, umode_t mode,
> dev_t dev, vma_flags_t flags)
> @@ -3102,7 +3102,7 @@ static struct inode *__shmem_get_inode(struct mnt_idmap *idmap,
> }
>
> #ifdef CONFIG_TMPFS_QUOTA
> -static struct inode *shmem_get_inode(struct mnt_idmap *idmap,
> +static struct inode *shmem_get_inode(const struct mnt_idmap *idmap,
> struct super_block *sb, struct inode *dir,
> umode_t mode, dev_t dev, vma_flags_t flags)
> {
> @@ -3130,7 +3130,7 @@ static struct inode *shmem_get_inode(struct mnt_idmap *idmap,
> return ERR_PTR(err);
> }
> #else
> -static struct inode *shmem_get_inode(struct mnt_idmap *idmap,
> +static struct inode *shmem_get_inode(const struct mnt_idmap *idmap,
> struct super_block *sb, struct inode *dir,
> umode_t mode, dev_t dev, vma_flags_t flags)
> {
> @@ -5792,7 +5792,7 @@ static inline void shmem_unacct_size(unsigned long flags, loff_t size)
> {
> }
>
> -static inline struct inode *shmem_get_inode(struct mnt_idmap *idmap,
> +static inline struct inode *shmem_get_inode(const struct mnt_idmap *idmap,
> struct super_block *sb, struct inode *dir,
> umode_t mode, dev_t dev, vma_flags_t flags)
> {
>
> --
> 2.53.0
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 62+ messages in thread
* [PATCH 11/27] fs: port acl to const mnt_idmap
2026-09-01 12:14 [PATCH 00/27] fs: port to const struct mnt_idmap Christian Brauner
` (9 preceding siblings ...)
2026-09-01 12:14 ` [PATCH 10/27] fs: port inode_init_owner() " Christian Brauner
@ 2026-09-01 12:14 ` 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
` (15 subsequent siblings)
26 siblings, 2 replies; 62+ messages in thread
From: Christian Brauner @ 2026-09-01 12:14 UTC (permalink / raw)
To: linux-fsdevel
Cc: Alexander Viro, Jan Kara, Christoph Hellwig, Seth Forshee,
Paul Moore, linux-security-module, Mimi Zohar, linux-integrity,
Ilya Dryomov, ceph-devel, Carlos Maiolino, linux-xfs,
Miklos Szeredi, Amir Goldstein, linux-unionfs, Namjae Jeon,
linux-cifs, linux-kernel, Christian Brauner (Amutable)
Convert to const struct mnt_idmap.
A mount's idmapping is immutable. The only thing that is allowed to be
modified afterwards is the reference count and that is hidden behind
mnt_idmap_get() and mnt_idmap_put(). Everything else only ever reads
from the idmapping. This is the same model that struct cred uses and the
idmapping is also rather sensitive.
So make the idmap argument const wherever we can. The conversion is done
from the bottom up so callers can continue to pass a non-const pointer
to a const parameter until the conversion is finished.
No functional changes.
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
---
fs/ntfs/ea.c | 4 ++--
fs/ntfs/ea.h | 2 +-
fs/ntfs/namei.c | 2 +-
fs/ntfs3/inode.c | 2 +-
fs/ntfs3/ntfs_fs.h | 4 ++--
fs/ntfs3/xattr.c | 4 ++--
fs/posix_acl.c | 6 +++---
include/linux/lsm_hook_defs.h | 8 ++++----
include/linux/posix_acl.h | 4 ++--
include/linux/security.h | 16 ++++++++--------
security/integrity/evm/evm_main.c | 10 +++++-----
security/integrity/ima/ima_appraise.c | 4 ++--
security/security.c | 8 ++++----
security/selinux/hooks.c | 6 +++---
security/smack/smack_lsm.c | 6 +++---
15 files changed, 43 insertions(+), 43 deletions(-)
diff --git a/fs/ntfs/ea.c b/fs/ntfs/ea.c
index cdd306933d73..744ea8c446e5 100644
--- a/fs/ntfs/ea.c
+++ b/fs/ntfs/ea.c
@@ -998,7 +998,7 @@ struct posix_acl *ntfs_get_acl(struct mnt_idmap *idmap, struct dentry *dentry,
return acl;
}
-static noinline int ntfs_set_acl_ex(struct mnt_idmap *idmap,
+static noinline int ntfs_set_acl_ex(const struct mnt_idmap *idmap,
struct inode *inode, struct posix_acl *acl,
int type, bool init_acl)
{
@@ -1086,7 +1086,7 @@ int ntfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
return ntfs_set_acl_ex(idmap, d_inode(dentry), acl, type, false);
}
-int ntfs_init_acl(struct mnt_idmap *idmap, struct inode *inode,
+int ntfs_init_acl(const struct mnt_idmap *idmap, struct inode *inode,
struct inode *dir)
{
struct posix_acl *default_acl, *acl;
diff --git a/fs/ntfs/ea.h b/fs/ntfs/ea.h
index acb39c2a6fbc..9d17abc2e491 100644
--- a/fs/ntfs/ea.h
+++ b/fs/ntfs/ea.h
@@ -21,7 +21,7 @@ struct posix_acl *ntfs_get_acl(struct mnt_idmap *idmap, struct dentry *dentry,
int type);
int ntfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
struct posix_acl *acl, int type);
-int ntfs_init_acl(struct mnt_idmap *idmap, struct inode *inode,
+int ntfs_init_acl(const struct mnt_idmap *idmap, struct inode *inode,
struct inode *dir);
#else
#define ntfs_get_acl NULL
diff --git a/fs/ntfs/namei.c b/fs/ntfs/namei.c
index 7091b2496fac..e2cf1ab6935a 100644
--- a/fs/ntfs/namei.c
+++ b/fs/ntfs/namei.c
@@ -391,7 +391,7 @@ static int ntfs_sd_add_everyone(struct ntfs_inode *ni)
return ret;
}
-static struct ntfs_inode *__ntfs_create(struct mnt_idmap *idmap, struct inode *dir,
+static struct ntfs_inode *__ntfs_create(const struct mnt_idmap *idmap, struct inode *dir,
__le16 *name, u8 name_len, mode_t mode, dev_t dev,
const char *target, int target_len)
{
diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c
index 56b4f6469a28..a9fdd33f2886 100644
--- a/fs/ntfs3/inode.c
+++ b/fs/ntfs3/inode.c
@@ -1381,7 +1381,7 @@ ntfs_create_reparse_buffer(struct ntfs_sb_info *sbi, const char *symname,
*
* NOTE: if fnd != NULL (ntfs_atomic_open) then @dir is locked
*/
-int ntfs_create_inode(struct mnt_idmap *idmap, struct inode *dir,
+int ntfs_create_inode(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, const struct cpu_str *uni,
umode_t mode, dev_t dev, const char *symname, u32 size,
struct ntfs_fnd *fnd)
diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h
index 5811d89d67b3..a2b74f41048f 100644
--- a/fs/ntfs3/ntfs_fs.h
+++ b/fs/ntfs3/ntfs_fs.h
@@ -803,7 +803,7 @@ int ntfs_set_size(struct inode *inode, u64 new_size);
int ntfs3_write_inode(struct inode *inode, struct writeback_control *wbc);
int ntfs_sync_inode(struct inode *inode);
int inode_read_data(struct inode *inode, void *data, size_t bytes);
-int ntfs_create_inode(struct mnt_idmap *idmap, struct inode *dir,
+int ntfs_create_inode(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, const struct cpu_str *uni,
umode_t mode, dev_t dev, const char *symname, u32 size,
struct ntfs_fnd *fnd);
@@ -967,7 +967,7 @@ struct posix_acl *ntfs_get_acl(struct mnt_idmap *idmap, struct dentry *dentry,
int type);
int ntfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
struct posix_acl *acl, int type);
-int ntfs_init_acl(struct mnt_idmap *idmap, struct inode *inode,
+int ntfs_init_acl(const struct mnt_idmap *idmap, struct inode *inode,
struct inode *dir);
#else
#define ntfs_get_acl NULL
diff --git a/fs/ntfs3/xattr.c b/fs/ntfs3/xattr.c
index 594ef6860b93..d800735477c3 100644
--- a/fs/ntfs3/xattr.c
+++ b/fs/ntfs3/xattr.c
@@ -595,7 +595,7 @@ struct posix_acl *ntfs_get_acl(struct mnt_idmap *idmap, struct dentry *dentry,
return acl;
}
-static noinline int ntfs_set_acl_ex(struct mnt_idmap *idmap,
+static noinline int ntfs_set_acl_ex(const struct mnt_idmap *idmap,
struct inode *inode, struct posix_acl *acl,
int type, bool init_acl)
{
@@ -688,7 +688,7 @@ int ntfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
*
* Called from ntfs_create_inode().
*/
-int ntfs_init_acl(struct mnt_idmap *idmap, struct inode *inode,
+int ntfs_init_acl(const struct mnt_idmap *idmap, struct inode *inode,
struct inode *dir)
{
struct posix_acl *default_acl, *acl;
diff --git a/fs/posix_acl.c b/fs/posix_acl.c
index f9c55a59c6c6..b279804ebf56 100644
--- a/fs/posix_acl.c
+++ b/fs/posix_acl.c
@@ -378,7 +378,7 @@ EXPORT_SYMBOL(posix_acl_from_mode);
* by the acl. Returns -E... otherwise.
*/
int
-posix_acl_permission(struct mnt_idmap *idmap, struct inode *inode,
+posix_acl_permission(const struct mnt_idmap *idmap, struct inode *inode,
const struct posix_acl *acl, int want)
{
const struct posix_acl_entry *pa, *pe, *mask_obj;
@@ -709,7 +709,7 @@ EXPORT_SYMBOL_GPL(posix_acl_create);
*
* Called from set_acl inode operations.
*/
-int posix_acl_update_mode(struct mnt_idmap *idmap,
+int posix_acl_update_mode(const struct mnt_idmap *idmap,
struct inode *inode, umode_t *mode_p,
struct posix_acl **acl)
{
@@ -889,7 +889,7 @@ EXPORT_SYMBOL (posix_acl_to_xattr);
* Return: On success, the size of the stored uapi posix acls, on error a
* negative errno.
*/
-static ssize_t vfs_posix_acl_to_xattr(struct mnt_idmap *idmap,
+static ssize_t vfs_posix_acl_to_xattr(const struct mnt_idmap *idmap,
struct inode *inode,
const struct posix_acl *acl, void *buffer,
size_t size)
diff --git a/include/linux/lsm_hook_defs.h b/include/linux/lsm_hook_defs.h
index 65c9609ec207..30897590258f 100644
--- a/include/linux/lsm_hook_defs.h
+++ b/include/linux/lsm_hook_defs.h
@@ -159,15 +159,15 @@ LSM_HOOK(void, LSM_RET_VOID, inode_post_removexattr, struct dentry *dentry,
const char *name)
LSM_HOOK(int, 0, inode_file_setattr, struct dentry *dentry, struct file_kattr *fa)
LSM_HOOK(int, 0, inode_file_getattr, struct dentry *dentry, struct file_kattr *fa)
-LSM_HOOK(int, 0, inode_set_acl, struct mnt_idmap *idmap,
+LSM_HOOK(int, 0, inode_set_acl, const struct mnt_idmap *idmap,
struct dentry *dentry, const char *acl_name, struct posix_acl *kacl)
LSM_HOOK(void, LSM_RET_VOID, inode_post_set_acl, struct dentry *dentry,
const char *acl_name, struct posix_acl *kacl)
-LSM_HOOK(int, 0, inode_get_acl, struct mnt_idmap *idmap,
+LSM_HOOK(int, 0, inode_get_acl, const struct mnt_idmap *idmap,
struct dentry *dentry, const char *acl_name)
-LSM_HOOK(int, 0, inode_remove_acl, struct mnt_idmap *idmap,
+LSM_HOOK(int, 0, inode_remove_acl, const struct mnt_idmap *idmap,
struct dentry *dentry, const char *acl_name)
-LSM_HOOK(void, LSM_RET_VOID, inode_post_remove_acl, struct mnt_idmap *idmap,
+LSM_HOOK(void, LSM_RET_VOID, inode_post_remove_acl, const struct mnt_idmap *idmap,
struct dentry *dentry, const char *acl_name)
LSM_HOOK(int, 0, inode_need_killpriv, struct dentry *dentry)
LSM_HOOK(int, 0, inode_killpriv, struct mnt_idmap *idmap,
diff --git a/include/linux/posix_acl.h b/include/linux/posix_acl.h
index 62d497763e25..7c6cfcae0a9d 100644
--- a/include/linux/posix_acl.h
+++ b/include/linux/posix_acl.h
@@ -84,7 +84,7 @@ struct posix_acl *posix_acl_clone(const struct posix_acl *acl, gfp_t flags);
int posix_acl_chmod(struct mnt_idmap *, struct dentry *, umode_t);
extern int posix_acl_create(struct inode *, umode_t *, struct posix_acl **,
struct posix_acl **);
-int posix_acl_update_mode(struct mnt_idmap *, struct inode *, umode_t *,
+int posix_acl_update_mode(const struct mnt_idmap *, struct inode *, umode_t *,
struct posix_acl **);
int simple_set_acl(struct mnt_idmap *, struct dentry *,
@@ -96,7 +96,7 @@ void set_cached_acl(struct inode *inode, int type, struct posix_acl *acl);
void forget_cached_acl(struct inode *inode, int type);
void forget_all_cached_acls(struct inode *inode);
int posix_acl_valid(struct user_namespace *, const struct posix_acl *);
-int posix_acl_permission(struct mnt_idmap *, struct inode *,
+int posix_acl_permission(const struct mnt_idmap *, struct inode *,
const struct posix_acl *, int);
static inline void cache_no_acl(struct inode *inode)
diff --git a/include/linux/security.h b/include/linux/security.h
index 4598a13657ee..12bc12e243bf 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -430,16 +430,16 @@ int security_inode_getattr(const struct path *path);
int security_inode_setxattr(struct mnt_idmap *idmap,
struct dentry *dentry, const char *name,
const void *value, size_t size, int flags);
-int security_inode_set_acl(struct mnt_idmap *idmap,
+int security_inode_set_acl(const struct mnt_idmap *idmap,
struct dentry *dentry, const char *acl_name,
struct posix_acl *kacl);
void security_inode_post_set_acl(struct dentry *dentry, const char *acl_name,
struct posix_acl *kacl);
-int security_inode_get_acl(struct mnt_idmap *idmap,
+int security_inode_get_acl(const struct mnt_idmap *idmap,
struct dentry *dentry, const char *acl_name);
-int security_inode_remove_acl(struct mnt_idmap *idmap,
+int security_inode_remove_acl(const struct mnt_idmap *idmap,
struct dentry *dentry, const char *acl_name);
-void security_inode_post_remove_acl(struct mnt_idmap *idmap,
+void security_inode_post_remove_acl(const struct mnt_idmap *idmap,
struct dentry *dentry,
const char *acl_name);
void security_inode_post_setxattr(struct dentry *dentry, const char *name,
@@ -1003,7 +1003,7 @@ static inline int security_inode_setxattr(struct mnt_idmap *idmap,
return cap_inode_setxattr(dentry, name, value, size, flags);
}
-static inline int security_inode_set_acl(struct mnt_idmap *idmap,
+static inline int security_inode_set_acl(const struct mnt_idmap *idmap,
struct dentry *dentry,
const char *acl_name,
struct posix_acl *kacl)
@@ -1016,21 +1016,21 @@ static inline void security_inode_post_set_acl(struct dentry *dentry,
struct posix_acl *kacl)
{ }
-static inline int security_inode_get_acl(struct mnt_idmap *idmap,
+static inline int security_inode_get_acl(const struct mnt_idmap *idmap,
struct dentry *dentry,
const char *acl_name)
{
return 0;
}
-static inline int security_inode_remove_acl(struct mnt_idmap *idmap,
+static inline int security_inode_remove_acl(const struct mnt_idmap *idmap,
struct dentry *dentry,
const char *acl_name)
{
return 0;
}
-static inline void security_inode_post_remove_acl(struct mnt_idmap *idmap,
+static inline void security_inode_post_remove_acl(const struct mnt_idmap *idmap,
struct dentry *dentry,
const char *acl_name)
{ }
diff --git a/security/integrity/evm/evm_main.c b/security/integrity/evm/evm_main.c
index 06e187c9912d..aaf228ebed7c 100644
--- a/security/integrity/evm/evm_main.c
+++ b/security/integrity/evm/evm_main.c
@@ -652,7 +652,7 @@ static int evm_inode_removexattr(struct mnt_idmap *idmap, struct dentry *dentry,
}
#ifdef CONFIG_FS_POSIX_ACL
-static int evm_inode_set_acl_change(struct mnt_idmap *idmap,
+static int evm_inode_set_acl_change(const struct mnt_idmap *idmap,
struct dentry *dentry, const char *name,
struct posix_acl *kacl)
{
@@ -671,7 +671,7 @@ static int evm_inode_set_acl_change(struct mnt_idmap *idmap,
return 0;
}
#else
-static inline int evm_inode_set_acl_change(struct mnt_idmap *idmap,
+static inline int evm_inode_set_acl_change(const struct mnt_idmap *idmap,
struct dentry *dentry,
const char *name,
struct posix_acl *kacl)
@@ -693,7 +693,7 @@ static inline int evm_inode_set_acl_change(struct mnt_idmap *idmap,
*
* Return: zero on success, -EPERM on failure.
*/
-static int evm_inode_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
+static int evm_inode_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
const char *acl_name, struct posix_acl *kacl)
{
enum integrity_status evm_status;
@@ -745,7 +745,7 @@ static int evm_inode_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
*
* Return: zero on success, -EPERM on failure.
*/
-static int evm_inode_remove_acl(struct mnt_idmap *idmap, struct dentry *dentry,
+static int evm_inode_remove_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
const char *acl_name)
{
return evm_inode_set_acl(idmap, dentry, acl_name, NULL);
@@ -926,7 +926,7 @@ static void evm_inode_post_removexattr(struct dentry *dentry,
* Update the 'security.evm' xattr with the EVM HMAC re-calculated after
* removing posix acls.
*/
-static inline void evm_inode_post_remove_acl(struct mnt_idmap *idmap,
+static inline void evm_inode_post_remove_acl(const struct mnt_idmap *idmap,
struct dentry *dentry,
const char *acl_name)
{
diff --git a/security/integrity/ima/ima_appraise.c b/security/integrity/ima/ima_appraise.c
index 6b21db789ef1..1aed041c127a 100644
--- a/security/integrity/ima/ima_appraise.c
+++ b/security/integrity/ima/ima_appraise.c
@@ -790,7 +790,7 @@ static int ima_inode_setxattr(struct mnt_idmap *idmap, struct dentry *dentry,
return result;
}
-static int ima_inode_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
+static int ima_inode_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
const char *acl_name, struct posix_acl *kacl)
{
if (evm_revalidate_status(acl_name))
@@ -815,7 +815,7 @@ static int ima_inode_removexattr(struct mnt_idmap *idmap, struct dentry *dentry,
return result;
}
-static int ima_inode_remove_acl(struct mnt_idmap *idmap, struct dentry *dentry,
+static int ima_inode_remove_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
const char *acl_name)
{
return ima_inode_set_acl(idmap, dentry, acl_name, NULL);
diff --git a/security/security.c b/security/security.c
index 2ee276ab15c5..e81dcda3050b 100644
--- a/security/security.c
+++ b/security/security.c
@@ -1953,7 +1953,7 @@ int security_inode_setxattr(struct mnt_idmap *idmap,
*
* Return: Returns 0 if permission is granted.
*/
-int security_inode_set_acl(struct mnt_idmap *idmap,
+int security_inode_set_acl(const struct mnt_idmap *idmap,
struct dentry *dentry, const char *acl_name,
struct posix_acl *kacl)
{
@@ -1990,7 +1990,7 @@ void security_inode_post_set_acl(struct dentry *dentry, const char *acl_name,
*
* Return: Returns 0 if permission is granted.
*/
-int security_inode_get_acl(struct mnt_idmap *idmap,
+int security_inode_get_acl(const struct mnt_idmap *idmap,
struct dentry *dentry, const char *acl_name)
{
if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
@@ -2009,7 +2009,7 @@ int security_inode_get_acl(struct mnt_idmap *idmap,
*
* Return: Returns 0 if permission is granted.
*/
-int security_inode_remove_acl(struct mnt_idmap *idmap,
+int security_inode_remove_acl(const struct mnt_idmap *idmap,
struct dentry *dentry, const char *acl_name)
{
if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
@@ -2026,7 +2026,7 @@ int security_inode_remove_acl(struct mnt_idmap *idmap,
* Update inode security data after successfully removing posix acls on
* @dentry in @idmap. The posix acls are identified by @acl_name.
*/
-void security_inode_post_remove_acl(struct mnt_idmap *idmap,
+void security_inode_post_remove_acl(const struct mnt_idmap *idmap,
struct dentry *dentry, const char *acl_name)
{
if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 035aaf113d1d..672d6374d8b0 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -3453,20 +3453,20 @@ static int selinux_inode_setxattr(struct mnt_idmap *idmap,
&ad);
}
-static int selinux_inode_set_acl(struct mnt_idmap *idmap,
+static int selinux_inode_set_acl(const struct mnt_idmap *idmap,
struct dentry *dentry, const char *acl_name,
struct posix_acl *kacl)
{
return dentry_has_perm(current_cred(), dentry, FILE__SETATTR);
}
-static int selinux_inode_get_acl(struct mnt_idmap *idmap,
+static int selinux_inode_get_acl(const struct mnt_idmap *idmap,
struct dentry *dentry, const char *acl_name)
{
return dentry_has_perm(current_cred(), dentry, FILE__GETATTR);
}
-static int selinux_inode_remove_acl(struct mnt_idmap *idmap,
+static int selinux_inode_remove_acl(const struct mnt_idmap *idmap,
struct dentry *dentry, const char *acl_name)
{
return dentry_has_perm(current_cred(), dentry, FILE__SETATTR);
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
index 8e88ac65fd7f..244cdb49e928 100644
--- a/security/smack/smack_lsm.c
+++ b/security/smack/smack_lsm.c
@@ -1543,7 +1543,7 @@ static int smack_inode_removexattr(struct mnt_idmap *idmap,
*
* Returns 0 if access is permitted, an error code otherwise
*/
-static int smack_inode_set_acl(struct mnt_idmap *idmap,
+static int smack_inode_set_acl(const struct mnt_idmap *idmap,
struct dentry *dentry, const char *acl_name,
struct posix_acl *kacl)
{
@@ -1566,7 +1566,7 @@ static int smack_inode_set_acl(struct mnt_idmap *idmap,
*
* Returns 0 if access is permitted, an error code otherwise
*/
-static int smack_inode_get_acl(struct mnt_idmap *idmap,
+static int smack_inode_get_acl(const struct mnt_idmap *idmap,
struct dentry *dentry, const char *acl_name)
{
struct smk_audit_info ad;
@@ -1588,7 +1588,7 @@ static int smack_inode_get_acl(struct mnt_idmap *idmap,
*
* Returns 0 if access is permitted, an error code otherwise
*/
-static int smack_inode_remove_acl(struct mnt_idmap *idmap,
+static int smack_inode_remove_acl(const struct mnt_idmap *idmap,
struct dentry *dentry, const char *acl_name)
{
struct smk_audit_info ad;
--
2.53.0
^ permalink raw reply related [flat|nested] 62+ messages in thread* Re: [PATCH 11/27] fs: port acl to const mnt_idmap
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
1 sibling, 0 replies; 62+ messages in thread
From: Jan Kara @ 2026-09-02 14:22 UTC (permalink / raw)
To: Christian Brauner
Cc: linux-fsdevel, Alexander Viro, Jan Kara, Christoph Hellwig,
Seth Forshee, Paul Moore, linux-security-module, Mimi Zohar,
linux-integrity, Ilya Dryomov, ceph-devel, Carlos Maiolino,
linux-xfs, Miklos Szeredi, Amir Goldstein, linux-unionfs,
Namjae Jeon, linux-cifs, linux-kernel
On Tue 01-09-26 14:14:36, Christian Brauner wrote:
> Convert to const struct mnt_idmap.
>
> A mount's idmapping is immutable. The only thing that is allowed to be
> modified afterwards is the reference count and that is hidden behind
> mnt_idmap_get() and mnt_idmap_put(). Everything else only ever reads
> from the idmapping. This is the same model that struct cred uses and the
> idmapping is also rather sensitive.
>
> So make the idmap argument const wherever we can. The conversion is done
> from the bottom up so callers can continue to pass a non-const pointer
> to a const parameter until the conversion is finished.
>
> No functional changes.
>
> Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> fs/ntfs/ea.c | 4 ++--
> fs/ntfs/ea.h | 2 +-
> fs/ntfs/namei.c | 2 +-
> fs/ntfs3/inode.c | 2 +-
> fs/ntfs3/ntfs_fs.h | 4 ++--
> fs/ntfs3/xattr.c | 4 ++--
> fs/posix_acl.c | 6 +++---
> include/linux/lsm_hook_defs.h | 8 ++++----
> include/linux/posix_acl.h | 4 ++--
> include/linux/security.h | 16 ++++++++--------
> security/integrity/evm/evm_main.c | 10 +++++-----
> security/integrity/ima/ima_appraise.c | 4 ++--
> security/security.c | 8 ++++----
> security/selinux/hooks.c | 6 +++---
> security/smack/smack_lsm.c | 6 +++---
> 15 files changed, 43 insertions(+), 43 deletions(-)
>
> diff --git a/fs/ntfs/ea.c b/fs/ntfs/ea.c
> index cdd306933d73..744ea8c446e5 100644
> --- a/fs/ntfs/ea.c
> +++ b/fs/ntfs/ea.c
> @@ -998,7 +998,7 @@ struct posix_acl *ntfs_get_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> return acl;
> }
>
> -static noinline int ntfs_set_acl_ex(struct mnt_idmap *idmap,
> +static noinline int ntfs_set_acl_ex(const struct mnt_idmap *idmap,
> struct inode *inode, struct posix_acl *acl,
> int type, bool init_acl)
> {
> @@ -1086,7 +1086,7 @@ int ntfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> return ntfs_set_acl_ex(idmap, d_inode(dentry), acl, type, false);
> }
>
> -int ntfs_init_acl(struct mnt_idmap *idmap, struct inode *inode,
> +int ntfs_init_acl(const struct mnt_idmap *idmap, struct inode *inode,
> struct inode *dir)
> {
> struct posix_acl *default_acl, *acl;
> diff --git a/fs/ntfs/ea.h b/fs/ntfs/ea.h
> index acb39c2a6fbc..9d17abc2e491 100644
> --- a/fs/ntfs/ea.h
> +++ b/fs/ntfs/ea.h
> @@ -21,7 +21,7 @@ struct posix_acl *ntfs_get_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> int type);
> int ntfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> struct posix_acl *acl, int type);
> -int ntfs_init_acl(struct mnt_idmap *idmap, struct inode *inode,
> +int ntfs_init_acl(const struct mnt_idmap *idmap, struct inode *inode,
> struct inode *dir);
> #else
> #define ntfs_get_acl NULL
> diff --git a/fs/ntfs/namei.c b/fs/ntfs/namei.c
> index 7091b2496fac..e2cf1ab6935a 100644
> --- a/fs/ntfs/namei.c
> +++ b/fs/ntfs/namei.c
> @@ -391,7 +391,7 @@ static int ntfs_sd_add_everyone(struct ntfs_inode *ni)
> return ret;
> }
>
> -static struct ntfs_inode *__ntfs_create(struct mnt_idmap *idmap, struct inode *dir,
> +static struct ntfs_inode *__ntfs_create(const struct mnt_idmap *idmap, struct inode *dir,
> __le16 *name, u8 name_len, mode_t mode, dev_t dev,
> const char *target, int target_len)
> {
> diff --git a/fs/ntfs3/inode.c b/fs/ntfs3/inode.c
> index 56b4f6469a28..a9fdd33f2886 100644
> --- a/fs/ntfs3/inode.c
> +++ b/fs/ntfs3/inode.c
> @@ -1381,7 +1381,7 @@ ntfs_create_reparse_buffer(struct ntfs_sb_info *sbi, const char *symname,
> *
> * NOTE: if fnd != NULL (ntfs_atomic_open) then @dir is locked
> */
> -int ntfs_create_inode(struct mnt_idmap *idmap, struct inode *dir,
> +int ntfs_create_inode(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, const struct cpu_str *uni,
> umode_t mode, dev_t dev, const char *symname, u32 size,
> struct ntfs_fnd *fnd)
> diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h
> index 5811d89d67b3..a2b74f41048f 100644
> --- a/fs/ntfs3/ntfs_fs.h
> +++ b/fs/ntfs3/ntfs_fs.h
> @@ -803,7 +803,7 @@ int ntfs_set_size(struct inode *inode, u64 new_size);
> int ntfs3_write_inode(struct inode *inode, struct writeback_control *wbc);
> int ntfs_sync_inode(struct inode *inode);
> int inode_read_data(struct inode *inode, void *data, size_t bytes);
> -int ntfs_create_inode(struct mnt_idmap *idmap, struct inode *dir,
> +int ntfs_create_inode(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, const struct cpu_str *uni,
> umode_t mode, dev_t dev, const char *symname, u32 size,
> struct ntfs_fnd *fnd);
> @@ -967,7 +967,7 @@ struct posix_acl *ntfs_get_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> int type);
> int ntfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> struct posix_acl *acl, int type);
> -int ntfs_init_acl(struct mnt_idmap *idmap, struct inode *inode,
> +int ntfs_init_acl(const struct mnt_idmap *idmap, struct inode *inode,
> struct inode *dir);
> #else
> #define ntfs_get_acl NULL
> diff --git a/fs/ntfs3/xattr.c b/fs/ntfs3/xattr.c
> index 594ef6860b93..d800735477c3 100644
> --- a/fs/ntfs3/xattr.c
> +++ b/fs/ntfs3/xattr.c
> @@ -595,7 +595,7 @@ struct posix_acl *ntfs_get_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> return acl;
> }
>
> -static noinline int ntfs_set_acl_ex(struct mnt_idmap *idmap,
> +static noinline int ntfs_set_acl_ex(const struct mnt_idmap *idmap,
> struct inode *inode, struct posix_acl *acl,
> int type, bool init_acl)
> {
> @@ -688,7 +688,7 @@ int ntfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> *
> * Called from ntfs_create_inode().
> */
> -int ntfs_init_acl(struct mnt_idmap *idmap, struct inode *inode,
> +int ntfs_init_acl(const struct mnt_idmap *idmap, struct inode *inode,
> struct inode *dir)
> {
> struct posix_acl *default_acl, *acl;
> diff --git a/fs/posix_acl.c b/fs/posix_acl.c
> index f9c55a59c6c6..b279804ebf56 100644
> --- a/fs/posix_acl.c
> +++ b/fs/posix_acl.c
> @@ -378,7 +378,7 @@ EXPORT_SYMBOL(posix_acl_from_mode);
> * by the acl. Returns -E... otherwise.
> */
> int
> -posix_acl_permission(struct mnt_idmap *idmap, struct inode *inode,
> +posix_acl_permission(const struct mnt_idmap *idmap, struct inode *inode,
> const struct posix_acl *acl, int want)
> {
> const struct posix_acl_entry *pa, *pe, *mask_obj;
> @@ -709,7 +709,7 @@ EXPORT_SYMBOL_GPL(posix_acl_create);
> *
> * Called from set_acl inode operations.
> */
> -int posix_acl_update_mode(struct mnt_idmap *idmap,
> +int posix_acl_update_mode(const struct mnt_idmap *idmap,
> struct inode *inode, umode_t *mode_p,
> struct posix_acl **acl)
> {
> @@ -889,7 +889,7 @@ EXPORT_SYMBOL (posix_acl_to_xattr);
> * Return: On success, the size of the stored uapi posix acls, on error a
> * negative errno.
> */
> -static ssize_t vfs_posix_acl_to_xattr(struct mnt_idmap *idmap,
> +static ssize_t vfs_posix_acl_to_xattr(const struct mnt_idmap *idmap,
> struct inode *inode,
> const struct posix_acl *acl, void *buffer,
> size_t size)
> diff --git a/include/linux/lsm_hook_defs.h b/include/linux/lsm_hook_defs.h
> index 65c9609ec207..30897590258f 100644
> --- a/include/linux/lsm_hook_defs.h
> +++ b/include/linux/lsm_hook_defs.h
> @@ -159,15 +159,15 @@ LSM_HOOK(void, LSM_RET_VOID, inode_post_removexattr, struct dentry *dentry,
> const char *name)
> LSM_HOOK(int, 0, inode_file_setattr, struct dentry *dentry, struct file_kattr *fa)
> LSM_HOOK(int, 0, inode_file_getattr, struct dentry *dentry, struct file_kattr *fa)
> -LSM_HOOK(int, 0, inode_set_acl, struct mnt_idmap *idmap,
> +LSM_HOOK(int, 0, inode_set_acl, const struct mnt_idmap *idmap,
> struct dentry *dentry, const char *acl_name, struct posix_acl *kacl)
> LSM_HOOK(void, LSM_RET_VOID, inode_post_set_acl, struct dentry *dentry,
> const char *acl_name, struct posix_acl *kacl)
> -LSM_HOOK(int, 0, inode_get_acl, struct mnt_idmap *idmap,
> +LSM_HOOK(int, 0, inode_get_acl, const struct mnt_idmap *idmap,
> struct dentry *dentry, const char *acl_name)
> -LSM_HOOK(int, 0, inode_remove_acl, struct mnt_idmap *idmap,
> +LSM_HOOK(int, 0, inode_remove_acl, const struct mnt_idmap *idmap,
> struct dentry *dentry, const char *acl_name)
> -LSM_HOOK(void, LSM_RET_VOID, inode_post_remove_acl, struct mnt_idmap *idmap,
> +LSM_HOOK(void, LSM_RET_VOID, inode_post_remove_acl, const struct mnt_idmap *idmap,
> struct dentry *dentry, const char *acl_name)
> LSM_HOOK(int, 0, inode_need_killpriv, struct dentry *dentry)
> LSM_HOOK(int, 0, inode_killpriv, struct mnt_idmap *idmap,
> diff --git a/include/linux/posix_acl.h b/include/linux/posix_acl.h
> index 62d497763e25..7c6cfcae0a9d 100644
> --- a/include/linux/posix_acl.h
> +++ b/include/linux/posix_acl.h
> @@ -84,7 +84,7 @@ struct posix_acl *posix_acl_clone(const struct posix_acl *acl, gfp_t flags);
> int posix_acl_chmod(struct mnt_idmap *, struct dentry *, umode_t);
> extern int posix_acl_create(struct inode *, umode_t *, struct posix_acl **,
> struct posix_acl **);
> -int posix_acl_update_mode(struct mnt_idmap *, struct inode *, umode_t *,
> +int posix_acl_update_mode(const struct mnt_idmap *, struct inode *, umode_t *,
> struct posix_acl **);
>
> int simple_set_acl(struct mnt_idmap *, struct dentry *,
> @@ -96,7 +96,7 @@ void set_cached_acl(struct inode *inode, int type, struct posix_acl *acl);
> void forget_cached_acl(struct inode *inode, int type);
> void forget_all_cached_acls(struct inode *inode);
> int posix_acl_valid(struct user_namespace *, const struct posix_acl *);
> -int posix_acl_permission(struct mnt_idmap *, struct inode *,
> +int posix_acl_permission(const struct mnt_idmap *, struct inode *,
> const struct posix_acl *, int);
>
> static inline void cache_no_acl(struct inode *inode)
> diff --git a/include/linux/security.h b/include/linux/security.h
> index 4598a13657ee..12bc12e243bf 100644
> --- a/include/linux/security.h
> +++ b/include/linux/security.h
> @@ -430,16 +430,16 @@ int security_inode_getattr(const struct path *path);
> int security_inode_setxattr(struct mnt_idmap *idmap,
> struct dentry *dentry, const char *name,
> const void *value, size_t size, int flags);
> -int security_inode_set_acl(struct mnt_idmap *idmap,
> +int security_inode_set_acl(const struct mnt_idmap *idmap,
> struct dentry *dentry, const char *acl_name,
> struct posix_acl *kacl);
> void security_inode_post_set_acl(struct dentry *dentry, const char *acl_name,
> struct posix_acl *kacl);
> -int security_inode_get_acl(struct mnt_idmap *idmap,
> +int security_inode_get_acl(const struct mnt_idmap *idmap,
> struct dentry *dentry, const char *acl_name);
> -int security_inode_remove_acl(struct mnt_idmap *idmap,
> +int security_inode_remove_acl(const struct mnt_idmap *idmap,
> struct dentry *dentry, const char *acl_name);
> -void security_inode_post_remove_acl(struct mnt_idmap *idmap,
> +void security_inode_post_remove_acl(const struct mnt_idmap *idmap,
> struct dentry *dentry,
> const char *acl_name);
> void security_inode_post_setxattr(struct dentry *dentry, const char *name,
> @@ -1003,7 +1003,7 @@ static inline int security_inode_setxattr(struct mnt_idmap *idmap,
> return cap_inode_setxattr(dentry, name, value, size, flags);
> }
>
> -static inline int security_inode_set_acl(struct mnt_idmap *idmap,
> +static inline int security_inode_set_acl(const struct mnt_idmap *idmap,
> struct dentry *dentry,
> const char *acl_name,
> struct posix_acl *kacl)
> @@ -1016,21 +1016,21 @@ static inline void security_inode_post_set_acl(struct dentry *dentry,
> struct posix_acl *kacl)
> { }
>
> -static inline int security_inode_get_acl(struct mnt_idmap *idmap,
> +static inline int security_inode_get_acl(const struct mnt_idmap *idmap,
> struct dentry *dentry,
> const char *acl_name)
> {
> return 0;
> }
>
> -static inline int security_inode_remove_acl(struct mnt_idmap *idmap,
> +static inline int security_inode_remove_acl(const struct mnt_idmap *idmap,
> struct dentry *dentry,
> const char *acl_name)
> {
> return 0;
> }
>
> -static inline void security_inode_post_remove_acl(struct mnt_idmap *idmap,
> +static inline void security_inode_post_remove_acl(const struct mnt_idmap *idmap,
> struct dentry *dentry,
> const char *acl_name)
> { }
> diff --git a/security/integrity/evm/evm_main.c b/security/integrity/evm/evm_main.c
> index 06e187c9912d..aaf228ebed7c 100644
> --- a/security/integrity/evm/evm_main.c
> +++ b/security/integrity/evm/evm_main.c
> @@ -652,7 +652,7 @@ static int evm_inode_removexattr(struct mnt_idmap *idmap, struct dentry *dentry,
> }
>
> #ifdef CONFIG_FS_POSIX_ACL
> -static int evm_inode_set_acl_change(struct mnt_idmap *idmap,
> +static int evm_inode_set_acl_change(const struct mnt_idmap *idmap,
> struct dentry *dentry, const char *name,
> struct posix_acl *kacl)
> {
> @@ -671,7 +671,7 @@ static int evm_inode_set_acl_change(struct mnt_idmap *idmap,
> return 0;
> }
> #else
> -static inline int evm_inode_set_acl_change(struct mnt_idmap *idmap,
> +static inline int evm_inode_set_acl_change(const struct mnt_idmap *idmap,
> struct dentry *dentry,
> const char *name,
> struct posix_acl *kacl)
> @@ -693,7 +693,7 @@ static inline int evm_inode_set_acl_change(struct mnt_idmap *idmap,
> *
> * Return: zero on success, -EPERM on failure.
> */
> -static int evm_inode_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> +static int evm_inode_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> const char *acl_name, struct posix_acl *kacl)
> {
> enum integrity_status evm_status;
> @@ -745,7 +745,7 @@ static int evm_inode_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> *
> * Return: zero on success, -EPERM on failure.
> */
> -static int evm_inode_remove_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> +static int evm_inode_remove_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> const char *acl_name)
> {
> return evm_inode_set_acl(idmap, dentry, acl_name, NULL);
> @@ -926,7 +926,7 @@ static void evm_inode_post_removexattr(struct dentry *dentry,
> * Update the 'security.evm' xattr with the EVM HMAC re-calculated after
> * removing posix acls.
> */
> -static inline void evm_inode_post_remove_acl(struct mnt_idmap *idmap,
> +static inline void evm_inode_post_remove_acl(const struct mnt_idmap *idmap,
> struct dentry *dentry,
> const char *acl_name)
> {
> diff --git a/security/integrity/ima/ima_appraise.c b/security/integrity/ima/ima_appraise.c
> index 6b21db789ef1..1aed041c127a 100644
> --- a/security/integrity/ima/ima_appraise.c
> +++ b/security/integrity/ima/ima_appraise.c
> @@ -790,7 +790,7 @@ static int ima_inode_setxattr(struct mnt_idmap *idmap, struct dentry *dentry,
> return result;
> }
>
> -static int ima_inode_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> +static int ima_inode_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> const char *acl_name, struct posix_acl *kacl)
> {
> if (evm_revalidate_status(acl_name))
> @@ -815,7 +815,7 @@ static int ima_inode_removexattr(struct mnt_idmap *idmap, struct dentry *dentry,
> return result;
> }
>
> -static int ima_inode_remove_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> +static int ima_inode_remove_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> const char *acl_name)
> {
> return ima_inode_set_acl(idmap, dentry, acl_name, NULL);
> diff --git a/security/security.c b/security/security.c
> index 2ee276ab15c5..e81dcda3050b 100644
> --- a/security/security.c
> +++ b/security/security.c
> @@ -1953,7 +1953,7 @@ int security_inode_setxattr(struct mnt_idmap *idmap,
> *
> * Return: Returns 0 if permission is granted.
> */
> -int security_inode_set_acl(struct mnt_idmap *idmap,
> +int security_inode_set_acl(const struct mnt_idmap *idmap,
> struct dentry *dentry, const char *acl_name,
> struct posix_acl *kacl)
> {
> @@ -1990,7 +1990,7 @@ void security_inode_post_set_acl(struct dentry *dentry, const char *acl_name,
> *
> * Return: Returns 0 if permission is granted.
> */
> -int security_inode_get_acl(struct mnt_idmap *idmap,
> +int security_inode_get_acl(const struct mnt_idmap *idmap,
> struct dentry *dentry, const char *acl_name)
> {
> if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
> @@ -2009,7 +2009,7 @@ int security_inode_get_acl(struct mnt_idmap *idmap,
> *
> * Return: Returns 0 if permission is granted.
> */
> -int security_inode_remove_acl(struct mnt_idmap *idmap,
> +int security_inode_remove_acl(const struct mnt_idmap *idmap,
> struct dentry *dentry, const char *acl_name)
> {
> if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
> @@ -2026,7 +2026,7 @@ int security_inode_remove_acl(struct mnt_idmap *idmap,
> * Update inode security data after successfully removing posix acls on
> * @dentry in @idmap. The posix acls are identified by @acl_name.
> */
> -void security_inode_post_remove_acl(struct mnt_idmap *idmap,
> +void security_inode_post_remove_acl(const struct mnt_idmap *idmap,
> struct dentry *dentry, const char *acl_name)
> {
> if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
> diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
> index 035aaf113d1d..672d6374d8b0 100644
> --- a/security/selinux/hooks.c
> +++ b/security/selinux/hooks.c
> @@ -3453,20 +3453,20 @@ static int selinux_inode_setxattr(struct mnt_idmap *idmap,
> &ad);
> }
>
> -static int selinux_inode_set_acl(struct mnt_idmap *idmap,
> +static int selinux_inode_set_acl(const struct mnt_idmap *idmap,
> struct dentry *dentry, const char *acl_name,
> struct posix_acl *kacl)
> {
> return dentry_has_perm(current_cred(), dentry, FILE__SETATTR);
> }
>
> -static int selinux_inode_get_acl(struct mnt_idmap *idmap,
> +static int selinux_inode_get_acl(const struct mnt_idmap *idmap,
> struct dentry *dentry, const char *acl_name)
> {
> return dentry_has_perm(current_cred(), dentry, FILE__GETATTR);
> }
>
> -static int selinux_inode_remove_acl(struct mnt_idmap *idmap,
> +static int selinux_inode_remove_acl(const struct mnt_idmap *idmap,
> struct dentry *dentry, const char *acl_name)
> {
> return dentry_has_perm(current_cred(), dentry, FILE__SETATTR);
> diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
> index 8e88ac65fd7f..244cdb49e928 100644
> --- a/security/smack/smack_lsm.c
> +++ b/security/smack/smack_lsm.c
> @@ -1543,7 +1543,7 @@ static int smack_inode_removexattr(struct mnt_idmap *idmap,
> *
> * Returns 0 if access is permitted, an error code otherwise
> */
> -static int smack_inode_set_acl(struct mnt_idmap *idmap,
> +static int smack_inode_set_acl(const struct mnt_idmap *idmap,
> struct dentry *dentry, const char *acl_name,
> struct posix_acl *kacl)
> {
> @@ -1566,7 +1566,7 @@ static int smack_inode_set_acl(struct mnt_idmap *idmap,
> *
> * Returns 0 if access is permitted, an error code otherwise
> */
> -static int smack_inode_get_acl(struct mnt_idmap *idmap,
> +static int smack_inode_get_acl(const struct mnt_idmap *idmap,
> struct dentry *dentry, const char *acl_name)
> {
> struct smk_audit_info ad;
> @@ -1588,7 +1588,7 @@ static int smack_inode_get_acl(struct mnt_idmap *idmap,
> *
> * Returns 0 if access is permitted, an error code otherwise
> */
> -static int smack_inode_remove_acl(struct mnt_idmap *idmap,
> +static int smack_inode_remove_acl(const struct mnt_idmap *idmap,
> struct dentry *dentry, const char *acl_name)
> {
> struct smk_audit_info ad;
>
> --
> 2.53.0
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 62+ messages in thread* Re: [PATCH 11/27] fs: port acl to const mnt_idmap
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
1 sibling, 0 replies; 62+ messages in thread
From: Paul Moore @ 2026-09-02 19:34 UTC (permalink / raw)
To: Christian Brauner, linux-fsdevel
Cc: Alexander Viro, Jan Kara, Christoph Hellwig, Seth Forshee,
linux-security-module, Mimi Zohar, linux-integrity, Ilya Dryomov,
ceph-devel, Carlos Maiolino, linux-xfs, Miklos Szeredi,
Amir Goldstein, linux-unionfs, Namjae Jeon, linux-cifs,
linux-kernel, Christian Brauner (Amutable)
On Sep 1, 2026 Christian Brauner <brauner@kernel.org> wrote:
>
> Convert to const struct mnt_idmap.
>
> A mount's idmapping is immutable. The only thing that is allowed to be
> modified afterwards is the reference count and that is hidden behind
> mnt_idmap_get() and mnt_idmap_put(). Everything else only ever reads
> from the idmapping. This is the same model that struct cred uses and the
> idmapping is also rather sensitive.
>
> So make the idmap argument const wherever we can. The conversion is done
> from the bottom up so callers can continue to pass a non-const pointer
> to a const parameter until the conversion is finished.
>
> No functional changes.
>
> Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
> Reviewed-by: Jan Kara <jack@suse.cz>
> ---
> fs/ntfs/ea.c | 4 ++--
> fs/ntfs/ea.h | 2 +-
> fs/ntfs/namei.c | 2 +-
> fs/ntfs3/inode.c | 2 +-
> fs/ntfs3/ntfs_fs.h | 4 ++--
> fs/ntfs3/xattr.c | 4 ++--
> fs/posix_acl.c | 6 +++---
> include/linux/lsm_hook_defs.h | 8 ++++----
> include/linux/posix_acl.h | 4 ++--
> include/linux/security.h | 16 ++++++++--------
> security/integrity/evm/evm_main.c | 10 +++++-----
> security/integrity/ima/ima_appraise.c | 4 ++--
> security/security.c | 8 ++++----
> security/selinux/hooks.c | 6 +++---
> security/smack/smack_lsm.c | 6 +++---
> 15 files changed, 43 insertions(+), 43 deletions(-)
Acked-by: Paul Moore <paul@paul-moore.com> (LSM, SELinux)
--
paul-moore.com
^ permalink raw reply [flat|nested] 62+ messages in thread
* [PATCH 12/27] fs: port ->permission() to pass const mnt_idmap
2026-09-01 12:14 [PATCH 00/27] fs: port to const struct mnt_idmap Christian Brauner
` (10 preceding siblings ...)
2026-09-01 12:14 ` [PATCH 11/27] fs: port acl " Christian Brauner
@ 2026-09-01 12:14 ` 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
` (14 subsequent siblings)
26 siblings, 2 replies; 62+ messages in thread
From: Christian Brauner @ 2026-09-01 12:14 UTC (permalink / raw)
To: linux-fsdevel
Cc: Alexander Viro, Jan Kara, Christoph Hellwig, Seth Forshee,
Paul Moore, linux-security-module, Mimi Zohar, linux-integrity,
Ilya Dryomov, ceph-devel, Carlos Maiolino, linux-xfs,
Miklos Szeredi, Amir Goldstein, linux-unionfs, Namjae Jeon,
linux-cifs, linux-kernel, Christian Brauner (Amutable)
Convert to const struct mnt_idmap.
A mount's idmapping is immutable. The only thing that is allowed to be
modified afterwards is the reference count and that is hidden behind
mnt_idmap_get() and mnt_idmap_put(). Everything else only ever reads
from the idmapping. This is the same model that struct cred uses and the
idmapping is also rather sensitive.
So make the idmap argument const wherever we can. The conversion is done
from the bottom up so callers can continue to pass a non-const pointer
to a const parameter until the conversion is finished.
No functional changes.
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
---
Documentation/filesystems/locking.rst | 2 +-
Documentation/filesystems/vfs.rst | 2 +-
fs/afs/internal.h | 2 +-
fs/afs/security.c | 2 +-
fs/attr.c | 2 +-
fs/autofs/root.c | 4 ++--
fs/bad_inode.c | 2 +-
fs/btrfs/inode.c | 2 +-
fs/btrfs/ioctl.c | 2 +-
fs/ceph/inode.c | 2 +-
fs/ceph/super.h | 2 +-
fs/coda/coda_linux.h | 2 +-
fs/coda/dir.c | 2 +-
fs/coda/pioctl.c | 4 ++--
fs/ecryptfs/inode.c | 2 +-
fs/failfs.c | 2 +-
fs/fuse/dir.c | 2 +-
fs/gfs2/inode.c | 2 +-
fs/gfs2/inode.h | 2 +-
fs/hostfs/hostfs_kern.c | 2 +-
fs/internal.h | 2 +-
fs/kernfs/inode.c | 2 +-
fs/kernfs/kernfs-internal.h | 2 +-
fs/namei.c | 22 +++++++++++-----------
fs/nfs/dir.c | 2 +-
fs/nilfs2/inode.c | 2 +-
fs/nilfs2/nilfs.h | 2 +-
fs/ocfs2/file.c | 2 +-
fs/ocfs2/file.h | 2 +-
fs/orangefs/inode.c | 2 +-
fs/orangefs/orangefs-kernel.h | 2 +-
fs/overlayfs/inode.c | 2 +-
fs/overlayfs/overlayfs.h | 2 +-
fs/proc/base.c | 4 ++--
fs/proc/fd.c | 4 ++--
fs/proc/fd.h | 2 +-
fs/proc/proc_sysctl.c | 2 +-
fs/smb/client/cifsfs.c | 2 +-
fs/smb/server/vfs.c | 2 +-
fs/smb/server/vfs.h | 2 +-
fs/tracefs/inode.c | 2 +-
include/linux/fs.h | 8 ++++----
include/linux/nfs_fs.h | 2 +-
security/selinux/selinuxfs.c | 2 +-
44 files changed, 61 insertions(+), 61 deletions(-)
diff --git a/Documentation/filesystems/locking.rst b/Documentation/filesystems/locking.rst
index 844d65eb47a5..5af7d3bfcd5e 100644
--- a/Documentation/filesystems/locking.rst
+++ b/Documentation/filesystems/locking.rst
@@ -74,7 +74,7 @@ prototypes::
int (*readlink) (struct dentry *, char __user *,int);
const char *(*get_link) (struct dentry *, struct inode *, struct delayed_call *);
void (*truncate) (struct inode *);
- int (*permission) (struct mnt_idmap *, struct inode *, int, unsigned int);
+ int (*permission) (const struct mnt_idmap *, struct inode *, int, unsigned int);
struct posix_acl * (*get_inode_acl)(struct inode *, int, bool);
int (*setattr) (struct mnt_idmap *, struct dentry *, struct iattr *);
int (*getattr) (struct mnt_idmap *, const struct path *, struct kstat *, u32, unsigned int);
diff --git a/Documentation/filesystems/vfs.rst b/Documentation/filesystems/vfs.rst
index d3a93eec3945..b7e476f70185 100644
--- a/Documentation/filesystems/vfs.rst
+++ b/Documentation/filesystems/vfs.rst
@@ -428,7 +428,7 @@ As of kernel 2.6.22, the following members are defined:
int (*readlink) (struct dentry *, char __user *,int);
const char *(*get_link) (struct dentry *, struct inode *,
struct delayed_call *);
- int (*permission) (struct mnt_idmap *, struct inode *, int);
+ int (*permission) (const struct mnt_idmap *, struct inode *, int);
struct posix_acl * (*get_inode_acl)(struct inode *, int, bool);
int (*setattr) (struct mnt_idmap *, struct dentry *, struct iattr *);
int (*getattr) (struct mnt_idmap *, const struct path *, struct kstat *, u32, unsigned int);
diff --git a/fs/afs/internal.h b/fs/afs/internal.h
index 290873bac89b..e772da2a15f2 100644
--- a/fs/afs/internal.h
+++ b/fs/afs/internal.h
@@ -1530,7 +1530,7 @@ extern void afs_cache_permit(struct afs_vnode *, struct key *, unsigned int,
extern struct key *afs_request_key(struct afs_cell *);
extern struct key *afs_request_key_rcu(struct afs_cell *);
extern int afs_check_permit(struct afs_vnode *, struct key *, afs_access_t *);
-extern int afs_permission(struct mnt_idmap *, struct inode *, int);
+extern int afs_permission(const struct mnt_idmap *, struct inode *, int);
extern void __exit afs_clean_up_permit_cache(void);
/*
diff --git a/fs/afs/security.c b/fs/afs/security.c
index 6d00d62a65ed..fd040f7c6766 100644
--- a/fs/afs/security.c
+++ b/fs/afs/security.c
@@ -428,7 +428,7 @@ int afs_check_permit(struct afs_vnode *vnode, struct key *key,
* - AFS ACLs are attached to directories only, and a file is controlled by its
* parent directory's ACL
*/
-int afs_permission(struct mnt_idmap *idmap, struct inode *inode,
+int afs_permission(const struct mnt_idmap *idmap, struct inode *inode,
int mask)
{
struct afs_vnode *vnode = AFS_FS_I(inode);
diff --git a/fs/attr.c b/fs/attr.c
index 23f1347ff240..c5033afe04bf 100644
--- a/fs/attr.c
+++ b/fs/attr.c
@@ -369,7 +369,7 @@ void setattr_copy(const struct mnt_idmap *idmap, struct inode *inode,
}
EXPORT_SYMBOL(setattr_copy);
-int may_setattr(struct mnt_idmap *idmap, struct inode *inode,
+int may_setattr(const struct mnt_idmap *idmap, struct inode *inode,
unsigned int ia_valid)
{
int error;
diff --git a/fs/autofs/root.c b/fs/autofs/root.c
index b36439f4521e..3158df448025 100644
--- a/fs/autofs/root.c
+++ b/fs/autofs/root.c
@@ -11,7 +11,7 @@
#include "autofs_i.h"
-static int autofs_dir_permission(struct mnt_idmap *, struct inode *, int);
+static int autofs_dir_permission(const struct mnt_idmap *, struct inode *, int);
static int autofs_dir_symlink(struct mnt_idmap *, struct inode *,
struct dentry *, const char *);
static int autofs_dir_unlink(struct inode *, struct dentry *);
@@ -552,7 +552,7 @@ static struct dentry *autofs_lookup(struct inode *dir,
return NULL;
}
-static int autofs_dir_permission(struct mnt_idmap *idmap,
+static int autofs_dir_permission(const struct mnt_idmap *idmap,
struct inode *inode, int mask)
{
if (mask & MAY_WRITE) {
diff --git a/fs/bad_inode.c b/fs/bad_inode.c
index 486c40f73e51..c2cfa9395bc9 100644
--- a/fs/bad_inode.c
+++ b/fs/bad_inode.c
@@ -89,7 +89,7 @@ static int bad_inode_readlink(struct dentry *dentry, char __user *buffer,
return -EIO;
}
-static int bad_inode_permission(struct mnt_idmap *idmap,
+static int bad_inode_permission(const struct mnt_idmap *idmap,
struct inode *inode, int mask)
{
return -EIO;
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index d5a78d9027e2..7bf38f069116 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -9375,7 +9375,7 @@ int btrfs_prealloc_file_range_trans(struct inode *inode,
* we are marking them with IOP_FASTPERM_MAY_EXEC, allowing path lookup to
* elide calls here.
*/
-static int btrfs_permission(struct mnt_idmap *idmap,
+static int btrfs_permission(const struct mnt_idmap *idmap,
struct inode *inode, int mask)
{
struct btrfs_root *root = BTRFS_I(inode)->root;
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 8eacdc2ee4de..9d6302547b12 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -1726,7 +1726,7 @@ static noinline int btrfs_search_path_in_tree(struct btrfs_root *root, u64 dirid
return 0;
}
-static int btrfs_search_path_in_tree_user(struct mnt_idmap *idmap,
+static int btrfs_search_path_in_tree_user(const struct mnt_idmap *idmap,
struct inode *inode,
struct btrfs_ioctl_ino_lookup_user_args *args)
{
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index 3921b601ad59..b8527f67e3f0 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -3098,7 +3098,7 @@ int ceph_do_getvxattr(struct inode *inode, const char *name, void *value,
* Check inode permissions. We verify we have a valid value for
* the AUTH cap, then call the generic handler.
*/
-int ceph_permission(struct mnt_idmap *idmap, struct inode *inode,
+int ceph_permission(const struct mnt_idmap *idmap, struct inode *inode,
int mask)
{
int err;
diff --git a/fs/ceph/super.h b/fs/ceph/super.h
index e9a9d5737c80..ef9861797eb2 100644
--- a/fs/ceph/super.h
+++ b/fs/ceph/super.h
@@ -1166,7 +1166,7 @@ static inline int ceph_do_getattr(struct inode *inode, int mask, bool force)
{
return __ceph_do_getattr(inode, NULL, mask, force);
}
-extern int ceph_permission(struct mnt_idmap *idmap,
+extern int ceph_permission(const struct mnt_idmap *idmap,
struct inode *inode, int mask);
struct ceph_iattr {
diff --git a/fs/coda/coda_linux.h b/fs/coda/coda_linux.h
index dd6277d87afb..5ee6cedd3865 100644
--- a/fs/coda/coda_linux.h
+++ b/fs/coda/coda_linux.h
@@ -46,7 +46,7 @@ extern const struct file_operations coda_ioctl_operations;
/* operations shared over more than one file */
int coda_open(struct inode *i, struct file *f);
int coda_release(struct inode *i, struct file *f);
-int coda_permission(struct mnt_idmap *idmap, struct inode *inode,
+int coda_permission(const struct mnt_idmap *idmap, struct inode *inode,
int mask);
int coda_revalidate_inode(struct inode *);
int coda_getattr(struct mnt_idmap *, const struct path *, struct kstat *,
diff --git a/fs/coda/dir.c b/fs/coda/dir.c
index 67148edfadee..e8db5960b61b 100644
--- a/fs/coda/dir.c
+++ b/fs/coda/dir.c
@@ -73,7 +73,7 @@ static struct dentry *coda_lookup(struct inode *dir, struct dentry *entry, unsig
}
-int coda_permission(struct mnt_idmap *idmap, struct inode *inode,
+int coda_permission(const struct mnt_idmap *idmap, struct inode *inode,
int mask)
{
int error;
diff --git a/fs/coda/pioctl.c b/fs/coda/pioctl.c
index 36e35c15561a..c457e9bab94b 100644
--- a/fs/coda/pioctl.c
+++ b/fs/coda/pioctl.c
@@ -24,7 +24,7 @@
#include "coda_linux.h"
/* pioctl ops */
-static int coda_ioctl_permission(struct mnt_idmap *idmap,
+static int coda_ioctl_permission(const struct mnt_idmap *idmap,
struct inode *inode, int mask);
static long coda_pioctl(struct file *filp, unsigned int cmd,
unsigned long user_data);
@@ -41,7 +41,7 @@ const struct file_operations coda_ioctl_operations = {
};
/* the coda pioctl inode ops */
-static int coda_ioctl_permission(struct mnt_idmap *idmap,
+static int coda_ioctl_permission(const struct mnt_idmap *idmap,
struct inode *inode, int mask)
{
return (mask & MAY_EXEC) ? -EACCES : 0;
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index 525297c7ebd8..6dafca14ca78 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -849,7 +849,7 @@ int ecryptfs_truncate(struct dentry *dentry, loff_t new_length)
}
static int
-ecryptfs_permission(struct mnt_idmap *idmap, struct inode *inode,
+ecryptfs_permission(const struct mnt_idmap *idmap, struct inode *inode,
int mask)
{
return inode_permission(&nop_mnt_idmap,
diff --git a/fs/failfs.c b/fs/failfs.c
index 66a36da3d236..cec6cad99eb2 100644
--- a/fs/failfs.c
+++ b/fs/failfs.c
@@ -22,7 +22,7 @@ bool failfs_mnt(const struct vfsmount *mnt)
return mnt->mnt_sb == failfs_root_path.mnt->mnt_sb;
}
-static int failfs_permission(struct mnt_idmap *idmap, struct inode *inode,
+static int failfs_permission(const struct mnt_idmap *idmap, struct inode *inode,
int mask)
{
return -EOPNOTSUPP;
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 7a204f55ca84..4b87973c727d 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -1763,7 +1763,7 @@ static int fuse_perm_getattr(struct inode *inode, int mask)
* access request is sent. Execute permission is still checked
* locally based on file mode.
*/
-static int fuse_permission(struct mnt_idmap *idmap,
+static int fuse_permission(const struct mnt_idmap *idmap,
struct inode *inode, int mask)
{
struct fuse_conn *fc = get_fuse_conn(inode);
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index f361876c5583..1b1d22abe1d4 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -1963,7 +1963,7 @@ static const char *gfs2_get_link(struct dentry *dentry,
* Returns: errno
*/
-int gfs2_permission(struct mnt_idmap *idmap, struct inode *inode,
+int gfs2_permission(const struct mnt_idmap *idmap, struct inode *inode,
int mask)
{
int may_not_block = mask & MAY_NOT_BLOCK;
diff --git a/fs/gfs2/inode.h b/fs/gfs2/inode.h
index 2fcd96dd1361..373473eb091c 100644
--- a/fs/gfs2/inode.h
+++ b/fs/gfs2/inode.h
@@ -97,7 +97,7 @@ int gfs2_dinode_dealloc(struct gfs2_inode *ip);
struct inode *gfs2_lookupi(struct inode *dir, const struct qstr *name,
int is_root);
-int gfs2_permission(struct mnt_idmap *idmap,
+int gfs2_permission(const struct mnt_idmap *idmap,
struct inode *inode, int mask);
struct inode *gfs2_lookup_meta(struct inode *dip, const char *name);
void gfs2_dinode_out(const struct gfs2_inode *ip, void *buf);
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
index 7add056d47d8..0d5c5f11f913 100644
--- a/fs/hostfs/hostfs_kern.c
+++ b/fs/hostfs/hostfs_kern.c
@@ -774,7 +774,7 @@ static int hostfs_rename2(struct mnt_idmap *idmap,
return err;
}
-static int hostfs_permission(struct mnt_idmap *idmap,
+static int hostfs_permission(const struct mnt_idmap *idmap,
struct inode *ino, int desired)
{
char *name;
diff --git a/fs/internal.h b/fs/internal.h
index 161b0cafe17f..a502b1fbacd2 100644
--- a/fs/internal.h
+++ b/fs/internal.h
@@ -55,7 +55,7 @@ extern int filename_lookup(int dfd, struct filename *name, unsigned flags,
struct path *path, const struct path *root);
int filename_rmdir(int dfd, struct filename *name);
int filename_unlinkat(int dfd, struct filename *name);
-int may_linkat(struct mnt_idmap *idmap, const struct path *link);
+int may_linkat(const struct mnt_idmap *idmap, const struct path *link);
int filename_renameat2(int olddfd, struct filename *oldname, int newdfd,
struct filename *newname, unsigned int flags);
int filename_mkdirat(int dfd, struct filename *name, umode_t mode);
diff --git a/fs/kernfs/inode.c b/fs/kernfs/inode.c
index 237dcdd73fc2..d53d104e54d5 100644
--- a/fs/kernfs/inode.c
+++ b/fs/kernfs/inode.c
@@ -272,7 +272,7 @@ void kernfs_evict_inode(struct inode *inode)
kernfs_put(kn);
}
-int kernfs_iop_permission(struct mnt_idmap *idmap,
+int kernfs_iop_permission(const struct mnt_idmap *idmap,
struct inode *inode, int mask)
{
struct kernfs_node *kn;
diff --git a/fs/kernfs/kernfs-internal.h b/fs/kernfs/kernfs-internal.h
index aa784b540b36..0f6f412213f6 100644
--- a/fs/kernfs/kernfs-internal.h
+++ b/fs/kernfs/kernfs-internal.h
@@ -171,7 +171,7 @@ extern struct kmem_cache *kernfs_node_cache, *kernfs_iattrs_cache;
*/
extern const struct xattr_handler * const kernfs_xattr_handlers[];
void kernfs_evict_inode(struct inode *inode);
-int kernfs_iop_permission(struct mnt_idmap *idmap,
+int kernfs_iop_permission(const struct mnt_idmap *idmap,
struct inode *inode, int mask);
int kernfs_iop_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *iattr);
diff --git a/fs/namei.c b/fs/namei.c
index db82daec3646..f5e00ae41ed4 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -371,7 +371,7 @@ struct filename *complete_getname(struct delayed_filename *v)
* On non-idmapped mounts or if permission checking is to be performed on the
* raw inode simply pass @nop_mnt_idmap.
*/
-static int check_acl(struct mnt_idmap *idmap,
+static int check_acl(const struct mnt_idmap *idmap,
struct inode *inode, int mask)
{
#ifdef CONFIG_FS_POSIX_ACL
@@ -435,7 +435,7 @@ static inline bool no_acl_inode(struct inode *inode)
* On non-idmapped mounts or if permission checking is to be performed on the
* raw inode simply pass @nop_mnt_idmap.
*/
-static int acl_permission_check(struct mnt_idmap *idmap,
+static int acl_permission_check(const struct mnt_idmap *idmap,
struct inode *inode, int mask)
{
unsigned int mode = inode->i_mode;
@@ -518,7 +518,7 @@ static int acl_permission_check(struct mnt_idmap *idmap,
* On non-idmapped mounts or if permission checking is to be performed on the
* raw inode simply pass @nop_mnt_idmap.
*/
-int generic_permission(struct mnt_idmap *idmap, struct inode *inode,
+int generic_permission(const struct mnt_idmap *idmap, struct inode *inode,
int mask)
{
int ret;
@@ -575,7 +575,7 @@ EXPORT_SYMBOL(generic_permission);
* flag in inode->i_opflags, that says "this has not special
* permission function, use the fast case".
*/
-static inline int do_inode_permission(struct mnt_idmap *idmap,
+static inline int do_inode_permission(const struct mnt_idmap *idmap,
struct inode *inode, int mask)
{
if (unlikely(!(inode->i_opflags & IOP_FASTPERM))) {
@@ -625,7 +625,7 @@ static int sb_permission(struct super_block *sb, struct inode *inode, int mask)
*
* When checking for MAY_APPEND, MAY_WRITE must also be set in @mask.
*/
-int inode_permission(struct mnt_idmap *idmap,
+int inode_permission(const struct mnt_idmap *idmap,
struct inode *inode, int mask)
{
int retval;
@@ -680,7 +680,7 @@ EXPORT_SYMBOL(inode_permission);
* on IOP_FASTPERM can still get the optimization if they set IOP_FASTPERM_MAY_EXEC
* on their directory inodes.
*/
-static __always_inline int lookup_inode_permission_may_exec(struct mnt_idmap *idmap,
+static __always_inline int lookup_inode_permission_may_exec(const struct mnt_idmap *idmap,
struct inode *inode, int mask)
{
/* Lookup already checked this to return -ENOTDIR */
@@ -1314,7 +1314,7 @@ static inline int may_follow_link(struct nameidata *nd, const struct inode *inod
*
* Otherwise returns true.
*/
-static bool safe_hardlink_source(struct mnt_idmap *idmap,
+static bool safe_hardlink_source(const struct mnt_idmap *idmap,
struct inode *inode)
{
umode_t mode = inode->i_mode;
@@ -1357,7 +1357,7 @@ static bool safe_hardlink_source(struct mnt_idmap *idmap,
*
* Returns 0 if successful, -ve on error.
*/
-int may_linkat(struct mnt_idmap *idmap, const struct path *link)
+int may_linkat(const struct mnt_idmap *idmap, const struct path *link)
{
struct inode *inode = link->dentry->d_inode;
@@ -1952,7 +1952,7 @@ static struct dentry *lookup_slow_killable(const struct qstr *name,
return res;
}
-static inline int may_lookup(struct mnt_idmap *idmap,
+static inline int may_lookup(const struct mnt_idmap *idmap,
struct nameidata *restrict nd)
{
int err, mask;
@@ -4228,7 +4228,7 @@ bool may_open_dev(const struct path *path)
!(path->mnt->mnt_sb->s_iflags & SB_I_NODEV);
}
-static int may_open(struct mnt_idmap *idmap, const struct path *path,
+static int may_open(const struct mnt_idmap *idmap, const struct path *path,
int acc_mode, int flag)
{
struct dentry *dentry = path->dentry;
@@ -4312,7 +4312,7 @@ static inline int open_to_namei_flags(int flag)
return flag;
}
-static int may_o_create(struct mnt_idmap *idmap,
+static int may_o_create(const struct mnt_idmap *idmap,
const struct path *dir, struct dentry *dentry,
umode_t mode)
{
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 49394123bd09..7574bc2fb677 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -3393,7 +3393,7 @@ static int nfs_execute_ok(struct inode *inode, int mask)
return ret;
}
-int nfs_permission(struct mnt_idmap *idmap,
+int nfs_permission(const struct mnt_idmap *idmap,
struct inode *inode,
int mask)
{
diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c
index 34e6096069ad..9342f651bf9b 100644
--- a/fs/nilfs2/inode.c
+++ b/fs/nilfs2/inode.c
@@ -943,7 +943,7 @@ int nilfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
return err;
}
-int nilfs_permission(struct mnt_idmap *idmap, struct inode *inode,
+int nilfs_permission(const struct mnt_idmap *idmap, struct inode *inode,
int mask)
{
struct nilfs_root *root = NILFS_I(inode)->i_root;
diff --git a/fs/nilfs2/nilfs.h b/fs/nilfs2/nilfs.h
index 4fc42d3787a4..0eaa191f70b8 100644
--- a/fs/nilfs2/nilfs.h
+++ b/fs/nilfs2/nilfs.h
@@ -302,7 +302,7 @@ extern void nilfs_evict_inode(struct inode *);
extern int nilfs_setattr(struct mnt_idmap *, struct dentry *,
struct iattr *);
extern void nilfs_write_failed(struct address_space *mapping, loff_t to);
-int nilfs_permission(struct mnt_idmap *idmap, struct inode *inode,
+int nilfs_permission(const struct mnt_idmap *idmap, struct inode *inode,
int mask);
int nilfs_load_inode_block(struct inode *inode, struct buffer_head **pbh);
extern int nilfs_inode_dirty(struct inode *);
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index d6e977ba6565..24bbf607546c 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -1349,7 +1349,7 @@ int ocfs2_getattr(struct mnt_idmap *idmap, const struct path *path,
return err;
}
-int ocfs2_permission(struct mnt_idmap *idmap, struct inode *inode,
+int ocfs2_permission(const struct mnt_idmap *idmap, struct inode *inode,
int mask)
{
int ret, had_lock;
diff --git a/fs/ocfs2/file.h b/fs/ocfs2/file.h
index 41e65e45a9f3..08e4d6796531 100644
--- a/fs/ocfs2/file.h
+++ b/fs/ocfs2/file.h
@@ -54,7 +54,7 @@ int ocfs2_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *attr);
int ocfs2_getattr(struct mnt_idmap *idmap, const struct path *path,
struct kstat *stat, u32 request_mask, unsigned int flags);
-int ocfs2_permission(struct mnt_idmap *idmap,
+int ocfs2_permission(const struct mnt_idmap *idmap,
struct inode *inode,
int mask);
diff --git a/fs/orangefs/inode.c b/fs/orangefs/inode.c
index cd3273c88e03..8e6eeec501bc 100644
--- a/fs/orangefs/inode.c
+++ b/fs/orangefs/inode.c
@@ -872,7 +872,7 @@ int orangefs_getattr(struct mnt_idmap *idmap, const struct path *path,
return ret;
}
-int orangefs_permission(struct mnt_idmap *idmap,
+int orangefs_permission(const struct mnt_idmap *idmap,
struct inode *inode, int mask)
{
int ret;
diff --git a/fs/orangefs/orangefs-kernel.h b/fs/orangefs/orangefs-kernel.h
index 1451fc2c1917..c582ceffb26e 100644
--- a/fs/orangefs/orangefs-kernel.h
+++ b/fs/orangefs/orangefs-kernel.h
@@ -357,7 +357,7 @@ int orangefs_setattr(struct mnt_idmap *, struct dentry *, struct iattr *);
int orangefs_getattr(struct mnt_idmap *idmap, const struct path *path,
struct kstat *stat, u32 request_mask, unsigned int flags);
-int orangefs_permission(struct mnt_idmap *idmap,
+int orangefs_permission(const struct mnt_idmap *idmap,
struct inode *inode, int mask);
int orangefs_update_time(struct inode *inode, enum fs_update_time type,
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
index 0364e7d08ad7..1166381f1852 100644
--- a/fs/overlayfs/inode.c
+++ b/fs/overlayfs/inode.c
@@ -303,7 +303,7 @@ int ovl_getattr(struct mnt_idmap *idmap, const struct path *path,
return err;
}
-int ovl_permission(struct mnt_idmap *idmap,
+int ovl_permission(const struct mnt_idmap *idmap,
struct inode *inode, int mask)
{
struct inode *upperinode = ovl_inode_upper(inode);
diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h
index 6508f30aaaca..513ba93c7d1b 100644
--- a/fs/overlayfs/overlayfs.h
+++ b/fs/overlayfs/overlayfs.h
@@ -802,7 +802,7 @@ int ovl_set_nlink_lower(struct dentry *dentry);
unsigned int ovl_get_nlink(struct ovl_fs *ofs, struct dentry *lowerdentry,
struct dentry *upperdentry,
unsigned int fallback);
-int ovl_permission(struct mnt_idmap *idmap, struct inode *inode,
+int ovl_permission(const struct mnt_idmap *idmap, struct inode *inode,
int mask);
#ifdef CONFIG_FS_POSIX_ACL
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 6a39de424f62..8dc43c846298 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -743,7 +743,7 @@ static bool has_pid_permissions(struct proc_fs_info *fs_info,
}
-static int proc_pid_permission(struct mnt_idmap *idmap,
+static int proc_pid_permission(const struct mnt_idmap *idmap,
struct inode *inode, int mask)
{
struct proc_fs_info *fs_info = proc_sb_info(inode->i_sb);
@@ -3607,7 +3607,7 @@ int proc_pid_readdir(struct file *file, struct dir_context *ctx)
* This function makes sure that the node is always accessible for members of
* same thread group.
*/
-static int proc_tid_comm_permission(struct mnt_idmap *idmap,
+static int proc_tid_comm_permission(const struct mnt_idmap *idmap,
struct inode *inode, int mask)
{
bool is_same_tgroup;
diff --git a/fs/proc/fd.c b/fs/proc/fd.c
index 0f9a1556f2a3..0653bceb730d 100644
--- a/fs/proc/fd.c
+++ b/fs/proc/fd.c
@@ -82,7 +82,7 @@ static int seq_fdinfo_open(struct inode *inode, struct file *file)
* that the current task has PTRACE_MODE_READ in addition to the normal
* POSIX-like checks.
*/
-static int proc_fdinfo_permission(struct mnt_idmap *idmap, struct inode *inode,
+static int proc_fdinfo_permission(const struct mnt_idmap *idmap, struct inode *inode,
int mask)
{
bool allowed = false;
@@ -323,7 +323,7 @@ static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
* /proc/pid/fd needs a special permission handler so that a process can still
* access /proc/self/fd after it has executed a setuid().
*/
-int proc_fd_permission(struct mnt_idmap *idmap,
+int proc_fd_permission(const struct mnt_idmap *idmap,
struct inode *inode, int mask)
{
struct task_struct *p;
diff --git a/fs/proc/fd.h b/fs/proc/fd.h
index 7e7265f7e06f..77f2e4f38592 100644
--- a/fs/proc/fd.h
+++ b/fs/proc/fd.h
@@ -10,7 +10,7 @@ extern const struct inode_operations proc_fd_inode_operations;
extern const struct file_operations proc_fdinfo_operations;
extern const struct inode_operations proc_fdinfo_inode_operations;
-extern int proc_fd_permission(struct mnt_idmap *idmap,
+extern int proc_fd_permission(const struct mnt_idmap *idmap,
struct inode *inode, int mask);
static inline unsigned int proc_fd(struct inode *inode)
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index 04a382178c65..5315d891f244 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -788,7 +788,7 @@ static int proc_sys_readdir(struct file *file, struct dir_context *ctx)
return 0;
}
-static int proc_sys_permission(struct mnt_idmap *idmap,
+static int proc_sys_permission(const struct mnt_idmap *idmap,
struct inode *inode, int mask)
{
/*
diff --git a/fs/smb/client/cifsfs.c b/fs/smb/client/cifsfs.c
index 7ecd70efdfea..b1ecbcfb154e 100644
--- a/fs/smb/client/cifsfs.c
+++ b/fs/smb/client/cifsfs.c
@@ -402,7 +402,7 @@ static long cifs_fallocate(struct file *file, int mode, loff_t off, loff_t len)
return rc;
}
-static int cifs_permission(struct mnt_idmap *idmap,
+static int cifs_permission(const struct mnt_idmap *idmap,
struct inode *inode, int mask)
{
unsigned int sbflags = cifs_sb_flags(CIFS_SB(inode));
diff --git a/fs/smb/server/vfs.c b/fs/smb/server/vfs.c
index cb52dce113b9..0361de56edc2 100644
--- a/fs/smb/server/vfs.c
+++ b/fs/smb/server/vfs.c
@@ -115,7 +115,7 @@ static int ksmbd_vfs_path_lookup(struct ksmbd_share_config *share_conf,
return 0;
}
-void ksmbd_vfs_query_maximal_access(struct mnt_idmap *idmap,
+void ksmbd_vfs_query_maximal_access(const struct mnt_idmap *idmap,
struct dentry *dentry, __le32 *daccess)
{
*daccess = cpu_to_le32(FILE_READ_ATTRIBUTES | READ_CONTROL);
diff --git a/fs/smb/server/vfs.h b/fs/smb/server/vfs.h
index 9f4b003166e5..9c8b5b288926 100644
--- a/fs/smb/server/vfs.h
+++ b/fs/smb/server/vfs.h
@@ -74,7 +74,7 @@ struct ksmbd_kstat {
};
int ksmbd_vfs_lock_parent(struct dentry *parent, struct dentry *child);
-void ksmbd_vfs_query_maximal_access(struct mnt_idmap *idmap,
+void ksmbd_vfs_query_maximal_access(const struct mnt_idmap *idmap,
struct dentry *dentry, __le32 *daccess);
int ksmbd_vfs_create(struct ksmbd_work *work, const char *name, umode_t mode);
int ksmbd_vfs_mkdir(struct ksmbd_work *work, const char *name, umode_t mode);
diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c
index f3d6188a3b7b..7cf32384ad50 100644
--- a/fs/tracefs/inode.c
+++ b/fs/tracefs/inode.c
@@ -189,7 +189,7 @@ static void set_tracefs_inode_owner(struct inode *inode)
inode->i_gid = gid;
}
-static int tracefs_permission(struct mnt_idmap *idmap,
+static int tracefs_permission(const struct mnt_idmap *idmap,
struct inode *inode, int mask)
{
set_tracefs_inode_owner(inode);
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 91a23c8dbbf6..f815594dd8cb 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1994,7 +1994,7 @@ enum fs_update_time {
struct inode_operations {
struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
const char * (*get_link) (struct dentry *, struct inode *, struct delayed_call *);
- int (*permission) (struct mnt_idmap *, struct inode *, int);
+ int (*permission) (const struct mnt_idmap *, struct inode *, int);
struct posix_acl * (*get_inode_acl)(struct inode *, int, bool);
int (*readlink) (struct dentry *, char __user *,int);
@@ -2709,8 +2709,8 @@ static inline int bmap(struct inode *inode, sector_t *block)
int notify_change(struct mnt_idmap *, struct dentry *,
struct iattr *, struct delegated_inode *);
-int inode_permission(struct mnt_idmap *, struct inode *, int);
-int generic_permission(struct mnt_idmap *, struct inode *, int);
+int inode_permission(const struct mnt_idmap *, struct inode *, int);
+int generic_permission(const struct mnt_idmap *, struct inode *, int);
static inline int file_permission(struct file *file, int mask)
{
return inode_permission(file_mnt_idmap(file),
@@ -3397,7 +3397,7 @@ static inline bool generic_ci_validate_strict_name(struct inode *dir,
}
#endif
-int may_setattr(struct mnt_idmap *idmap, struct inode *inode,
+int may_setattr(const struct mnt_idmap *idmap, struct inode *inode,
unsigned int ia_valid);
int setattr_prepare(struct mnt_idmap *, struct dentry *, struct iattr *);
extern int inode_newsize_ok(const struct inode *, loff_t offset);
diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h
index b85a73ae7919..b2828ea03abe 100644
--- a/include/linux/nfs_fs.h
+++ b/include/linux/nfs_fs.h
@@ -441,7 +441,7 @@ extern int nfs_getattr(struct mnt_idmap *, const struct path *,
struct kstat *, u32, unsigned int);
extern void nfs_access_add_cache(struct inode *, struct nfs_access_entry *, const struct cred *);
extern void nfs_access_set_mask(struct nfs_access_entry *, u32);
-extern int nfs_permission(struct mnt_idmap *, struct inode *, int);
+extern int nfs_permission(const struct mnt_idmap *, struct inode *, int);
extern int nfs_open(struct inode *, struct file *);
extern int nfs_attribute_cache_expired(struct inode *inode);
extern int nfs_revalidate_inode(struct inode *inode, unsigned long flags);
diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c
index c7d91476971c..a0be7f1b5993 100644
--- a/security/selinux/selinuxfs.c
+++ b/security/selinux/selinuxfs.c
@@ -1782,7 +1782,7 @@ static struct dentry *sel_make_dir(struct dentry *dir, const char *name,
return sel_attach(dir, name, inode);
}
-static int reject_all(struct mnt_idmap *idmap, struct inode *inode, int mask)
+static int reject_all(const struct mnt_idmap *idmap, struct inode *inode, int mask)
{
return -EPERM; // no access for anyone, root or no root.
}
--
2.53.0
^ permalink raw reply related [flat|nested] 62+ messages in thread* Re: [PATCH 12/27] fs: port ->permission() to pass const mnt_idmap
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
1 sibling, 0 replies; 62+ messages in thread
From: Jan Kara @ 2026-09-02 15:38 UTC (permalink / raw)
To: Christian Brauner
Cc: linux-fsdevel, Alexander Viro, Jan Kara, Christoph Hellwig,
Seth Forshee, Paul Moore, linux-security-module, Mimi Zohar,
linux-integrity, Ilya Dryomov, ceph-devel, Carlos Maiolino,
linux-xfs, Miklos Szeredi, Amir Goldstein, linux-unionfs,
Namjae Jeon, linux-cifs, linux-kernel
On Tue 01-09-26 14:14:37, Christian Brauner wrote:
> Convert to const struct mnt_idmap.
>
> A mount's idmapping is immutable. The only thing that is allowed to be
> modified afterwards is the reference count and that is hidden behind
> mnt_idmap_get() and mnt_idmap_put(). Everything else only ever reads
> from the idmapping. This is the same model that struct cred uses and the
> idmapping is also rather sensitive.
>
> So make the idmap argument const wherever we can. The conversion is done
> from the bottom up so callers can continue to pass a non-const pointer
> to a const parameter until the conversion is finished.
>
> No functional changes.
>
> Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> Documentation/filesystems/locking.rst | 2 +-
> Documentation/filesystems/vfs.rst | 2 +-
> fs/afs/internal.h | 2 +-
> fs/afs/security.c | 2 +-
> fs/attr.c | 2 +-
> fs/autofs/root.c | 4 ++--
> fs/bad_inode.c | 2 +-
> fs/btrfs/inode.c | 2 +-
> fs/btrfs/ioctl.c | 2 +-
> fs/ceph/inode.c | 2 +-
> fs/ceph/super.h | 2 +-
> fs/coda/coda_linux.h | 2 +-
> fs/coda/dir.c | 2 +-
> fs/coda/pioctl.c | 4 ++--
> fs/ecryptfs/inode.c | 2 +-
> fs/failfs.c | 2 +-
> fs/fuse/dir.c | 2 +-
> fs/gfs2/inode.c | 2 +-
> fs/gfs2/inode.h | 2 +-
> fs/hostfs/hostfs_kern.c | 2 +-
> fs/internal.h | 2 +-
> fs/kernfs/inode.c | 2 +-
> fs/kernfs/kernfs-internal.h | 2 +-
> fs/namei.c | 22 +++++++++++-----------
> fs/nfs/dir.c | 2 +-
> fs/nilfs2/inode.c | 2 +-
> fs/nilfs2/nilfs.h | 2 +-
> fs/ocfs2/file.c | 2 +-
> fs/ocfs2/file.h | 2 +-
> fs/orangefs/inode.c | 2 +-
> fs/orangefs/orangefs-kernel.h | 2 +-
> fs/overlayfs/inode.c | 2 +-
> fs/overlayfs/overlayfs.h | 2 +-
> fs/proc/base.c | 4 ++--
> fs/proc/fd.c | 4 ++--
> fs/proc/fd.h | 2 +-
> fs/proc/proc_sysctl.c | 2 +-
> fs/smb/client/cifsfs.c | 2 +-
> fs/smb/server/vfs.c | 2 +-
> fs/smb/server/vfs.h | 2 +-
> fs/tracefs/inode.c | 2 +-
> include/linux/fs.h | 8 ++++----
> include/linux/nfs_fs.h | 2 +-
> security/selinux/selinuxfs.c | 2 +-
> 44 files changed, 61 insertions(+), 61 deletions(-)
>
> diff --git a/Documentation/filesystems/locking.rst b/Documentation/filesystems/locking.rst
> index 844d65eb47a5..5af7d3bfcd5e 100644
> --- a/Documentation/filesystems/locking.rst
> +++ b/Documentation/filesystems/locking.rst
> @@ -74,7 +74,7 @@ prototypes::
> int (*readlink) (struct dentry *, char __user *,int);
> const char *(*get_link) (struct dentry *, struct inode *, struct delayed_call *);
> void (*truncate) (struct inode *);
> - int (*permission) (struct mnt_idmap *, struct inode *, int, unsigned int);
> + int (*permission) (const struct mnt_idmap *, struct inode *, int, unsigned int);
> struct posix_acl * (*get_inode_acl)(struct inode *, int, bool);
> int (*setattr) (struct mnt_idmap *, struct dentry *, struct iattr *);
> int (*getattr) (struct mnt_idmap *, const struct path *, struct kstat *, u32, unsigned int);
> diff --git a/Documentation/filesystems/vfs.rst b/Documentation/filesystems/vfs.rst
> index d3a93eec3945..b7e476f70185 100644
> --- a/Documentation/filesystems/vfs.rst
> +++ b/Documentation/filesystems/vfs.rst
> @@ -428,7 +428,7 @@ As of kernel 2.6.22, the following members are defined:
> int (*readlink) (struct dentry *, char __user *,int);
> const char *(*get_link) (struct dentry *, struct inode *,
> struct delayed_call *);
> - int (*permission) (struct mnt_idmap *, struct inode *, int);
> + int (*permission) (const struct mnt_idmap *, struct inode *, int);
> struct posix_acl * (*get_inode_acl)(struct inode *, int, bool);
> int (*setattr) (struct mnt_idmap *, struct dentry *, struct iattr *);
> int (*getattr) (struct mnt_idmap *, const struct path *, struct kstat *, u32, unsigned int);
> diff --git a/fs/afs/internal.h b/fs/afs/internal.h
> index 290873bac89b..e772da2a15f2 100644
> --- a/fs/afs/internal.h
> +++ b/fs/afs/internal.h
> @@ -1530,7 +1530,7 @@ extern void afs_cache_permit(struct afs_vnode *, struct key *, unsigned int,
> extern struct key *afs_request_key(struct afs_cell *);
> extern struct key *afs_request_key_rcu(struct afs_cell *);
> extern int afs_check_permit(struct afs_vnode *, struct key *, afs_access_t *);
> -extern int afs_permission(struct mnt_idmap *, struct inode *, int);
> +extern int afs_permission(const struct mnt_idmap *, struct inode *, int);
> extern void __exit afs_clean_up_permit_cache(void);
>
> /*
> diff --git a/fs/afs/security.c b/fs/afs/security.c
> index 6d00d62a65ed..fd040f7c6766 100644
> --- a/fs/afs/security.c
> +++ b/fs/afs/security.c
> @@ -428,7 +428,7 @@ int afs_check_permit(struct afs_vnode *vnode, struct key *key,
> * - AFS ACLs are attached to directories only, and a file is controlled by its
> * parent directory's ACL
> */
> -int afs_permission(struct mnt_idmap *idmap, struct inode *inode,
> +int afs_permission(const struct mnt_idmap *idmap, struct inode *inode,
> int mask)
> {
> struct afs_vnode *vnode = AFS_FS_I(inode);
> diff --git a/fs/attr.c b/fs/attr.c
> index 23f1347ff240..c5033afe04bf 100644
> --- a/fs/attr.c
> +++ b/fs/attr.c
> @@ -369,7 +369,7 @@ void setattr_copy(const struct mnt_idmap *idmap, struct inode *inode,
> }
> EXPORT_SYMBOL(setattr_copy);
>
> -int may_setattr(struct mnt_idmap *idmap, struct inode *inode,
> +int may_setattr(const struct mnt_idmap *idmap, struct inode *inode,
> unsigned int ia_valid)
> {
> int error;
> diff --git a/fs/autofs/root.c b/fs/autofs/root.c
> index b36439f4521e..3158df448025 100644
> --- a/fs/autofs/root.c
> +++ b/fs/autofs/root.c
> @@ -11,7 +11,7 @@
>
> #include "autofs_i.h"
>
> -static int autofs_dir_permission(struct mnt_idmap *, struct inode *, int);
> +static int autofs_dir_permission(const struct mnt_idmap *, struct inode *, int);
> static int autofs_dir_symlink(struct mnt_idmap *, struct inode *,
> struct dentry *, const char *);
> static int autofs_dir_unlink(struct inode *, struct dentry *);
> @@ -552,7 +552,7 @@ static struct dentry *autofs_lookup(struct inode *dir,
> return NULL;
> }
>
> -static int autofs_dir_permission(struct mnt_idmap *idmap,
> +static int autofs_dir_permission(const struct mnt_idmap *idmap,
> struct inode *inode, int mask)
> {
> if (mask & MAY_WRITE) {
> diff --git a/fs/bad_inode.c b/fs/bad_inode.c
> index 486c40f73e51..c2cfa9395bc9 100644
> --- a/fs/bad_inode.c
> +++ b/fs/bad_inode.c
> @@ -89,7 +89,7 @@ static int bad_inode_readlink(struct dentry *dentry, char __user *buffer,
> return -EIO;
> }
>
> -static int bad_inode_permission(struct mnt_idmap *idmap,
> +static int bad_inode_permission(const struct mnt_idmap *idmap,
> struct inode *inode, int mask)
> {
> return -EIO;
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index d5a78d9027e2..7bf38f069116 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -9375,7 +9375,7 @@ int btrfs_prealloc_file_range_trans(struct inode *inode,
> * we are marking them with IOP_FASTPERM_MAY_EXEC, allowing path lookup to
> * elide calls here.
> */
> -static int btrfs_permission(struct mnt_idmap *idmap,
> +static int btrfs_permission(const struct mnt_idmap *idmap,
> struct inode *inode, int mask)
> {
> struct btrfs_root *root = BTRFS_I(inode)->root;
> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
> index 8eacdc2ee4de..9d6302547b12 100644
> --- a/fs/btrfs/ioctl.c
> +++ b/fs/btrfs/ioctl.c
> @@ -1726,7 +1726,7 @@ static noinline int btrfs_search_path_in_tree(struct btrfs_root *root, u64 dirid
> return 0;
> }
>
> -static int btrfs_search_path_in_tree_user(struct mnt_idmap *idmap,
> +static int btrfs_search_path_in_tree_user(const struct mnt_idmap *idmap,
> struct inode *inode,
> struct btrfs_ioctl_ino_lookup_user_args *args)
> {
> diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
> index 3921b601ad59..b8527f67e3f0 100644
> --- a/fs/ceph/inode.c
> +++ b/fs/ceph/inode.c
> @@ -3098,7 +3098,7 @@ int ceph_do_getvxattr(struct inode *inode, const char *name, void *value,
> * Check inode permissions. We verify we have a valid value for
> * the AUTH cap, then call the generic handler.
> */
> -int ceph_permission(struct mnt_idmap *idmap, struct inode *inode,
> +int ceph_permission(const struct mnt_idmap *idmap, struct inode *inode,
> int mask)
> {
> int err;
> diff --git a/fs/ceph/super.h b/fs/ceph/super.h
> index e9a9d5737c80..ef9861797eb2 100644
> --- a/fs/ceph/super.h
> +++ b/fs/ceph/super.h
> @@ -1166,7 +1166,7 @@ static inline int ceph_do_getattr(struct inode *inode, int mask, bool force)
> {
> return __ceph_do_getattr(inode, NULL, mask, force);
> }
> -extern int ceph_permission(struct mnt_idmap *idmap,
> +extern int ceph_permission(const struct mnt_idmap *idmap,
> struct inode *inode, int mask);
>
> struct ceph_iattr {
> diff --git a/fs/coda/coda_linux.h b/fs/coda/coda_linux.h
> index dd6277d87afb..5ee6cedd3865 100644
> --- a/fs/coda/coda_linux.h
> +++ b/fs/coda/coda_linux.h
> @@ -46,7 +46,7 @@ extern const struct file_operations coda_ioctl_operations;
> /* operations shared over more than one file */
> int coda_open(struct inode *i, struct file *f);
> int coda_release(struct inode *i, struct file *f);
> -int coda_permission(struct mnt_idmap *idmap, struct inode *inode,
> +int coda_permission(const struct mnt_idmap *idmap, struct inode *inode,
> int mask);
> int coda_revalidate_inode(struct inode *);
> int coda_getattr(struct mnt_idmap *, const struct path *, struct kstat *,
> diff --git a/fs/coda/dir.c b/fs/coda/dir.c
> index 67148edfadee..e8db5960b61b 100644
> --- a/fs/coda/dir.c
> +++ b/fs/coda/dir.c
> @@ -73,7 +73,7 @@ static struct dentry *coda_lookup(struct inode *dir, struct dentry *entry, unsig
> }
>
>
> -int coda_permission(struct mnt_idmap *idmap, struct inode *inode,
> +int coda_permission(const struct mnt_idmap *idmap, struct inode *inode,
> int mask)
> {
> int error;
> diff --git a/fs/coda/pioctl.c b/fs/coda/pioctl.c
> index 36e35c15561a..c457e9bab94b 100644
> --- a/fs/coda/pioctl.c
> +++ b/fs/coda/pioctl.c
> @@ -24,7 +24,7 @@
> #include "coda_linux.h"
>
> /* pioctl ops */
> -static int coda_ioctl_permission(struct mnt_idmap *idmap,
> +static int coda_ioctl_permission(const struct mnt_idmap *idmap,
> struct inode *inode, int mask);
> static long coda_pioctl(struct file *filp, unsigned int cmd,
> unsigned long user_data);
> @@ -41,7 +41,7 @@ const struct file_operations coda_ioctl_operations = {
> };
>
> /* the coda pioctl inode ops */
> -static int coda_ioctl_permission(struct mnt_idmap *idmap,
> +static int coda_ioctl_permission(const struct mnt_idmap *idmap,
> struct inode *inode, int mask)
> {
> return (mask & MAY_EXEC) ? -EACCES : 0;
> diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
> index 525297c7ebd8..6dafca14ca78 100644
> --- a/fs/ecryptfs/inode.c
> +++ b/fs/ecryptfs/inode.c
> @@ -849,7 +849,7 @@ int ecryptfs_truncate(struct dentry *dentry, loff_t new_length)
> }
>
> static int
> -ecryptfs_permission(struct mnt_idmap *idmap, struct inode *inode,
> +ecryptfs_permission(const struct mnt_idmap *idmap, struct inode *inode,
> int mask)
> {
> return inode_permission(&nop_mnt_idmap,
> diff --git a/fs/failfs.c b/fs/failfs.c
> index 66a36da3d236..cec6cad99eb2 100644
> --- a/fs/failfs.c
> +++ b/fs/failfs.c
> @@ -22,7 +22,7 @@ bool failfs_mnt(const struct vfsmount *mnt)
> return mnt->mnt_sb == failfs_root_path.mnt->mnt_sb;
> }
>
> -static int failfs_permission(struct mnt_idmap *idmap, struct inode *inode,
> +static int failfs_permission(const struct mnt_idmap *idmap, struct inode *inode,
> int mask)
> {
> return -EOPNOTSUPP;
> diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
> index 7a204f55ca84..4b87973c727d 100644
> --- a/fs/fuse/dir.c
> +++ b/fs/fuse/dir.c
> @@ -1763,7 +1763,7 @@ static int fuse_perm_getattr(struct inode *inode, int mask)
> * access request is sent. Execute permission is still checked
> * locally based on file mode.
> */
> -static int fuse_permission(struct mnt_idmap *idmap,
> +static int fuse_permission(const struct mnt_idmap *idmap,
> struct inode *inode, int mask)
> {
> struct fuse_conn *fc = get_fuse_conn(inode);
> diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
> index f361876c5583..1b1d22abe1d4 100644
> --- a/fs/gfs2/inode.c
> +++ b/fs/gfs2/inode.c
> @@ -1963,7 +1963,7 @@ static const char *gfs2_get_link(struct dentry *dentry,
> * Returns: errno
> */
>
> -int gfs2_permission(struct mnt_idmap *idmap, struct inode *inode,
> +int gfs2_permission(const struct mnt_idmap *idmap, struct inode *inode,
> int mask)
> {
> int may_not_block = mask & MAY_NOT_BLOCK;
> diff --git a/fs/gfs2/inode.h b/fs/gfs2/inode.h
> index 2fcd96dd1361..373473eb091c 100644
> --- a/fs/gfs2/inode.h
> +++ b/fs/gfs2/inode.h
> @@ -97,7 +97,7 @@ int gfs2_dinode_dealloc(struct gfs2_inode *ip);
>
> struct inode *gfs2_lookupi(struct inode *dir, const struct qstr *name,
> int is_root);
> -int gfs2_permission(struct mnt_idmap *idmap,
> +int gfs2_permission(const struct mnt_idmap *idmap,
> struct inode *inode, int mask);
> struct inode *gfs2_lookup_meta(struct inode *dip, const char *name);
> void gfs2_dinode_out(const struct gfs2_inode *ip, void *buf);
> diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
> index 7add056d47d8..0d5c5f11f913 100644
> --- a/fs/hostfs/hostfs_kern.c
> +++ b/fs/hostfs/hostfs_kern.c
> @@ -774,7 +774,7 @@ static int hostfs_rename2(struct mnt_idmap *idmap,
> return err;
> }
>
> -static int hostfs_permission(struct mnt_idmap *idmap,
> +static int hostfs_permission(const struct mnt_idmap *idmap,
> struct inode *ino, int desired)
> {
> char *name;
> diff --git a/fs/internal.h b/fs/internal.h
> index 161b0cafe17f..a502b1fbacd2 100644
> --- a/fs/internal.h
> +++ b/fs/internal.h
> @@ -55,7 +55,7 @@ extern int filename_lookup(int dfd, struct filename *name, unsigned flags,
> struct path *path, const struct path *root);
> int filename_rmdir(int dfd, struct filename *name);
> int filename_unlinkat(int dfd, struct filename *name);
> -int may_linkat(struct mnt_idmap *idmap, const struct path *link);
> +int may_linkat(const struct mnt_idmap *idmap, const struct path *link);
> int filename_renameat2(int olddfd, struct filename *oldname, int newdfd,
> struct filename *newname, unsigned int flags);
> int filename_mkdirat(int dfd, struct filename *name, umode_t mode);
> diff --git a/fs/kernfs/inode.c b/fs/kernfs/inode.c
> index 237dcdd73fc2..d53d104e54d5 100644
> --- a/fs/kernfs/inode.c
> +++ b/fs/kernfs/inode.c
> @@ -272,7 +272,7 @@ void kernfs_evict_inode(struct inode *inode)
> kernfs_put(kn);
> }
>
> -int kernfs_iop_permission(struct mnt_idmap *idmap,
> +int kernfs_iop_permission(const struct mnt_idmap *idmap,
> struct inode *inode, int mask)
> {
> struct kernfs_node *kn;
> diff --git a/fs/kernfs/kernfs-internal.h b/fs/kernfs/kernfs-internal.h
> index aa784b540b36..0f6f412213f6 100644
> --- a/fs/kernfs/kernfs-internal.h
> +++ b/fs/kernfs/kernfs-internal.h
> @@ -171,7 +171,7 @@ extern struct kmem_cache *kernfs_node_cache, *kernfs_iattrs_cache;
> */
> extern const struct xattr_handler * const kernfs_xattr_handlers[];
> void kernfs_evict_inode(struct inode *inode);
> -int kernfs_iop_permission(struct mnt_idmap *idmap,
> +int kernfs_iop_permission(const struct mnt_idmap *idmap,
> struct inode *inode, int mask);
> int kernfs_iop_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *iattr);
> diff --git a/fs/namei.c b/fs/namei.c
> index db82daec3646..f5e00ae41ed4 100644
> --- a/fs/namei.c
> +++ b/fs/namei.c
> @@ -371,7 +371,7 @@ struct filename *complete_getname(struct delayed_filename *v)
> * On non-idmapped mounts or if permission checking is to be performed on the
> * raw inode simply pass @nop_mnt_idmap.
> */
> -static int check_acl(struct mnt_idmap *idmap,
> +static int check_acl(const struct mnt_idmap *idmap,
> struct inode *inode, int mask)
> {
> #ifdef CONFIG_FS_POSIX_ACL
> @@ -435,7 +435,7 @@ static inline bool no_acl_inode(struct inode *inode)
> * On non-idmapped mounts or if permission checking is to be performed on the
> * raw inode simply pass @nop_mnt_idmap.
> */
> -static int acl_permission_check(struct mnt_idmap *idmap,
> +static int acl_permission_check(const struct mnt_idmap *idmap,
> struct inode *inode, int mask)
> {
> unsigned int mode = inode->i_mode;
> @@ -518,7 +518,7 @@ static int acl_permission_check(struct mnt_idmap *idmap,
> * On non-idmapped mounts or if permission checking is to be performed on the
> * raw inode simply pass @nop_mnt_idmap.
> */
> -int generic_permission(struct mnt_idmap *idmap, struct inode *inode,
> +int generic_permission(const struct mnt_idmap *idmap, struct inode *inode,
> int mask)
> {
> int ret;
> @@ -575,7 +575,7 @@ EXPORT_SYMBOL(generic_permission);
> * flag in inode->i_opflags, that says "this has not special
> * permission function, use the fast case".
> */
> -static inline int do_inode_permission(struct mnt_idmap *idmap,
> +static inline int do_inode_permission(const struct mnt_idmap *idmap,
> struct inode *inode, int mask)
> {
> if (unlikely(!(inode->i_opflags & IOP_FASTPERM))) {
> @@ -625,7 +625,7 @@ static int sb_permission(struct super_block *sb, struct inode *inode, int mask)
> *
> * When checking for MAY_APPEND, MAY_WRITE must also be set in @mask.
> */
> -int inode_permission(struct mnt_idmap *idmap,
> +int inode_permission(const struct mnt_idmap *idmap,
> struct inode *inode, int mask)
> {
> int retval;
> @@ -680,7 +680,7 @@ EXPORT_SYMBOL(inode_permission);
> * on IOP_FASTPERM can still get the optimization if they set IOP_FASTPERM_MAY_EXEC
> * on their directory inodes.
> */
> -static __always_inline int lookup_inode_permission_may_exec(struct mnt_idmap *idmap,
> +static __always_inline int lookup_inode_permission_may_exec(const struct mnt_idmap *idmap,
> struct inode *inode, int mask)
> {
> /* Lookup already checked this to return -ENOTDIR */
> @@ -1314,7 +1314,7 @@ static inline int may_follow_link(struct nameidata *nd, const struct inode *inod
> *
> * Otherwise returns true.
> */
> -static bool safe_hardlink_source(struct mnt_idmap *idmap,
> +static bool safe_hardlink_source(const struct mnt_idmap *idmap,
> struct inode *inode)
> {
> umode_t mode = inode->i_mode;
> @@ -1357,7 +1357,7 @@ static bool safe_hardlink_source(struct mnt_idmap *idmap,
> *
> * Returns 0 if successful, -ve on error.
> */
> -int may_linkat(struct mnt_idmap *idmap, const struct path *link)
> +int may_linkat(const struct mnt_idmap *idmap, const struct path *link)
> {
> struct inode *inode = link->dentry->d_inode;
>
> @@ -1952,7 +1952,7 @@ static struct dentry *lookup_slow_killable(const struct qstr *name,
> return res;
> }
>
> -static inline int may_lookup(struct mnt_idmap *idmap,
> +static inline int may_lookup(const struct mnt_idmap *idmap,
> struct nameidata *restrict nd)
> {
> int err, mask;
> @@ -4228,7 +4228,7 @@ bool may_open_dev(const struct path *path)
> !(path->mnt->mnt_sb->s_iflags & SB_I_NODEV);
> }
>
> -static int may_open(struct mnt_idmap *idmap, const struct path *path,
> +static int may_open(const struct mnt_idmap *idmap, const struct path *path,
> int acc_mode, int flag)
> {
> struct dentry *dentry = path->dentry;
> @@ -4312,7 +4312,7 @@ static inline int open_to_namei_flags(int flag)
> return flag;
> }
>
> -static int may_o_create(struct mnt_idmap *idmap,
> +static int may_o_create(const struct mnt_idmap *idmap,
> const struct path *dir, struct dentry *dentry,
> umode_t mode)
> {
> diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
> index 49394123bd09..7574bc2fb677 100644
> --- a/fs/nfs/dir.c
> +++ b/fs/nfs/dir.c
> @@ -3393,7 +3393,7 @@ static int nfs_execute_ok(struct inode *inode, int mask)
> return ret;
> }
>
> -int nfs_permission(struct mnt_idmap *idmap,
> +int nfs_permission(const struct mnt_idmap *idmap,
> struct inode *inode,
> int mask)
> {
> diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c
> index 34e6096069ad..9342f651bf9b 100644
> --- a/fs/nilfs2/inode.c
> +++ b/fs/nilfs2/inode.c
> @@ -943,7 +943,7 @@ int nilfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> return err;
> }
>
> -int nilfs_permission(struct mnt_idmap *idmap, struct inode *inode,
> +int nilfs_permission(const struct mnt_idmap *idmap, struct inode *inode,
> int mask)
> {
> struct nilfs_root *root = NILFS_I(inode)->i_root;
> diff --git a/fs/nilfs2/nilfs.h b/fs/nilfs2/nilfs.h
> index 4fc42d3787a4..0eaa191f70b8 100644
> --- a/fs/nilfs2/nilfs.h
> +++ b/fs/nilfs2/nilfs.h
> @@ -302,7 +302,7 @@ extern void nilfs_evict_inode(struct inode *);
> extern int nilfs_setattr(struct mnt_idmap *, struct dentry *,
> struct iattr *);
> extern void nilfs_write_failed(struct address_space *mapping, loff_t to);
> -int nilfs_permission(struct mnt_idmap *idmap, struct inode *inode,
> +int nilfs_permission(const struct mnt_idmap *idmap, struct inode *inode,
> int mask);
> int nilfs_load_inode_block(struct inode *inode, struct buffer_head **pbh);
> extern int nilfs_inode_dirty(struct inode *);
> diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
> index d6e977ba6565..24bbf607546c 100644
> --- a/fs/ocfs2/file.c
> +++ b/fs/ocfs2/file.c
> @@ -1349,7 +1349,7 @@ int ocfs2_getattr(struct mnt_idmap *idmap, const struct path *path,
> return err;
> }
>
> -int ocfs2_permission(struct mnt_idmap *idmap, struct inode *inode,
> +int ocfs2_permission(const struct mnt_idmap *idmap, struct inode *inode,
> int mask)
> {
> int ret, had_lock;
> diff --git a/fs/ocfs2/file.h b/fs/ocfs2/file.h
> index 41e65e45a9f3..08e4d6796531 100644
> --- a/fs/ocfs2/file.h
> +++ b/fs/ocfs2/file.h
> @@ -54,7 +54,7 @@ int ocfs2_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *attr);
> int ocfs2_getattr(struct mnt_idmap *idmap, const struct path *path,
> struct kstat *stat, u32 request_mask, unsigned int flags);
> -int ocfs2_permission(struct mnt_idmap *idmap,
> +int ocfs2_permission(const struct mnt_idmap *idmap,
> struct inode *inode,
> int mask);
>
> diff --git a/fs/orangefs/inode.c b/fs/orangefs/inode.c
> index cd3273c88e03..8e6eeec501bc 100644
> --- a/fs/orangefs/inode.c
> +++ b/fs/orangefs/inode.c
> @@ -872,7 +872,7 @@ int orangefs_getattr(struct mnt_idmap *idmap, const struct path *path,
> return ret;
> }
>
> -int orangefs_permission(struct mnt_idmap *idmap,
> +int orangefs_permission(const struct mnt_idmap *idmap,
> struct inode *inode, int mask)
> {
> int ret;
> diff --git a/fs/orangefs/orangefs-kernel.h b/fs/orangefs/orangefs-kernel.h
> index 1451fc2c1917..c582ceffb26e 100644
> --- a/fs/orangefs/orangefs-kernel.h
> +++ b/fs/orangefs/orangefs-kernel.h
> @@ -357,7 +357,7 @@ int orangefs_setattr(struct mnt_idmap *, struct dentry *, struct iattr *);
> int orangefs_getattr(struct mnt_idmap *idmap, const struct path *path,
> struct kstat *stat, u32 request_mask, unsigned int flags);
>
> -int orangefs_permission(struct mnt_idmap *idmap,
> +int orangefs_permission(const struct mnt_idmap *idmap,
> struct inode *inode, int mask);
>
> int orangefs_update_time(struct inode *inode, enum fs_update_time type,
> diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
> index 0364e7d08ad7..1166381f1852 100644
> --- a/fs/overlayfs/inode.c
> +++ b/fs/overlayfs/inode.c
> @@ -303,7 +303,7 @@ int ovl_getattr(struct mnt_idmap *idmap, const struct path *path,
> return err;
> }
>
> -int ovl_permission(struct mnt_idmap *idmap,
> +int ovl_permission(const struct mnt_idmap *idmap,
> struct inode *inode, int mask)
> {
> struct inode *upperinode = ovl_inode_upper(inode);
> diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h
> index 6508f30aaaca..513ba93c7d1b 100644
> --- a/fs/overlayfs/overlayfs.h
> +++ b/fs/overlayfs/overlayfs.h
> @@ -802,7 +802,7 @@ int ovl_set_nlink_lower(struct dentry *dentry);
> unsigned int ovl_get_nlink(struct ovl_fs *ofs, struct dentry *lowerdentry,
> struct dentry *upperdentry,
> unsigned int fallback);
> -int ovl_permission(struct mnt_idmap *idmap, struct inode *inode,
> +int ovl_permission(const struct mnt_idmap *idmap, struct inode *inode,
> int mask);
>
> #ifdef CONFIG_FS_POSIX_ACL
> diff --git a/fs/proc/base.c b/fs/proc/base.c
> index 6a39de424f62..8dc43c846298 100644
> --- a/fs/proc/base.c
> +++ b/fs/proc/base.c
> @@ -743,7 +743,7 @@ static bool has_pid_permissions(struct proc_fs_info *fs_info,
> }
>
>
> -static int proc_pid_permission(struct mnt_idmap *idmap,
> +static int proc_pid_permission(const struct mnt_idmap *idmap,
> struct inode *inode, int mask)
> {
> struct proc_fs_info *fs_info = proc_sb_info(inode->i_sb);
> @@ -3607,7 +3607,7 @@ int proc_pid_readdir(struct file *file, struct dir_context *ctx)
> * This function makes sure that the node is always accessible for members of
> * same thread group.
> */
> -static int proc_tid_comm_permission(struct mnt_idmap *idmap,
> +static int proc_tid_comm_permission(const struct mnt_idmap *idmap,
> struct inode *inode, int mask)
> {
> bool is_same_tgroup;
> diff --git a/fs/proc/fd.c b/fs/proc/fd.c
> index 0f9a1556f2a3..0653bceb730d 100644
> --- a/fs/proc/fd.c
> +++ b/fs/proc/fd.c
> @@ -82,7 +82,7 @@ static int seq_fdinfo_open(struct inode *inode, struct file *file)
> * that the current task has PTRACE_MODE_READ in addition to the normal
> * POSIX-like checks.
> */
> -static int proc_fdinfo_permission(struct mnt_idmap *idmap, struct inode *inode,
> +static int proc_fdinfo_permission(const struct mnt_idmap *idmap, struct inode *inode,
> int mask)
> {
> bool allowed = false;
> @@ -323,7 +323,7 @@ static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
> * /proc/pid/fd needs a special permission handler so that a process can still
> * access /proc/self/fd after it has executed a setuid().
> */
> -int proc_fd_permission(struct mnt_idmap *idmap,
> +int proc_fd_permission(const struct mnt_idmap *idmap,
> struct inode *inode, int mask)
> {
> struct task_struct *p;
> diff --git a/fs/proc/fd.h b/fs/proc/fd.h
> index 7e7265f7e06f..77f2e4f38592 100644
> --- a/fs/proc/fd.h
> +++ b/fs/proc/fd.h
> @@ -10,7 +10,7 @@ extern const struct inode_operations proc_fd_inode_operations;
> extern const struct file_operations proc_fdinfo_operations;
> extern const struct inode_operations proc_fdinfo_inode_operations;
>
> -extern int proc_fd_permission(struct mnt_idmap *idmap,
> +extern int proc_fd_permission(const struct mnt_idmap *idmap,
> struct inode *inode, int mask);
>
> static inline unsigned int proc_fd(struct inode *inode)
> diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
> index 04a382178c65..5315d891f244 100644
> --- a/fs/proc/proc_sysctl.c
> +++ b/fs/proc/proc_sysctl.c
> @@ -788,7 +788,7 @@ static int proc_sys_readdir(struct file *file, struct dir_context *ctx)
> return 0;
> }
>
> -static int proc_sys_permission(struct mnt_idmap *idmap,
> +static int proc_sys_permission(const struct mnt_idmap *idmap,
> struct inode *inode, int mask)
> {
> /*
> diff --git a/fs/smb/client/cifsfs.c b/fs/smb/client/cifsfs.c
> index 7ecd70efdfea..b1ecbcfb154e 100644
> --- a/fs/smb/client/cifsfs.c
> +++ b/fs/smb/client/cifsfs.c
> @@ -402,7 +402,7 @@ static long cifs_fallocate(struct file *file, int mode, loff_t off, loff_t len)
> return rc;
> }
>
> -static int cifs_permission(struct mnt_idmap *idmap,
> +static int cifs_permission(const struct mnt_idmap *idmap,
> struct inode *inode, int mask)
> {
> unsigned int sbflags = cifs_sb_flags(CIFS_SB(inode));
> diff --git a/fs/smb/server/vfs.c b/fs/smb/server/vfs.c
> index cb52dce113b9..0361de56edc2 100644
> --- a/fs/smb/server/vfs.c
> +++ b/fs/smb/server/vfs.c
> @@ -115,7 +115,7 @@ static int ksmbd_vfs_path_lookup(struct ksmbd_share_config *share_conf,
> return 0;
> }
>
> -void ksmbd_vfs_query_maximal_access(struct mnt_idmap *idmap,
> +void ksmbd_vfs_query_maximal_access(const struct mnt_idmap *idmap,
> struct dentry *dentry, __le32 *daccess)
> {
> *daccess = cpu_to_le32(FILE_READ_ATTRIBUTES | READ_CONTROL);
> diff --git a/fs/smb/server/vfs.h b/fs/smb/server/vfs.h
> index 9f4b003166e5..9c8b5b288926 100644
> --- a/fs/smb/server/vfs.h
> +++ b/fs/smb/server/vfs.h
> @@ -74,7 +74,7 @@ struct ksmbd_kstat {
> };
>
> int ksmbd_vfs_lock_parent(struct dentry *parent, struct dentry *child);
> -void ksmbd_vfs_query_maximal_access(struct mnt_idmap *idmap,
> +void ksmbd_vfs_query_maximal_access(const struct mnt_idmap *idmap,
> struct dentry *dentry, __le32 *daccess);
> int ksmbd_vfs_create(struct ksmbd_work *work, const char *name, umode_t mode);
> int ksmbd_vfs_mkdir(struct ksmbd_work *work, const char *name, umode_t mode);
> diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c
> index f3d6188a3b7b..7cf32384ad50 100644
> --- a/fs/tracefs/inode.c
> +++ b/fs/tracefs/inode.c
> @@ -189,7 +189,7 @@ static void set_tracefs_inode_owner(struct inode *inode)
> inode->i_gid = gid;
> }
>
> -static int tracefs_permission(struct mnt_idmap *idmap,
> +static int tracefs_permission(const struct mnt_idmap *idmap,
> struct inode *inode, int mask)
> {
> set_tracefs_inode_owner(inode);
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 91a23c8dbbf6..f815594dd8cb 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -1994,7 +1994,7 @@ enum fs_update_time {
> struct inode_operations {
> struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
> const char * (*get_link) (struct dentry *, struct inode *, struct delayed_call *);
> - int (*permission) (struct mnt_idmap *, struct inode *, int);
> + int (*permission) (const struct mnt_idmap *, struct inode *, int);
> struct posix_acl * (*get_inode_acl)(struct inode *, int, bool);
>
> int (*readlink) (struct dentry *, char __user *,int);
> @@ -2709,8 +2709,8 @@ static inline int bmap(struct inode *inode, sector_t *block)
>
> int notify_change(struct mnt_idmap *, struct dentry *,
> struct iattr *, struct delegated_inode *);
> -int inode_permission(struct mnt_idmap *, struct inode *, int);
> -int generic_permission(struct mnt_idmap *, struct inode *, int);
> +int inode_permission(const struct mnt_idmap *, struct inode *, int);
> +int generic_permission(const struct mnt_idmap *, struct inode *, int);
> static inline int file_permission(struct file *file, int mask)
> {
> return inode_permission(file_mnt_idmap(file),
> @@ -3397,7 +3397,7 @@ static inline bool generic_ci_validate_strict_name(struct inode *dir,
> }
> #endif
>
> -int may_setattr(struct mnt_idmap *idmap, struct inode *inode,
> +int may_setattr(const struct mnt_idmap *idmap, struct inode *inode,
> unsigned int ia_valid);
> int setattr_prepare(struct mnt_idmap *, struct dentry *, struct iattr *);
> extern int inode_newsize_ok(const struct inode *, loff_t offset);
> diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h
> index b85a73ae7919..b2828ea03abe 100644
> --- a/include/linux/nfs_fs.h
> +++ b/include/linux/nfs_fs.h
> @@ -441,7 +441,7 @@ extern int nfs_getattr(struct mnt_idmap *, const struct path *,
> struct kstat *, u32, unsigned int);
> extern void nfs_access_add_cache(struct inode *, struct nfs_access_entry *, const struct cred *);
> extern void nfs_access_set_mask(struct nfs_access_entry *, u32);
> -extern int nfs_permission(struct mnt_idmap *, struct inode *, int);
> +extern int nfs_permission(const struct mnt_idmap *, struct inode *, int);
> extern int nfs_open(struct inode *, struct file *);
> extern int nfs_attribute_cache_expired(struct inode *inode);
> extern int nfs_revalidate_inode(struct inode *inode, unsigned long flags);
> diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c
> index c7d91476971c..a0be7f1b5993 100644
> --- a/security/selinux/selinuxfs.c
> +++ b/security/selinux/selinuxfs.c
> @@ -1782,7 +1782,7 @@ static struct dentry *sel_make_dir(struct dentry *dir, const char *name,
> return sel_attach(dir, name, inode);
> }
>
> -static int reject_all(struct mnt_idmap *idmap, struct inode *inode, int mask)
> +static int reject_all(const struct mnt_idmap *idmap, struct inode *inode, int mask)
> {
> return -EPERM; // no access for anyone, root or no root.
> }
>
> --
> 2.53.0
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 62+ messages in thread* Re: [PATCH 12/27] fs: port ->permission() to pass const mnt_idmap
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
1 sibling, 0 replies; 62+ messages in thread
From: Paul Moore @ 2026-09-02 19:34 UTC (permalink / raw)
To: Christian Brauner, linux-fsdevel
Cc: Alexander Viro, Jan Kara, Christoph Hellwig, Seth Forshee,
linux-security-module, Mimi Zohar, linux-integrity, Ilya Dryomov,
ceph-devel, Carlos Maiolino, linux-xfs, Miklos Szeredi,
Amir Goldstein, linux-unionfs, Namjae Jeon, linux-cifs,
linux-kernel, Christian Brauner (Amutable)
On Sep 1, 2026 Christian Brauner <brauner@kernel.org> wrote:
>
> Convert to const struct mnt_idmap.
>
> A mount's idmapping is immutable. The only thing that is allowed to be
> modified afterwards is the reference count and that is hidden behind
> mnt_idmap_get() and mnt_idmap_put(). Everything else only ever reads
> from the idmapping. This is the same model that struct cred uses and the
> idmapping is also rather sensitive.
>
> So make the idmap argument const wherever we can. The conversion is done
> from the bottom up so callers can continue to pass a non-const pointer
> to a const parameter until the conversion is finished.
>
> No functional changes.
>
> Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
> Reviewed-by: Jan Kara <jack@suse.cz>
> ---
> Documentation/filesystems/locking.rst | 2 +-
> Documentation/filesystems/vfs.rst | 2 +-
> fs/afs/internal.h | 2 +-
> fs/afs/security.c | 2 +-
> fs/attr.c | 2 +-
> fs/autofs/root.c | 4 ++--
> fs/bad_inode.c | 2 +-
> fs/btrfs/inode.c | 2 +-
> fs/btrfs/ioctl.c | 2 +-
> fs/ceph/inode.c | 2 +-
> fs/ceph/super.h | 2 +-
> fs/coda/coda_linux.h | 2 +-
> fs/coda/dir.c | 2 +-
> fs/coda/pioctl.c | 4 ++--
> fs/ecryptfs/inode.c | 2 +-
> fs/failfs.c | 2 +-
> fs/fuse/dir.c | 2 +-
> fs/gfs2/inode.c | 2 +-
> fs/gfs2/inode.h | 2 +-
> fs/hostfs/hostfs_kern.c | 2 +-
> fs/internal.h | 2 +-
> fs/kernfs/inode.c | 2 +-
> fs/kernfs/kernfs-internal.h | 2 +-
> fs/namei.c | 22 +++++++++++-----------
> fs/nfs/dir.c | 2 +-
> fs/nilfs2/inode.c | 2 +-
> fs/nilfs2/nilfs.h | 2 +-
> fs/ocfs2/file.c | 2 +-
> fs/ocfs2/file.h | 2 +-
> fs/orangefs/inode.c | 2 +-
> fs/orangefs/orangefs-kernel.h | 2 +-
> fs/overlayfs/inode.c | 2 +-
> fs/overlayfs/overlayfs.h | 2 +-
> fs/proc/base.c | 4 ++--
> fs/proc/fd.c | 4 ++--
> fs/proc/fd.h | 2 +-
> fs/proc/proc_sysctl.c | 2 +-
> fs/smb/client/cifsfs.c | 2 +-
> fs/smb/server/vfs.c | 2 +-
> fs/smb/server/vfs.h | 2 +-
> fs/tracefs/inode.c | 2 +-
> include/linux/fs.h | 8 ++++----
> include/linux/nfs_fs.h | 2 +-
> security/selinux/selinuxfs.c | 2 +-
> 44 files changed, 61 insertions(+), 61 deletions(-)
Acked-by: Paul Moore <paul@paul-moore.com> (SELinux)
--
paul-moore.com
^ permalink raw reply [flat|nested] 62+ messages in thread
* [PATCH 13/27] fs: port xattr to const mnt_idmap
2026-09-01 12:14 [PATCH 00/27] fs: port to const struct mnt_idmap Christian Brauner
` (11 preceding siblings ...)
2026-09-01 12:14 ` [PATCH 12/27] fs: port ->permission() to pass " Christian Brauner
@ 2026-09-01 12:14 ` 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
` (13 subsequent siblings)
26 siblings, 2 replies; 62+ messages in thread
From: Christian Brauner @ 2026-09-01 12:14 UTC (permalink / raw)
To: linux-fsdevel
Cc: Alexander Viro, Jan Kara, Christoph Hellwig, Seth Forshee,
Paul Moore, linux-security-module, Mimi Zohar, linux-integrity,
Ilya Dryomov, ceph-devel, Carlos Maiolino, linux-xfs,
Miklos Szeredi, Amir Goldstein, linux-unionfs, Namjae Jeon,
linux-cifs, linux-kernel, Christian Brauner (Amutable)
Convert to const struct mnt_idmap.
A mount's idmapping is immutable. The only thing that is allowed to be
modified afterwards is the reference count and that is hidden behind
mnt_idmap_get() and mnt_idmap_put(). Everything else only ever reads
from the idmapping. This is the same model that struct cred uses and the
idmapping is also rather sensitive.
So make the idmap argument const wherever we can. The conversion is done
from the bottom up so callers can continue to pass a non-const pointer
to a const parameter until the conversion is finished.
No functional changes.
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
---
Documentation/filesystems/locking.rst | 2 +-
fs/9p/xattr.c | 2 +-
fs/afs/xattr.c | 4 ++--
fs/attr.c | 2 +-
fs/btrfs/xattr.c | 6 +++---
fs/ceph/xattr.c | 2 +-
fs/ecryptfs/inode.c | 2 +-
fs/ext2/xattr_security.c | 2 +-
fs/ext2/xattr_trusted.c | 2 +-
fs/ext2/xattr_user.c | 2 +-
fs/ext4/xattr_hurd.c | 2 +-
fs/ext4/xattr_security.c | 2 +-
fs/ext4/xattr_trusted.c | 2 +-
fs/ext4/xattr_user.c | 2 +-
fs/f2fs/xattr.c | 4 ++--
fs/fuse/dir.c | 2 +-
fs/fuse/fuse_i.h | 2 +-
fs/fuse/xattr.c | 2 +-
fs/gfs2/xattr.c | 2 +-
fs/hfs/attr.c | 2 +-
fs/hfsplus/xattr.c | 2 +-
fs/hfsplus/xattr_security.c | 2 +-
fs/hfsplus/xattr_trusted.c | 2 +-
fs/hfsplus/xattr_user.c | 2 +-
fs/jffs2/security.c | 2 +-
fs/jffs2/xattr_trusted.c | 2 +-
fs/jffs2/xattr_user.c | 2 +-
fs/jfs/xattr.c | 4 ++--
fs/kernfs/inode.c | 4 ++--
fs/nfs/nfs4proc.c | 10 +++++-----
fs/ntfs/ea.c | 2 +-
fs/ntfs3/xattr.c | 2 +-
fs/ocfs2/xattr.c | 6 +++---
fs/orangefs/xattr.c | 2 +-
fs/overlayfs/xattrs.c | 4 ++--
fs/pidfs.c | 2 +-
fs/smb/client/xattr.c | 2 +-
fs/smb/server/vfs.c | 24 ++++++++++++------------
fs/smb/server/vfs.h | 20 ++++++++++----------
fs/ubifs/xattr.c | 2 +-
fs/xattr.c | 22 +++++++++++-----------
fs/xfs/xfs_iops.c | 2 +-
fs/xfs/xfs_xattr.c | 2 +-
include/linux/capability.h | 4 ++--
include/linux/fs.h | 2 +-
include/linux/lsm_hook_defs.h | 8 ++++----
include/linux/security.h | 20 ++++++++++----------
include/linux/xattr.h | 20 ++++++++++----------
kernel/bpf/inode.c | 2 +-
mm/shmem.c | 2 +-
net/socket.c | 4 ++--
security/commoncap.c | 8 ++++----
security/integrity/evm/evm_main.c | 4 ++--
security/integrity/ima/ima_appraise.c | 4 ++--
security/security.c | 8 ++++----
security/selinux/hooks.c | 6 +++---
security/smack/smack_lsm.c | 6 +++---
57 files changed, 135 insertions(+), 135 deletions(-)
diff --git a/Documentation/filesystems/locking.rst b/Documentation/filesystems/locking.rst
index 5af7d3bfcd5e..2a91bc9c15f5 100644
--- a/Documentation/filesystems/locking.rst
+++ b/Documentation/filesystems/locking.rst
@@ -148,7 +148,7 @@ prototypes::
struct inode *inode, const char *name, void *buffer,
size_t size);
int (*set)(const struct xattr_handler *handler,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *dentry, struct inode *inode, const char *name,
const void *buffer, size_t size, int flags);
diff --git a/fs/9p/xattr.c b/fs/9p/xattr.c
index 8604e3377ee7..dac06587f67a 100644
--- a/fs/9p/xattr.c
+++ b/fs/9p/xattr.c
@@ -153,7 +153,7 @@ static int v9fs_xattr_handler_get(const struct xattr_handler *handler,
}
static int v9fs_xattr_handler_set(const struct xattr_handler *handler,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *dentry, struct inode *inode,
const char *name, const void *value,
size_t size, int flags)
diff --git a/fs/afs/xattr.c b/fs/afs/xattr.c
index 3770ed236f67..bcffd7236cc9 100644
--- a/fs/afs/xattr.c
+++ b/fs/afs/xattr.c
@@ -97,7 +97,7 @@ static const struct afs_operation_ops afs_store_acl_operation = {
* Set a file's AFS3 ACL.
*/
static int afs_xattr_set_acl(const struct xattr_handler *handler,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *dentry,
struct inode *inode, const char *name,
const void *buffer, size_t size, int flags)
@@ -228,7 +228,7 @@ static const struct afs_operation_ops yfs_store_opaque_acl2_operation = {
* Set a file's YFS ACL.
*/
static int afs_xattr_set_yfs(const struct xattr_handler *handler,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *dentry,
struct inode *inode, const char *name,
const void *buffer, size_t size, int flags)
diff --git a/fs/attr.c b/fs/attr.c
index c5033afe04bf..1845d145fe4c 100644
--- a/fs/attr.c
+++ b/fs/attr.c
@@ -158,7 +158,7 @@ static bool chgrp_ok(const struct mnt_idmap *idmap,
* Should be called as the first thing in ->setattr implementations,
* possibly after taking additional locks.
*/
-int setattr_prepare(struct mnt_idmap *idmap, struct dentry *dentry,
+int setattr_prepare(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *attr)
{
struct inode *inode = d_inode(dentry);
diff --git a/fs/btrfs/xattr.c b/fs/btrfs/xattr.c
index ab55d10bd71f..a06420b9c662 100644
--- a/fs/btrfs/xattr.c
+++ b/fs/btrfs/xattr.c
@@ -353,7 +353,7 @@ static int btrfs_xattr_handler_get(const struct xattr_handler *handler,
}
static int btrfs_xattr_handler_set(const struct xattr_handler *handler,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *unused, struct inode *inode,
const char *name, const void *buffer,
size_t size, int flags)
@@ -395,7 +395,7 @@ static int btrfs_xattr_handler_get_security(const struct xattr_handler *handler,
}
static int btrfs_xattr_handler_set_security(const struct xattr_handler *handler,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *unused,
struct inode *inode,
const char *name,
@@ -413,7 +413,7 @@ static int btrfs_xattr_handler_set_security(const struct xattr_handler *handler,
}
static int btrfs_xattr_handler_set_prop(const struct xattr_handler *handler,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *unused, struct inode *inode,
const char *name, const void *value,
size_t size, int flags)
diff --git a/fs/ceph/xattr.c b/fs/ceph/xattr.c
index cc4ffbbcb719..7d77214c76c6 100644
--- a/fs/ceph/xattr.c
+++ b/fs/ceph/xattr.c
@@ -1352,7 +1352,7 @@ static int ceph_get_xattr_handler(const struct xattr_handler *handler,
}
static int ceph_set_xattr_handler(const struct xattr_handler *handler,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *unused, struct inode *inode,
const char *name, const void *value,
size_t size, int flags)
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index 6dafca14ca78..691b3a24b60a 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -1158,7 +1158,7 @@ static int ecryptfs_xattr_get(const struct xattr_handler *handler,
}
static int ecryptfs_xattr_set(const struct xattr_handler *handler,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *dentry, struct inode *inode,
const char *name, const void *value, size_t size,
int flags)
diff --git a/fs/ext2/xattr_security.c b/fs/ext2/xattr_security.c
index db47b8ab153e..ade074354258 100644
--- a/fs/ext2/xattr_security.c
+++ b/fs/ext2/xattr_security.c
@@ -19,7 +19,7 @@ ext2_xattr_security_get(const struct xattr_handler *handler,
static int
ext2_xattr_security_set(const struct xattr_handler *handler,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *unused, struct inode *inode,
const char *name, const void *value,
size_t size, int flags)
diff --git a/fs/ext2/xattr_trusted.c b/fs/ext2/xattr_trusted.c
index 995f931228ce..0f12d634d6d0 100644
--- a/fs/ext2/xattr_trusted.c
+++ b/fs/ext2/xattr_trusted.c
@@ -26,7 +26,7 @@ ext2_xattr_trusted_get(const struct xattr_handler *handler,
static int
ext2_xattr_trusted_set(const struct xattr_handler *handler,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *unused, struct inode *inode,
const char *name, const void *value,
size_t size, int flags)
diff --git a/fs/ext2/xattr_user.c b/fs/ext2/xattr_user.c
index dd1507231081..48002c033e9c 100644
--- a/fs/ext2/xattr_user.c
+++ b/fs/ext2/xattr_user.c
@@ -30,7 +30,7 @@ ext2_xattr_user_get(const struct xattr_handler *handler,
static int
ext2_xattr_user_set(const struct xattr_handler *handler,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *unused, struct inode *inode,
const char *name, const void *value,
size_t size, int flags)
diff --git a/fs/ext4/xattr_hurd.c b/fs/ext4/xattr_hurd.c
index 8a5842e4cd95..a3ecbff72b10 100644
--- a/fs/ext4/xattr_hurd.c
+++ b/fs/ext4/xattr_hurd.c
@@ -32,7 +32,7 @@ ext4_xattr_hurd_get(const struct xattr_handler *handler,
static int
ext4_xattr_hurd_set(const struct xattr_handler *handler,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *unused, struct inode *inode,
const char *name, const void *value,
size_t size, int flags)
diff --git a/fs/ext4/xattr_security.c b/fs/ext4/xattr_security.c
index 776cf11d24ca..af5b8a93fed1 100644
--- a/fs/ext4/xattr_security.c
+++ b/fs/ext4/xattr_security.c
@@ -23,7 +23,7 @@ ext4_xattr_security_get(const struct xattr_handler *handler,
static int
ext4_xattr_security_set(const struct xattr_handler *handler,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *unused, struct inode *inode,
const char *name, const void *value,
size_t size, int flags)
diff --git a/fs/ext4/xattr_trusted.c b/fs/ext4/xattr_trusted.c
index 9811eb0ab276..458e1982ef83 100644
--- a/fs/ext4/xattr_trusted.c
+++ b/fs/ext4/xattr_trusted.c
@@ -30,7 +30,7 @@ ext4_xattr_trusted_get(const struct xattr_handler *handler,
static int
ext4_xattr_trusted_set(const struct xattr_handler *handler,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *unused, struct inode *inode,
const char *name, const void *value,
size_t size, int flags)
diff --git a/fs/ext4/xattr_user.c b/fs/ext4/xattr_user.c
index 4b70bf4e7626..ad35215f6610 100644
--- a/fs/ext4/xattr_user.c
+++ b/fs/ext4/xattr_user.c
@@ -31,7 +31,7 @@ ext4_xattr_user_get(const struct xattr_handler *handler,
static int
ext4_xattr_user_set(const struct xattr_handler *handler,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *unused, struct inode *inode,
const char *name, const void *value,
size_t size, int flags)
diff --git a/fs/f2fs/xattr.c b/fs/f2fs/xattr.c
index 6728d1488cad..ffe4815ffa6d 100644
--- a/fs/f2fs/xattr.c
+++ b/fs/f2fs/xattr.c
@@ -67,7 +67,7 @@ static int f2fs_xattr_generic_get(const struct xattr_handler *handler,
}
static int f2fs_xattr_generic_set(const struct xattr_handler *handler,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *unused, struct inode *inode,
const char *name, const void *value,
size_t size, int flags)
@@ -111,7 +111,7 @@ static int f2fs_xattr_advise_get(const struct xattr_handler *handler,
}
static int f2fs_xattr_advise_set(const struct xattr_handler *handler,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *unused, struct inode *inode,
const char *name, const void *value,
size_t size, int flags)
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 4b87973c727d..0dbe3c6560f8 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -2143,7 +2143,7 @@ int fuse_flush_times(struct inode *inode, struct fuse_file *ff)
* vmtruncate() doesn't allow for this case, so do the rlimit checking
* and the actual truncation by hand.
*/
-int fuse_do_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+int fuse_do_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *attr, struct file *file)
{
struct inode *inode = d_inode(dentry);
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index a07c75377a30..9ea346ea2e01 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -1189,7 +1189,7 @@ bool fuse_write_update_attr(struct inode *inode, loff_t pos, ssize_t written);
int fuse_flush_times(struct inode *inode, struct fuse_file *ff);
int fuse_write_inode(struct inode *inode, struct writeback_control *wbc);
-int fuse_do_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+int fuse_do_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *attr, struct file *file);
void fuse_unlock_inode(struct inode *inode, bool locked);
diff --git a/fs/fuse/xattr.c b/fs/fuse/xattr.c
index cab2685acc65..53e3c5e6fff0 100644
--- a/fs/fuse/xattr.c
+++ b/fs/fuse/xattr.c
@@ -188,7 +188,7 @@ static int fuse_xattr_get(const struct xattr_handler *handler,
}
static int fuse_xattr_set(const struct xattr_handler *handler,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *dentry, struct inode *inode,
const char *name, const void *value, size_t size,
int flags)
diff --git a/fs/gfs2/xattr.c b/fs/gfs2/xattr.c
index b9f48d6f10a9..0e66e4849b57 100644
--- a/fs/gfs2/xattr.c
+++ b/fs/gfs2/xattr.c
@@ -1229,7 +1229,7 @@ int __gfs2_xattr_set(struct inode *inode, const char *name,
}
static int gfs2_xattr_set(const struct xattr_handler *handler,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *unused, struct inode *inode,
const char *name, const void *value,
size_t size, int flags)
diff --git a/fs/hfs/attr.c b/fs/hfs/attr.c
index f8395cdd1adf..6d737a085461 100644
--- a/fs/hfs/attr.c
+++ b/fs/hfs/attr.c
@@ -121,7 +121,7 @@ static int hfs_xattr_get(const struct xattr_handler *handler,
}
static int hfs_xattr_set(const struct xattr_handler *handler,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *unused, struct inode *inode,
const char *name, const void *value, size_t size,
int flags)
diff --git a/fs/hfsplus/xattr.c b/fs/hfsplus/xattr.c
index 21a1c196c71f..71364e093fa7 100644
--- a/fs/hfsplus/xattr.c
+++ b/fs/hfsplus/xattr.c
@@ -1008,7 +1008,7 @@ static int hfsplus_osx_getxattr(const struct xattr_handler *handler,
}
static int hfsplus_osx_setxattr(const struct xattr_handler *handler,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *unused, struct inode *inode,
const char *name, const void *buffer,
size_t size, int flags)
diff --git a/fs/hfsplus/xattr_security.c b/fs/hfsplus/xattr_security.c
index 90f68ec119cd..1969919c12cb 100644
--- a/fs/hfsplus/xattr_security.c
+++ b/fs/hfsplus/xattr_security.c
@@ -23,7 +23,7 @@ static int hfsplus_security_getxattr(const struct xattr_handler *handler,
}
static int hfsplus_security_setxattr(const struct xattr_handler *handler,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *unused, struct inode *inode,
const char *name, const void *buffer,
size_t size, int flags)
diff --git a/fs/hfsplus/xattr_trusted.c b/fs/hfsplus/xattr_trusted.c
index fdbaebc1c49a..c140a95ab3f0 100644
--- a/fs/hfsplus/xattr_trusted.c
+++ b/fs/hfsplus/xattr_trusted.c
@@ -22,7 +22,7 @@ static int hfsplus_trusted_getxattr(const struct xattr_handler *handler,
}
static int hfsplus_trusted_setxattr(const struct xattr_handler *handler,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *unused, struct inode *inode,
const char *name, const void *buffer,
size_t size, int flags)
diff --git a/fs/hfsplus/xattr_user.c b/fs/hfsplus/xattr_user.c
index 6464b6c3d58d..7e5da15f9937 100644
--- a/fs/hfsplus/xattr_user.c
+++ b/fs/hfsplus/xattr_user.c
@@ -22,7 +22,7 @@ static int hfsplus_user_getxattr(const struct xattr_handler *handler,
}
static int hfsplus_user_setxattr(const struct xattr_handler *handler,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *unused, struct inode *inode,
const char *name, const void *buffer,
size_t size, int flags)
diff --git a/fs/jffs2/security.c b/fs/jffs2/security.c
index 437f3a2c1b54..67330aeb8ae8 100644
--- a/fs/jffs2/security.c
+++ b/fs/jffs2/security.c
@@ -57,7 +57,7 @@ static int jffs2_security_getxattr(const struct xattr_handler *handler,
}
static int jffs2_security_setxattr(const struct xattr_handler *handler,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *unused, struct inode *inode,
const char *name, const void *buffer,
size_t size, int flags)
diff --git a/fs/jffs2/xattr_trusted.c b/fs/jffs2/xattr_trusted.c
index b7c5da2d89bd..85133ad8b449 100644
--- a/fs/jffs2/xattr_trusted.c
+++ b/fs/jffs2/xattr_trusted.c
@@ -25,7 +25,7 @@ static int jffs2_trusted_getxattr(const struct xattr_handler *handler,
}
static int jffs2_trusted_setxattr(const struct xattr_handler *handler,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *unused, struct inode *inode,
const char *name, const void *buffer,
size_t size, int flags)
diff --git a/fs/jffs2/xattr_user.c b/fs/jffs2/xattr_user.c
index f64edce4927b..dcfd3caf1d8b 100644
--- a/fs/jffs2/xattr_user.c
+++ b/fs/jffs2/xattr_user.c
@@ -25,7 +25,7 @@ static int jffs2_user_getxattr(const struct xattr_handler *handler,
}
static int jffs2_user_setxattr(const struct xattr_handler *handler,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *unused, struct inode *inode,
const char *name, const void *buffer,
size_t size, int flags)
diff --git a/fs/jfs/xattr.c b/fs/jfs/xattr.c
index 11d7f74d207b..dcc4a69d44fe 100644
--- a/fs/jfs/xattr.c
+++ b/fs/jfs/xattr.c
@@ -956,7 +956,7 @@ static int jfs_xattr_get(const struct xattr_handler *handler,
}
static int jfs_xattr_set(const struct xattr_handler *handler,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *unused, struct inode *inode,
const char *name, const void *value,
size_t size, int flags)
@@ -975,7 +975,7 @@ static int jfs_xattr_get_os2(const struct xattr_handler *handler,
}
static int jfs_xattr_set_os2(const struct xattr_handler *handler,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *unused, struct inode *inode,
const char *name, const void *value,
size_t size, int flags)
diff --git a/fs/kernfs/inode.c b/fs/kernfs/inode.c
index d53d104e54d5..b348d4cd150b 100644
--- a/fs/kernfs/inode.c
+++ b/fs/kernfs/inode.c
@@ -344,7 +344,7 @@ static int kernfs_vfs_xattr_get(const struct xattr_handler *handler,
}
static int kernfs_vfs_xattr_set(const struct xattr_handler *handler,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *unused, struct inode *inode,
const char *suffix, const void *value,
size_t size, int flags)
@@ -356,7 +356,7 @@ static int kernfs_vfs_xattr_set(const struct xattr_handler *handler,
}
static int kernfs_vfs_user_xattr_set(const struct xattr_handler *handler,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *unused, struct inode *inode,
const char *suffix, const void *value,
size_t size, int flags)
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 04b1987115d5..21e5df7e5251 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -7866,7 +7866,7 @@ int nfs4_lock_delegation_recall(struct file_lock *fl, struct nfs4_state *state,
#define XATTR_NAME_NFSV4_ACL "system.nfs4_acl"
static int nfs4_xattr_set_nfs4_acl(const struct xattr_handler *handler,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *unused, struct inode *inode,
const char *key, const void *buf,
size_t buflen, int flags)
@@ -7889,7 +7889,7 @@ static bool nfs4_xattr_list_nfs4_acl(struct dentry *dentry)
#define XATTR_NAME_NFSV4_DACL "system.nfs4_dacl"
static int nfs4_xattr_set_nfs4_dacl(const struct xattr_handler *handler,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *unused, struct inode *inode,
const char *key, const void *buf,
size_t buflen, int flags)
@@ -7912,7 +7912,7 @@ static bool nfs4_xattr_list_nfs4_dacl(struct dentry *dentry)
#define XATTR_NAME_NFSV4_SACL "system.nfs4_sacl"
static int nfs4_xattr_set_nfs4_sacl(const struct xattr_handler *handler,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *unused, struct inode *inode,
const char *key, const void *buf,
size_t buflen, int flags)
@@ -7935,7 +7935,7 @@ static bool nfs4_xattr_list_nfs4_sacl(struct dentry *dentry)
#ifdef CONFIG_NFS_V4_SECURITY_LABEL
static int nfs4_xattr_set_nfs4_label(const struct xattr_handler *handler,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *unused, struct inode *inode,
const char *key, const void *buf,
size_t buflen, int flags)
@@ -7965,7 +7965,7 @@ static const struct xattr_handler nfs4_xattr_nfs4_label_handler = {
#ifdef CONFIG_NFS_V4_2
static int nfs4_xattr_set_nfs4_user(const struct xattr_handler *handler,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *unused, struct inode *inode,
const char *key, const void *buf,
size_t buflen, int flags)
diff --git a/fs/ntfs/ea.c b/fs/ntfs/ea.c
index 744ea8c446e5..7fd323912510 100644
--- a/fs/ntfs/ea.c
+++ b/fs/ntfs/ea.c
@@ -852,7 +852,7 @@ static int ntfs_validate_fattr(struct ntfs_inode *ni, __le32 fattr)
}
static int ntfs_setxattr(const struct xattr_handler *handler,
- struct mnt_idmap *idmap, struct dentry *unused,
+ const struct mnt_idmap *idmap, struct dentry *unused,
struct inode *inode, const char *name, const void *value,
size_t size, int flags)
{
diff --git a/fs/ntfs3/xattr.c b/fs/ntfs3/xattr.c
index d800735477c3..5644167de863 100644
--- a/fs/ntfs3/xattr.c
+++ b/fs/ntfs3/xattr.c
@@ -863,7 +863,7 @@ static bool ntfs_is_reserved_lxattr(const char *name)
* ntfs_setxattr - inode_operations::setxattr
*/
static noinline int ntfs_setxattr(const struct xattr_handler *handler,
- struct mnt_idmap *idmap, struct dentry *de,
+ const struct mnt_idmap *idmap, struct dentry *de,
struct inode *inode, const char *name,
const void *value, size_t size, int flags)
{
diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
index 35bcbb0ff607..da8e19e21a91 100644
--- a/fs/ocfs2/xattr.c
+++ b/fs/ocfs2/xattr.c
@@ -7503,7 +7503,7 @@ static int ocfs2_xattr_security_get(const struct xattr_handler *handler,
}
static int ocfs2_xattr_security_set(const struct xattr_handler *handler,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *unused, struct inode *inode,
const char *name, const void *value,
size_t size, int flags)
@@ -7598,7 +7598,7 @@ static int ocfs2_xattr_trusted_get(const struct xattr_handler *handler,
}
static int ocfs2_xattr_trusted_set(const struct xattr_handler *handler,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *unused, struct inode *inode,
const char *name, const void *value,
size_t size, int flags)
@@ -7629,7 +7629,7 @@ static int ocfs2_xattr_user_get(const struct xattr_handler *handler,
}
static int ocfs2_xattr_user_set(const struct xattr_handler *handler,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *unused, struct inode *inode,
const char *name, const void *value,
size_t size, int flags)
diff --git a/fs/orangefs/xattr.c b/fs/orangefs/xattr.c
index 885fd3bd5a3d..a49e64566e1e 100644
--- a/fs/orangefs/xattr.c
+++ b/fs/orangefs/xattr.c
@@ -527,7 +527,7 @@ ssize_t orangefs_listxattr(struct dentry *dentry, char *buffer, size_t size)
}
static int orangefs_xattr_set_default(const struct xattr_handler *handler,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *unused,
struct inode *inode,
const char *name,
diff --git a/fs/overlayfs/xattrs.c b/fs/overlayfs/xattrs.c
index 5ae44b9c8790..acc54f6138ef 100644
--- a/fs/overlayfs/xattrs.c
+++ b/fs/overlayfs/xattrs.c
@@ -190,7 +190,7 @@ static int ovl_own_xattr_get(const struct xattr_handler *handler,
}
static int ovl_own_xattr_set(const struct xattr_handler *handler,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *dentry, struct inode *inode,
const char *name, const void *value,
size_t size, int flags)
@@ -217,7 +217,7 @@ static int ovl_other_xattr_get(const struct xattr_handler *handler,
}
static int ovl_other_xattr_set(const struct xattr_handler *handler,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *dentry, struct inode *inode,
const char *name, const void *value,
size_t size, int flags)
diff --git a/fs/pidfs.c b/fs/pidfs.c
index a6a643f15d08..5bc136de8660 100644
--- a/fs/pidfs.c
+++ b/fs/pidfs.c
@@ -1102,7 +1102,7 @@ static int pidfs_xattr_get(const struct xattr_handler *handler,
}
static int pidfs_xattr_set(const struct xattr_handler *handler,
- struct mnt_idmap *idmap, struct dentry *unused,
+ const struct mnt_idmap *idmap, struct dentry *unused,
struct inode *inode, const char *suffix,
const void *value, size_t size, int flags)
{
diff --git a/fs/smb/client/xattr.c b/fs/smb/client/xattr.c
index 5091f6c0d7fe..f6c9343016f7 100644
--- a/fs/smb/client/xattr.c
+++ b/fs/smb/client/xattr.c
@@ -91,7 +91,7 @@ static int cifs_creation_time_set(unsigned int xid, struct cifs_tcon *pTcon,
}
static int cifs_xattr_set(const struct xattr_handler *handler,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *dentry, struct inode *inode,
const char *name, const void *value,
size_t size, int flags)
diff --git a/fs/smb/server/vfs.c b/fs/smb/server/vfs.c
index 0361de56edc2..3c4d18a4e8d5 100644
--- a/fs/smb/server/vfs.c
+++ b/fs/smb/server/vfs.c
@@ -216,7 +216,7 @@ int ksmbd_vfs_mkdir(struct ksmbd_work *work, const char *name, umode_t mode)
return err;
}
-static ssize_t ksmbd_vfs_getcasexattr(struct mnt_idmap *idmap,
+static ssize_t ksmbd_vfs_getcasexattr(const struct mnt_idmap *idmap,
struct dentry *dentry, char *attr_name,
int attr_name_len, char **attr_value)
{
@@ -841,7 +841,7 @@ ssize_t ksmbd_vfs_listxattr(struct dentry *dentry, char **list)
return size;
}
-static ssize_t ksmbd_vfs_xattr_len(struct mnt_idmap *idmap,
+static ssize_t ksmbd_vfs_xattr_len(const struct mnt_idmap *idmap,
struct dentry *dentry, char *xattr_name)
{
return vfs_getxattr(idmap, dentry, xattr_name, NULL, 0);
@@ -856,7 +856,7 @@ static ssize_t ksmbd_vfs_xattr_len(struct mnt_idmap *idmap,
*
* Return: read xattr value length on success, otherwise error
*/
-ssize_t ksmbd_vfs_getxattr(struct mnt_idmap *idmap,
+ssize_t ksmbd_vfs_getxattr(const struct mnt_idmap *idmap,
struct dentry *dentry,
char *xattr_name, char **xattr_buf)
{
@@ -893,7 +893,7 @@ ssize_t ksmbd_vfs_getxattr(struct mnt_idmap *idmap,
*
* Return: 0 on success, otherwise error
*/
-int ksmbd_vfs_setxattr(struct mnt_idmap *idmap,
+int ksmbd_vfs_setxattr(const struct mnt_idmap *idmap,
const struct path *path, const char *attr_name,
void *attr_value, size_t attr_size, int flags,
bool get_write)
@@ -1177,7 +1177,7 @@ int ksmbd_vfs_query_allocated_ranges(struct ksmbd_file *fp, loff_t start,
return ret;
}
-int ksmbd_vfs_remove_xattr(struct mnt_idmap *idmap,
+int ksmbd_vfs_remove_xattr(const struct mnt_idmap *idmap,
const struct path *path, char *attr_name,
bool get_write)
{
@@ -1511,7 +1511,7 @@ int ksmbd_vfs_remove_acl_xattrs(struct mnt_idmap *idmap,
return err;
}
-int ksmbd_vfs_remove_sd_xattrs(struct mnt_idmap *idmap, const struct path *path)
+int ksmbd_vfs_remove_sd_xattrs(const struct mnt_idmap *idmap, const struct path *path)
{
char *name, *xattr_list = NULL;
ssize_t xattr_list_len;
@@ -1606,7 +1606,7 @@ static struct xattr_smb_acl *ksmbd_vfs_make_xattr_posix_acl(const struct mnt_idm
}
int ksmbd_vfs_set_sd_xattr(struct ksmbd_conn *conn,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
const struct path *path,
struct smb_ntsd *pntsd, int len,
bool get_write)
@@ -1673,7 +1673,7 @@ int ksmbd_vfs_set_sd_xattr(struct ksmbd_conn *conn,
}
int ksmbd_vfs_get_sd_xattr(struct ksmbd_conn *conn,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *dentry,
struct smb_ntsd **pntsd)
{
@@ -1742,7 +1742,7 @@ int ksmbd_vfs_get_sd_xattr(struct ksmbd_conn *conn,
return rc;
}
-int ksmbd_vfs_set_dos_attrib_xattr(struct mnt_idmap *idmap,
+int ksmbd_vfs_set_dos_attrib_xattr(const struct mnt_idmap *idmap,
const struct path *path,
struct xattr_dos_attrib *da,
bool get_write)
@@ -1764,7 +1764,7 @@ int ksmbd_vfs_set_dos_attrib_xattr(struct mnt_idmap *idmap,
return err;
}
-int ksmbd_vfs_get_dos_attrib_xattr(struct mnt_idmap *idmap,
+int ksmbd_vfs_get_dos_attrib_xattr(const struct mnt_idmap *idmap,
struct dentry *dentry,
struct xattr_dos_attrib *da)
{
@@ -1820,7 +1820,7 @@ void *ksmbd_vfs_init_kstat(char **p, struct ksmbd_kstat *ksmbd_kstat)
}
int ksmbd_vfs_fill_dentry_attrs(struct ksmbd_work *work,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *dentry,
struct ksmbd_kstat *ksmbd_kstat)
{
@@ -1895,7 +1895,7 @@ int ksmbd_vfs_fill_dentry_attrs(struct ksmbd_work *work,
return 0;
}
-ssize_t ksmbd_vfs_casexattr_len(struct mnt_idmap *idmap,
+ssize_t ksmbd_vfs_casexattr_len(const struct mnt_idmap *idmap,
struct dentry *dentry, char *attr_name,
int attr_name_len)
{
diff --git a/fs/smb/server/vfs.h b/fs/smb/server/vfs.h
index 9c8b5b288926..5e34fc61b48b 100644
--- a/fs/smb/server/vfs.h
+++ b/fs/smb/server/vfs.h
@@ -104,20 +104,20 @@ int ksmbd_vfs_copy_file_ranges(struct ksmbd_work *work,
unsigned int *chunk_size_written,
loff_t *total_size_written);
ssize_t ksmbd_vfs_listxattr(struct dentry *dentry, char **list);
-ssize_t ksmbd_vfs_getxattr(struct mnt_idmap *idmap,
+ssize_t ksmbd_vfs_getxattr(const struct mnt_idmap *idmap,
struct dentry *dentry,
char *xattr_name,
char **xattr_buf);
-ssize_t ksmbd_vfs_casexattr_len(struct mnt_idmap *idmap,
+ssize_t ksmbd_vfs_casexattr_len(const struct mnt_idmap *idmap,
struct dentry *dentry, char *attr_name,
int attr_name_len);
-int ksmbd_vfs_setxattr(struct mnt_idmap *idmap,
+int ksmbd_vfs_setxattr(const struct mnt_idmap *idmap,
const struct path *path, const char *attr_name,
void *attr_value, size_t attr_size, int flags,
bool get_write);
int ksmbd_vfs_xattr_stream_name(char *stream_name, char **xattr_stream_name,
size_t *xattr_stream_name_size, int s_type);
-int ksmbd_vfs_remove_xattr(struct mnt_idmap *idmap,
+int ksmbd_vfs_remove_xattr(const struct mnt_idmap *idmap,
const struct path *path, char *attr_name,
bool get_write);
int ksmbd_vfs_kern_path(struct ksmbd_work *work, char *name,
@@ -147,28 +147,28 @@ int ksmbd_vfs_query_allocated_ranges(struct ksmbd_file *fp, loff_t start,
int ksmbd_vfs_unlink(struct file *filp);
void *ksmbd_vfs_init_kstat(char **p, struct ksmbd_kstat *ksmbd_kstat);
int ksmbd_vfs_fill_dentry_attrs(struct ksmbd_work *work,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *dentry,
struct ksmbd_kstat *ksmbd_kstat);
void ksmbd_vfs_posix_lock_wait(struct file_lock *flock);
void ksmbd_vfs_posix_lock_unblock(struct file_lock *flock);
int ksmbd_vfs_remove_acl_xattrs(struct mnt_idmap *idmap,
const struct path *path);
-int ksmbd_vfs_remove_sd_xattrs(struct mnt_idmap *idmap, const struct path *path);
+int ksmbd_vfs_remove_sd_xattrs(const struct mnt_idmap *idmap, const struct path *path);
int ksmbd_vfs_set_sd_xattr(struct ksmbd_conn *conn,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
const struct path *path,
struct smb_ntsd *pntsd, int len,
bool get_write);
int ksmbd_vfs_get_sd_xattr(struct ksmbd_conn *conn,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *dentry,
struct smb_ntsd **pntsd);
-int ksmbd_vfs_set_dos_attrib_xattr(struct mnt_idmap *idmap,
+int ksmbd_vfs_set_dos_attrib_xattr(const struct mnt_idmap *idmap,
const struct path *path,
struct xattr_dos_attrib *da,
bool get_write);
-int ksmbd_vfs_get_dos_attrib_xattr(struct mnt_idmap *idmap,
+int ksmbd_vfs_get_dos_attrib_xattr(const struct mnt_idmap *idmap,
struct dentry *dentry,
struct xattr_dos_attrib *da);
int ksmbd_vfs_set_init_posix_acl(struct mnt_idmap *idmap,
diff --git a/fs/ubifs/xattr.c b/fs/ubifs/xattr.c
index b5a9ab9d8a10..3b0e8a270f59 100644
--- a/fs/ubifs/xattr.c
+++ b/fs/ubifs/xattr.c
@@ -660,7 +660,7 @@ static int xattr_get(const struct xattr_handler *handler,
}
static int xattr_set(const struct xattr_handler *handler,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *dentry, struct inode *inode,
const char *name, const void *value,
size_t size, int flags)
diff --git a/fs/xattr.c b/fs/xattr.c
index c08f188748a9..acdaafb0c7c1 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -123,7 +123,7 @@ static inline int xattr_permission_error(int mask)
* because different namespaces have very different rules.
*/
static int
-xattr_permission(struct mnt_idmap *idmap, struct inode *inode,
+xattr_permission(const struct mnt_idmap *idmap, struct inode *inode,
const char *name, int mask)
{
if (mask & MAY_WRITE) {
@@ -204,7 +204,7 @@ xattr_supports_user_prefix(struct inode *inode)
EXPORT_SYMBOL(xattr_supports_user_prefix);
int
-__vfs_setxattr(struct mnt_idmap *idmap, struct dentry *dentry,
+__vfs_setxattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct inode *inode, const char *name, const void *value,
size_t size, int flags)
{
@@ -242,7 +242,7 @@ EXPORT_SYMBOL(__vfs_setxattr);
* is executed. It also assumes that the caller will make the appropriate
* permission checks.
*/
-int __vfs_setxattr_noperm(struct mnt_idmap *idmap,
+int __vfs_setxattr_noperm(const struct mnt_idmap *idmap,
struct dentry *dentry, const char *name,
const void *value, size_t size, int flags)
{
@@ -295,7 +295,7 @@ int __vfs_setxattr_noperm(struct mnt_idmap *idmap,
* a delegation was broken on, NULL if none.
*/
int
-__vfs_setxattr_locked(struct mnt_idmap *idmap, struct dentry *dentry,
+__vfs_setxattr_locked(const struct mnt_idmap *idmap, struct dentry *dentry,
const char *name, const void *value, size_t size,
int flags, struct delegated_inode *delegated_inode)
{
@@ -324,7 +324,7 @@ __vfs_setxattr_locked(struct mnt_idmap *idmap, struct dentry *dentry,
EXPORT_SYMBOL_GPL(__vfs_setxattr_locked);
int
-vfs_setxattr(struct mnt_idmap *idmap, struct dentry *dentry,
+vfs_setxattr(const struct mnt_idmap *idmap, struct dentry *dentry,
const char *name, const void *value, size_t size, int flags)
{
struct inode *inode = dentry->d_inode;
@@ -358,7 +358,7 @@ vfs_setxattr(struct mnt_idmap *idmap, struct dentry *dentry,
EXPORT_SYMBOL_GPL(vfs_setxattr);
static ssize_t
-xattr_getsecurity(struct mnt_idmap *idmap, struct inode *inode,
+xattr_getsecurity(const struct mnt_idmap *idmap, struct inode *inode,
const char *name, void *value, size_t size)
{
void *buffer = NULL;
@@ -395,7 +395,7 @@ xattr_getsecurity(struct mnt_idmap *idmap, struct inode *inode,
* Returns the result of alloc, if failed, or the getxattr operation.
*/
int
-vfs_getxattr_alloc(struct mnt_idmap *idmap, struct dentry *dentry,
+vfs_getxattr_alloc(const struct mnt_idmap *idmap, struct dentry *dentry,
const char *name, char **xattr_value, size_t xattr_size,
gfp_t flags)
{
@@ -448,7 +448,7 @@ __vfs_getxattr(struct dentry *dentry, struct inode *inode, const char *name,
EXPORT_SYMBOL(__vfs_getxattr);
ssize_t
-vfs_getxattr(struct mnt_idmap *idmap, struct dentry *dentry,
+vfs_getxattr(const struct mnt_idmap *idmap, struct dentry *dentry,
const char *name, void *value, size_t size)
{
struct inode *inode = dentry->d_inode;
@@ -527,7 +527,7 @@ vfs_listxattr(struct dentry *dentry, char *list, size_t size)
EXPORT_SYMBOL_GPL(vfs_listxattr);
int
-__vfs_removexattr(struct mnt_idmap *idmap, struct dentry *dentry,
+__vfs_removexattr(const struct mnt_idmap *idmap, struct dentry *dentry,
const char *name)
{
struct inode *inode = d_inode(dentry);
@@ -557,7 +557,7 @@ EXPORT_SYMBOL(__vfs_removexattr);
* a delegation was broken on, NULL if none.
*/
int
-__vfs_removexattr_locked(struct mnt_idmap *idmap,
+__vfs_removexattr_locked(const struct mnt_idmap *idmap,
struct dentry *dentry, const char *name,
struct delegated_inode *delegated_inode)
{
@@ -589,7 +589,7 @@ __vfs_removexattr_locked(struct mnt_idmap *idmap,
EXPORT_SYMBOL_GPL(__vfs_removexattr_locked);
int
-vfs_removexattr(struct mnt_idmap *idmap, struct dentry *dentry,
+vfs_removexattr(const struct mnt_idmap *idmap, struct dentry *dentry,
const char *name)
{
struct inode *inode = dentry->d_inode;
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index df5e7c1b2334..b652f129c85e 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -754,7 +754,7 @@ xfs_vn_getattr(
static int
xfs_vn_change_ok(
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *dentry,
struct iattr *iattr)
{
diff --git a/fs/xfs/xfs_xattr.c b/fs/xfs/xfs_xattr.c
index 1efe6c8139b2..b059a9714d11 100644
--- a/fs/xfs/xfs_xattr.c
+++ b/fs/xfs/xfs_xattr.c
@@ -169,7 +169,7 @@ xfs_xattr_flags_to_op(
static int
xfs_xattr_set(const struct xattr_handler *handler,
- struct mnt_idmap *idmap, struct dentry *unused,
+ const struct mnt_idmap *idmap, struct dentry *unused,
struct inode *inode, const char *name, const void *value,
size_t size, int flags)
{
diff --git a/include/linux/capability.h b/include/linux/capability.h
index c39a2bbefc47..8ab509c4e1ef 100644
--- a/include/linux/capability.h
+++ b/include/linux/capability.h
@@ -210,11 +210,11 @@ static inline bool checkpoint_restore_ns_capable_noaudit(struct user_namespace *
}
/* audit system wants to get cap info from files as well */
-int get_vfs_caps_from_disk(struct mnt_idmap *idmap,
+int get_vfs_caps_from_disk(const struct mnt_idmap *idmap,
const struct dentry *dentry,
struct cpu_vfs_cap_data *cpu_caps);
-int cap_convert_nscap(struct mnt_idmap *idmap, struct dentry *dentry,
+int cap_convert_nscap(const struct mnt_idmap *idmap, struct dentry *dentry,
const void **ivalue, size_t size);
#endif /* !_LINUX_CAPABILITY_H */
diff --git a/include/linux/fs.h b/include/linux/fs.h
index f815594dd8cb..08166900931a 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -3399,7 +3399,7 @@ static inline bool generic_ci_validate_strict_name(struct inode *dir,
int may_setattr(const struct mnt_idmap *idmap, struct inode *inode,
unsigned int ia_valid);
-int setattr_prepare(struct mnt_idmap *, struct dentry *, struct iattr *);
+int setattr_prepare(const struct mnt_idmap *, struct dentry *, struct iattr *);
extern int inode_newsize_ok(const struct inode *, loff_t offset);
void setattr_copy(const struct mnt_idmap *, struct inode *inode,
const struct iattr *attr);
diff --git a/include/linux/lsm_hook_defs.h b/include/linux/lsm_hook_defs.h
index 30897590258f..e8638f7d2245 100644
--- a/include/linux/lsm_hook_defs.h
+++ b/include/linux/lsm_hook_defs.h
@@ -146,14 +146,14 @@ LSM_HOOK(void, LSM_RET_VOID, inode_post_setattr, struct mnt_idmap *idmap,
struct dentry *dentry, int ia_valid)
LSM_HOOK(int, 0, inode_getattr, const struct path *path)
LSM_HOOK(int, 0, inode_xattr_skipcap, const char *name)
-LSM_HOOK(int, 0, inode_setxattr, struct mnt_idmap *idmap,
+LSM_HOOK(int, 0, inode_setxattr, const struct mnt_idmap *idmap,
struct dentry *dentry, const char *name, const void *value,
size_t size, int flags)
LSM_HOOK(void, LSM_RET_VOID, inode_post_setxattr, struct dentry *dentry,
const char *name, const void *value, size_t size, int flags)
LSM_HOOK(int, 0, inode_getxattr, struct dentry *dentry, const char *name)
LSM_HOOK(int, 0, inode_listxattr, struct dentry *dentry)
-LSM_HOOK(int, 0, inode_removexattr, struct mnt_idmap *idmap,
+LSM_HOOK(int, 0, inode_removexattr, const struct mnt_idmap *idmap,
struct dentry *dentry, const char *name)
LSM_HOOK(void, LSM_RET_VOID, inode_post_removexattr, struct dentry *dentry,
const char *name)
@@ -170,9 +170,9 @@ LSM_HOOK(int, 0, inode_remove_acl, const struct mnt_idmap *idmap,
LSM_HOOK(void, LSM_RET_VOID, inode_post_remove_acl, const struct mnt_idmap *idmap,
struct dentry *dentry, const char *acl_name)
LSM_HOOK(int, 0, inode_need_killpriv, struct dentry *dentry)
-LSM_HOOK(int, 0, inode_killpriv, struct mnt_idmap *idmap,
+LSM_HOOK(int, 0, inode_killpriv, const struct mnt_idmap *idmap,
struct dentry *dentry)
-LSM_HOOK(int, -EOPNOTSUPP, inode_getsecurity, struct mnt_idmap *idmap,
+LSM_HOOK(int, -EOPNOTSUPP, inode_getsecurity, const struct mnt_idmap *idmap,
struct inode *inode, const char *name, void **buffer, bool alloc)
LSM_HOOK(int, -EOPNOTSUPP, inode_setsecurity, struct inode *inode,
const char *name, const void *value, size_t size, int flags)
diff --git a/include/linux/security.h b/include/linux/security.h
index 12bc12e243bf..d5832750418a 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -188,8 +188,8 @@ int cap_inode_setxattr(struct dentry *dentry, const char *name,
int cap_inode_removexattr(const struct mnt_idmap *idmap,
struct dentry *dentry, const char *name);
int cap_inode_need_killpriv(struct dentry *dentry);
-int cap_inode_killpriv(struct mnt_idmap *idmap, struct dentry *dentry);
-int cap_inode_getsecurity(struct mnt_idmap *idmap,
+int cap_inode_killpriv(const struct mnt_idmap *idmap, struct dentry *dentry);
+int cap_inode_getsecurity(const struct mnt_idmap *idmap,
struct inode *inode, const char *name, void **buffer,
bool alloc);
extern int cap_mmap_addr(unsigned long addr);
@@ -427,7 +427,7 @@ int security_inode_setattr(struct mnt_idmap *idmap,
void security_inode_post_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
int ia_valid);
int security_inode_getattr(const struct path *path);
-int security_inode_setxattr(struct mnt_idmap *idmap,
+int security_inode_setxattr(const struct mnt_idmap *idmap,
struct dentry *dentry, const char *name,
const void *value, size_t size, int flags);
int security_inode_set_acl(const struct mnt_idmap *idmap,
@@ -446,7 +446,7 @@ void security_inode_post_setxattr(struct dentry *dentry, const char *name,
const void *value, size_t size, int flags);
int security_inode_getxattr(struct dentry *dentry, const char *name);
int security_inode_listxattr(struct dentry *dentry);
-int security_inode_removexattr(struct mnt_idmap *idmap,
+int security_inode_removexattr(const struct mnt_idmap *idmap,
struct dentry *dentry, const char *name);
void security_inode_post_removexattr(struct dentry *dentry, const char *name);
int security_inode_file_setattr(struct dentry *dentry,
@@ -454,8 +454,8 @@ int security_inode_file_setattr(struct dentry *dentry,
int security_inode_file_getattr(struct dentry *dentry,
struct file_kattr *fa);
int security_inode_need_killpriv(struct dentry *dentry);
-int security_inode_killpriv(struct mnt_idmap *idmap, struct dentry *dentry);
-int security_inode_getsecurity(struct mnt_idmap *idmap,
+int security_inode_killpriv(const struct mnt_idmap *idmap, struct dentry *dentry);
+int security_inode_getsecurity(const struct mnt_idmap *idmap,
struct inode *inode, const char *name,
void **buffer, bool alloc);
int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags);
@@ -996,7 +996,7 @@ static inline int security_inode_getattr(const struct path *path)
return 0;
}
-static inline int security_inode_setxattr(struct mnt_idmap *idmap,
+static inline int security_inode_setxattr(const struct mnt_idmap *idmap,
struct dentry *dentry, const char *name, const void *value,
size_t size, int flags)
{
@@ -1050,7 +1050,7 @@ static inline int security_inode_listxattr(struct dentry *dentry)
return 0;
}
-static inline int security_inode_removexattr(struct mnt_idmap *idmap,
+static inline int security_inode_removexattr(const struct mnt_idmap *idmap,
struct dentry *dentry,
const char *name)
{
@@ -1078,13 +1078,13 @@ static inline int security_inode_need_killpriv(struct dentry *dentry)
return cap_inode_need_killpriv(dentry);
}
-static inline int security_inode_killpriv(struct mnt_idmap *idmap,
+static inline int security_inode_killpriv(const struct mnt_idmap *idmap,
struct dentry *dentry)
{
return cap_inode_killpriv(idmap, dentry);
}
-static inline int security_inode_getsecurity(struct mnt_idmap *idmap,
+static inline int security_inode_getsecurity(const struct mnt_idmap *idmap,
struct inode *inode,
const char *name, void **buffer,
bool alloc)
diff --git a/include/linux/xattr.h b/include/linux/xattr.h
index 54ac3cbc133f..4cc4257de084 100644
--- a/include/linux/xattr.h
+++ b/include/linux/xattr.h
@@ -47,7 +47,7 @@ struct xattr_handler {
struct inode *inode, const char *name, void *buffer,
size_t size);
int (*set)(const struct xattr_handler *,
- struct mnt_idmap *idmap, struct dentry *dentry,
+ const struct mnt_idmap *idmap, struct dentry *dentry,
struct inode *inode, const char *name, const void *buffer,
size_t size, int flags);
};
@@ -77,25 +77,25 @@ struct xattr {
};
ssize_t __vfs_getxattr(struct dentry *, struct inode *, const char *, void *, size_t);
-ssize_t vfs_getxattr(struct mnt_idmap *, struct dentry *, const char *,
+ssize_t vfs_getxattr(const struct mnt_idmap *, struct dentry *, const char *,
void *, size_t);
ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size);
-int __vfs_setxattr(struct mnt_idmap *, struct dentry *, struct inode *,
+int __vfs_setxattr(const struct mnt_idmap *, struct dentry *, struct inode *,
const char *, const void *, size_t, int);
-int __vfs_setxattr_noperm(struct mnt_idmap *, struct dentry *,
+int __vfs_setxattr_noperm(const struct mnt_idmap *, struct dentry *,
const char *, const void *, size_t, int);
-int __vfs_setxattr_locked(struct mnt_idmap *, struct dentry *,
+int __vfs_setxattr_locked(const struct mnt_idmap *, struct dentry *,
const char *, const void *, size_t, int,
struct delegated_inode *);
-int vfs_setxattr(struct mnt_idmap *, struct dentry *, const char *,
+int vfs_setxattr(const struct mnt_idmap *, struct dentry *, const char *,
const void *, size_t, int);
-int __vfs_removexattr(struct mnt_idmap *, struct dentry *, const char *);
-int __vfs_removexattr_locked(struct mnt_idmap *, struct dentry *,
+int __vfs_removexattr(const struct mnt_idmap *, struct dentry *, const char *);
+int __vfs_removexattr_locked(const struct mnt_idmap *, struct dentry *,
const char *, struct delegated_inode *);
-int vfs_removexattr(struct mnt_idmap *, struct dentry *, const char *);
+int vfs_removexattr(const struct mnt_idmap *, struct dentry *, const char *);
ssize_t generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size);
-int vfs_getxattr_alloc(struct mnt_idmap *idmap,
+int vfs_getxattr_alloc(const struct mnt_idmap *idmap,
struct dentry *dentry, const char *name,
char **xattr_value, size_t size, gfp_t flags);
diff --git a/kernel/bpf/inode.c b/kernel/bpf/inode.c
index 7837968c0842..11174037a9ca 100644
--- a/kernel/bpf/inode.c
+++ b/kernel/bpf/inode.c
@@ -874,7 +874,7 @@ enum {
};
static int bpf_fs_xattr_set(const struct xattr_handler *handler,
- struct mnt_idmap *idmap, struct dentry *unused,
+ const struct mnt_idmap *idmap, struct dentry *unused,
struct inode *inode, const char *name,
const void *value, size_t size, int flags)
{
diff --git a/mm/shmem.c b/mm/shmem.c
index 9ab5231c4dfe..ed633b3bc38d 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -4264,7 +4264,7 @@ static int shmem_xattr_handler_get(const struct xattr_handler *handler,
}
static int shmem_xattr_handler_set(const struct xattr_handler *handler,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *unused, struct inode *inode,
const char *name, const void *value,
size_t size, int flags)
diff --git a/net/socket.c b/net/socket.c
index c05d86e63abf..052273ad081a 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -422,7 +422,7 @@ static const struct xattr_handler sockfs_xattr_handler = {
};
static int sockfs_security_xattr_set(const struct xattr_handler *handler,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *dentry, struct inode *inode,
const char *suffix, const void *value,
size_t size, int flags)
@@ -447,7 +447,7 @@ static int sockfs_user_xattr_get(const struct xattr_handler *handler,
}
static int sockfs_user_xattr_set(const struct xattr_handler *handler,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *dentry, struct inode *inode,
const char *suffix, const void *value,
size_t size, int flags)
diff --git a/security/commoncap.c b/security/commoncap.c
index 9361393fd756..d47ab3022343 100644
--- a/security/commoncap.c
+++ b/security/commoncap.c
@@ -348,7 +348,7 @@ int cap_inode_need_killpriv(struct dentry *dentry)
*
* Return: 0 if successful, -ve on error.
*/
-int cap_inode_killpriv(struct mnt_idmap *idmap, struct dentry *dentry)
+int cap_inode_killpriv(const struct mnt_idmap *idmap, struct dentry *dentry)
{
int error;
@@ -417,7 +417,7 @@ static bool is_v3header(int size, const struct vfs_cap_data *cap)
* by the integrity subsystem, which really wants the unconverted values -
* so that's good.
*/
-int cap_inode_getsecurity(struct mnt_idmap *idmap,
+int cap_inode_getsecurity(const struct mnt_idmap *idmap,
struct inode *inode, const char *name, void **buffer,
bool alloc)
{
@@ -566,7 +566,7 @@ static bool validheader(size_t size, const struct vfs_cap_data *cap)
*
* Return: On success, return the new size; on error, return < 0.
*/
-int cap_convert_nscap(struct mnt_idmap *idmap, struct dentry *dentry,
+int cap_convert_nscap(const struct mnt_idmap *idmap, struct dentry *dentry,
const void **ivalue, size_t size)
{
struct vfs_ns_cap_data *nscap;
@@ -672,7 +672,7 @@ static inline int bprm_caps_from_vfs_caps(struct cpu_vfs_cap_data *caps,
* permissions. On non-idmapped mounts or if permission checking is to be
* performed on the raw inode simply pass @nop_mnt_idmap.
*/
-int get_vfs_caps_from_disk(struct mnt_idmap *idmap,
+int get_vfs_caps_from_disk(const struct mnt_idmap *idmap,
const struct dentry *dentry,
struct cpu_vfs_cap_data *cpu_caps)
{
diff --git a/security/integrity/evm/evm_main.c b/security/integrity/evm/evm_main.c
index aaf228ebed7c..94928549bfab 100644
--- a/security/integrity/evm/evm_main.c
+++ b/security/integrity/evm/evm_main.c
@@ -607,7 +607,7 @@ static int evm_protect_xattr(const struct mnt_idmap *idmap,
* userspace from writing HMAC value. Writing 'security.evm' requires
* requires CAP_SYS_ADMIN privileges.
*/
-static int evm_inode_setxattr(struct mnt_idmap *idmap, struct dentry *dentry,
+static int evm_inode_setxattr(const struct mnt_idmap *idmap, struct dentry *dentry,
const char *xattr_name, const void *xattr_value,
size_t xattr_value_len, int flags)
{
@@ -639,7 +639,7 @@ static int evm_inode_setxattr(struct mnt_idmap *idmap, struct dentry *dentry,
* Removing 'security.evm' requires CAP_SYS_ADMIN privileges and that
* the current value is valid.
*/
-static int evm_inode_removexattr(struct mnt_idmap *idmap, struct dentry *dentry,
+static int evm_inode_removexattr(const struct mnt_idmap *idmap, struct dentry *dentry,
const char *xattr_name)
{
/* Policy permits modification of the protected xattrs even though
diff --git a/security/integrity/ima/ima_appraise.c b/security/integrity/ima/ima_appraise.c
index 1aed041c127a..cfc20c63a814 100644
--- a/security/integrity/ima/ima_appraise.c
+++ b/security/integrity/ima/ima_appraise.c
@@ -757,7 +757,7 @@ static int validate_hash_algo(struct dentry *dentry,
return -EACCES;
}
-static int ima_inode_setxattr(struct mnt_idmap *idmap, struct dentry *dentry,
+static int ima_inode_setxattr(const struct mnt_idmap *idmap, struct dentry *dentry,
const char *xattr_name, const void *xattr_value,
size_t xattr_value_len, int flags)
{
@@ -799,7 +799,7 @@ static int ima_inode_set_acl(const struct mnt_idmap *idmap, struct dentry *dentr
return 0;
}
-static int ima_inode_removexattr(struct mnt_idmap *idmap, struct dentry *dentry,
+static int ima_inode_removexattr(const struct mnt_idmap *idmap, struct dentry *dentry,
const char *xattr_name)
{
int result, digsig = -1;
diff --git a/security/security.c b/security/security.c
index e81dcda3050b..e3a14c958bc4 100644
--- a/security/security.c
+++ b/security/security.c
@@ -1921,7 +1921,7 @@ int security_inode_getattr(const struct path *path)
*
* Return: Returns 0 if permission is granted.
*/
-int security_inode_setxattr(struct mnt_idmap *idmap,
+int security_inode_setxattr(const struct mnt_idmap *idmap,
struct dentry *dentry, const char *name,
const void *value, size_t size, int flags)
{
@@ -2108,7 +2108,7 @@ int security_inode_listxattr(struct dentry *dentry)
*
* Return: Returns 0 if permission is granted.
*/
-int security_inode_removexattr(struct mnt_idmap *idmap,
+int security_inode_removexattr(const struct mnt_idmap *idmap,
struct dentry *dentry, const char *name)
{
int rc;
@@ -2197,7 +2197,7 @@ int security_inode_need_killpriv(struct dentry *dentry)
* Return: Return 0 on success. If error is returned, then the operation
* causing setuid bit removal is failed.
*/
-int security_inode_killpriv(struct mnt_idmap *idmap,
+int security_inode_killpriv(const struct mnt_idmap *idmap,
struct dentry *dentry)
{
return call_int_hook(inode_killpriv, idmap, dentry);
@@ -2219,7 +2219,7 @@ int security_inode_killpriv(struct mnt_idmap *idmap,
*
* Return: Returns size of buffer on success.
*/
-int security_inode_getsecurity(struct mnt_idmap *idmap,
+int security_inode_getsecurity(const struct mnt_idmap *idmap,
struct inode *inode, const char *name,
void **buffer, bool alloc)
{
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index 672d6374d8b0..b7c6eba08fdc 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -3367,7 +3367,7 @@ static int selinux_inode_xattr_skipcap(const char *name)
return !strcmp(name, XATTR_NAME_SELINUX);
}
-static int selinux_inode_setxattr(struct mnt_idmap *idmap,
+static int selinux_inode_setxattr(const struct mnt_idmap *idmap,
struct dentry *dentry, const char *name,
const void *value, size_t size, int flags)
{
@@ -3526,7 +3526,7 @@ static int selinux_inode_listxattr(struct dentry *dentry)
return dentry_has_perm(cred, dentry, FILE__GETATTR);
}
-static int selinux_inode_removexattr(struct mnt_idmap *idmap,
+static int selinux_inode_removexattr(const struct mnt_idmap *idmap,
struct dentry *dentry, const char *name)
{
/* if not a selinux xattr, only check the ordinary setattr perm */
@@ -3606,7 +3606,7 @@ static int selinux_path_notify(const struct path *path, u64 mask,
*
* Permission check is handled by selinux_inode_getxattr hook.
*/
-static int selinux_inode_getsecurity(struct mnt_idmap *idmap,
+static int selinux_inode_getsecurity(const struct mnt_idmap *idmap,
struct inode *inode, const char *name,
void **buffer, bool alloc)
{
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
index 244cdb49e928..df4fc6ff26aa 100644
--- a/security/smack/smack_lsm.c
+++ b/security/smack/smack_lsm.c
@@ -1348,7 +1348,7 @@ static int smack_inode_xattr_skipcap(const char *name)
*
* Returns 0 if access is permitted, an error code otherwise
*/
-static int smack_inode_setxattr(struct mnt_idmap *idmap,
+static int smack_inode_setxattr(const struct mnt_idmap *idmap,
struct dentry *dentry, const char *name,
const void *value, size_t size, int flags)
{
@@ -1482,7 +1482,7 @@ static int smack_inode_getxattr(struct dentry *dentry, const char *name)
*
* Returns 0 if access is permitted, an error code otherwise
*/
-static int smack_inode_removexattr(struct mnt_idmap *idmap,
+static int smack_inode_removexattr(const struct mnt_idmap *idmap,
struct dentry *dentry, const char *name)
{
struct inode_smack *isp;
@@ -1612,7 +1612,7 @@ static int smack_inode_remove_acl(const struct mnt_idmap *idmap,
*
* Returns the size of the attribute or an error code
*/
-static int smack_inode_getsecurity(struct mnt_idmap *idmap,
+static int smack_inode_getsecurity(const struct mnt_idmap *idmap,
struct inode *inode, const char *name,
void **buffer, bool alloc)
{
--
2.53.0
^ permalink raw reply related [flat|nested] 62+ messages in thread* Re: [PATCH 13/27] fs: port xattr to const mnt_idmap
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
1 sibling, 0 replies; 62+ messages in thread
From: Jan Kara @ 2026-09-02 15:42 UTC (permalink / raw)
To: Christian Brauner
Cc: linux-fsdevel, Alexander Viro, Jan Kara, Christoph Hellwig,
Seth Forshee, Paul Moore, linux-security-module, Mimi Zohar,
linux-integrity, Ilya Dryomov, ceph-devel, Carlos Maiolino,
linux-xfs, Miklos Szeredi, Amir Goldstein, linux-unionfs,
Namjae Jeon, linux-cifs, linux-kernel
On Tue 01-09-26 14:14:38, Christian Brauner wrote:
> Convert to const struct mnt_idmap.
>
> A mount's idmapping is immutable. The only thing that is allowed to be
> modified afterwards is the reference count and that is hidden behind
> mnt_idmap_get() and mnt_idmap_put(). Everything else only ever reads
> from the idmapping. This is the same model that struct cred uses and the
> idmapping is also rather sensitive.
>
> So make the idmap argument const wherever we can. The conversion is done
> from the bottom up so callers can continue to pass a non-const pointer
> to a const parameter until the conversion is finished.
>
> No functional changes.
>
> Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> Documentation/filesystems/locking.rst | 2 +-
> fs/9p/xattr.c | 2 +-
> fs/afs/xattr.c | 4 ++--
> fs/attr.c | 2 +-
> fs/btrfs/xattr.c | 6 +++---
> fs/ceph/xattr.c | 2 +-
> fs/ecryptfs/inode.c | 2 +-
> fs/ext2/xattr_security.c | 2 +-
> fs/ext2/xattr_trusted.c | 2 +-
> fs/ext2/xattr_user.c | 2 +-
> fs/ext4/xattr_hurd.c | 2 +-
> fs/ext4/xattr_security.c | 2 +-
> fs/ext4/xattr_trusted.c | 2 +-
> fs/ext4/xattr_user.c | 2 +-
> fs/f2fs/xattr.c | 4 ++--
> fs/fuse/dir.c | 2 +-
> fs/fuse/fuse_i.h | 2 +-
> fs/fuse/xattr.c | 2 +-
> fs/gfs2/xattr.c | 2 +-
> fs/hfs/attr.c | 2 +-
> fs/hfsplus/xattr.c | 2 +-
> fs/hfsplus/xattr_security.c | 2 +-
> fs/hfsplus/xattr_trusted.c | 2 +-
> fs/hfsplus/xattr_user.c | 2 +-
> fs/jffs2/security.c | 2 +-
> fs/jffs2/xattr_trusted.c | 2 +-
> fs/jffs2/xattr_user.c | 2 +-
> fs/jfs/xattr.c | 4 ++--
> fs/kernfs/inode.c | 4 ++--
> fs/nfs/nfs4proc.c | 10 +++++-----
> fs/ntfs/ea.c | 2 +-
> fs/ntfs3/xattr.c | 2 +-
> fs/ocfs2/xattr.c | 6 +++---
> fs/orangefs/xattr.c | 2 +-
> fs/overlayfs/xattrs.c | 4 ++--
> fs/pidfs.c | 2 +-
> fs/smb/client/xattr.c | 2 +-
> fs/smb/server/vfs.c | 24 ++++++++++++------------
> fs/smb/server/vfs.h | 20 ++++++++++----------
> fs/ubifs/xattr.c | 2 +-
> fs/xattr.c | 22 +++++++++++-----------
> fs/xfs/xfs_iops.c | 2 +-
> fs/xfs/xfs_xattr.c | 2 +-
> include/linux/capability.h | 4 ++--
> include/linux/fs.h | 2 +-
> include/linux/lsm_hook_defs.h | 8 ++++----
> include/linux/security.h | 20 ++++++++++----------
> include/linux/xattr.h | 20 ++++++++++----------
> kernel/bpf/inode.c | 2 +-
> mm/shmem.c | 2 +-
> net/socket.c | 4 ++--
> security/commoncap.c | 8 ++++----
> security/integrity/evm/evm_main.c | 4 ++--
> security/integrity/ima/ima_appraise.c | 4 ++--
> security/security.c | 8 ++++----
> security/selinux/hooks.c | 6 +++---
> security/smack/smack_lsm.c | 6 +++---
> 57 files changed, 135 insertions(+), 135 deletions(-)
>
> diff --git a/Documentation/filesystems/locking.rst b/Documentation/filesystems/locking.rst
> index 5af7d3bfcd5e..2a91bc9c15f5 100644
> --- a/Documentation/filesystems/locking.rst
> +++ b/Documentation/filesystems/locking.rst
> @@ -148,7 +148,7 @@ prototypes::
> struct inode *inode, const char *name, void *buffer,
> size_t size);
> int (*set)(const struct xattr_handler *handler,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *dentry, struct inode *inode, const char *name,
> const void *buffer, size_t size, int flags);
>
> diff --git a/fs/9p/xattr.c b/fs/9p/xattr.c
> index 8604e3377ee7..dac06587f67a 100644
> --- a/fs/9p/xattr.c
> +++ b/fs/9p/xattr.c
> @@ -153,7 +153,7 @@ static int v9fs_xattr_handler_get(const struct xattr_handler *handler,
> }
>
> static int v9fs_xattr_handler_set(const struct xattr_handler *handler,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *dentry, struct inode *inode,
> const char *name, const void *value,
> size_t size, int flags)
> diff --git a/fs/afs/xattr.c b/fs/afs/xattr.c
> index 3770ed236f67..bcffd7236cc9 100644
> --- a/fs/afs/xattr.c
> +++ b/fs/afs/xattr.c
> @@ -97,7 +97,7 @@ static const struct afs_operation_ops afs_store_acl_operation = {
> * Set a file's AFS3 ACL.
> */
> static int afs_xattr_set_acl(const struct xattr_handler *handler,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *dentry,
> struct inode *inode, const char *name,
> const void *buffer, size_t size, int flags)
> @@ -228,7 +228,7 @@ static const struct afs_operation_ops yfs_store_opaque_acl2_operation = {
> * Set a file's YFS ACL.
> */
> static int afs_xattr_set_yfs(const struct xattr_handler *handler,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *dentry,
> struct inode *inode, const char *name,
> const void *buffer, size_t size, int flags)
> diff --git a/fs/attr.c b/fs/attr.c
> index c5033afe04bf..1845d145fe4c 100644
> --- a/fs/attr.c
> +++ b/fs/attr.c
> @@ -158,7 +158,7 @@ static bool chgrp_ok(const struct mnt_idmap *idmap,
> * Should be called as the first thing in ->setattr implementations,
> * possibly after taking additional locks.
> */
> -int setattr_prepare(struct mnt_idmap *idmap, struct dentry *dentry,
> +int setattr_prepare(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *attr)
> {
> struct inode *inode = d_inode(dentry);
> diff --git a/fs/btrfs/xattr.c b/fs/btrfs/xattr.c
> index ab55d10bd71f..a06420b9c662 100644
> --- a/fs/btrfs/xattr.c
> +++ b/fs/btrfs/xattr.c
> @@ -353,7 +353,7 @@ static int btrfs_xattr_handler_get(const struct xattr_handler *handler,
> }
>
> static int btrfs_xattr_handler_set(const struct xattr_handler *handler,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *unused, struct inode *inode,
> const char *name, const void *buffer,
> size_t size, int flags)
> @@ -395,7 +395,7 @@ static int btrfs_xattr_handler_get_security(const struct xattr_handler *handler,
> }
>
> static int btrfs_xattr_handler_set_security(const struct xattr_handler *handler,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *unused,
> struct inode *inode,
> const char *name,
> @@ -413,7 +413,7 @@ static int btrfs_xattr_handler_set_security(const struct xattr_handler *handler,
> }
>
> static int btrfs_xattr_handler_set_prop(const struct xattr_handler *handler,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *unused, struct inode *inode,
> const char *name, const void *value,
> size_t size, int flags)
> diff --git a/fs/ceph/xattr.c b/fs/ceph/xattr.c
> index cc4ffbbcb719..7d77214c76c6 100644
> --- a/fs/ceph/xattr.c
> +++ b/fs/ceph/xattr.c
> @@ -1352,7 +1352,7 @@ static int ceph_get_xattr_handler(const struct xattr_handler *handler,
> }
>
> static int ceph_set_xattr_handler(const struct xattr_handler *handler,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *unused, struct inode *inode,
> const char *name, const void *value,
> size_t size, int flags)
> diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
> index 6dafca14ca78..691b3a24b60a 100644
> --- a/fs/ecryptfs/inode.c
> +++ b/fs/ecryptfs/inode.c
> @@ -1158,7 +1158,7 @@ static int ecryptfs_xattr_get(const struct xattr_handler *handler,
> }
>
> static int ecryptfs_xattr_set(const struct xattr_handler *handler,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *dentry, struct inode *inode,
> const char *name, const void *value, size_t size,
> int flags)
> diff --git a/fs/ext2/xattr_security.c b/fs/ext2/xattr_security.c
> index db47b8ab153e..ade074354258 100644
> --- a/fs/ext2/xattr_security.c
> +++ b/fs/ext2/xattr_security.c
> @@ -19,7 +19,7 @@ ext2_xattr_security_get(const struct xattr_handler *handler,
>
> static int
> ext2_xattr_security_set(const struct xattr_handler *handler,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *unused, struct inode *inode,
> const char *name, const void *value,
> size_t size, int flags)
> diff --git a/fs/ext2/xattr_trusted.c b/fs/ext2/xattr_trusted.c
> index 995f931228ce..0f12d634d6d0 100644
> --- a/fs/ext2/xattr_trusted.c
> +++ b/fs/ext2/xattr_trusted.c
> @@ -26,7 +26,7 @@ ext2_xattr_trusted_get(const struct xattr_handler *handler,
>
> static int
> ext2_xattr_trusted_set(const struct xattr_handler *handler,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *unused, struct inode *inode,
> const char *name, const void *value,
> size_t size, int flags)
> diff --git a/fs/ext2/xattr_user.c b/fs/ext2/xattr_user.c
> index dd1507231081..48002c033e9c 100644
> --- a/fs/ext2/xattr_user.c
> +++ b/fs/ext2/xattr_user.c
> @@ -30,7 +30,7 @@ ext2_xattr_user_get(const struct xattr_handler *handler,
>
> static int
> ext2_xattr_user_set(const struct xattr_handler *handler,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *unused, struct inode *inode,
> const char *name, const void *value,
> size_t size, int flags)
> diff --git a/fs/ext4/xattr_hurd.c b/fs/ext4/xattr_hurd.c
> index 8a5842e4cd95..a3ecbff72b10 100644
> --- a/fs/ext4/xattr_hurd.c
> +++ b/fs/ext4/xattr_hurd.c
> @@ -32,7 +32,7 @@ ext4_xattr_hurd_get(const struct xattr_handler *handler,
>
> static int
> ext4_xattr_hurd_set(const struct xattr_handler *handler,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *unused, struct inode *inode,
> const char *name, const void *value,
> size_t size, int flags)
> diff --git a/fs/ext4/xattr_security.c b/fs/ext4/xattr_security.c
> index 776cf11d24ca..af5b8a93fed1 100644
> --- a/fs/ext4/xattr_security.c
> +++ b/fs/ext4/xattr_security.c
> @@ -23,7 +23,7 @@ ext4_xattr_security_get(const struct xattr_handler *handler,
>
> static int
> ext4_xattr_security_set(const struct xattr_handler *handler,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *unused, struct inode *inode,
> const char *name, const void *value,
> size_t size, int flags)
> diff --git a/fs/ext4/xattr_trusted.c b/fs/ext4/xattr_trusted.c
> index 9811eb0ab276..458e1982ef83 100644
> --- a/fs/ext4/xattr_trusted.c
> +++ b/fs/ext4/xattr_trusted.c
> @@ -30,7 +30,7 @@ ext4_xattr_trusted_get(const struct xattr_handler *handler,
>
> static int
> ext4_xattr_trusted_set(const struct xattr_handler *handler,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *unused, struct inode *inode,
> const char *name, const void *value,
> size_t size, int flags)
> diff --git a/fs/ext4/xattr_user.c b/fs/ext4/xattr_user.c
> index 4b70bf4e7626..ad35215f6610 100644
> --- a/fs/ext4/xattr_user.c
> +++ b/fs/ext4/xattr_user.c
> @@ -31,7 +31,7 @@ ext4_xattr_user_get(const struct xattr_handler *handler,
>
> static int
> ext4_xattr_user_set(const struct xattr_handler *handler,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *unused, struct inode *inode,
> const char *name, const void *value,
> size_t size, int flags)
> diff --git a/fs/f2fs/xattr.c b/fs/f2fs/xattr.c
> index 6728d1488cad..ffe4815ffa6d 100644
> --- a/fs/f2fs/xattr.c
> +++ b/fs/f2fs/xattr.c
> @@ -67,7 +67,7 @@ static int f2fs_xattr_generic_get(const struct xattr_handler *handler,
> }
>
> static int f2fs_xattr_generic_set(const struct xattr_handler *handler,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *unused, struct inode *inode,
> const char *name, const void *value,
> size_t size, int flags)
> @@ -111,7 +111,7 @@ static int f2fs_xattr_advise_get(const struct xattr_handler *handler,
> }
>
> static int f2fs_xattr_advise_set(const struct xattr_handler *handler,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *unused, struct inode *inode,
> const char *name, const void *value,
> size_t size, int flags)
> diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
> index 4b87973c727d..0dbe3c6560f8 100644
> --- a/fs/fuse/dir.c
> +++ b/fs/fuse/dir.c
> @@ -2143,7 +2143,7 @@ int fuse_flush_times(struct inode *inode, struct fuse_file *ff)
> * vmtruncate() doesn't allow for this case, so do the rlimit checking
> * and the actual truncation by hand.
> */
> -int fuse_do_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +int fuse_do_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *attr, struct file *file)
> {
> struct inode *inode = d_inode(dentry);
> diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
> index a07c75377a30..9ea346ea2e01 100644
> --- a/fs/fuse/fuse_i.h
> +++ b/fs/fuse/fuse_i.h
> @@ -1189,7 +1189,7 @@ bool fuse_write_update_attr(struct inode *inode, loff_t pos, ssize_t written);
> int fuse_flush_times(struct inode *inode, struct fuse_file *ff);
> int fuse_write_inode(struct inode *inode, struct writeback_control *wbc);
>
> -int fuse_do_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +int fuse_do_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *attr, struct file *file);
>
> void fuse_unlock_inode(struct inode *inode, bool locked);
> diff --git a/fs/fuse/xattr.c b/fs/fuse/xattr.c
> index cab2685acc65..53e3c5e6fff0 100644
> --- a/fs/fuse/xattr.c
> +++ b/fs/fuse/xattr.c
> @@ -188,7 +188,7 @@ static int fuse_xattr_get(const struct xattr_handler *handler,
> }
>
> static int fuse_xattr_set(const struct xattr_handler *handler,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *dentry, struct inode *inode,
> const char *name, const void *value, size_t size,
> int flags)
> diff --git a/fs/gfs2/xattr.c b/fs/gfs2/xattr.c
> index b9f48d6f10a9..0e66e4849b57 100644
> --- a/fs/gfs2/xattr.c
> +++ b/fs/gfs2/xattr.c
> @@ -1229,7 +1229,7 @@ int __gfs2_xattr_set(struct inode *inode, const char *name,
> }
>
> static int gfs2_xattr_set(const struct xattr_handler *handler,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *unused, struct inode *inode,
> const char *name, const void *value,
> size_t size, int flags)
> diff --git a/fs/hfs/attr.c b/fs/hfs/attr.c
> index f8395cdd1adf..6d737a085461 100644
> --- a/fs/hfs/attr.c
> +++ b/fs/hfs/attr.c
> @@ -121,7 +121,7 @@ static int hfs_xattr_get(const struct xattr_handler *handler,
> }
>
> static int hfs_xattr_set(const struct xattr_handler *handler,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *unused, struct inode *inode,
> const char *name, const void *value, size_t size,
> int flags)
> diff --git a/fs/hfsplus/xattr.c b/fs/hfsplus/xattr.c
> index 21a1c196c71f..71364e093fa7 100644
> --- a/fs/hfsplus/xattr.c
> +++ b/fs/hfsplus/xattr.c
> @@ -1008,7 +1008,7 @@ static int hfsplus_osx_getxattr(const struct xattr_handler *handler,
> }
>
> static int hfsplus_osx_setxattr(const struct xattr_handler *handler,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *unused, struct inode *inode,
> const char *name, const void *buffer,
> size_t size, int flags)
> diff --git a/fs/hfsplus/xattr_security.c b/fs/hfsplus/xattr_security.c
> index 90f68ec119cd..1969919c12cb 100644
> --- a/fs/hfsplus/xattr_security.c
> +++ b/fs/hfsplus/xattr_security.c
> @@ -23,7 +23,7 @@ static int hfsplus_security_getxattr(const struct xattr_handler *handler,
> }
>
> static int hfsplus_security_setxattr(const struct xattr_handler *handler,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *unused, struct inode *inode,
> const char *name, const void *buffer,
> size_t size, int flags)
> diff --git a/fs/hfsplus/xattr_trusted.c b/fs/hfsplus/xattr_trusted.c
> index fdbaebc1c49a..c140a95ab3f0 100644
> --- a/fs/hfsplus/xattr_trusted.c
> +++ b/fs/hfsplus/xattr_trusted.c
> @@ -22,7 +22,7 @@ static int hfsplus_trusted_getxattr(const struct xattr_handler *handler,
> }
>
> static int hfsplus_trusted_setxattr(const struct xattr_handler *handler,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *unused, struct inode *inode,
> const char *name, const void *buffer,
> size_t size, int flags)
> diff --git a/fs/hfsplus/xattr_user.c b/fs/hfsplus/xattr_user.c
> index 6464b6c3d58d..7e5da15f9937 100644
> --- a/fs/hfsplus/xattr_user.c
> +++ b/fs/hfsplus/xattr_user.c
> @@ -22,7 +22,7 @@ static int hfsplus_user_getxattr(const struct xattr_handler *handler,
> }
>
> static int hfsplus_user_setxattr(const struct xattr_handler *handler,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *unused, struct inode *inode,
> const char *name, const void *buffer,
> size_t size, int flags)
> diff --git a/fs/jffs2/security.c b/fs/jffs2/security.c
> index 437f3a2c1b54..67330aeb8ae8 100644
> --- a/fs/jffs2/security.c
> +++ b/fs/jffs2/security.c
> @@ -57,7 +57,7 @@ static int jffs2_security_getxattr(const struct xattr_handler *handler,
> }
>
> static int jffs2_security_setxattr(const struct xattr_handler *handler,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *unused, struct inode *inode,
> const char *name, const void *buffer,
> size_t size, int flags)
> diff --git a/fs/jffs2/xattr_trusted.c b/fs/jffs2/xattr_trusted.c
> index b7c5da2d89bd..85133ad8b449 100644
> --- a/fs/jffs2/xattr_trusted.c
> +++ b/fs/jffs2/xattr_trusted.c
> @@ -25,7 +25,7 @@ static int jffs2_trusted_getxattr(const struct xattr_handler *handler,
> }
>
> static int jffs2_trusted_setxattr(const struct xattr_handler *handler,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *unused, struct inode *inode,
> const char *name, const void *buffer,
> size_t size, int flags)
> diff --git a/fs/jffs2/xattr_user.c b/fs/jffs2/xattr_user.c
> index f64edce4927b..dcfd3caf1d8b 100644
> --- a/fs/jffs2/xattr_user.c
> +++ b/fs/jffs2/xattr_user.c
> @@ -25,7 +25,7 @@ static int jffs2_user_getxattr(const struct xattr_handler *handler,
> }
>
> static int jffs2_user_setxattr(const struct xattr_handler *handler,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *unused, struct inode *inode,
> const char *name, const void *buffer,
> size_t size, int flags)
> diff --git a/fs/jfs/xattr.c b/fs/jfs/xattr.c
> index 11d7f74d207b..dcc4a69d44fe 100644
> --- a/fs/jfs/xattr.c
> +++ b/fs/jfs/xattr.c
> @@ -956,7 +956,7 @@ static int jfs_xattr_get(const struct xattr_handler *handler,
> }
>
> static int jfs_xattr_set(const struct xattr_handler *handler,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *unused, struct inode *inode,
> const char *name, const void *value,
> size_t size, int flags)
> @@ -975,7 +975,7 @@ static int jfs_xattr_get_os2(const struct xattr_handler *handler,
> }
>
> static int jfs_xattr_set_os2(const struct xattr_handler *handler,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *unused, struct inode *inode,
> const char *name, const void *value,
> size_t size, int flags)
> diff --git a/fs/kernfs/inode.c b/fs/kernfs/inode.c
> index d53d104e54d5..b348d4cd150b 100644
> --- a/fs/kernfs/inode.c
> +++ b/fs/kernfs/inode.c
> @@ -344,7 +344,7 @@ static int kernfs_vfs_xattr_get(const struct xattr_handler *handler,
> }
>
> static int kernfs_vfs_xattr_set(const struct xattr_handler *handler,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *unused, struct inode *inode,
> const char *suffix, const void *value,
> size_t size, int flags)
> @@ -356,7 +356,7 @@ static int kernfs_vfs_xattr_set(const struct xattr_handler *handler,
> }
>
> static int kernfs_vfs_user_xattr_set(const struct xattr_handler *handler,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *unused, struct inode *inode,
> const char *suffix, const void *value,
> size_t size, int flags)
> diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
> index 04b1987115d5..21e5df7e5251 100644
> --- a/fs/nfs/nfs4proc.c
> +++ b/fs/nfs/nfs4proc.c
> @@ -7866,7 +7866,7 @@ int nfs4_lock_delegation_recall(struct file_lock *fl, struct nfs4_state *state,
> #define XATTR_NAME_NFSV4_ACL "system.nfs4_acl"
>
> static int nfs4_xattr_set_nfs4_acl(const struct xattr_handler *handler,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *unused, struct inode *inode,
> const char *key, const void *buf,
> size_t buflen, int flags)
> @@ -7889,7 +7889,7 @@ static bool nfs4_xattr_list_nfs4_acl(struct dentry *dentry)
> #define XATTR_NAME_NFSV4_DACL "system.nfs4_dacl"
>
> static int nfs4_xattr_set_nfs4_dacl(const struct xattr_handler *handler,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *unused, struct inode *inode,
> const char *key, const void *buf,
> size_t buflen, int flags)
> @@ -7912,7 +7912,7 @@ static bool nfs4_xattr_list_nfs4_dacl(struct dentry *dentry)
> #define XATTR_NAME_NFSV4_SACL "system.nfs4_sacl"
>
> static int nfs4_xattr_set_nfs4_sacl(const struct xattr_handler *handler,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *unused, struct inode *inode,
> const char *key, const void *buf,
> size_t buflen, int flags)
> @@ -7935,7 +7935,7 @@ static bool nfs4_xattr_list_nfs4_sacl(struct dentry *dentry)
> #ifdef CONFIG_NFS_V4_SECURITY_LABEL
>
> static int nfs4_xattr_set_nfs4_label(const struct xattr_handler *handler,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *unused, struct inode *inode,
> const char *key, const void *buf,
> size_t buflen, int flags)
> @@ -7965,7 +7965,7 @@ static const struct xattr_handler nfs4_xattr_nfs4_label_handler = {
>
> #ifdef CONFIG_NFS_V4_2
> static int nfs4_xattr_set_nfs4_user(const struct xattr_handler *handler,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *unused, struct inode *inode,
> const char *key, const void *buf,
> size_t buflen, int flags)
> diff --git a/fs/ntfs/ea.c b/fs/ntfs/ea.c
> index 744ea8c446e5..7fd323912510 100644
> --- a/fs/ntfs/ea.c
> +++ b/fs/ntfs/ea.c
> @@ -852,7 +852,7 @@ static int ntfs_validate_fattr(struct ntfs_inode *ni, __le32 fattr)
> }
>
> static int ntfs_setxattr(const struct xattr_handler *handler,
> - struct mnt_idmap *idmap, struct dentry *unused,
> + const struct mnt_idmap *idmap, struct dentry *unused,
> struct inode *inode, const char *name, const void *value,
> size_t size, int flags)
> {
> diff --git a/fs/ntfs3/xattr.c b/fs/ntfs3/xattr.c
> index d800735477c3..5644167de863 100644
> --- a/fs/ntfs3/xattr.c
> +++ b/fs/ntfs3/xattr.c
> @@ -863,7 +863,7 @@ static bool ntfs_is_reserved_lxattr(const char *name)
> * ntfs_setxattr - inode_operations::setxattr
> */
> static noinline int ntfs_setxattr(const struct xattr_handler *handler,
> - struct mnt_idmap *idmap, struct dentry *de,
> + const struct mnt_idmap *idmap, struct dentry *de,
> struct inode *inode, const char *name,
> const void *value, size_t size, int flags)
> {
> diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
> index 35bcbb0ff607..da8e19e21a91 100644
> --- a/fs/ocfs2/xattr.c
> +++ b/fs/ocfs2/xattr.c
> @@ -7503,7 +7503,7 @@ static int ocfs2_xattr_security_get(const struct xattr_handler *handler,
> }
>
> static int ocfs2_xattr_security_set(const struct xattr_handler *handler,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *unused, struct inode *inode,
> const char *name, const void *value,
> size_t size, int flags)
> @@ -7598,7 +7598,7 @@ static int ocfs2_xattr_trusted_get(const struct xattr_handler *handler,
> }
>
> static int ocfs2_xattr_trusted_set(const struct xattr_handler *handler,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *unused, struct inode *inode,
> const char *name, const void *value,
> size_t size, int flags)
> @@ -7629,7 +7629,7 @@ static int ocfs2_xattr_user_get(const struct xattr_handler *handler,
> }
>
> static int ocfs2_xattr_user_set(const struct xattr_handler *handler,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *unused, struct inode *inode,
> const char *name, const void *value,
> size_t size, int flags)
> diff --git a/fs/orangefs/xattr.c b/fs/orangefs/xattr.c
> index 885fd3bd5a3d..a49e64566e1e 100644
> --- a/fs/orangefs/xattr.c
> +++ b/fs/orangefs/xattr.c
> @@ -527,7 +527,7 @@ ssize_t orangefs_listxattr(struct dentry *dentry, char *buffer, size_t size)
> }
>
> static int orangefs_xattr_set_default(const struct xattr_handler *handler,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *unused,
> struct inode *inode,
> const char *name,
> diff --git a/fs/overlayfs/xattrs.c b/fs/overlayfs/xattrs.c
> index 5ae44b9c8790..acc54f6138ef 100644
> --- a/fs/overlayfs/xattrs.c
> +++ b/fs/overlayfs/xattrs.c
> @@ -190,7 +190,7 @@ static int ovl_own_xattr_get(const struct xattr_handler *handler,
> }
>
> static int ovl_own_xattr_set(const struct xattr_handler *handler,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *dentry, struct inode *inode,
> const char *name, const void *value,
> size_t size, int flags)
> @@ -217,7 +217,7 @@ static int ovl_other_xattr_get(const struct xattr_handler *handler,
> }
>
> static int ovl_other_xattr_set(const struct xattr_handler *handler,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *dentry, struct inode *inode,
> const char *name, const void *value,
> size_t size, int flags)
> diff --git a/fs/pidfs.c b/fs/pidfs.c
> index a6a643f15d08..5bc136de8660 100644
> --- a/fs/pidfs.c
> +++ b/fs/pidfs.c
> @@ -1102,7 +1102,7 @@ static int pidfs_xattr_get(const struct xattr_handler *handler,
> }
>
> static int pidfs_xattr_set(const struct xattr_handler *handler,
> - struct mnt_idmap *idmap, struct dentry *unused,
> + const struct mnt_idmap *idmap, struct dentry *unused,
> struct inode *inode, const char *suffix,
> const void *value, size_t size, int flags)
> {
> diff --git a/fs/smb/client/xattr.c b/fs/smb/client/xattr.c
> index 5091f6c0d7fe..f6c9343016f7 100644
> --- a/fs/smb/client/xattr.c
> +++ b/fs/smb/client/xattr.c
> @@ -91,7 +91,7 @@ static int cifs_creation_time_set(unsigned int xid, struct cifs_tcon *pTcon,
> }
>
> static int cifs_xattr_set(const struct xattr_handler *handler,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *dentry, struct inode *inode,
> const char *name, const void *value,
> size_t size, int flags)
> diff --git a/fs/smb/server/vfs.c b/fs/smb/server/vfs.c
> index 0361de56edc2..3c4d18a4e8d5 100644
> --- a/fs/smb/server/vfs.c
> +++ b/fs/smb/server/vfs.c
> @@ -216,7 +216,7 @@ int ksmbd_vfs_mkdir(struct ksmbd_work *work, const char *name, umode_t mode)
> return err;
> }
>
> -static ssize_t ksmbd_vfs_getcasexattr(struct mnt_idmap *idmap,
> +static ssize_t ksmbd_vfs_getcasexattr(const struct mnt_idmap *idmap,
> struct dentry *dentry, char *attr_name,
> int attr_name_len, char **attr_value)
> {
> @@ -841,7 +841,7 @@ ssize_t ksmbd_vfs_listxattr(struct dentry *dentry, char **list)
> return size;
> }
>
> -static ssize_t ksmbd_vfs_xattr_len(struct mnt_idmap *idmap,
> +static ssize_t ksmbd_vfs_xattr_len(const struct mnt_idmap *idmap,
> struct dentry *dentry, char *xattr_name)
> {
> return vfs_getxattr(idmap, dentry, xattr_name, NULL, 0);
> @@ -856,7 +856,7 @@ static ssize_t ksmbd_vfs_xattr_len(struct mnt_idmap *idmap,
> *
> * Return: read xattr value length on success, otherwise error
> */
> -ssize_t ksmbd_vfs_getxattr(struct mnt_idmap *idmap,
> +ssize_t ksmbd_vfs_getxattr(const struct mnt_idmap *idmap,
> struct dentry *dentry,
> char *xattr_name, char **xattr_buf)
> {
> @@ -893,7 +893,7 @@ ssize_t ksmbd_vfs_getxattr(struct mnt_idmap *idmap,
> *
> * Return: 0 on success, otherwise error
> */
> -int ksmbd_vfs_setxattr(struct mnt_idmap *idmap,
> +int ksmbd_vfs_setxattr(const struct mnt_idmap *idmap,
> const struct path *path, const char *attr_name,
> void *attr_value, size_t attr_size, int flags,
> bool get_write)
> @@ -1177,7 +1177,7 @@ int ksmbd_vfs_query_allocated_ranges(struct ksmbd_file *fp, loff_t start,
> return ret;
> }
>
> -int ksmbd_vfs_remove_xattr(struct mnt_idmap *idmap,
> +int ksmbd_vfs_remove_xattr(const struct mnt_idmap *idmap,
> const struct path *path, char *attr_name,
> bool get_write)
> {
> @@ -1511,7 +1511,7 @@ int ksmbd_vfs_remove_acl_xattrs(struct mnt_idmap *idmap,
> return err;
> }
>
> -int ksmbd_vfs_remove_sd_xattrs(struct mnt_idmap *idmap, const struct path *path)
> +int ksmbd_vfs_remove_sd_xattrs(const struct mnt_idmap *idmap, const struct path *path)
> {
> char *name, *xattr_list = NULL;
> ssize_t xattr_list_len;
> @@ -1606,7 +1606,7 @@ static struct xattr_smb_acl *ksmbd_vfs_make_xattr_posix_acl(const struct mnt_idm
> }
>
> int ksmbd_vfs_set_sd_xattr(struct ksmbd_conn *conn,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> const struct path *path,
> struct smb_ntsd *pntsd, int len,
> bool get_write)
> @@ -1673,7 +1673,7 @@ int ksmbd_vfs_set_sd_xattr(struct ksmbd_conn *conn,
> }
>
> int ksmbd_vfs_get_sd_xattr(struct ksmbd_conn *conn,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *dentry,
> struct smb_ntsd **pntsd)
> {
> @@ -1742,7 +1742,7 @@ int ksmbd_vfs_get_sd_xattr(struct ksmbd_conn *conn,
> return rc;
> }
>
> -int ksmbd_vfs_set_dos_attrib_xattr(struct mnt_idmap *idmap,
> +int ksmbd_vfs_set_dos_attrib_xattr(const struct mnt_idmap *idmap,
> const struct path *path,
> struct xattr_dos_attrib *da,
> bool get_write)
> @@ -1764,7 +1764,7 @@ int ksmbd_vfs_set_dos_attrib_xattr(struct mnt_idmap *idmap,
> return err;
> }
>
> -int ksmbd_vfs_get_dos_attrib_xattr(struct mnt_idmap *idmap,
> +int ksmbd_vfs_get_dos_attrib_xattr(const struct mnt_idmap *idmap,
> struct dentry *dentry,
> struct xattr_dos_attrib *da)
> {
> @@ -1820,7 +1820,7 @@ void *ksmbd_vfs_init_kstat(char **p, struct ksmbd_kstat *ksmbd_kstat)
> }
>
> int ksmbd_vfs_fill_dentry_attrs(struct ksmbd_work *work,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *dentry,
> struct ksmbd_kstat *ksmbd_kstat)
> {
> @@ -1895,7 +1895,7 @@ int ksmbd_vfs_fill_dentry_attrs(struct ksmbd_work *work,
> return 0;
> }
>
> -ssize_t ksmbd_vfs_casexattr_len(struct mnt_idmap *idmap,
> +ssize_t ksmbd_vfs_casexattr_len(const struct mnt_idmap *idmap,
> struct dentry *dentry, char *attr_name,
> int attr_name_len)
> {
> diff --git a/fs/smb/server/vfs.h b/fs/smb/server/vfs.h
> index 9c8b5b288926..5e34fc61b48b 100644
> --- a/fs/smb/server/vfs.h
> +++ b/fs/smb/server/vfs.h
> @@ -104,20 +104,20 @@ int ksmbd_vfs_copy_file_ranges(struct ksmbd_work *work,
> unsigned int *chunk_size_written,
> loff_t *total_size_written);
> ssize_t ksmbd_vfs_listxattr(struct dentry *dentry, char **list);
> -ssize_t ksmbd_vfs_getxattr(struct mnt_idmap *idmap,
> +ssize_t ksmbd_vfs_getxattr(const struct mnt_idmap *idmap,
> struct dentry *dentry,
> char *xattr_name,
> char **xattr_buf);
> -ssize_t ksmbd_vfs_casexattr_len(struct mnt_idmap *idmap,
> +ssize_t ksmbd_vfs_casexattr_len(const struct mnt_idmap *idmap,
> struct dentry *dentry, char *attr_name,
> int attr_name_len);
> -int ksmbd_vfs_setxattr(struct mnt_idmap *idmap,
> +int ksmbd_vfs_setxattr(const struct mnt_idmap *idmap,
> const struct path *path, const char *attr_name,
> void *attr_value, size_t attr_size, int flags,
> bool get_write);
> int ksmbd_vfs_xattr_stream_name(char *stream_name, char **xattr_stream_name,
> size_t *xattr_stream_name_size, int s_type);
> -int ksmbd_vfs_remove_xattr(struct mnt_idmap *idmap,
> +int ksmbd_vfs_remove_xattr(const struct mnt_idmap *idmap,
> const struct path *path, char *attr_name,
> bool get_write);
> int ksmbd_vfs_kern_path(struct ksmbd_work *work, char *name,
> @@ -147,28 +147,28 @@ int ksmbd_vfs_query_allocated_ranges(struct ksmbd_file *fp, loff_t start,
> int ksmbd_vfs_unlink(struct file *filp);
> void *ksmbd_vfs_init_kstat(char **p, struct ksmbd_kstat *ksmbd_kstat);
> int ksmbd_vfs_fill_dentry_attrs(struct ksmbd_work *work,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *dentry,
> struct ksmbd_kstat *ksmbd_kstat);
> void ksmbd_vfs_posix_lock_wait(struct file_lock *flock);
> void ksmbd_vfs_posix_lock_unblock(struct file_lock *flock);
> int ksmbd_vfs_remove_acl_xattrs(struct mnt_idmap *idmap,
> const struct path *path);
> -int ksmbd_vfs_remove_sd_xattrs(struct mnt_idmap *idmap, const struct path *path);
> +int ksmbd_vfs_remove_sd_xattrs(const struct mnt_idmap *idmap, const struct path *path);
> int ksmbd_vfs_set_sd_xattr(struct ksmbd_conn *conn,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> const struct path *path,
> struct smb_ntsd *pntsd, int len,
> bool get_write);
> int ksmbd_vfs_get_sd_xattr(struct ksmbd_conn *conn,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *dentry,
> struct smb_ntsd **pntsd);
> -int ksmbd_vfs_set_dos_attrib_xattr(struct mnt_idmap *idmap,
> +int ksmbd_vfs_set_dos_attrib_xattr(const struct mnt_idmap *idmap,
> const struct path *path,
> struct xattr_dos_attrib *da,
> bool get_write);
> -int ksmbd_vfs_get_dos_attrib_xattr(struct mnt_idmap *idmap,
> +int ksmbd_vfs_get_dos_attrib_xattr(const struct mnt_idmap *idmap,
> struct dentry *dentry,
> struct xattr_dos_attrib *da);
> int ksmbd_vfs_set_init_posix_acl(struct mnt_idmap *idmap,
> diff --git a/fs/ubifs/xattr.c b/fs/ubifs/xattr.c
> index b5a9ab9d8a10..3b0e8a270f59 100644
> --- a/fs/ubifs/xattr.c
> +++ b/fs/ubifs/xattr.c
> @@ -660,7 +660,7 @@ static int xattr_get(const struct xattr_handler *handler,
> }
>
> static int xattr_set(const struct xattr_handler *handler,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *dentry, struct inode *inode,
> const char *name, const void *value,
> size_t size, int flags)
> diff --git a/fs/xattr.c b/fs/xattr.c
> index c08f188748a9..acdaafb0c7c1 100644
> --- a/fs/xattr.c
> +++ b/fs/xattr.c
> @@ -123,7 +123,7 @@ static inline int xattr_permission_error(int mask)
> * because different namespaces have very different rules.
> */
> static int
> -xattr_permission(struct mnt_idmap *idmap, struct inode *inode,
> +xattr_permission(const struct mnt_idmap *idmap, struct inode *inode,
> const char *name, int mask)
> {
> if (mask & MAY_WRITE) {
> @@ -204,7 +204,7 @@ xattr_supports_user_prefix(struct inode *inode)
> EXPORT_SYMBOL(xattr_supports_user_prefix);
>
> int
> -__vfs_setxattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +__vfs_setxattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct inode *inode, const char *name, const void *value,
> size_t size, int flags)
> {
> @@ -242,7 +242,7 @@ EXPORT_SYMBOL(__vfs_setxattr);
> * is executed. It also assumes that the caller will make the appropriate
> * permission checks.
> */
> -int __vfs_setxattr_noperm(struct mnt_idmap *idmap,
> +int __vfs_setxattr_noperm(const struct mnt_idmap *idmap,
> struct dentry *dentry, const char *name,
> const void *value, size_t size, int flags)
> {
> @@ -295,7 +295,7 @@ int __vfs_setxattr_noperm(struct mnt_idmap *idmap,
> * a delegation was broken on, NULL if none.
> */
> int
> -__vfs_setxattr_locked(struct mnt_idmap *idmap, struct dentry *dentry,
> +__vfs_setxattr_locked(const struct mnt_idmap *idmap, struct dentry *dentry,
> const char *name, const void *value, size_t size,
> int flags, struct delegated_inode *delegated_inode)
> {
> @@ -324,7 +324,7 @@ __vfs_setxattr_locked(struct mnt_idmap *idmap, struct dentry *dentry,
> EXPORT_SYMBOL_GPL(__vfs_setxattr_locked);
>
> int
> -vfs_setxattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +vfs_setxattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> const char *name, const void *value, size_t size, int flags)
> {
> struct inode *inode = dentry->d_inode;
> @@ -358,7 +358,7 @@ vfs_setxattr(struct mnt_idmap *idmap, struct dentry *dentry,
> EXPORT_SYMBOL_GPL(vfs_setxattr);
>
> static ssize_t
> -xattr_getsecurity(struct mnt_idmap *idmap, struct inode *inode,
> +xattr_getsecurity(const struct mnt_idmap *idmap, struct inode *inode,
> const char *name, void *value, size_t size)
> {
> void *buffer = NULL;
> @@ -395,7 +395,7 @@ xattr_getsecurity(struct mnt_idmap *idmap, struct inode *inode,
> * Returns the result of alloc, if failed, or the getxattr operation.
> */
> int
> -vfs_getxattr_alloc(struct mnt_idmap *idmap, struct dentry *dentry,
> +vfs_getxattr_alloc(const struct mnt_idmap *idmap, struct dentry *dentry,
> const char *name, char **xattr_value, size_t xattr_size,
> gfp_t flags)
> {
> @@ -448,7 +448,7 @@ __vfs_getxattr(struct dentry *dentry, struct inode *inode, const char *name,
> EXPORT_SYMBOL(__vfs_getxattr);
>
> ssize_t
> -vfs_getxattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +vfs_getxattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> const char *name, void *value, size_t size)
> {
> struct inode *inode = dentry->d_inode;
> @@ -527,7 +527,7 @@ vfs_listxattr(struct dentry *dentry, char *list, size_t size)
> EXPORT_SYMBOL_GPL(vfs_listxattr);
>
> int
> -__vfs_removexattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +__vfs_removexattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> const char *name)
> {
> struct inode *inode = d_inode(dentry);
> @@ -557,7 +557,7 @@ EXPORT_SYMBOL(__vfs_removexattr);
> * a delegation was broken on, NULL if none.
> */
> int
> -__vfs_removexattr_locked(struct mnt_idmap *idmap,
> +__vfs_removexattr_locked(const struct mnt_idmap *idmap,
> struct dentry *dentry, const char *name,
> struct delegated_inode *delegated_inode)
> {
> @@ -589,7 +589,7 @@ __vfs_removexattr_locked(struct mnt_idmap *idmap,
> EXPORT_SYMBOL_GPL(__vfs_removexattr_locked);
>
> int
> -vfs_removexattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +vfs_removexattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> const char *name)
> {
> struct inode *inode = dentry->d_inode;
> diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
> index df5e7c1b2334..b652f129c85e 100644
> --- a/fs/xfs/xfs_iops.c
> +++ b/fs/xfs/xfs_iops.c
> @@ -754,7 +754,7 @@ xfs_vn_getattr(
>
> static int
> xfs_vn_change_ok(
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *dentry,
> struct iattr *iattr)
> {
> diff --git a/fs/xfs/xfs_xattr.c b/fs/xfs/xfs_xattr.c
> index 1efe6c8139b2..b059a9714d11 100644
> --- a/fs/xfs/xfs_xattr.c
> +++ b/fs/xfs/xfs_xattr.c
> @@ -169,7 +169,7 @@ xfs_xattr_flags_to_op(
>
> static int
> xfs_xattr_set(const struct xattr_handler *handler,
> - struct mnt_idmap *idmap, struct dentry *unused,
> + const struct mnt_idmap *idmap, struct dentry *unused,
> struct inode *inode, const char *name, const void *value,
> size_t size, int flags)
> {
> diff --git a/include/linux/capability.h b/include/linux/capability.h
> index c39a2bbefc47..8ab509c4e1ef 100644
> --- a/include/linux/capability.h
> +++ b/include/linux/capability.h
> @@ -210,11 +210,11 @@ static inline bool checkpoint_restore_ns_capable_noaudit(struct user_namespace *
> }
>
> /* audit system wants to get cap info from files as well */
> -int get_vfs_caps_from_disk(struct mnt_idmap *idmap,
> +int get_vfs_caps_from_disk(const struct mnt_idmap *idmap,
> const struct dentry *dentry,
> struct cpu_vfs_cap_data *cpu_caps);
>
> -int cap_convert_nscap(struct mnt_idmap *idmap, struct dentry *dentry,
> +int cap_convert_nscap(const struct mnt_idmap *idmap, struct dentry *dentry,
> const void **ivalue, size_t size);
>
> #endif /* !_LINUX_CAPABILITY_H */
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index f815594dd8cb..08166900931a 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -3399,7 +3399,7 @@ static inline bool generic_ci_validate_strict_name(struct inode *dir,
>
> int may_setattr(const struct mnt_idmap *idmap, struct inode *inode,
> unsigned int ia_valid);
> -int setattr_prepare(struct mnt_idmap *, struct dentry *, struct iattr *);
> +int setattr_prepare(const struct mnt_idmap *, struct dentry *, struct iattr *);
> extern int inode_newsize_ok(const struct inode *, loff_t offset);
> void setattr_copy(const struct mnt_idmap *, struct inode *inode,
> const struct iattr *attr);
> diff --git a/include/linux/lsm_hook_defs.h b/include/linux/lsm_hook_defs.h
> index 30897590258f..e8638f7d2245 100644
> --- a/include/linux/lsm_hook_defs.h
> +++ b/include/linux/lsm_hook_defs.h
> @@ -146,14 +146,14 @@ LSM_HOOK(void, LSM_RET_VOID, inode_post_setattr, struct mnt_idmap *idmap,
> struct dentry *dentry, int ia_valid)
> LSM_HOOK(int, 0, inode_getattr, const struct path *path)
> LSM_HOOK(int, 0, inode_xattr_skipcap, const char *name)
> -LSM_HOOK(int, 0, inode_setxattr, struct mnt_idmap *idmap,
> +LSM_HOOK(int, 0, inode_setxattr, const struct mnt_idmap *idmap,
> struct dentry *dentry, const char *name, const void *value,
> size_t size, int flags)
> LSM_HOOK(void, LSM_RET_VOID, inode_post_setxattr, struct dentry *dentry,
> const char *name, const void *value, size_t size, int flags)
> LSM_HOOK(int, 0, inode_getxattr, struct dentry *dentry, const char *name)
> LSM_HOOK(int, 0, inode_listxattr, struct dentry *dentry)
> -LSM_HOOK(int, 0, inode_removexattr, struct mnt_idmap *idmap,
> +LSM_HOOK(int, 0, inode_removexattr, const struct mnt_idmap *idmap,
> struct dentry *dentry, const char *name)
> LSM_HOOK(void, LSM_RET_VOID, inode_post_removexattr, struct dentry *dentry,
> const char *name)
> @@ -170,9 +170,9 @@ LSM_HOOK(int, 0, inode_remove_acl, const struct mnt_idmap *idmap,
> LSM_HOOK(void, LSM_RET_VOID, inode_post_remove_acl, const struct mnt_idmap *idmap,
> struct dentry *dentry, const char *acl_name)
> LSM_HOOK(int, 0, inode_need_killpriv, struct dentry *dentry)
> -LSM_HOOK(int, 0, inode_killpriv, struct mnt_idmap *idmap,
> +LSM_HOOK(int, 0, inode_killpriv, const struct mnt_idmap *idmap,
> struct dentry *dentry)
> -LSM_HOOK(int, -EOPNOTSUPP, inode_getsecurity, struct mnt_idmap *idmap,
> +LSM_HOOK(int, -EOPNOTSUPP, inode_getsecurity, const struct mnt_idmap *idmap,
> struct inode *inode, const char *name, void **buffer, bool alloc)
> LSM_HOOK(int, -EOPNOTSUPP, inode_setsecurity, struct inode *inode,
> const char *name, const void *value, size_t size, int flags)
> diff --git a/include/linux/security.h b/include/linux/security.h
> index 12bc12e243bf..d5832750418a 100644
> --- a/include/linux/security.h
> +++ b/include/linux/security.h
> @@ -188,8 +188,8 @@ int cap_inode_setxattr(struct dentry *dentry, const char *name,
> int cap_inode_removexattr(const struct mnt_idmap *idmap,
> struct dentry *dentry, const char *name);
> int cap_inode_need_killpriv(struct dentry *dentry);
> -int cap_inode_killpriv(struct mnt_idmap *idmap, struct dentry *dentry);
> -int cap_inode_getsecurity(struct mnt_idmap *idmap,
> +int cap_inode_killpriv(const struct mnt_idmap *idmap, struct dentry *dentry);
> +int cap_inode_getsecurity(const struct mnt_idmap *idmap,
> struct inode *inode, const char *name, void **buffer,
> bool alloc);
> extern int cap_mmap_addr(unsigned long addr);
> @@ -427,7 +427,7 @@ int security_inode_setattr(struct mnt_idmap *idmap,
> void security_inode_post_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> int ia_valid);
> int security_inode_getattr(const struct path *path);
> -int security_inode_setxattr(struct mnt_idmap *idmap,
> +int security_inode_setxattr(const struct mnt_idmap *idmap,
> struct dentry *dentry, const char *name,
> const void *value, size_t size, int flags);
> int security_inode_set_acl(const struct mnt_idmap *idmap,
> @@ -446,7 +446,7 @@ void security_inode_post_setxattr(struct dentry *dentry, const char *name,
> const void *value, size_t size, int flags);
> int security_inode_getxattr(struct dentry *dentry, const char *name);
> int security_inode_listxattr(struct dentry *dentry);
> -int security_inode_removexattr(struct mnt_idmap *idmap,
> +int security_inode_removexattr(const struct mnt_idmap *idmap,
> struct dentry *dentry, const char *name);
> void security_inode_post_removexattr(struct dentry *dentry, const char *name);
> int security_inode_file_setattr(struct dentry *dentry,
> @@ -454,8 +454,8 @@ int security_inode_file_setattr(struct dentry *dentry,
> int security_inode_file_getattr(struct dentry *dentry,
> struct file_kattr *fa);
> int security_inode_need_killpriv(struct dentry *dentry);
> -int security_inode_killpriv(struct mnt_idmap *idmap, struct dentry *dentry);
> -int security_inode_getsecurity(struct mnt_idmap *idmap,
> +int security_inode_killpriv(const struct mnt_idmap *idmap, struct dentry *dentry);
> +int security_inode_getsecurity(const struct mnt_idmap *idmap,
> struct inode *inode, const char *name,
> void **buffer, bool alloc);
> int security_inode_setsecurity(struct inode *inode, const char *name, const void *value, size_t size, int flags);
> @@ -996,7 +996,7 @@ static inline int security_inode_getattr(const struct path *path)
> return 0;
> }
>
> -static inline int security_inode_setxattr(struct mnt_idmap *idmap,
> +static inline int security_inode_setxattr(const struct mnt_idmap *idmap,
> struct dentry *dentry, const char *name, const void *value,
> size_t size, int flags)
> {
> @@ -1050,7 +1050,7 @@ static inline int security_inode_listxattr(struct dentry *dentry)
> return 0;
> }
>
> -static inline int security_inode_removexattr(struct mnt_idmap *idmap,
> +static inline int security_inode_removexattr(const struct mnt_idmap *idmap,
> struct dentry *dentry,
> const char *name)
> {
> @@ -1078,13 +1078,13 @@ static inline int security_inode_need_killpriv(struct dentry *dentry)
> return cap_inode_need_killpriv(dentry);
> }
>
> -static inline int security_inode_killpriv(struct mnt_idmap *idmap,
> +static inline int security_inode_killpriv(const struct mnt_idmap *idmap,
> struct dentry *dentry)
> {
> return cap_inode_killpriv(idmap, dentry);
> }
>
> -static inline int security_inode_getsecurity(struct mnt_idmap *idmap,
> +static inline int security_inode_getsecurity(const struct mnt_idmap *idmap,
> struct inode *inode,
> const char *name, void **buffer,
> bool alloc)
> diff --git a/include/linux/xattr.h b/include/linux/xattr.h
> index 54ac3cbc133f..4cc4257de084 100644
> --- a/include/linux/xattr.h
> +++ b/include/linux/xattr.h
> @@ -47,7 +47,7 @@ struct xattr_handler {
> struct inode *inode, const char *name, void *buffer,
> size_t size);
> int (*set)(const struct xattr_handler *,
> - struct mnt_idmap *idmap, struct dentry *dentry,
> + const struct mnt_idmap *idmap, struct dentry *dentry,
> struct inode *inode, const char *name, const void *buffer,
> size_t size, int flags);
> };
> @@ -77,25 +77,25 @@ struct xattr {
> };
>
> ssize_t __vfs_getxattr(struct dentry *, struct inode *, const char *, void *, size_t);
> -ssize_t vfs_getxattr(struct mnt_idmap *, struct dentry *, const char *,
> +ssize_t vfs_getxattr(const struct mnt_idmap *, struct dentry *, const char *,
> void *, size_t);
> ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size);
> -int __vfs_setxattr(struct mnt_idmap *, struct dentry *, struct inode *,
> +int __vfs_setxattr(const struct mnt_idmap *, struct dentry *, struct inode *,
> const char *, const void *, size_t, int);
> -int __vfs_setxattr_noperm(struct mnt_idmap *, struct dentry *,
> +int __vfs_setxattr_noperm(const struct mnt_idmap *, struct dentry *,
> const char *, const void *, size_t, int);
> -int __vfs_setxattr_locked(struct mnt_idmap *, struct dentry *,
> +int __vfs_setxattr_locked(const struct mnt_idmap *, struct dentry *,
> const char *, const void *, size_t, int,
> struct delegated_inode *);
> -int vfs_setxattr(struct mnt_idmap *, struct dentry *, const char *,
> +int vfs_setxattr(const struct mnt_idmap *, struct dentry *, const char *,
> const void *, size_t, int);
> -int __vfs_removexattr(struct mnt_idmap *, struct dentry *, const char *);
> -int __vfs_removexattr_locked(struct mnt_idmap *, struct dentry *,
> +int __vfs_removexattr(const struct mnt_idmap *, struct dentry *, const char *);
> +int __vfs_removexattr_locked(const struct mnt_idmap *, struct dentry *,
> const char *, struct delegated_inode *);
> -int vfs_removexattr(struct mnt_idmap *, struct dentry *, const char *);
> +int vfs_removexattr(const struct mnt_idmap *, struct dentry *, const char *);
>
> ssize_t generic_listxattr(struct dentry *dentry, char *buffer, size_t buffer_size);
> -int vfs_getxattr_alloc(struct mnt_idmap *idmap,
> +int vfs_getxattr_alloc(const struct mnt_idmap *idmap,
> struct dentry *dentry, const char *name,
> char **xattr_value, size_t size, gfp_t flags);
>
> diff --git a/kernel/bpf/inode.c b/kernel/bpf/inode.c
> index 7837968c0842..11174037a9ca 100644
> --- a/kernel/bpf/inode.c
> +++ b/kernel/bpf/inode.c
> @@ -874,7 +874,7 @@ enum {
> };
>
> static int bpf_fs_xattr_set(const struct xattr_handler *handler,
> - struct mnt_idmap *idmap, struct dentry *unused,
> + const struct mnt_idmap *idmap, struct dentry *unused,
> struct inode *inode, const char *name,
> const void *value, size_t size, int flags)
> {
> diff --git a/mm/shmem.c b/mm/shmem.c
> index 9ab5231c4dfe..ed633b3bc38d 100644
> --- a/mm/shmem.c
> +++ b/mm/shmem.c
> @@ -4264,7 +4264,7 @@ static int shmem_xattr_handler_get(const struct xattr_handler *handler,
> }
>
> static int shmem_xattr_handler_set(const struct xattr_handler *handler,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *unused, struct inode *inode,
> const char *name, const void *value,
> size_t size, int flags)
> diff --git a/net/socket.c b/net/socket.c
> index c05d86e63abf..052273ad081a 100644
> --- a/net/socket.c
> +++ b/net/socket.c
> @@ -422,7 +422,7 @@ static const struct xattr_handler sockfs_xattr_handler = {
> };
>
> static int sockfs_security_xattr_set(const struct xattr_handler *handler,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *dentry, struct inode *inode,
> const char *suffix, const void *value,
> size_t size, int flags)
> @@ -447,7 +447,7 @@ static int sockfs_user_xattr_get(const struct xattr_handler *handler,
> }
>
> static int sockfs_user_xattr_set(const struct xattr_handler *handler,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *dentry, struct inode *inode,
> const char *suffix, const void *value,
> size_t size, int flags)
> diff --git a/security/commoncap.c b/security/commoncap.c
> index 9361393fd756..d47ab3022343 100644
> --- a/security/commoncap.c
> +++ b/security/commoncap.c
> @@ -348,7 +348,7 @@ int cap_inode_need_killpriv(struct dentry *dentry)
> *
> * Return: 0 if successful, -ve on error.
> */
> -int cap_inode_killpriv(struct mnt_idmap *idmap, struct dentry *dentry)
> +int cap_inode_killpriv(const struct mnt_idmap *idmap, struct dentry *dentry)
> {
> int error;
>
> @@ -417,7 +417,7 @@ static bool is_v3header(int size, const struct vfs_cap_data *cap)
> * by the integrity subsystem, which really wants the unconverted values -
> * so that's good.
> */
> -int cap_inode_getsecurity(struct mnt_idmap *idmap,
> +int cap_inode_getsecurity(const struct mnt_idmap *idmap,
> struct inode *inode, const char *name, void **buffer,
> bool alloc)
> {
> @@ -566,7 +566,7 @@ static bool validheader(size_t size, const struct vfs_cap_data *cap)
> *
> * Return: On success, return the new size; on error, return < 0.
> */
> -int cap_convert_nscap(struct mnt_idmap *idmap, struct dentry *dentry,
> +int cap_convert_nscap(const struct mnt_idmap *idmap, struct dentry *dentry,
> const void **ivalue, size_t size)
> {
> struct vfs_ns_cap_data *nscap;
> @@ -672,7 +672,7 @@ static inline int bprm_caps_from_vfs_caps(struct cpu_vfs_cap_data *caps,
> * permissions. On non-idmapped mounts or if permission checking is to be
> * performed on the raw inode simply pass @nop_mnt_idmap.
> */
> -int get_vfs_caps_from_disk(struct mnt_idmap *idmap,
> +int get_vfs_caps_from_disk(const struct mnt_idmap *idmap,
> const struct dentry *dentry,
> struct cpu_vfs_cap_data *cpu_caps)
> {
> diff --git a/security/integrity/evm/evm_main.c b/security/integrity/evm/evm_main.c
> index aaf228ebed7c..94928549bfab 100644
> --- a/security/integrity/evm/evm_main.c
> +++ b/security/integrity/evm/evm_main.c
> @@ -607,7 +607,7 @@ static int evm_protect_xattr(const struct mnt_idmap *idmap,
> * userspace from writing HMAC value. Writing 'security.evm' requires
> * requires CAP_SYS_ADMIN privileges.
> */
> -static int evm_inode_setxattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +static int evm_inode_setxattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> const char *xattr_name, const void *xattr_value,
> size_t xattr_value_len, int flags)
> {
> @@ -639,7 +639,7 @@ static int evm_inode_setxattr(struct mnt_idmap *idmap, struct dentry *dentry,
> * Removing 'security.evm' requires CAP_SYS_ADMIN privileges and that
> * the current value is valid.
> */
> -static int evm_inode_removexattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +static int evm_inode_removexattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> const char *xattr_name)
> {
> /* Policy permits modification of the protected xattrs even though
> diff --git a/security/integrity/ima/ima_appraise.c b/security/integrity/ima/ima_appraise.c
> index 1aed041c127a..cfc20c63a814 100644
> --- a/security/integrity/ima/ima_appraise.c
> +++ b/security/integrity/ima/ima_appraise.c
> @@ -757,7 +757,7 @@ static int validate_hash_algo(struct dentry *dentry,
> return -EACCES;
> }
>
> -static int ima_inode_setxattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +static int ima_inode_setxattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> const char *xattr_name, const void *xattr_value,
> size_t xattr_value_len, int flags)
> {
> @@ -799,7 +799,7 @@ static int ima_inode_set_acl(const struct mnt_idmap *idmap, struct dentry *dentr
> return 0;
> }
>
> -static int ima_inode_removexattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +static int ima_inode_removexattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> const char *xattr_name)
> {
> int result, digsig = -1;
> diff --git a/security/security.c b/security/security.c
> index e81dcda3050b..e3a14c958bc4 100644
> --- a/security/security.c
> +++ b/security/security.c
> @@ -1921,7 +1921,7 @@ int security_inode_getattr(const struct path *path)
> *
> * Return: Returns 0 if permission is granted.
> */
> -int security_inode_setxattr(struct mnt_idmap *idmap,
> +int security_inode_setxattr(const struct mnt_idmap *idmap,
> struct dentry *dentry, const char *name,
> const void *value, size_t size, int flags)
> {
> @@ -2108,7 +2108,7 @@ int security_inode_listxattr(struct dentry *dentry)
> *
> * Return: Returns 0 if permission is granted.
> */
> -int security_inode_removexattr(struct mnt_idmap *idmap,
> +int security_inode_removexattr(const struct mnt_idmap *idmap,
> struct dentry *dentry, const char *name)
> {
> int rc;
> @@ -2197,7 +2197,7 @@ int security_inode_need_killpriv(struct dentry *dentry)
> * Return: Return 0 on success. If error is returned, then the operation
> * causing setuid bit removal is failed.
> */
> -int security_inode_killpriv(struct mnt_idmap *idmap,
> +int security_inode_killpriv(const struct mnt_idmap *idmap,
> struct dentry *dentry)
> {
> return call_int_hook(inode_killpriv, idmap, dentry);
> @@ -2219,7 +2219,7 @@ int security_inode_killpriv(struct mnt_idmap *idmap,
> *
> * Return: Returns size of buffer on success.
> */
> -int security_inode_getsecurity(struct mnt_idmap *idmap,
> +int security_inode_getsecurity(const struct mnt_idmap *idmap,
> struct inode *inode, const char *name,
> void **buffer, bool alloc)
> {
> diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
> index 672d6374d8b0..b7c6eba08fdc 100644
> --- a/security/selinux/hooks.c
> +++ b/security/selinux/hooks.c
> @@ -3367,7 +3367,7 @@ static int selinux_inode_xattr_skipcap(const char *name)
> return !strcmp(name, XATTR_NAME_SELINUX);
> }
>
> -static int selinux_inode_setxattr(struct mnt_idmap *idmap,
> +static int selinux_inode_setxattr(const struct mnt_idmap *idmap,
> struct dentry *dentry, const char *name,
> const void *value, size_t size, int flags)
> {
> @@ -3526,7 +3526,7 @@ static int selinux_inode_listxattr(struct dentry *dentry)
> return dentry_has_perm(cred, dentry, FILE__GETATTR);
> }
>
> -static int selinux_inode_removexattr(struct mnt_idmap *idmap,
> +static int selinux_inode_removexattr(const struct mnt_idmap *idmap,
> struct dentry *dentry, const char *name)
> {
> /* if not a selinux xattr, only check the ordinary setattr perm */
> @@ -3606,7 +3606,7 @@ static int selinux_path_notify(const struct path *path, u64 mask,
> *
> * Permission check is handled by selinux_inode_getxattr hook.
> */
> -static int selinux_inode_getsecurity(struct mnt_idmap *idmap,
> +static int selinux_inode_getsecurity(const struct mnt_idmap *idmap,
> struct inode *inode, const char *name,
> void **buffer, bool alloc)
> {
> diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
> index 244cdb49e928..df4fc6ff26aa 100644
> --- a/security/smack/smack_lsm.c
> +++ b/security/smack/smack_lsm.c
> @@ -1348,7 +1348,7 @@ static int smack_inode_xattr_skipcap(const char *name)
> *
> * Returns 0 if access is permitted, an error code otherwise
> */
> -static int smack_inode_setxattr(struct mnt_idmap *idmap,
> +static int smack_inode_setxattr(const struct mnt_idmap *idmap,
> struct dentry *dentry, const char *name,
> const void *value, size_t size, int flags)
> {
> @@ -1482,7 +1482,7 @@ static int smack_inode_getxattr(struct dentry *dentry, const char *name)
> *
> * Returns 0 if access is permitted, an error code otherwise
> */
> -static int smack_inode_removexattr(struct mnt_idmap *idmap,
> +static int smack_inode_removexattr(const struct mnt_idmap *idmap,
> struct dentry *dentry, const char *name)
> {
> struct inode_smack *isp;
> @@ -1612,7 +1612,7 @@ static int smack_inode_remove_acl(const struct mnt_idmap *idmap,
> *
> * Returns the size of the attribute or an error code
> */
> -static int smack_inode_getsecurity(struct mnt_idmap *idmap,
> +static int smack_inode_getsecurity(const struct mnt_idmap *idmap,
> struct inode *inode, const char *name,
> void **buffer, bool alloc)
> {
>
> --
> 2.53.0
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 62+ messages in thread* Re: [PATCH 13/27] fs: port xattr to const mnt_idmap
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
1 sibling, 0 replies; 62+ messages in thread
From: Paul Moore @ 2026-09-02 19:34 UTC (permalink / raw)
To: Christian Brauner, linux-fsdevel
Cc: Alexander Viro, Jan Kara, Christoph Hellwig, Seth Forshee,
linux-security-module, Mimi Zohar, linux-integrity, Ilya Dryomov,
ceph-devel, Carlos Maiolino, linux-xfs, Miklos Szeredi,
Amir Goldstein, linux-unionfs, Namjae Jeon, linux-cifs,
linux-kernel, Christian Brauner (Amutable)
On Sep 1, 2026 Christian Brauner <brauner@kernel.org> wrote:
>
> Convert to const struct mnt_idmap.
>
> A mount's idmapping is immutable. The only thing that is allowed to be
> modified afterwards is the reference count and that is hidden behind
> mnt_idmap_get() and mnt_idmap_put(). Everything else only ever reads
> from the idmapping. This is the same model that struct cred uses and the
> idmapping is also rather sensitive.
>
> So make the idmap argument const wherever we can. The conversion is done
> from the bottom up so callers can continue to pass a non-const pointer
> to a const parameter until the conversion is finished.
>
> No functional changes.
>
> Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
> Reviewed-by: Jan Kara <jack@suse.cz>
> ---
> Documentation/filesystems/locking.rst | 2 +-
> fs/9p/xattr.c | 2 +-
> fs/afs/xattr.c | 4 ++--
> fs/attr.c | 2 +-
> fs/btrfs/xattr.c | 6 +++---
> fs/ceph/xattr.c | 2 +-
> fs/ecryptfs/inode.c | 2 +-
> fs/ext2/xattr_security.c | 2 +-
> fs/ext2/xattr_trusted.c | 2 +-
> fs/ext2/xattr_user.c | 2 +-
> fs/ext4/xattr_hurd.c | 2 +-
> fs/ext4/xattr_security.c | 2 +-
> fs/ext4/xattr_trusted.c | 2 +-
> fs/ext4/xattr_user.c | 2 +-
> fs/f2fs/xattr.c | 4 ++--
> fs/fuse/dir.c | 2 +-
> fs/fuse/fuse_i.h | 2 +-
> fs/fuse/xattr.c | 2 +-
> fs/gfs2/xattr.c | 2 +-
> fs/hfs/attr.c | 2 +-
> fs/hfsplus/xattr.c | 2 +-
> fs/hfsplus/xattr_security.c | 2 +-
> fs/hfsplus/xattr_trusted.c | 2 +-
> fs/hfsplus/xattr_user.c | 2 +-
> fs/jffs2/security.c | 2 +-
> fs/jffs2/xattr_trusted.c | 2 +-
> fs/jffs2/xattr_user.c | 2 +-
> fs/jfs/xattr.c | 4 ++--
> fs/kernfs/inode.c | 4 ++--
> fs/nfs/nfs4proc.c | 10 +++++-----
> fs/ntfs/ea.c | 2 +-
> fs/ntfs3/xattr.c | 2 +-
> fs/ocfs2/xattr.c | 6 +++---
> fs/orangefs/xattr.c | 2 +-
> fs/overlayfs/xattrs.c | 4 ++--
> fs/pidfs.c | 2 +-
> fs/smb/client/xattr.c | 2 +-
> fs/smb/server/vfs.c | 24 ++++++++++++------------
> fs/smb/server/vfs.h | 20 ++++++++++----------
> fs/ubifs/xattr.c | 2 +-
> fs/xattr.c | 22 +++++++++++-----------
> fs/xfs/xfs_iops.c | 2 +-
> fs/xfs/xfs_xattr.c | 2 +-
> include/linux/capability.h | 4 ++--
> include/linux/fs.h | 2 +-
> include/linux/lsm_hook_defs.h | 8 ++++----
> include/linux/security.h | 20 ++++++++++----------
> include/linux/xattr.h | 20 ++++++++++----------
> kernel/bpf/inode.c | 2 +-
> mm/shmem.c | 2 +-
> net/socket.c | 4 ++--
> security/commoncap.c | 8 ++++----
> security/integrity/evm/evm_main.c | 4 ++--
> security/integrity/ima/ima_appraise.c | 4 ++--
> security/security.c | 8 ++++----
> security/selinux/hooks.c | 6 +++---
> security/smack/smack_lsm.c | 6 +++---
> 57 files changed, 135 insertions(+), 135 deletions(-)
Acked-by: Paul Moore <paul@paul-moore.com> (LSM, SELinux)
--
paul-moore.com
^ permalink raw reply [flat|nested] 62+ messages in thread
* [PATCH 14/27] fs: port ->fileattr_set() to pass const mnt_idmap
2026-09-01 12:14 [PATCH 00/27] fs: port to const struct mnt_idmap Christian Brauner
` (12 preceding siblings ...)
2026-09-01 12:14 ` [PATCH 13/27] fs: port xattr to " Christian Brauner
@ 2026-09-01 12:14 ` Christian Brauner
2026-09-02 15:43 ` Jan Kara
2026-09-01 12:14 ` [PATCH 15/27] fs: port ->set_acl() " Christian Brauner
` (12 subsequent siblings)
26 siblings, 1 reply; 62+ messages in thread
From: Christian Brauner @ 2026-09-01 12:14 UTC (permalink / raw)
To: linux-fsdevel
Cc: Alexander Viro, Jan Kara, Christoph Hellwig, Seth Forshee,
Paul Moore, linux-security-module, Mimi Zohar, linux-integrity,
Ilya Dryomov, ceph-devel, Carlos Maiolino, linux-xfs,
Miklos Szeredi, Amir Goldstein, linux-unionfs, Namjae Jeon,
linux-cifs, linux-kernel, Christian Brauner (Amutable)
Convert to const struct mnt_idmap.
A mount's idmapping is immutable. The only thing that is allowed to be
modified afterwards is the reference count and that is hidden behind
mnt_idmap_get() and mnt_idmap_put(). Everything else only ever reads
from the idmapping. This is the same model that struct cred uses and the
idmapping is also rather sensitive.
So make the idmap argument const wherever we can. The conversion is done
from the bottom up so callers can continue to pass a non-const pointer
to a const parameter until the conversion is finished.
No functional changes.
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
---
Documentation/filesystems/locking.rst | 2 +-
Documentation/filesystems/vfs.rst | 2 +-
fs/btrfs/ioctl.c | 2 +-
fs/btrfs/ioctl.h | 2 +-
fs/ecryptfs/inode.c | 2 +-
fs/efivarfs/inode.c | 2 +-
fs/ext2/ext2.h | 2 +-
fs/ext2/ioctl.c | 2 +-
fs/ext4/ext4.h | 2 +-
fs/ext4/ioctl.c | 2 +-
fs/f2fs/f2fs.h | 2 +-
fs/f2fs/file.c | 2 +-
fs/file_attr.c | 2 +-
fs/fuse/fuse_i.h | 2 +-
fs/fuse/ioctl.c | 2 +-
fs/gfs2/file.c | 2 +-
fs/gfs2/inode.h | 2 +-
fs/hfsplus/hfsplus_fs.h | 2 +-
fs/hfsplus/inode.c | 2 +-
fs/jfs/ioctl.c | 2 +-
fs/jfs/jfs_inode.h | 2 +-
fs/nilfs2/ioctl.c | 2 +-
fs/nilfs2/nilfs.h | 2 +-
fs/ntfs3/file.c | 2 +-
fs/ntfs3/ntfs_fs.h | 2 +-
fs/ocfs2/ioctl.c | 2 +-
fs/ocfs2/ioctl.h | 2 +-
fs/orangefs/inode.c | 2 +-
fs/overlayfs/inode.c | 2 +-
fs/overlayfs/overlayfs.h | 2 +-
fs/ubifs/ioctl.c | 2 +-
fs/ubifs/ubifs.h | 2 +-
fs/xfs/xfs_ioctl.c | 2 +-
fs/xfs/xfs_ioctl.h | 2 +-
include/linux/fileattr.h | 2 +-
include/linux/fs.h | 2 +-
mm/shmem.c | 2 +-
37 files changed, 37 insertions(+), 37 deletions(-)
diff --git a/Documentation/filesystems/locking.rst b/Documentation/filesystems/locking.rst
index 2a91bc9c15f5..b95cd4992896 100644
--- a/Documentation/filesystems/locking.rst
+++ b/Documentation/filesystems/locking.rst
@@ -88,7 +88,7 @@ prototypes::
umode_t create_mode);
int (*tmpfile) (struct mnt_idmap *, struct inode *,
struct file *, umode_t);
- int (*fileattr_set)(struct mnt_idmap *idmap,
+ int (*fileattr_set)(const struct mnt_idmap *idmap,
struct dentry *dentry, struct file_kattr *fa);
int (*fileattr_get)(struct dentry *dentry, struct file_kattr *fa);
struct posix_acl * (*get_acl)(struct mnt_idmap *, struct dentry *, int);
diff --git a/Documentation/filesystems/vfs.rst b/Documentation/filesystems/vfs.rst
index b7e476f70185..c43bad400c30 100644
--- a/Documentation/filesystems/vfs.rst
+++ b/Documentation/filesystems/vfs.rst
@@ -441,7 +441,7 @@ As of kernel 2.6.22, the following members are defined:
int (*tmpfile) (struct mnt_idmap *, struct inode *, struct file *, umode_t);
struct posix_acl * (*get_acl)(struct mnt_idmap *, struct dentry *, int);
int (*set_acl)(struct mnt_idmap *, struct dentry *, struct posix_acl *, int);
- int (*fileattr_set)(struct mnt_idmap *idmap,
+ int (*fileattr_set)(const struct mnt_idmap *idmap,
struct dentry *dentry, struct file_kattr *fa);
int (*fileattr_get)(struct dentry *dentry, struct file_kattr *fa);
struct offset_ctx *(*get_offset_ctx)(struct inode *inode);
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 9d6302547b12..94c98801800f 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -278,7 +278,7 @@ int btrfs_fileattr_get(struct dentry *dentry, struct file_kattr *fa)
return 0;
}
-int btrfs_fileattr_set(struct mnt_idmap *idmap,
+int btrfs_fileattr_set(const struct mnt_idmap *idmap,
struct dentry *dentry, struct file_kattr *fa)
{
struct btrfs_inode *inode = BTRFS_I(d_inode(dentry));
diff --git a/fs/btrfs/ioctl.h b/fs/btrfs/ioctl.h
index ccf6bed9cc24..55f86aeb3500 100644
--- a/fs/btrfs/ioctl.h
+++ b/fs/btrfs/ioctl.h
@@ -17,7 +17,7 @@ struct btrfs_ioctl_balance_args;
long btrfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
long btrfs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
int btrfs_fileattr_get(struct dentry *dentry, struct file_kattr *fa);
-int btrfs_fileattr_set(struct mnt_idmap *idmap,
+int btrfs_fileattr_set(const struct mnt_idmap *idmap,
struct dentry *dentry, struct file_kattr *fa);
int btrfs_ioctl_get_supported_features(void __user *arg);
void btrfs_sync_inode_flags_to_i_flags(struct btrfs_inode *inode);
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index 691b3a24b60a..b9c32e8f855a 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -1078,7 +1078,7 @@ static int ecryptfs_fileattr_get(struct dentry *dentry, struct file_kattr *fa)
return vfs_fileattr_get(ecryptfs_dentry_to_lower(dentry), fa);
}
-static int ecryptfs_fileattr_set(struct mnt_idmap *idmap,
+static int ecryptfs_fileattr_set(const struct mnt_idmap *idmap,
struct dentry *dentry, struct file_kattr *fa)
{
struct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry);
diff --git a/fs/efivarfs/inode.c b/fs/efivarfs/inode.c
index f0d009555fc6..f7dcd72e4a07 100644
--- a/fs/efivarfs/inode.c
+++ b/fs/efivarfs/inode.c
@@ -150,7 +150,7 @@ efivarfs_fileattr_get(struct dentry *dentry, struct file_kattr *fa)
}
static int
-efivarfs_fileattr_set(struct mnt_idmap *idmap,
+efivarfs_fileattr_set(const struct mnt_idmap *idmap,
struct dentry *dentry, struct file_kattr *fa)
{
unsigned int i_flags = 0;
diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h
index 5642451bf191..702cb7aa1afd 100644
--- a/fs/ext2/ext2.h
+++ b/fs/ext2/ext2.h
@@ -748,7 +748,7 @@ extern int ext2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
/* ioctl.c */
extern int ext2_fileattr_get(struct dentry *dentry, struct file_kattr *fa);
-extern int ext2_fileattr_set(struct mnt_idmap *idmap,
+extern int ext2_fileattr_set(const struct mnt_idmap *idmap,
struct dentry *dentry, struct file_kattr *fa);
extern long ext2_ioctl(struct file *, unsigned int, unsigned long);
extern long ext2_compat_ioctl(struct file *, unsigned int, unsigned long);
diff --git a/fs/ext2/ioctl.c b/fs/ext2/ioctl.c
index c3fea55b8efa..f2218455fa47 100644
--- a/fs/ext2/ioctl.c
+++ b/fs/ext2/ioctl.c
@@ -27,7 +27,7 @@ int ext2_fileattr_get(struct dentry *dentry, struct file_kattr *fa)
return 0;
}
-int ext2_fileattr_set(struct mnt_idmap *idmap,
+int ext2_fileattr_set(const struct mnt_idmap *idmap,
struct dentry *dentry, struct file_kattr *fa)
{
struct inode *inode = d_inode(dentry);
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index aef86b1d10fa..2c9a845ed0f8 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -3246,7 +3246,7 @@ extern int ext4_ind_remove_space(handle_t *handle, struct inode *inode,
/* ioctl.c */
extern long ext4_ioctl(struct file *, unsigned int, unsigned long);
extern long ext4_compat_ioctl(struct file *, unsigned int, unsigned long);
-int ext4_fileattr_set(struct mnt_idmap *idmap,
+int ext4_fileattr_set(const struct mnt_idmap *idmap,
struct dentry *dentry, struct file_kattr *fa);
int ext4_fileattr_get(struct dentry *dentry, struct file_kattr *fa);
extern void ext4_reset_inode_seed(struct inode *inode);
diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index 6de77da4203c..2719f20493c8 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -1008,7 +1008,7 @@ int ext4_fileattr_get(struct dentry *dentry, struct file_kattr *fa)
return 0;
}
-int ext4_fileattr_set(struct mnt_idmap *idmap,
+int ext4_fileattr_set(const struct mnt_idmap *idmap,
struct dentry *dentry, struct file_kattr *fa)
{
struct inode *inode = d_inode(dentry);
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index eefc886e3ffc..245df8563256 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -3858,7 +3858,7 @@ int f2fs_do_shutdown(struct f2fs_sb_info *sbi, unsigned int flag,
bool readonly, bool need_lock);
int f2fs_precache_extents(struct inode *inode);
int f2fs_fileattr_get(struct dentry *dentry, struct file_kattr *fa);
-int f2fs_fileattr_set(struct mnt_idmap *idmap,
+int f2fs_fileattr_set(const struct mnt_idmap *idmap,
struct dentry *dentry, struct file_kattr *fa);
long f2fs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
long f2fs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 03bb3a9a449f..d0cc2ca1397a 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -3580,7 +3580,7 @@ int f2fs_fileattr_get(struct dentry *dentry, struct file_kattr *fa)
return 0;
}
-int f2fs_fileattr_set(struct mnt_idmap *idmap,
+int f2fs_fileattr_set(const struct mnt_idmap *idmap,
struct dentry *dentry, struct file_kattr *fa)
{
struct inode *inode = d_inode(dentry);
diff --git a/fs/file_attr.c b/fs/file_attr.c
index bfb00d256dd5..5393c4dfa4a8 100644
--- a/fs/file_attr.c
+++ b/fs/file_attr.c
@@ -265,7 +265,7 @@ static int fileattr_set_prepare(struct inode *inode,
*
* Return: 0 on success, or a negative error on failure.
*/
-int vfs_fileattr_set(struct mnt_idmap *idmap, struct dentry *dentry,
+int vfs_fileattr_set(const struct mnt_idmap *idmap, struct dentry *dentry,
struct file_kattr *fa)
{
struct inode *inode = d_inode(dentry);
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index 9ea346ea2e01..6ca56757869c 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -1238,7 +1238,7 @@ long fuse_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
long fuse_file_compat_ioctl(struct file *file, unsigned int cmd,
unsigned long arg);
int fuse_fileattr_get(struct dentry *dentry, struct file_kattr *fa);
-int fuse_fileattr_set(struct mnt_idmap *idmap,
+int fuse_fileattr_set(const struct mnt_idmap *idmap,
struct dentry *dentry, struct file_kattr *fa);
/* iomode.c */
diff --git a/fs/fuse/ioctl.c b/fs/fuse/ioctl.c
index 3614ea603913..3ee45b2e148f 100644
--- a/fs/fuse/ioctl.c
+++ b/fs/fuse/ioctl.c
@@ -540,7 +540,7 @@ int fuse_fileattr_get(struct dentry *dentry, struct file_kattr *fa)
return err;
}
-int fuse_fileattr_set(struct mnt_idmap *idmap,
+int fuse_fileattr_set(const struct mnt_idmap *idmap,
struct dentry *dentry, struct file_kattr *fa)
{
struct inode *inode = d_inode(dentry);
diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c
index b8c10de113ba..9487625a4166 100644
--- a/fs/gfs2/file.c
+++ b/fs/gfs2/file.c
@@ -275,7 +275,7 @@ static int do_gfs2_set_flags(struct inode *inode, u32 reqflags, u32 mask)
return error;
}
-int gfs2_fileattr_set(struct mnt_idmap *idmap,
+int gfs2_fileattr_set(const struct mnt_idmap *idmap,
struct dentry *dentry, struct file_kattr *fa)
{
struct inode *inode = d_inode(dentry);
diff --git a/fs/gfs2/inode.h b/fs/gfs2/inode.h
index 373473eb091c..99196d3114e4 100644
--- a/fs/gfs2/inode.h
+++ b/fs/gfs2/inode.h
@@ -109,7 +109,7 @@ extern const struct file_operations gfs2_file_fops_nolock;
extern const struct file_operations gfs2_dir_fops_nolock;
int gfs2_fileattr_get(struct dentry *dentry, struct file_kattr *fa);
-int gfs2_fileattr_set(struct mnt_idmap *idmap,
+int gfs2_fileattr_set(const struct mnt_idmap *idmap,
struct dentry *dentry, struct file_kattr *fa);
void gfs2_set_inode_flags(struct inode *inode);
diff --git a/fs/hfsplus/hfsplus_fs.h b/fs/hfsplus/hfsplus_fs.h
index 1e5b58e6a13f..86fc1c1cdfd6 100644
--- a/fs/hfsplus/hfsplus_fs.h
+++ b/fs/hfsplus/hfsplus_fs.h
@@ -465,7 +465,7 @@ int hfsplus_getattr(struct mnt_idmap *idmap, const struct path *path,
int hfsplus_file_fsync(struct file *file, loff_t start, loff_t end,
int datasync);
int hfsplus_fileattr_get(struct dentry *dentry, struct file_kattr *fa);
-int hfsplus_fileattr_set(struct mnt_idmap *idmap,
+int hfsplus_fileattr_set(const struct mnt_idmap *idmap,
struct dentry *dentry, struct file_kattr *fa);
/* ioctl.c */
diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
index 2ce6de574fa6..9821662bfc1d 100644
--- a/fs/hfsplus/inode.c
+++ b/fs/hfsplus/inode.c
@@ -797,7 +797,7 @@ int hfsplus_fileattr_get(struct dentry *dentry, struct file_kattr *fa)
return 0;
}
-int hfsplus_fileattr_set(struct mnt_idmap *idmap,
+int hfsplus_fileattr_set(const struct mnt_idmap *idmap,
struct dentry *dentry, struct file_kattr *fa)
{
struct inode *inode = d_inode(dentry);
diff --git a/fs/jfs/ioctl.c b/fs/jfs/ioctl.c
index 563f148be8af..27d39cddaca6 100644
--- a/fs/jfs/ioctl.c
+++ b/fs/jfs/ioctl.c
@@ -70,7 +70,7 @@ int jfs_fileattr_get(struct dentry *dentry, struct file_kattr *fa)
return 0;
}
-int jfs_fileattr_set(struct mnt_idmap *idmap,
+int jfs_fileattr_set(const struct mnt_idmap *idmap,
struct dentry *dentry, struct file_kattr *fa)
{
struct inode *inode = d_inode(dentry);
diff --git a/fs/jfs/jfs_inode.h b/fs/jfs/jfs_inode.h
index 2c6c81c8cb9f..88cfc3886282 100644
--- a/fs/jfs/jfs_inode.h
+++ b/fs/jfs/jfs_inode.h
@@ -10,7 +10,7 @@ struct fid;
extern struct inode *ialloc(struct inode *, umode_t);
extern int jfs_fsync(struct file *, loff_t, loff_t, int);
extern int jfs_fileattr_get(struct dentry *dentry, struct file_kattr *fa);
-extern int jfs_fileattr_set(struct mnt_idmap *idmap,
+extern int jfs_fileattr_set(const struct mnt_idmap *idmap,
struct dentry *dentry, struct file_kattr *fa);
extern long jfs_ioctl(struct file *, unsigned int, unsigned long);
extern struct inode *jfs_iget(struct super_block *, unsigned long);
diff --git a/fs/nilfs2/ioctl.c b/fs/nilfs2/ioctl.c
index 01a04080ef70..f56a79767c69 100644
--- a/fs/nilfs2/ioctl.c
+++ b/fs/nilfs2/ioctl.c
@@ -135,7 +135,7 @@ int nilfs_fileattr_get(struct dentry *dentry, struct file_kattr *fa)
*
* Return: 0 on success, or a negative error code on failure.
*/
-int nilfs_fileattr_set(struct mnt_idmap *idmap,
+int nilfs_fileattr_set(const struct mnt_idmap *idmap,
struct dentry *dentry, struct file_kattr *fa)
{
struct inode *inode = d_inode(dentry);
diff --git a/fs/nilfs2/nilfs.h b/fs/nilfs2/nilfs.h
index 0eaa191f70b8..829df7be11fe 100644
--- a/fs/nilfs2/nilfs.h
+++ b/fs/nilfs2/nilfs.h
@@ -270,7 +270,7 @@ extern int nilfs_sync_file(struct file *, loff_t, loff_t, int);
/* ioctl.c */
int nilfs_fileattr_get(struct dentry *dentry, struct file_kattr *m);
-int nilfs_fileattr_set(struct mnt_idmap *idmap,
+int nilfs_fileattr_set(const struct mnt_idmap *idmap,
struct dentry *dentry, struct file_kattr *fa);
long nilfs_ioctl(struct file *, unsigned int, unsigned long);
long nilfs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c
index 2abf334bfa0c..f7baa202dc28 100644
--- a/fs/ntfs3/file.c
+++ b/fs/ntfs3/file.c
@@ -129,7 +129,7 @@ int ntfs_fileattr_get(struct dentry *dentry, struct file_kattr *fa)
/*
* ntfs_fileattr_set - inode_operations::fileattr_set
*/
-int ntfs_fileattr_set(struct mnt_idmap *idmap, struct dentry *dentry,
+int ntfs_fileattr_set(const struct mnt_idmap *idmap, struct dentry *dentry,
struct file_kattr *fa)
{
struct inode *inode = d_inode(dentry);
diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h
index a2b74f41048f..e494bed87679 100644
--- a/fs/ntfs3/ntfs_fs.h
+++ b/fs/ntfs3/ntfs_fs.h
@@ -551,7 +551,7 @@ extern const struct file_operations ntfs_dir_operations;
/* Globals from file.c */
int ntfs_fileattr_get(struct dentry *dentry, struct file_kattr *fa);
-int ntfs_fileattr_set(struct mnt_idmap *idmap, struct dentry *dentry,
+int ntfs_fileattr_set(const struct mnt_idmap *idmap, struct dentry *dentry,
struct file_kattr *fa);
int ntfs_getattr(struct mnt_idmap *idmap, const struct path *path,
struct kstat *stat, u32 request_mask, u32 flags);
diff --git a/fs/ocfs2/ioctl.c b/fs/ocfs2/ioctl.c
index cbe59d231666..36c7c9ac8b5d 100644
--- a/fs/ocfs2/ioctl.c
+++ b/fs/ocfs2/ioctl.c
@@ -82,7 +82,7 @@ int ocfs2_fileattr_get(struct dentry *dentry, struct file_kattr *fa)
return status;
}
-int ocfs2_fileattr_set(struct mnt_idmap *idmap,
+int ocfs2_fileattr_set(const struct mnt_idmap *idmap,
struct dentry *dentry, struct file_kattr *fa)
{
struct inode *inode = d_inode(dentry);
diff --git a/fs/ocfs2/ioctl.h b/fs/ocfs2/ioctl.h
index 4a1c2313b429..b1cb529fc5f9 100644
--- a/fs/ocfs2/ioctl.h
+++ b/fs/ocfs2/ioctl.h
@@ -12,7 +12,7 @@
#define OCFS2_IOCTL_PROTO_H
int ocfs2_fileattr_get(struct dentry *dentry, struct file_kattr *fa);
-int ocfs2_fileattr_set(struct mnt_idmap *idmap,
+int ocfs2_fileattr_set(const struct mnt_idmap *idmap,
struct dentry *dentry, struct file_kattr *fa);
long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
long ocfs2_compat_ioctl(struct file *file, unsigned cmd, unsigned long arg);
diff --git a/fs/orangefs/inode.c b/fs/orangefs/inode.c
index 8e6eeec501bc..536d5e842c55 100644
--- a/fs/orangefs/inode.c
+++ b/fs/orangefs/inode.c
@@ -934,7 +934,7 @@ static int orangefs_fileattr_get(struct dentry *dentry, struct file_kattr *fa)
return 0;
}
-static int orangefs_fileattr_set(struct mnt_idmap *idmap,
+static int orangefs_fileattr_set(const struct mnt_idmap *idmap,
struct dentry *dentry, struct file_kattr *fa)
{
u64 val = 0;
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
index 1166381f1852..5f4e8b6d9722 100644
--- a/fs/overlayfs/inode.c
+++ b/fs/overlayfs/inode.c
@@ -650,7 +650,7 @@ int ovl_real_fileattr_set(const struct path *realpath, struct file_kattr *fa)
return vfs_fileattr_set(mnt_idmap(realpath->mnt), realpath->dentry, fa);
}
-int ovl_fileattr_set(struct mnt_idmap *idmap,
+int ovl_fileattr_set(const struct mnt_idmap *idmap,
struct dentry *dentry, struct file_kattr *fa)
{
struct inode *inode = d_inode(dentry);
diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h
index 513ba93c7d1b..46a5cf5dae4c 100644
--- a/fs/overlayfs/overlayfs.h
+++ b/fs/overlayfs/overlayfs.h
@@ -914,7 +914,7 @@ extern const struct file_operations ovl_file_operations;
int ovl_real_fileattr_get(const struct path *realpath, struct file_kattr *fa);
int ovl_real_fileattr_set(const struct path *realpath, struct file_kattr *fa);
int ovl_fileattr_get(struct dentry *dentry, struct file_kattr *fa);
-int ovl_fileattr_set(struct mnt_idmap *idmap,
+int ovl_fileattr_set(const struct mnt_idmap *idmap,
struct dentry *dentry, struct file_kattr *fa);
struct ovl_file;
struct ovl_file *ovl_file_alloc(struct file *realfile);
diff --git a/fs/ubifs/ioctl.c b/fs/ubifs/ioctl.c
index 79536b2e3d7a..5c34f895bd4e 100644
--- a/fs/ubifs/ioctl.c
+++ b/fs/ubifs/ioctl.c
@@ -144,7 +144,7 @@ int ubifs_fileattr_get(struct dentry *dentry, struct file_kattr *fa)
return 0;
}
-int ubifs_fileattr_set(struct mnt_idmap *idmap,
+int ubifs_fileattr_set(const struct mnt_idmap *idmap,
struct dentry *dentry, struct file_kattr *fa)
{
struct inode *inode = d_inode(dentry);
diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h
index 00db0d19a85e..af0ef3583aeb 100644
--- a/fs/ubifs/ubifs.h
+++ b/fs/ubifs/ubifs.h
@@ -2083,7 +2083,7 @@ void ubifs_destroy_size_tree(struct ubifs_info *c);
/* ioctl.c */
int ubifs_fileattr_get(struct dentry *dentry, struct file_kattr *fa);
-int ubifs_fileattr_set(struct mnt_idmap *idmap,
+int ubifs_fileattr_set(const struct mnt_idmap *idmap,
struct dentry *dentry, struct file_kattr *fa);
long ubifs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
void ubifs_set_inode_flags(struct inode *inode);
diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
index 1b53701bebea..0df67f0d573c 100644
--- a/fs/xfs/xfs_ioctl.c
+++ b/fs/xfs/xfs_ioctl.c
@@ -748,7 +748,7 @@ xfs_ioctl_setattr_check_projid(
int
xfs_fileattr_set(
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *dentry,
struct file_kattr *fa)
{
diff --git a/fs/xfs/xfs_ioctl.h b/fs/xfs/xfs_ioctl.h
index f5ed5cf9d3df..70c26cb05eb6 100644
--- a/fs/xfs/xfs_ioctl.h
+++ b/fs/xfs/xfs_ioctl.h
@@ -21,7 +21,7 @@ xfs_fileattr_get(
extern int
xfs_fileattr_set(
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *dentry,
struct file_kattr *fa);
diff --git a/include/linux/fileattr.h b/include/linux/fileattr.h
index 58044b598016..09e32b84e02a 100644
--- a/include/linux/fileattr.h
+++ b/include/linux/fileattr.h
@@ -74,7 +74,7 @@ static inline bool fileattr_has_fsx(const struct file_kattr *fa)
}
int vfs_fileattr_get(struct dentry *dentry, struct file_kattr *fa);
-int vfs_fileattr_set(struct mnt_idmap *idmap, struct dentry *dentry,
+int vfs_fileattr_set(const struct mnt_idmap *idmap, struct dentry *dentry,
struct file_kattr *fa);
int ioctl_getflags(struct file *file, unsigned int __user *argp);
int ioctl_setflags(struct file *file, unsigned int __user *argp);
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 08166900931a..764ef2d97a5d 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2030,7 +2030,7 @@ struct inode_operations {
int);
int (*set_acl)(struct mnt_idmap *, struct dentry *,
struct posix_acl *, int);
- int (*fileattr_set)(struct mnt_idmap *idmap,
+ int (*fileattr_set)(const struct mnt_idmap *idmap,
struct dentry *dentry, struct file_kattr *fa);
int (*fileattr_get)(struct dentry *dentry, struct file_kattr *fa);
struct offset_ctx *(*get_offset_ctx)(struct inode *inode);
diff --git a/mm/shmem.c b/mm/shmem.c
index ed633b3bc38d..097699ea2762 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -4159,7 +4159,7 @@ static int shmem_fileattr_get(struct dentry *dentry, struct file_kattr *fa)
return 0;
}
-static int shmem_fileattr_set(struct mnt_idmap *idmap,
+static int shmem_fileattr_set(const struct mnt_idmap *idmap,
struct dentry *dentry, struct file_kattr *fa)
{
struct inode *inode = d_inode(dentry);
--
2.53.0
^ permalink raw reply related [flat|nested] 62+ messages in thread* Re: [PATCH 14/27] fs: port ->fileattr_set() to pass const mnt_idmap
2026-09-01 12:14 ` [PATCH 14/27] fs: port ->fileattr_set() to pass " Christian Brauner
@ 2026-09-02 15:43 ` Jan Kara
0 siblings, 0 replies; 62+ messages in thread
From: Jan Kara @ 2026-09-02 15:43 UTC (permalink / raw)
To: Christian Brauner
Cc: linux-fsdevel, Alexander Viro, Jan Kara, Christoph Hellwig,
Seth Forshee, Paul Moore, linux-security-module, Mimi Zohar,
linux-integrity, Ilya Dryomov, ceph-devel, Carlos Maiolino,
linux-xfs, Miklos Szeredi, Amir Goldstein, linux-unionfs,
Namjae Jeon, linux-cifs, linux-kernel
On Tue 01-09-26 14:14:39, Christian Brauner wrote:
> Convert to const struct mnt_idmap.
>
> A mount's idmapping is immutable. The only thing that is allowed to be
> modified afterwards is the reference count and that is hidden behind
> mnt_idmap_get() and mnt_idmap_put(). Everything else only ever reads
> from the idmapping. This is the same model that struct cred uses and the
> idmapping is also rather sensitive.
>
> So make the idmap argument const wherever we can. The conversion is done
> from the bottom up so callers can continue to pass a non-const pointer
> to a const parameter until the conversion is finished.
>
> No functional changes.
>
> Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> Documentation/filesystems/locking.rst | 2 +-
> Documentation/filesystems/vfs.rst | 2 +-
> fs/btrfs/ioctl.c | 2 +-
> fs/btrfs/ioctl.h | 2 +-
> fs/ecryptfs/inode.c | 2 +-
> fs/efivarfs/inode.c | 2 +-
> fs/ext2/ext2.h | 2 +-
> fs/ext2/ioctl.c | 2 +-
> fs/ext4/ext4.h | 2 +-
> fs/ext4/ioctl.c | 2 +-
> fs/f2fs/f2fs.h | 2 +-
> fs/f2fs/file.c | 2 +-
> fs/file_attr.c | 2 +-
> fs/fuse/fuse_i.h | 2 +-
> fs/fuse/ioctl.c | 2 +-
> fs/gfs2/file.c | 2 +-
> fs/gfs2/inode.h | 2 +-
> fs/hfsplus/hfsplus_fs.h | 2 +-
> fs/hfsplus/inode.c | 2 +-
> fs/jfs/ioctl.c | 2 +-
> fs/jfs/jfs_inode.h | 2 +-
> fs/nilfs2/ioctl.c | 2 +-
> fs/nilfs2/nilfs.h | 2 +-
> fs/ntfs3/file.c | 2 +-
> fs/ntfs3/ntfs_fs.h | 2 +-
> fs/ocfs2/ioctl.c | 2 +-
> fs/ocfs2/ioctl.h | 2 +-
> fs/orangefs/inode.c | 2 +-
> fs/overlayfs/inode.c | 2 +-
> fs/overlayfs/overlayfs.h | 2 +-
> fs/ubifs/ioctl.c | 2 +-
> fs/ubifs/ubifs.h | 2 +-
> fs/xfs/xfs_ioctl.c | 2 +-
> fs/xfs/xfs_ioctl.h | 2 +-
> include/linux/fileattr.h | 2 +-
> include/linux/fs.h | 2 +-
> mm/shmem.c | 2 +-
> 37 files changed, 37 insertions(+), 37 deletions(-)
>
> diff --git a/Documentation/filesystems/locking.rst b/Documentation/filesystems/locking.rst
> index 2a91bc9c15f5..b95cd4992896 100644
> --- a/Documentation/filesystems/locking.rst
> +++ b/Documentation/filesystems/locking.rst
> @@ -88,7 +88,7 @@ prototypes::
> umode_t create_mode);
> int (*tmpfile) (struct mnt_idmap *, struct inode *,
> struct file *, umode_t);
> - int (*fileattr_set)(struct mnt_idmap *idmap,
> + int (*fileattr_set)(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct file_kattr *fa);
> int (*fileattr_get)(struct dentry *dentry, struct file_kattr *fa);
> struct posix_acl * (*get_acl)(struct mnt_idmap *, struct dentry *, int);
> diff --git a/Documentation/filesystems/vfs.rst b/Documentation/filesystems/vfs.rst
> index b7e476f70185..c43bad400c30 100644
> --- a/Documentation/filesystems/vfs.rst
> +++ b/Documentation/filesystems/vfs.rst
> @@ -441,7 +441,7 @@ As of kernel 2.6.22, the following members are defined:
> int (*tmpfile) (struct mnt_idmap *, struct inode *, struct file *, umode_t);
> struct posix_acl * (*get_acl)(struct mnt_idmap *, struct dentry *, int);
> int (*set_acl)(struct mnt_idmap *, struct dentry *, struct posix_acl *, int);
> - int (*fileattr_set)(struct mnt_idmap *idmap,
> + int (*fileattr_set)(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct file_kattr *fa);
> int (*fileattr_get)(struct dentry *dentry, struct file_kattr *fa);
> struct offset_ctx *(*get_offset_ctx)(struct inode *inode);
> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
> index 9d6302547b12..94c98801800f 100644
> --- a/fs/btrfs/ioctl.c
> +++ b/fs/btrfs/ioctl.c
> @@ -278,7 +278,7 @@ int btrfs_fileattr_get(struct dentry *dentry, struct file_kattr *fa)
> return 0;
> }
>
> -int btrfs_fileattr_set(struct mnt_idmap *idmap,
> +int btrfs_fileattr_set(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct file_kattr *fa)
> {
> struct btrfs_inode *inode = BTRFS_I(d_inode(dentry));
> diff --git a/fs/btrfs/ioctl.h b/fs/btrfs/ioctl.h
> index ccf6bed9cc24..55f86aeb3500 100644
> --- a/fs/btrfs/ioctl.h
> +++ b/fs/btrfs/ioctl.h
> @@ -17,7 +17,7 @@ struct btrfs_ioctl_balance_args;
> long btrfs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
> long btrfs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
> int btrfs_fileattr_get(struct dentry *dentry, struct file_kattr *fa);
> -int btrfs_fileattr_set(struct mnt_idmap *idmap,
> +int btrfs_fileattr_set(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct file_kattr *fa);
> int btrfs_ioctl_get_supported_features(void __user *arg);
> void btrfs_sync_inode_flags_to_i_flags(struct btrfs_inode *inode);
> diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
> index 691b3a24b60a..b9c32e8f855a 100644
> --- a/fs/ecryptfs/inode.c
> +++ b/fs/ecryptfs/inode.c
> @@ -1078,7 +1078,7 @@ static int ecryptfs_fileattr_get(struct dentry *dentry, struct file_kattr *fa)
> return vfs_fileattr_get(ecryptfs_dentry_to_lower(dentry), fa);
> }
>
> -static int ecryptfs_fileattr_set(struct mnt_idmap *idmap,
> +static int ecryptfs_fileattr_set(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct file_kattr *fa)
> {
> struct dentry *lower_dentry = ecryptfs_dentry_to_lower(dentry);
> diff --git a/fs/efivarfs/inode.c b/fs/efivarfs/inode.c
> index f0d009555fc6..f7dcd72e4a07 100644
> --- a/fs/efivarfs/inode.c
> +++ b/fs/efivarfs/inode.c
> @@ -150,7 +150,7 @@ efivarfs_fileattr_get(struct dentry *dentry, struct file_kattr *fa)
> }
>
> static int
> -efivarfs_fileattr_set(struct mnt_idmap *idmap,
> +efivarfs_fileattr_set(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct file_kattr *fa)
> {
> unsigned int i_flags = 0;
> diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h
> index 5642451bf191..702cb7aa1afd 100644
> --- a/fs/ext2/ext2.h
> +++ b/fs/ext2/ext2.h
> @@ -748,7 +748,7 @@ extern int ext2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
>
> /* ioctl.c */
> extern int ext2_fileattr_get(struct dentry *dentry, struct file_kattr *fa);
> -extern int ext2_fileattr_set(struct mnt_idmap *idmap,
> +extern int ext2_fileattr_set(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct file_kattr *fa);
> extern long ext2_ioctl(struct file *, unsigned int, unsigned long);
> extern long ext2_compat_ioctl(struct file *, unsigned int, unsigned long);
> diff --git a/fs/ext2/ioctl.c b/fs/ext2/ioctl.c
> index c3fea55b8efa..f2218455fa47 100644
> --- a/fs/ext2/ioctl.c
> +++ b/fs/ext2/ioctl.c
> @@ -27,7 +27,7 @@ int ext2_fileattr_get(struct dentry *dentry, struct file_kattr *fa)
> return 0;
> }
>
> -int ext2_fileattr_set(struct mnt_idmap *idmap,
> +int ext2_fileattr_set(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct file_kattr *fa)
> {
> struct inode *inode = d_inode(dentry);
> diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
> index aef86b1d10fa..2c9a845ed0f8 100644
> --- a/fs/ext4/ext4.h
> +++ b/fs/ext4/ext4.h
> @@ -3246,7 +3246,7 @@ extern int ext4_ind_remove_space(handle_t *handle, struct inode *inode,
> /* ioctl.c */
> extern long ext4_ioctl(struct file *, unsigned int, unsigned long);
> extern long ext4_compat_ioctl(struct file *, unsigned int, unsigned long);
> -int ext4_fileattr_set(struct mnt_idmap *idmap,
> +int ext4_fileattr_set(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct file_kattr *fa);
> int ext4_fileattr_get(struct dentry *dentry, struct file_kattr *fa);
> extern void ext4_reset_inode_seed(struct inode *inode);
> diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
> index 6de77da4203c..2719f20493c8 100644
> --- a/fs/ext4/ioctl.c
> +++ b/fs/ext4/ioctl.c
> @@ -1008,7 +1008,7 @@ int ext4_fileattr_get(struct dentry *dentry, struct file_kattr *fa)
> return 0;
> }
>
> -int ext4_fileattr_set(struct mnt_idmap *idmap,
> +int ext4_fileattr_set(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct file_kattr *fa)
> {
> struct inode *inode = d_inode(dentry);
> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> index eefc886e3ffc..245df8563256 100644
> --- a/fs/f2fs/f2fs.h
> +++ b/fs/f2fs/f2fs.h
> @@ -3858,7 +3858,7 @@ int f2fs_do_shutdown(struct f2fs_sb_info *sbi, unsigned int flag,
> bool readonly, bool need_lock);
> int f2fs_precache_extents(struct inode *inode);
> int f2fs_fileattr_get(struct dentry *dentry, struct file_kattr *fa);
> -int f2fs_fileattr_set(struct mnt_idmap *idmap,
> +int f2fs_fileattr_set(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct file_kattr *fa);
> long f2fs_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
> long f2fs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index 03bb3a9a449f..d0cc2ca1397a 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -3580,7 +3580,7 @@ int f2fs_fileattr_get(struct dentry *dentry, struct file_kattr *fa)
> return 0;
> }
>
> -int f2fs_fileattr_set(struct mnt_idmap *idmap,
> +int f2fs_fileattr_set(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct file_kattr *fa)
> {
> struct inode *inode = d_inode(dentry);
> diff --git a/fs/file_attr.c b/fs/file_attr.c
> index bfb00d256dd5..5393c4dfa4a8 100644
> --- a/fs/file_attr.c
> +++ b/fs/file_attr.c
> @@ -265,7 +265,7 @@ static int fileattr_set_prepare(struct inode *inode,
> *
> * Return: 0 on success, or a negative error on failure.
> */
> -int vfs_fileattr_set(struct mnt_idmap *idmap, struct dentry *dentry,
> +int vfs_fileattr_set(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct file_kattr *fa)
> {
> struct inode *inode = d_inode(dentry);
> diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
> index 9ea346ea2e01..6ca56757869c 100644
> --- a/fs/fuse/fuse_i.h
> +++ b/fs/fuse/fuse_i.h
> @@ -1238,7 +1238,7 @@ long fuse_file_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
> long fuse_file_compat_ioctl(struct file *file, unsigned int cmd,
> unsigned long arg);
> int fuse_fileattr_get(struct dentry *dentry, struct file_kattr *fa);
> -int fuse_fileattr_set(struct mnt_idmap *idmap,
> +int fuse_fileattr_set(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct file_kattr *fa);
>
> /* iomode.c */
> diff --git a/fs/fuse/ioctl.c b/fs/fuse/ioctl.c
> index 3614ea603913..3ee45b2e148f 100644
> --- a/fs/fuse/ioctl.c
> +++ b/fs/fuse/ioctl.c
> @@ -540,7 +540,7 @@ int fuse_fileattr_get(struct dentry *dentry, struct file_kattr *fa)
> return err;
> }
>
> -int fuse_fileattr_set(struct mnt_idmap *idmap,
> +int fuse_fileattr_set(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct file_kattr *fa)
> {
> struct inode *inode = d_inode(dentry);
> diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c
> index b8c10de113ba..9487625a4166 100644
> --- a/fs/gfs2/file.c
> +++ b/fs/gfs2/file.c
> @@ -275,7 +275,7 @@ static int do_gfs2_set_flags(struct inode *inode, u32 reqflags, u32 mask)
> return error;
> }
>
> -int gfs2_fileattr_set(struct mnt_idmap *idmap,
> +int gfs2_fileattr_set(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct file_kattr *fa)
> {
> struct inode *inode = d_inode(dentry);
> diff --git a/fs/gfs2/inode.h b/fs/gfs2/inode.h
> index 373473eb091c..99196d3114e4 100644
> --- a/fs/gfs2/inode.h
> +++ b/fs/gfs2/inode.h
> @@ -109,7 +109,7 @@ extern const struct file_operations gfs2_file_fops_nolock;
> extern const struct file_operations gfs2_dir_fops_nolock;
>
> int gfs2_fileattr_get(struct dentry *dentry, struct file_kattr *fa);
> -int gfs2_fileattr_set(struct mnt_idmap *idmap,
> +int gfs2_fileattr_set(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct file_kattr *fa);
> void gfs2_set_inode_flags(struct inode *inode);
>
> diff --git a/fs/hfsplus/hfsplus_fs.h b/fs/hfsplus/hfsplus_fs.h
> index 1e5b58e6a13f..86fc1c1cdfd6 100644
> --- a/fs/hfsplus/hfsplus_fs.h
> +++ b/fs/hfsplus/hfsplus_fs.h
> @@ -465,7 +465,7 @@ int hfsplus_getattr(struct mnt_idmap *idmap, const struct path *path,
> int hfsplus_file_fsync(struct file *file, loff_t start, loff_t end,
> int datasync);
> int hfsplus_fileattr_get(struct dentry *dentry, struct file_kattr *fa);
> -int hfsplus_fileattr_set(struct mnt_idmap *idmap,
> +int hfsplus_fileattr_set(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct file_kattr *fa);
>
> /* ioctl.c */
> diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
> index 2ce6de574fa6..9821662bfc1d 100644
> --- a/fs/hfsplus/inode.c
> +++ b/fs/hfsplus/inode.c
> @@ -797,7 +797,7 @@ int hfsplus_fileattr_get(struct dentry *dentry, struct file_kattr *fa)
> return 0;
> }
>
> -int hfsplus_fileattr_set(struct mnt_idmap *idmap,
> +int hfsplus_fileattr_set(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct file_kattr *fa)
> {
> struct inode *inode = d_inode(dentry);
> diff --git a/fs/jfs/ioctl.c b/fs/jfs/ioctl.c
> index 563f148be8af..27d39cddaca6 100644
> --- a/fs/jfs/ioctl.c
> +++ b/fs/jfs/ioctl.c
> @@ -70,7 +70,7 @@ int jfs_fileattr_get(struct dentry *dentry, struct file_kattr *fa)
> return 0;
> }
>
> -int jfs_fileattr_set(struct mnt_idmap *idmap,
> +int jfs_fileattr_set(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct file_kattr *fa)
> {
> struct inode *inode = d_inode(dentry);
> diff --git a/fs/jfs/jfs_inode.h b/fs/jfs/jfs_inode.h
> index 2c6c81c8cb9f..88cfc3886282 100644
> --- a/fs/jfs/jfs_inode.h
> +++ b/fs/jfs/jfs_inode.h
> @@ -10,7 +10,7 @@ struct fid;
> extern struct inode *ialloc(struct inode *, umode_t);
> extern int jfs_fsync(struct file *, loff_t, loff_t, int);
> extern int jfs_fileattr_get(struct dentry *dentry, struct file_kattr *fa);
> -extern int jfs_fileattr_set(struct mnt_idmap *idmap,
> +extern int jfs_fileattr_set(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct file_kattr *fa);
> extern long jfs_ioctl(struct file *, unsigned int, unsigned long);
> extern struct inode *jfs_iget(struct super_block *, unsigned long);
> diff --git a/fs/nilfs2/ioctl.c b/fs/nilfs2/ioctl.c
> index 01a04080ef70..f56a79767c69 100644
> --- a/fs/nilfs2/ioctl.c
> +++ b/fs/nilfs2/ioctl.c
> @@ -135,7 +135,7 @@ int nilfs_fileattr_get(struct dentry *dentry, struct file_kattr *fa)
> *
> * Return: 0 on success, or a negative error code on failure.
> */
> -int nilfs_fileattr_set(struct mnt_idmap *idmap,
> +int nilfs_fileattr_set(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct file_kattr *fa)
> {
> struct inode *inode = d_inode(dentry);
> diff --git a/fs/nilfs2/nilfs.h b/fs/nilfs2/nilfs.h
> index 0eaa191f70b8..829df7be11fe 100644
> --- a/fs/nilfs2/nilfs.h
> +++ b/fs/nilfs2/nilfs.h
> @@ -270,7 +270,7 @@ extern int nilfs_sync_file(struct file *, loff_t, loff_t, int);
>
> /* ioctl.c */
> int nilfs_fileattr_get(struct dentry *dentry, struct file_kattr *m);
> -int nilfs_fileattr_set(struct mnt_idmap *idmap,
> +int nilfs_fileattr_set(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct file_kattr *fa);
> long nilfs_ioctl(struct file *, unsigned int, unsigned long);
> long nilfs_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
> diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c
> index 2abf334bfa0c..f7baa202dc28 100644
> --- a/fs/ntfs3/file.c
> +++ b/fs/ntfs3/file.c
> @@ -129,7 +129,7 @@ int ntfs_fileattr_get(struct dentry *dentry, struct file_kattr *fa)
> /*
> * ntfs_fileattr_set - inode_operations::fileattr_set
> */
> -int ntfs_fileattr_set(struct mnt_idmap *idmap, struct dentry *dentry,
> +int ntfs_fileattr_set(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct file_kattr *fa)
> {
> struct inode *inode = d_inode(dentry);
> diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h
> index a2b74f41048f..e494bed87679 100644
> --- a/fs/ntfs3/ntfs_fs.h
> +++ b/fs/ntfs3/ntfs_fs.h
> @@ -551,7 +551,7 @@ extern const struct file_operations ntfs_dir_operations;
>
> /* Globals from file.c */
> int ntfs_fileattr_get(struct dentry *dentry, struct file_kattr *fa);
> -int ntfs_fileattr_set(struct mnt_idmap *idmap, struct dentry *dentry,
> +int ntfs_fileattr_set(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct file_kattr *fa);
> int ntfs_getattr(struct mnt_idmap *idmap, const struct path *path,
> struct kstat *stat, u32 request_mask, u32 flags);
> diff --git a/fs/ocfs2/ioctl.c b/fs/ocfs2/ioctl.c
> index cbe59d231666..36c7c9ac8b5d 100644
> --- a/fs/ocfs2/ioctl.c
> +++ b/fs/ocfs2/ioctl.c
> @@ -82,7 +82,7 @@ int ocfs2_fileattr_get(struct dentry *dentry, struct file_kattr *fa)
> return status;
> }
>
> -int ocfs2_fileattr_set(struct mnt_idmap *idmap,
> +int ocfs2_fileattr_set(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct file_kattr *fa)
> {
> struct inode *inode = d_inode(dentry);
> diff --git a/fs/ocfs2/ioctl.h b/fs/ocfs2/ioctl.h
> index 4a1c2313b429..b1cb529fc5f9 100644
> --- a/fs/ocfs2/ioctl.h
> +++ b/fs/ocfs2/ioctl.h
> @@ -12,7 +12,7 @@
> #define OCFS2_IOCTL_PROTO_H
>
> int ocfs2_fileattr_get(struct dentry *dentry, struct file_kattr *fa);
> -int ocfs2_fileattr_set(struct mnt_idmap *idmap,
> +int ocfs2_fileattr_set(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct file_kattr *fa);
> long ocfs2_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
> long ocfs2_compat_ioctl(struct file *file, unsigned cmd, unsigned long arg);
> diff --git a/fs/orangefs/inode.c b/fs/orangefs/inode.c
> index 8e6eeec501bc..536d5e842c55 100644
> --- a/fs/orangefs/inode.c
> +++ b/fs/orangefs/inode.c
> @@ -934,7 +934,7 @@ static int orangefs_fileattr_get(struct dentry *dentry, struct file_kattr *fa)
> return 0;
> }
>
> -static int orangefs_fileattr_set(struct mnt_idmap *idmap,
> +static int orangefs_fileattr_set(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct file_kattr *fa)
> {
> u64 val = 0;
> diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
> index 1166381f1852..5f4e8b6d9722 100644
> --- a/fs/overlayfs/inode.c
> +++ b/fs/overlayfs/inode.c
> @@ -650,7 +650,7 @@ int ovl_real_fileattr_set(const struct path *realpath, struct file_kattr *fa)
> return vfs_fileattr_set(mnt_idmap(realpath->mnt), realpath->dentry, fa);
> }
>
> -int ovl_fileattr_set(struct mnt_idmap *idmap,
> +int ovl_fileattr_set(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct file_kattr *fa)
> {
> struct inode *inode = d_inode(dentry);
> diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h
> index 513ba93c7d1b..46a5cf5dae4c 100644
> --- a/fs/overlayfs/overlayfs.h
> +++ b/fs/overlayfs/overlayfs.h
> @@ -914,7 +914,7 @@ extern const struct file_operations ovl_file_operations;
> int ovl_real_fileattr_get(const struct path *realpath, struct file_kattr *fa);
> int ovl_real_fileattr_set(const struct path *realpath, struct file_kattr *fa);
> int ovl_fileattr_get(struct dentry *dentry, struct file_kattr *fa);
> -int ovl_fileattr_set(struct mnt_idmap *idmap,
> +int ovl_fileattr_set(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct file_kattr *fa);
> struct ovl_file;
> struct ovl_file *ovl_file_alloc(struct file *realfile);
> diff --git a/fs/ubifs/ioctl.c b/fs/ubifs/ioctl.c
> index 79536b2e3d7a..5c34f895bd4e 100644
> --- a/fs/ubifs/ioctl.c
> +++ b/fs/ubifs/ioctl.c
> @@ -144,7 +144,7 @@ int ubifs_fileattr_get(struct dentry *dentry, struct file_kattr *fa)
> return 0;
> }
>
> -int ubifs_fileattr_set(struct mnt_idmap *idmap,
> +int ubifs_fileattr_set(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct file_kattr *fa)
> {
> struct inode *inode = d_inode(dentry);
> diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h
> index 00db0d19a85e..af0ef3583aeb 100644
> --- a/fs/ubifs/ubifs.h
> +++ b/fs/ubifs/ubifs.h
> @@ -2083,7 +2083,7 @@ void ubifs_destroy_size_tree(struct ubifs_info *c);
>
> /* ioctl.c */
> int ubifs_fileattr_get(struct dentry *dentry, struct file_kattr *fa);
> -int ubifs_fileattr_set(struct mnt_idmap *idmap,
> +int ubifs_fileattr_set(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct file_kattr *fa);
> long ubifs_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
> void ubifs_set_inode_flags(struct inode *inode);
> diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
> index 1b53701bebea..0df67f0d573c 100644
> --- a/fs/xfs/xfs_ioctl.c
> +++ b/fs/xfs/xfs_ioctl.c
> @@ -748,7 +748,7 @@ xfs_ioctl_setattr_check_projid(
>
> int
> xfs_fileattr_set(
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *dentry,
> struct file_kattr *fa)
> {
> diff --git a/fs/xfs/xfs_ioctl.h b/fs/xfs/xfs_ioctl.h
> index f5ed5cf9d3df..70c26cb05eb6 100644
> --- a/fs/xfs/xfs_ioctl.h
> +++ b/fs/xfs/xfs_ioctl.h
> @@ -21,7 +21,7 @@ xfs_fileattr_get(
>
> extern int
> xfs_fileattr_set(
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *dentry,
> struct file_kattr *fa);
>
> diff --git a/include/linux/fileattr.h b/include/linux/fileattr.h
> index 58044b598016..09e32b84e02a 100644
> --- a/include/linux/fileattr.h
> +++ b/include/linux/fileattr.h
> @@ -74,7 +74,7 @@ static inline bool fileattr_has_fsx(const struct file_kattr *fa)
> }
>
> int vfs_fileattr_get(struct dentry *dentry, struct file_kattr *fa);
> -int vfs_fileattr_set(struct mnt_idmap *idmap, struct dentry *dentry,
> +int vfs_fileattr_set(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct file_kattr *fa);
> int ioctl_getflags(struct file *file, unsigned int __user *argp);
> int ioctl_setflags(struct file *file, unsigned int __user *argp);
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 08166900931a..764ef2d97a5d 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -2030,7 +2030,7 @@ struct inode_operations {
> int);
> int (*set_acl)(struct mnt_idmap *, struct dentry *,
> struct posix_acl *, int);
> - int (*fileattr_set)(struct mnt_idmap *idmap,
> + int (*fileattr_set)(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct file_kattr *fa);
> int (*fileattr_get)(struct dentry *dentry, struct file_kattr *fa);
> struct offset_ctx *(*get_offset_ctx)(struct inode *inode);
> diff --git a/mm/shmem.c b/mm/shmem.c
> index ed633b3bc38d..097699ea2762 100644
> --- a/mm/shmem.c
> +++ b/mm/shmem.c
> @@ -4159,7 +4159,7 @@ static int shmem_fileattr_get(struct dentry *dentry, struct file_kattr *fa)
> return 0;
> }
>
> -static int shmem_fileattr_set(struct mnt_idmap *idmap,
> +static int shmem_fileattr_set(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct file_kattr *fa)
> {
> struct inode *inode = d_inode(dentry);
>
> --
> 2.53.0
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 62+ messages in thread
* [PATCH 15/27] fs: port ->set_acl() to pass const mnt_idmap
2026-09-01 12:14 [PATCH 00/27] fs: port to const struct mnt_idmap Christian Brauner
` (13 preceding siblings ...)
2026-09-01 12:14 ` [PATCH 14/27] fs: port ->fileattr_set() to pass " Christian Brauner
@ 2026-09-01 12:14 ` Christian Brauner
2026-09-02 15:45 ` Jan Kara
2026-09-01 12:14 ` [PATCH 16/27] fs: port ->get_acl() " Christian Brauner
` (11 subsequent siblings)
26 siblings, 1 reply; 62+ messages in thread
From: Christian Brauner @ 2026-09-01 12:14 UTC (permalink / raw)
To: linux-fsdevel
Cc: Alexander Viro, Jan Kara, Christoph Hellwig, Seth Forshee,
Paul Moore, linux-security-module, Mimi Zohar, linux-integrity,
Ilya Dryomov, ceph-devel, Carlos Maiolino, linux-xfs,
Miklos Szeredi, Amir Goldstein, linux-unionfs, Namjae Jeon,
linux-cifs, linux-kernel, Christian Brauner (Amutable)
Convert to const struct mnt_idmap.
A mount's idmapping is immutable. The only thing that is allowed to be
modified afterwards is the reference count and that is hidden behind
mnt_idmap_get() and mnt_idmap_put(). Everything else only ever reads
from the idmapping. This is the same model that struct cred uses and the
idmapping is also rather sensitive.
So make the idmap argument const wherever we can. The conversion is done
from the bottom up so callers can continue to pass a non-const pointer
to a const parameter until the conversion is finished.
No functional changes.
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
---
Documentation/filesystems/vfs.rst | 2 +-
fs/9p/acl.c | 2 +-
fs/9p/acl.h | 2 +-
fs/bad_inode.c | 2 +-
fs/btrfs/acl.c | 2 +-
fs/btrfs/acl.h | 2 +-
fs/ceph/acl.c | 2 +-
fs/ceph/super.h | 2 +-
fs/ecryptfs/inode.c | 2 +-
fs/ext2/acl.c | 2 +-
fs/ext2/acl.h | 2 +-
fs/ext4/acl.c | 2 +-
fs/ext4/acl.h | 2 +-
fs/f2fs/acl.c | 2 +-
fs/f2fs/acl.h | 2 +-
fs/fuse/acl.c | 2 +-
fs/fuse/fuse_i.h | 2 +-
fs/gfs2/acl.c | 2 +-
fs/gfs2/acl.h | 2 +-
fs/internal.h | 4 ++--
fs/jffs2/acl.c | 2 +-
fs/jffs2/acl.h | 2 +-
fs/jfs/acl.c | 2 +-
fs/jfs/jfs_acl.h | 2 +-
fs/nfs/nfs3_fs.h | 2 +-
fs/nfs/nfs3acl.c | 2 +-
fs/ntfs/ea.c | 2 +-
fs/ntfs/ea.h | 2 +-
fs/ntfs3/ntfs_fs.h | 4 ++--
fs/ntfs3/xattr.c | 4 ++--
fs/ocfs2/acl.c | 2 +-
fs/ocfs2/acl.h | 2 +-
fs/orangefs/acl.c | 2 +-
fs/orangefs/orangefs-kernel.h | 2 +-
fs/overlayfs/inode.c | 2 +-
fs/overlayfs/overlayfs.h | 2 +-
fs/posix_acl.c | 12 ++++++------
fs/smb/client/cifsacl.c | 2 +-
fs/smb/client/cifsproto.h | 2 +-
fs/smb/server/vfs.c | 4 ++--
fs/smb/server/vfs.h | 4 ++--
fs/xattr.c | 4 ++--
fs/xfs/xfs_acl.c | 2 +-
fs/xfs/xfs_acl.h | 2 +-
fs/xfs/xfs_iops.c | 4 ++--
fs/xfs/xfs_iops.h | 2 +-
include/linux/fs.h | 2 +-
include/linux/posix_acl.h | 16 ++++++++--------
48 files changed, 67 insertions(+), 67 deletions(-)
diff --git a/Documentation/filesystems/vfs.rst b/Documentation/filesystems/vfs.rst
index c43bad400c30..d0dd2be3885b 100644
--- a/Documentation/filesystems/vfs.rst
+++ b/Documentation/filesystems/vfs.rst
@@ -440,7 +440,7 @@ As of kernel 2.6.22, the following members are defined:
unsigned open_flag, umode_t create_mode);
int (*tmpfile) (struct mnt_idmap *, struct inode *, struct file *, umode_t);
struct posix_acl * (*get_acl)(struct mnt_idmap *, struct dentry *, int);
- int (*set_acl)(struct mnt_idmap *, struct dentry *, struct posix_acl *, int);
+ int (*set_acl)(const struct mnt_idmap *, struct dentry *, struct posix_acl *, int);
int (*fileattr_set)(const struct mnt_idmap *idmap,
struct dentry *dentry, struct file_kattr *fa);
int (*fileattr_get)(struct dentry *dentry, struct file_kattr *fa);
diff --git a/fs/9p/acl.c b/fs/9p/acl.c
index ae7e7cf7523a..d09a41336d0d 100644
--- a/fs/9p/acl.c
+++ b/fs/9p/acl.c
@@ -152,7 +152,7 @@ struct posix_acl *v9fs_iop_get_acl(struct mnt_idmap *idmap,
return v9fs_get_cached_acl(d_inode(dentry), type);
}
-int v9fs_iop_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
+int v9fs_iop_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
struct posix_acl *acl, int type)
{
int retval;
diff --git a/fs/9p/acl.h b/fs/9p/acl.h
index 333cfcc281da..7de74704c465 100644
--- a/fs/9p/acl.h
+++ b/fs/9p/acl.h
@@ -12,7 +12,7 @@ struct posix_acl *v9fs_iop_get_inode_acl(struct inode *inode, int type,
bool rcu);
struct posix_acl *v9fs_iop_get_acl(struct mnt_idmap *idmap,
struct dentry *dentry, int type);
-int v9fs_iop_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
+int v9fs_iop_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
struct posix_acl *acl, int type);
int v9fs_acl_chmod(struct inode *inode, struct p9_fid *fid);
int v9fs_set_create_acl(struct inode *inode, struct p9_fid *fid,
diff --git a/fs/bad_inode.c b/fs/bad_inode.c
index c2cfa9395bc9..6e116810f66d 100644
--- a/fs/bad_inode.c
+++ b/fs/bad_inode.c
@@ -153,7 +153,7 @@ static int bad_inode_tmpfile(struct mnt_idmap *idmap,
return -EIO;
}
-static int bad_inode_set_acl(struct mnt_idmap *idmap,
+static int bad_inode_set_acl(const struct mnt_idmap *idmap,
struct dentry *dentry, struct posix_acl *acl,
int type)
{
diff --git a/fs/btrfs/acl.c b/fs/btrfs/acl.c
index 662cdd1cbdef..10a0d733bfd1 100644
--- a/fs/btrfs/acl.c
+++ b/fs/btrfs/acl.c
@@ -101,7 +101,7 @@ int __btrfs_set_acl(struct btrfs_trans_handle *trans, struct inode *inode,
return 0;
}
-int btrfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
+int btrfs_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
struct posix_acl *acl, int type)
{
int ret;
diff --git a/fs/btrfs/acl.h b/fs/btrfs/acl.h
index 0458cd51ed48..6eae2db3654d 100644
--- a/fs/btrfs/acl.h
+++ b/fs/btrfs/acl.h
@@ -15,7 +15,7 @@ struct mnt_idmap;
struct dentry;
struct posix_acl *btrfs_get_acl(struct inode *inode, int type, bool rcu);
-int btrfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
+int btrfs_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
struct posix_acl *acl, int type);
int __btrfs_set_acl(struct btrfs_trans_handle *trans, struct inode *inode,
struct posix_acl *acl, int type);
diff --git a/fs/ceph/acl.c b/fs/ceph/acl.c
index 85d3dd48b167..124f07ae5b2d 100644
--- a/fs/ceph/acl.c
+++ b/fs/ceph/acl.c
@@ -87,7 +87,7 @@ struct posix_acl *ceph_get_acl(struct inode *inode, int type, bool rcu)
return acl;
}
-int ceph_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
+int ceph_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
struct posix_acl *acl, int type)
{
int ret = 0;
diff --git a/fs/ceph/super.h b/fs/ceph/super.h
index ef9861797eb2..fd603be209e4 100644
--- a/fs/ceph/super.h
+++ b/fs/ceph/super.h
@@ -1252,7 +1252,7 @@ void ceph_release_acl_sec_ctx(struct ceph_acl_sec_ctx *as_ctx);
#ifdef CONFIG_CEPH_FS_POSIX_ACL
struct posix_acl *ceph_get_acl(struct inode *, int, bool);
-int ceph_set_acl(struct mnt_idmap *idmap,
+int ceph_set_acl(const struct mnt_idmap *idmap,
struct dentry *dentry, struct posix_acl *acl, int type);
int ceph_pre_init_acls(struct inode *dir, umode_t *mode,
struct ceph_acl_sec_ctx *as_ctx);
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index b9c32e8f855a..1e5146485214 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -1097,7 +1097,7 @@ static struct posix_acl *ecryptfs_get_acl(struct mnt_idmap *idmap,
posix_acl_xattr_name(type));
}
-static int ecryptfs_set_acl(struct mnt_idmap *idmap,
+static int ecryptfs_set_acl(const struct mnt_idmap *idmap,
struct dentry *dentry, struct posix_acl *acl,
int type)
{
diff --git a/fs/ext2/acl.c b/fs/ext2/acl.c
index 7e54c31589c7..b2746657fc53 100644
--- a/fs/ext2/acl.c
+++ b/fs/ext2/acl.c
@@ -219,7 +219,7 @@ __ext2_set_acl(struct inode *inode, struct posix_acl *acl, int type)
* inode->i_mutex: down
*/
int
-ext2_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
+ext2_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
struct posix_acl *acl, int type)
{
int error;
diff --git a/fs/ext2/acl.h b/fs/ext2/acl.h
index 4a8443a2b8ec..e68bc3545608 100644
--- a/fs/ext2/acl.h
+++ b/fs/ext2/acl.h
@@ -56,7 +56,7 @@ static inline int ext2_acl_count(size_t size)
/* acl.c */
extern struct posix_acl *ext2_get_acl(struct inode *inode, int type, bool rcu);
-extern int ext2_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
+extern int ext2_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
struct posix_acl *acl, int type);
extern int ext2_init_acl (struct inode *, struct inode *);
diff --git a/fs/ext4/acl.c b/fs/ext4/acl.c
index 3bffe862f954..59fac55a2426 100644
--- a/fs/ext4/acl.c
+++ b/fs/ext4/acl.c
@@ -225,7 +225,7 @@ __ext4_set_acl(handle_t *handle, struct inode *inode, int type,
}
int
-ext4_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
+ext4_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
struct posix_acl *acl, int type)
{
handle_t *handle;
diff --git a/fs/ext4/acl.h b/fs/ext4/acl.h
index 0c5a79c3b5d4..a14838c5bc42 100644
--- a/fs/ext4/acl.h
+++ b/fs/ext4/acl.h
@@ -56,7 +56,7 @@ static inline int ext4_acl_count(size_t size)
/* acl.c */
struct posix_acl *ext4_get_acl(struct inode *inode, int type, bool rcu);
-int ext4_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
+int ext4_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
struct posix_acl *acl, int type);
extern int ext4_init_acl(handle_t *, struct inode *, struct inode *);
diff --git a/fs/f2fs/acl.c b/fs/f2fs/acl.c
index e7e0084d0a5f..22ca39e0aad6 100644
--- a/fs/f2fs/acl.c
+++ b/fs/f2fs/acl.c
@@ -289,7 +289,7 @@ static int __f2fs_set_acl(const struct mnt_idmap *idmap,
return error;
}
-int f2fs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
+int f2fs_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
struct posix_acl *acl, int type)
{
struct inode *inode = d_inode(dentry);
diff --git a/fs/f2fs/acl.h b/fs/f2fs/acl.h
index 20e87e63c089..01ec74b6daf2 100644
--- a/fs/f2fs/acl.h
+++ b/fs/f2fs/acl.h
@@ -34,7 +34,7 @@ struct f2fs_acl_header {
#ifdef CONFIG_F2FS_FS_POSIX_ACL
struct posix_acl *f2fs_get_acl(struct inode *, int, bool);
-int f2fs_set_acl(struct mnt_idmap *, struct dentry *,
+int f2fs_set_acl(const struct mnt_idmap *, struct dentry *,
struct posix_acl *, int);
int f2fs_init_acl(struct inode *, struct inode *, struct folio *ifolio,
struct folio *dfolio);
diff --git a/fs/fuse/acl.c b/fs/fuse/acl.c
index 31fb50e16aed..c3813fff4f27 100644
--- a/fs/fuse/acl.c
+++ b/fs/fuse/acl.c
@@ -90,7 +90,7 @@ struct posix_acl *fuse_get_inode_acl(struct inode *inode, int type, bool rcu)
return __fuse_get_acl(fc, inode, type, rcu);
}
-int fuse_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
+int fuse_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
struct posix_acl *acl, int type)
{
struct inode *inode = d_inode(dentry);
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index 6ca56757869c..561ada21ea86 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -1207,7 +1207,7 @@ struct posix_acl;
struct posix_acl *fuse_get_inode_acl(struct inode *inode, int type, bool rcu);
struct posix_acl *fuse_get_acl(struct mnt_idmap *idmap,
struct dentry *dentry, int type);
-int fuse_set_acl(struct mnt_idmap *, struct dentry *dentry,
+int fuse_set_acl(const struct mnt_idmap *, struct dentry *dentry,
struct posix_acl *acl, int type);
/* readdir.c */
diff --git a/fs/gfs2/acl.c b/fs/gfs2/acl.c
index a5b60778b91c..7b94efbbe8e3 100644
--- a/fs/gfs2/acl.c
+++ b/fs/gfs2/acl.c
@@ -102,7 +102,7 @@ int __gfs2_set_acl(struct inode *inode, struct posix_acl *acl, int type)
return error;
}
-int gfs2_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
+int gfs2_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
struct posix_acl *acl, int type)
{
struct inode *inode = d_inode(dentry);
diff --git a/fs/gfs2/acl.h b/fs/gfs2/acl.h
index 82f5b09c04e6..d19d41755936 100644
--- a/fs/gfs2/acl.h
+++ b/fs/gfs2/acl.h
@@ -13,7 +13,7 @@
struct posix_acl *gfs2_get_acl(struct inode *inode, int type, bool rcu);
int __gfs2_set_acl(struct inode *inode, struct posix_acl *acl, int type);
-int gfs2_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
+int gfs2_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
struct posix_acl *acl, int type);
#endif /* __ACL_DOT_H__ */
diff --git a/fs/internal.h b/fs/internal.h
index a502b1fbacd2..8ba0a1613d20 100644
--- a/fs/internal.h
+++ b/fs/internal.h
@@ -302,12 +302,12 @@ int import_xattr_name(struct xattr_name *kname, const char __user *name);
int may_write_xattr(const struct mnt_idmap *idmap, struct inode *inode);
#ifdef CONFIG_FS_POSIX_ACL
-int do_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
+int do_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
const char *acl_name, const void *kvalue, size_t size);
ssize_t do_get_acl(struct mnt_idmap *idmap, struct dentry *dentry,
const char *acl_name, void *kvalue, size_t size);
#else
-static inline int do_set_acl(struct mnt_idmap *idmap,
+static inline int do_set_acl(const struct mnt_idmap *idmap,
struct dentry *dentry, const char *acl_name,
const void *kvalue, size_t size)
{
diff --git a/fs/jffs2/acl.c b/fs/jffs2/acl.c
index f0f8a4f57add..7548f44bf327 100644
--- a/fs/jffs2/acl.c
+++ b/fs/jffs2/acl.c
@@ -228,7 +228,7 @@ static int __jffs2_set_acl(struct inode *inode, int xprefix, struct posix_acl *a
return rc;
}
-int jffs2_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
+int jffs2_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
struct posix_acl *acl, int type)
{
int rc, xprefix;
diff --git a/fs/jffs2/acl.h b/fs/jffs2/acl.h
index e976b8cb82cf..bc5df521633f 100644
--- a/fs/jffs2/acl.h
+++ b/fs/jffs2/acl.h
@@ -28,7 +28,7 @@ struct jffs2_acl_header {
#ifdef CONFIG_JFFS2_FS_POSIX_ACL
struct posix_acl *jffs2_get_acl(struct inode *inode, int type, bool rcu);
-int jffs2_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
+int jffs2_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
struct posix_acl *acl, int type);
extern int jffs2_init_acl_pre(struct inode *, struct inode *, umode_t *);
extern int jffs2_init_acl_post(struct inode *);
diff --git a/fs/jfs/acl.c b/fs/jfs/acl.c
index 16b71a23ff1e..6e0a7feb6c80 100644
--- a/fs/jfs/acl.c
+++ b/fs/jfs/acl.c
@@ -89,7 +89,7 @@ static int __jfs_set_acl(tid_t tid, struct inode *inode, int type,
return rc;
}
-int jfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
+int jfs_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
struct posix_acl *acl, int type)
{
int rc;
diff --git a/fs/jfs/jfs_acl.h b/fs/jfs/jfs_acl.h
index f892e54d0fcd..bda26b333519 100644
--- a/fs/jfs/jfs_acl.h
+++ b/fs/jfs/jfs_acl.h
@@ -8,7 +8,7 @@
#ifdef CONFIG_JFS_POSIX_ACL
struct posix_acl *jfs_get_acl(struct inode *inode, int type, bool rcu);
-int jfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
+int jfs_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
struct posix_acl *acl, int type);
int jfs_init_acl(tid_t, struct inode *, struct inode *);
diff --git a/fs/nfs/nfs3_fs.h b/fs/nfs/nfs3_fs.h
index b333ea119ef5..ffcabadb3546 100644
--- a/fs/nfs/nfs3_fs.h
+++ b/fs/nfs/nfs3_fs.h
@@ -12,7 +12,7 @@
*/
#ifdef CONFIG_NFS_V3_ACL
extern struct posix_acl *nfs3_get_acl(struct inode *inode, int type, bool rcu);
-extern int nfs3_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
+extern int nfs3_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
struct posix_acl *acl, int type);
extern int nfs3_proc_setacls(struct inode *inode, struct posix_acl *acl,
struct posix_acl *dfacl);
diff --git a/fs/nfs/nfs3acl.c b/fs/nfs/nfs3acl.c
index a126eb31f62f..2549a1985b9a 100644
--- a/fs/nfs/nfs3acl.c
+++ b/fs/nfs/nfs3acl.c
@@ -254,7 +254,7 @@ int nfs3_proc_setacls(struct inode *inode, struct posix_acl *acl,
}
-int nfs3_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
+int nfs3_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
struct posix_acl *acl, int type)
{
struct posix_acl *orig = acl, *dfacl = NULL, *alloc;
diff --git a/fs/ntfs/ea.c b/fs/ntfs/ea.c
index 7fd323912510..063cc15f1626 100644
--- a/fs/ntfs/ea.c
+++ b/fs/ntfs/ea.c
@@ -1080,7 +1080,7 @@ static noinline int ntfs_set_acl_ex(const struct mnt_idmap *idmap,
return err;
}
-int ntfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
+int ntfs_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
struct posix_acl *acl, int type)
{
return ntfs_set_acl_ex(idmap, d_inode(dentry), acl, type, false);
diff --git a/fs/ntfs/ea.h b/fs/ntfs/ea.h
index 9d17abc2e491..6d98e7487a2c 100644
--- a/fs/ntfs/ea.h
+++ b/fs/ntfs/ea.h
@@ -19,7 +19,7 @@ ssize_t ntfs_listxattr(struct dentry *dentry, char *buffer, size_t size);
#ifdef CONFIG_NTFS_FS_POSIX_ACL
struct posix_acl *ntfs_get_acl(struct mnt_idmap *idmap, struct dentry *dentry,
int type);
-int ntfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
+int ntfs_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
struct posix_acl *acl, int type);
int ntfs_init_acl(const struct mnt_idmap *idmap, struct inode *inode,
struct inode *dir);
diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h
index e494bed87679..0a5e81d420f0 100644
--- a/fs/ntfs3/ntfs_fs.h
+++ b/fs/ntfs3/ntfs_fs.h
@@ -965,7 +965,7 @@ unsigned long ntfs_names_hash(const u16 *name, size_t len, const u16 *upcase,
#ifdef CONFIG_NTFS3_FS_POSIX_ACL
struct posix_acl *ntfs_get_acl(struct mnt_idmap *idmap, struct dentry *dentry,
int type);
-int ntfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
+int ntfs_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
struct posix_acl *acl, int type);
int ntfs_init_acl(const struct mnt_idmap *idmap, struct inode *inode,
struct inode *dir);
@@ -974,7 +974,7 @@ int ntfs_init_acl(const struct mnt_idmap *idmap, struct inode *inode,
#define ntfs_set_acl NULL
#endif
-int ntfs_acl_chmod(struct mnt_idmap *idmap, struct dentry *dentry);
+int ntfs_acl_chmod(const struct mnt_idmap *idmap, struct dentry *dentry);
ssize_t ntfs_listxattr(struct dentry *dentry, char *buffer, size_t size);
extern const struct xattr_handler *const ntfs_xattr_handlers[];
diff --git a/fs/ntfs3/xattr.c b/fs/ntfs3/xattr.c
index 5644167de863..2d17b80999ca 100644
--- a/fs/ntfs3/xattr.c
+++ b/fs/ntfs3/xattr.c
@@ -677,7 +677,7 @@ static noinline int ntfs_set_acl_ex(const struct mnt_idmap *idmap,
/*
* ntfs_set_acl - inode_operations::set_acl
*/
-int ntfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
+int ntfs_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
struct posix_acl *acl, int type)
{
return ntfs_set_acl_ex(idmap, d_inode(dentry), acl, type, false);
@@ -722,7 +722,7 @@ int ntfs_init_acl(const struct mnt_idmap *idmap, struct inode *inode,
/*
* ntfs_acl_chmod - Helper for ntfs_setattr().
*/
-int ntfs_acl_chmod(struct mnt_idmap *idmap, struct dentry *dentry)
+int ntfs_acl_chmod(const struct mnt_idmap *idmap, struct dentry *dentry)
{
struct inode *inode = d_inode(dentry);
struct super_block *sb = inode->i_sb;
diff --git a/fs/ocfs2/acl.c b/fs/ocfs2/acl.c
index 090ec60fb576..801a2f56ad08 100644
--- a/fs/ocfs2/acl.c
+++ b/fs/ocfs2/acl.c
@@ -260,7 +260,7 @@ static int ocfs2_set_acl(handle_t *handle,
return ret;
}
-int ocfs2_iop_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
+int ocfs2_iop_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
struct posix_acl *acl, int type)
{
struct buffer_head *bh = NULL;
diff --git a/fs/ocfs2/acl.h b/fs/ocfs2/acl.h
index a91f9ce278d6..1ed05899cce1 100644
--- a/fs/ocfs2/acl.h
+++ b/fs/ocfs2/acl.h
@@ -17,7 +17,7 @@ struct ocfs2_acl_entry {
};
struct posix_acl *ocfs2_iop_get_acl(struct inode *inode, int type, bool rcu);
-int ocfs2_iop_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
+int ocfs2_iop_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
struct posix_acl *acl, int type);
extern int ocfs2_acl_chmod(struct inode *, struct buffer_head *);
struct ocfs2_acl_state {
diff --git a/fs/orangefs/acl.c b/fs/orangefs/acl.c
index a01ef0c1b1bf..f31196e4bfaa 100644
--- a/fs/orangefs/acl.c
+++ b/fs/orangefs/acl.c
@@ -112,7 +112,7 @@ int __orangefs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
return error;
}
-int orangefs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
+int orangefs_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
struct posix_acl *acl, int type)
{
int error;
diff --git a/fs/orangefs/orangefs-kernel.h b/fs/orangefs/orangefs-kernel.h
index c582ceffb26e..a5c9e7be4005 100644
--- a/fs/orangefs/orangefs-kernel.h
+++ b/fs/orangefs/orangefs-kernel.h
@@ -98,7 +98,7 @@ enum orangefs_vfs_op_states {
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,
+extern int orangefs_set_acl(const struct mnt_idmap *idmap,
struct dentry *dentry, struct posix_acl *acl,
int type);
int __orangefs_set_acl(struct inode *inode, struct posix_acl *acl, int type);
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
index 5f4e8b6d9722..18e4cbe154cf 100644
--- a/fs/overlayfs/inode.c
+++ b/fs/overlayfs/inode.c
@@ -536,7 +536,7 @@ static int ovl_set_or_remove_acl(struct dentry *dentry, struct inode *inode,
return err;
}
-int ovl_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
+int ovl_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
struct posix_acl *acl, int type)
{
int err;
diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h
index 46a5cf5dae4c..8b335993bf56 100644
--- a/fs/overlayfs/overlayfs.h
+++ b/fs/overlayfs/overlayfs.h
@@ -819,7 +819,7 @@ static inline struct posix_acl *ovl_get_acl(struct mnt_idmap *idmap,
{
return do_ovl_get_acl(idmap, d_inode(dentry), type, false, false);
}
-int ovl_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
+int ovl_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
struct posix_acl *acl, int type);
struct posix_acl *ovl_get_acl_path(const struct path *path,
const char *acl_name, bool noperm);
diff --git a/fs/posix_acl.c b/fs/posix_acl.c
index b279804ebf56..cec7fb557278 100644
--- a/fs/posix_acl.c
+++ b/fs/posix_acl.c
@@ -608,7 +608,7 @@ EXPORT_SYMBOL(__posix_acl_chmod);
* performed on the raw inode simply pass @nop_mnt_idmap.
*/
int
- posix_acl_chmod(struct mnt_idmap *idmap, struct dentry *dentry,
+ posix_acl_chmod(const struct mnt_idmap *idmap, struct dentry *dentry,
umode_t mode)
{
struct inode *inode = d_inode(dentry);
@@ -937,7 +937,7 @@ static ssize_t vfs_posix_acl_to_xattr(const struct mnt_idmap *idmap,
}
int
-set_posix_acl(struct mnt_idmap *idmap, struct dentry *dentry,
+set_posix_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
int type, struct posix_acl *acl)
{
struct inode *inode = d_inode(dentry);
@@ -1018,7 +1018,7 @@ const struct xattr_handler nop_posix_acl_default = {
};
EXPORT_SYMBOL_GPL(nop_posix_acl_default);
-int simple_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
+int simple_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
struct posix_acl *acl, int type)
{
int error;
@@ -1091,7 +1091,7 @@ static int vfs_set_acl_idmapped_mnt(const struct mnt_idmap *idmap,
*
* Return: On success 0, on error negative errno.
*/
-int vfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
+int vfs_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
const char *acl_name, struct posix_acl *kacl)
{
int acl_type;
@@ -1212,7 +1212,7 @@ EXPORT_SYMBOL_GPL(vfs_get_acl);
*
* Return: On success 0, on error negative errno.
*/
-int vfs_remove_acl(struct mnt_idmap *idmap, struct dentry *dentry,
+int vfs_remove_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
const char *acl_name)
{
int acl_type;
@@ -1265,7 +1265,7 @@ int vfs_remove_acl(struct mnt_idmap *idmap, struct dentry *dentry,
}
EXPORT_SYMBOL_GPL(vfs_remove_acl);
-int do_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
+int do_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
const char *acl_name, const void *kvalue, size_t size)
{
int error;
diff --git a/fs/smb/client/cifsacl.c b/fs/smb/client/cifsacl.c
index 12005f46307d..0a05b6b0be5f 100644
--- a/fs/smb/client/cifsacl.c
+++ b/fs/smb/client/cifsacl.c
@@ -1931,7 +1931,7 @@ struct posix_acl *cifs_get_acl(struct mnt_idmap *idmap,
#endif
}
-int cifs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
+int cifs_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
struct posix_acl *acl, int type)
{
#if defined(CONFIG_CIFS_ALLOW_INSECURE_LEGACY) && defined(CONFIG_CIFS_POSIX)
diff --git a/fs/smb/client/cifsproto.h b/fs/smb/client/cifsproto.h
index 00168839c123..565697c233a9 100644
--- a/fs/smb/client/cifsproto.h
+++ b/fs/smb/client/cifsproto.h
@@ -214,7 +214,7 @@ struct smb_ntsd *get_cifs_acl_by_fid(struct cifs_sb_info *cifs_sb,
u32 *pacllen, u32 info);
struct posix_acl *cifs_get_acl(struct mnt_idmap *idmap, struct dentry *dentry,
int type);
-int cifs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
+int cifs_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
struct posix_acl *acl, int type);
int set_cifs_acl(struct smb_ntsd *pnntsd, __u32 acllen, struct inode *inode,
const char *path, int aclflag);
diff --git a/fs/smb/server/vfs.c b/fs/smb/server/vfs.c
index 3c4d18a4e8d5..75edff8dde31 100644
--- a/fs/smb/server/vfs.c
+++ b/fs/smb/server/vfs.c
@@ -1471,7 +1471,7 @@ struct dentry *ksmbd_vfs_kern_path_create(struct ksmbd_work *work,
return dent;
}
-int ksmbd_vfs_remove_acl_xattrs(struct mnt_idmap *idmap,
+int ksmbd_vfs_remove_acl_xattrs(const struct mnt_idmap *idmap,
const struct path *path)
{
char *name, *xattr_list = NULL;
@@ -2200,7 +2200,7 @@ void ksmbd_vfs_posix_lock_unblock(struct file_lock *flock)
locks_delete_block(flock);
}
-int ksmbd_vfs_set_init_posix_acl(struct mnt_idmap *idmap,
+int ksmbd_vfs_set_init_posix_acl(const struct mnt_idmap *idmap,
const struct path *path)
{
struct posix_acl_state acl_state;
diff --git a/fs/smb/server/vfs.h b/fs/smb/server/vfs.h
index 5e34fc61b48b..67cc48e583c8 100644
--- a/fs/smb/server/vfs.h
+++ b/fs/smb/server/vfs.h
@@ -152,7 +152,7 @@ int ksmbd_vfs_fill_dentry_attrs(struct ksmbd_work *work,
struct ksmbd_kstat *ksmbd_kstat);
void ksmbd_vfs_posix_lock_wait(struct file_lock *flock);
void ksmbd_vfs_posix_lock_unblock(struct file_lock *flock);
-int ksmbd_vfs_remove_acl_xattrs(struct mnt_idmap *idmap,
+int ksmbd_vfs_remove_acl_xattrs(const struct mnt_idmap *idmap,
const struct path *path);
int ksmbd_vfs_remove_sd_xattrs(const struct mnt_idmap *idmap, const struct path *path);
int ksmbd_vfs_set_sd_xattr(struct ksmbd_conn *conn,
@@ -171,7 +171,7 @@ int ksmbd_vfs_set_dos_attrib_xattr(const struct mnt_idmap *idmap,
int ksmbd_vfs_get_dos_attrib_xattr(const struct mnt_idmap *idmap,
struct dentry *dentry,
struct xattr_dos_attrib *da);
-int ksmbd_vfs_set_init_posix_acl(struct mnt_idmap *idmap,
+int ksmbd_vfs_set_init_posix_acl(const struct mnt_idmap *idmap,
const struct path *path);
int ksmbd_vfs_inherit_posix_acl(const struct mnt_idmap *idmap,
const struct path *path,
diff --git a/fs/xattr.c b/fs/xattr.c
index acdaafb0c7c1..758a7ffe3a86 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -652,7 +652,7 @@ int setxattr_copy(const char __user *name, struct kernel_xattr_ctx *ctx)
return error;
}
-static int do_setxattr(struct mnt_idmap *idmap, struct dentry *dentry,
+static int do_setxattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct kernel_xattr_ctx *ctx)
{
if (is_posix_acl_xattr(ctx->kname->name))
@@ -1029,7 +1029,7 @@ SYSCALL_DEFINE3(flistxattr, int, fd, char __user *, list, size_t, size)
* Extended attribute REMOVE operations
*/
static long
-removexattr(struct mnt_idmap *idmap, struct dentry *d, const char *name)
+removexattr(const struct mnt_idmap *idmap, struct dentry *d, const char *name)
{
if (is_posix_acl_xattr(name))
return vfs_remove_acl(idmap, d, name);
diff --git a/fs/xfs/xfs_acl.c b/fs/xfs/xfs_acl.c
index fdfca6fc75b6..20d87b52c4fc 100644
--- a/fs/xfs/xfs_acl.c
+++ b/fs/xfs/xfs_acl.c
@@ -243,7 +243,7 @@ xfs_acl_set_mode(
}
int
-xfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
+xfs_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
struct posix_acl *acl, int type)
{
umode_t mode;
diff --git a/fs/xfs/xfs_acl.h b/fs/xfs/xfs_acl.h
index bf7f960997d3..183526bec32c 100644
--- a/fs/xfs/xfs_acl.h
+++ b/fs/xfs/xfs_acl.h
@@ -11,7 +11,7 @@ struct posix_acl;
#ifdef CONFIG_XFS_POSIX_ACL
extern struct posix_acl *xfs_get_acl(struct inode *inode, int type, bool rcu);
-extern int xfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
+extern int xfs_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
struct posix_acl *acl, int type);
extern int __xfs_set_acl(struct inode *inode, struct posix_acl *acl, int type);
void xfs_forget_acl(struct inode *inode, const char *name);
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index b652f129c85e..25d4d42fbc7f 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -777,7 +777,7 @@ xfs_vn_change_ok(
*/
static int
xfs_setattr_nonsize(
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *dentry,
struct xfs_inode *ip,
struct iattr *iattr)
@@ -903,7 +903,7 @@ xfs_setattr_nonsize(
*/
int
xfs_vn_setattr_size(
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *dentry,
struct iattr *iattr)
{
diff --git a/fs/xfs/xfs_iops.h b/fs/xfs/xfs_iops.h
index 0896f6b8b3b8..328305bba19d 100644
--- a/fs/xfs/xfs_iops.h
+++ b/fs/xfs/xfs_iops.h
@@ -10,7 +10,7 @@ struct xfs_inode;
extern ssize_t xfs_vn_listxattr(struct dentry *, char *data, size_t size);
-int xfs_vn_setattr_size(struct mnt_idmap *idmap,
+int xfs_vn_setattr_size(const struct mnt_idmap *idmap,
struct dentry *dentry, struct iattr *vap);
int xfs_inode_init_security(struct inode *inode, struct inode *dir,
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 764ef2d97a5d..9186d9bb2697 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2028,7 +2028,7 @@ struct inode_operations {
struct file *, umode_t);
struct posix_acl *(*get_acl)(struct mnt_idmap *, struct dentry *,
int);
- int (*set_acl)(struct mnt_idmap *, struct dentry *,
+ int (*set_acl)(const struct mnt_idmap *, struct dentry *,
struct posix_acl *, int);
int (*fileattr_set)(const struct mnt_idmap *idmap,
struct dentry *dentry, struct file_kattr *fa);
diff --git a/include/linux/posix_acl.h b/include/linux/posix_acl.h
index 7c6cfcae0a9d..9220fe0c965d 100644
--- a/include/linux/posix_acl.h
+++ b/include/linux/posix_acl.h
@@ -74,20 +74,20 @@ extern int __posix_acl_create(struct posix_acl **, gfp_t, umode_t *);
extern int __posix_acl_chmod(struct posix_acl **, gfp_t, umode_t);
extern struct posix_acl *get_posix_acl(struct inode *, int);
-int set_posix_acl(struct mnt_idmap *, struct dentry *, int,
+int set_posix_acl(const struct mnt_idmap *, struct dentry *, int,
struct posix_acl *);
struct posix_acl *get_cached_acl_rcu(struct inode *inode, int type);
struct posix_acl *posix_acl_clone(const struct posix_acl *acl, gfp_t flags);
#ifdef CONFIG_FS_POSIX_ACL
-int posix_acl_chmod(struct mnt_idmap *, struct dentry *, umode_t);
+int posix_acl_chmod(const struct mnt_idmap *, struct dentry *, umode_t);
extern int posix_acl_create(struct inode *, umode_t *, struct posix_acl **,
struct posix_acl **);
int posix_acl_update_mode(const struct mnt_idmap *, struct inode *, umode_t *,
struct posix_acl **);
-int simple_set_acl(struct mnt_idmap *, struct dentry *,
+int simple_set_acl(const struct mnt_idmap *, struct dentry *,
struct posix_acl *, int);
extern int simple_acl_create(struct inode *, struct inode *);
@@ -105,16 +105,16 @@ static inline void cache_no_acl(struct inode *inode)
inode->i_default_acl = NULL;
}
-int vfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
+int vfs_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
const char *acl_name, struct posix_acl *kacl);
struct posix_acl *vfs_get_acl(struct mnt_idmap *idmap,
struct dentry *dentry, const char *acl_name);
-int vfs_remove_acl(struct mnt_idmap *idmap, struct dentry *dentry,
+int vfs_remove_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
const char *acl_name);
int posix_acl_listxattr(struct inode *inode, char **buffer,
ssize_t *remaining_size);
#else
-static inline int posix_acl_chmod(struct mnt_idmap *idmap,
+static inline int posix_acl_chmod(const struct mnt_idmap *idmap,
struct dentry *dentry, umode_t mode)
{
return 0;
@@ -141,7 +141,7 @@ static inline void forget_all_cached_acls(struct inode *inode)
{
}
-static inline int vfs_set_acl(struct mnt_idmap *idmap,
+static inline int vfs_set_acl(const struct mnt_idmap *idmap,
struct dentry *dentry, const char *name,
struct posix_acl *acl)
{
@@ -155,7 +155,7 @@ static inline struct posix_acl *vfs_get_acl(struct mnt_idmap *idmap,
return ERR_PTR(-EOPNOTSUPP);
}
-static inline int vfs_remove_acl(struct mnt_idmap *idmap,
+static inline int vfs_remove_acl(const struct mnt_idmap *idmap,
struct dentry *dentry, const char *acl_name)
{
return -EOPNOTSUPP;
--
2.53.0
^ permalink raw reply related [flat|nested] 62+ messages in thread* Re: [PATCH 15/27] fs: port ->set_acl() to pass const mnt_idmap
2026-09-01 12:14 ` [PATCH 15/27] fs: port ->set_acl() " Christian Brauner
@ 2026-09-02 15:45 ` Jan Kara
0 siblings, 0 replies; 62+ messages in thread
From: Jan Kara @ 2026-09-02 15:45 UTC (permalink / raw)
To: Christian Brauner
Cc: linux-fsdevel, Alexander Viro, Jan Kara, Christoph Hellwig,
Seth Forshee, Paul Moore, linux-security-module, Mimi Zohar,
linux-integrity, Ilya Dryomov, ceph-devel, Carlos Maiolino,
linux-xfs, Miklos Szeredi, Amir Goldstein, linux-unionfs,
Namjae Jeon, linux-cifs, linux-kernel
On Tue 01-09-26 14:14:40, Christian Brauner wrote:
> Convert to const struct mnt_idmap.
>
> A mount's idmapping is immutable. The only thing that is allowed to be
> modified afterwards is the reference count and that is hidden behind
> mnt_idmap_get() and mnt_idmap_put(). Everything else only ever reads
> from the idmapping. This is the same model that struct cred uses and the
> idmapping is also rather sensitive.
>
> So make the idmap argument const wherever we can. The conversion is done
> from the bottom up so callers can continue to pass a non-const pointer
> to a const parameter until the conversion is finished.
>
> No functional changes.
>
> Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> Documentation/filesystems/vfs.rst | 2 +-
> fs/9p/acl.c | 2 +-
> fs/9p/acl.h | 2 +-
> fs/bad_inode.c | 2 +-
> fs/btrfs/acl.c | 2 +-
> fs/btrfs/acl.h | 2 +-
> fs/ceph/acl.c | 2 +-
> fs/ceph/super.h | 2 +-
> fs/ecryptfs/inode.c | 2 +-
> fs/ext2/acl.c | 2 +-
> fs/ext2/acl.h | 2 +-
> fs/ext4/acl.c | 2 +-
> fs/ext4/acl.h | 2 +-
> fs/f2fs/acl.c | 2 +-
> fs/f2fs/acl.h | 2 +-
> fs/fuse/acl.c | 2 +-
> fs/fuse/fuse_i.h | 2 +-
> fs/gfs2/acl.c | 2 +-
> fs/gfs2/acl.h | 2 +-
> fs/internal.h | 4 ++--
> fs/jffs2/acl.c | 2 +-
> fs/jffs2/acl.h | 2 +-
> fs/jfs/acl.c | 2 +-
> fs/jfs/jfs_acl.h | 2 +-
> fs/nfs/nfs3_fs.h | 2 +-
> fs/nfs/nfs3acl.c | 2 +-
> fs/ntfs/ea.c | 2 +-
> fs/ntfs/ea.h | 2 +-
> fs/ntfs3/ntfs_fs.h | 4 ++--
> fs/ntfs3/xattr.c | 4 ++--
> fs/ocfs2/acl.c | 2 +-
> fs/ocfs2/acl.h | 2 +-
> fs/orangefs/acl.c | 2 +-
> fs/orangefs/orangefs-kernel.h | 2 +-
> fs/overlayfs/inode.c | 2 +-
> fs/overlayfs/overlayfs.h | 2 +-
> fs/posix_acl.c | 12 ++++++------
> fs/smb/client/cifsacl.c | 2 +-
> fs/smb/client/cifsproto.h | 2 +-
> fs/smb/server/vfs.c | 4 ++--
> fs/smb/server/vfs.h | 4 ++--
> fs/xattr.c | 4 ++--
> fs/xfs/xfs_acl.c | 2 +-
> fs/xfs/xfs_acl.h | 2 +-
> fs/xfs/xfs_iops.c | 4 ++--
> fs/xfs/xfs_iops.h | 2 +-
> include/linux/fs.h | 2 +-
> include/linux/posix_acl.h | 16 ++++++++--------
> 48 files changed, 67 insertions(+), 67 deletions(-)
>
> diff --git a/Documentation/filesystems/vfs.rst b/Documentation/filesystems/vfs.rst
> index c43bad400c30..d0dd2be3885b 100644
> --- a/Documentation/filesystems/vfs.rst
> +++ b/Documentation/filesystems/vfs.rst
> @@ -440,7 +440,7 @@ As of kernel 2.6.22, the following members are defined:
> unsigned open_flag, umode_t create_mode);
> int (*tmpfile) (struct mnt_idmap *, struct inode *, struct file *, umode_t);
> struct posix_acl * (*get_acl)(struct mnt_idmap *, struct dentry *, int);
> - int (*set_acl)(struct mnt_idmap *, struct dentry *, struct posix_acl *, int);
> + int (*set_acl)(const struct mnt_idmap *, struct dentry *, struct posix_acl *, int);
> int (*fileattr_set)(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct file_kattr *fa);
> int (*fileattr_get)(struct dentry *dentry, struct file_kattr *fa);
> diff --git a/fs/9p/acl.c b/fs/9p/acl.c
> index ae7e7cf7523a..d09a41336d0d 100644
> --- a/fs/9p/acl.c
> +++ b/fs/9p/acl.c
> @@ -152,7 +152,7 @@ struct posix_acl *v9fs_iop_get_acl(struct mnt_idmap *idmap,
> return v9fs_get_cached_acl(d_inode(dentry), type);
> }
>
> -int v9fs_iop_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> +int v9fs_iop_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct posix_acl *acl, int type)
> {
> int retval;
> diff --git a/fs/9p/acl.h b/fs/9p/acl.h
> index 333cfcc281da..7de74704c465 100644
> --- a/fs/9p/acl.h
> +++ b/fs/9p/acl.h
> @@ -12,7 +12,7 @@ struct posix_acl *v9fs_iop_get_inode_acl(struct inode *inode, int type,
> bool rcu);
> struct posix_acl *v9fs_iop_get_acl(struct mnt_idmap *idmap,
> struct dentry *dentry, int type);
> -int v9fs_iop_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> +int v9fs_iop_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct posix_acl *acl, int type);
> int v9fs_acl_chmod(struct inode *inode, struct p9_fid *fid);
> int v9fs_set_create_acl(struct inode *inode, struct p9_fid *fid,
> diff --git a/fs/bad_inode.c b/fs/bad_inode.c
> index c2cfa9395bc9..6e116810f66d 100644
> --- a/fs/bad_inode.c
> +++ b/fs/bad_inode.c
> @@ -153,7 +153,7 @@ static int bad_inode_tmpfile(struct mnt_idmap *idmap,
> return -EIO;
> }
>
> -static int bad_inode_set_acl(struct mnt_idmap *idmap,
> +static int bad_inode_set_acl(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct posix_acl *acl,
> int type)
> {
> diff --git a/fs/btrfs/acl.c b/fs/btrfs/acl.c
> index 662cdd1cbdef..10a0d733bfd1 100644
> --- a/fs/btrfs/acl.c
> +++ b/fs/btrfs/acl.c
> @@ -101,7 +101,7 @@ int __btrfs_set_acl(struct btrfs_trans_handle *trans, struct inode *inode,
> return 0;
> }
>
> -int btrfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> +int btrfs_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct posix_acl *acl, int type)
> {
> int ret;
> diff --git a/fs/btrfs/acl.h b/fs/btrfs/acl.h
> index 0458cd51ed48..6eae2db3654d 100644
> --- a/fs/btrfs/acl.h
> +++ b/fs/btrfs/acl.h
> @@ -15,7 +15,7 @@ struct mnt_idmap;
> struct dentry;
>
> struct posix_acl *btrfs_get_acl(struct inode *inode, int type, bool rcu);
> -int btrfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> +int btrfs_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct posix_acl *acl, int type);
> int __btrfs_set_acl(struct btrfs_trans_handle *trans, struct inode *inode,
> struct posix_acl *acl, int type);
> diff --git a/fs/ceph/acl.c b/fs/ceph/acl.c
> index 85d3dd48b167..124f07ae5b2d 100644
> --- a/fs/ceph/acl.c
> +++ b/fs/ceph/acl.c
> @@ -87,7 +87,7 @@ struct posix_acl *ceph_get_acl(struct inode *inode, int type, bool rcu)
> return acl;
> }
>
> -int ceph_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> +int ceph_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct posix_acl *acl, int type)
> {
> int ret = 0;
> diff --git a/fs/ceph/super.h b/fs/ceph/super.h
> index ef9861797eb2..fd603be209e4 100644
> --- a/fs/ceph/super.h
> +++ b/fs/ceph/super.h
> @@ -1252,7 +1252,7 @@ void ceph_release_acl_sec_ctx(struct ceph_acl_sec_ctx *as_ctx);
> #ifdef CONFIG_CEPH_FS_POSIX_ACL
>
> struct posix_acl *ceph_get_acl(struct inode *, int, bool);
> -int ceph_set_acl(struct mnt_idmap *idmap,
> +int ceph_set_acl(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct posix_acl *acl, int type);
> int ceph_pre_init_acls(struct inode *dir, umode_t *mode,
> struct ceph_acl_sec_ctx *as_ctx);
> diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
> index b9c32e8f855a..1e5146485214 100644
> --- a/fs/ecryptfs/inode.c
> +++ b/fs/ecryptfs/inode.c
> @@ -1097,7 +1097,7 @@ static struct posix_acl *ecryptfs_get_acl(struct mnt_idmap *idmap,
> posix_acl_xattr_name(type));
> }
>
> -static int ecryptfs_set_acl(struct mnt_idmap *idmap,
> +static int ecryptfs_set_acl(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct posix_acl *acl,
> int type)
> {
> diff --git a/fs/ext2/acl.c b/fs/ext2/acl.c
> index 7e54c31589c7..b2746657fc53 100644
> --- a/fs/ext2/acl.c
> +++ b/fs/ext2/acl.c
> @@ -219,7 +219,7 @@ __ext2_set_acl(struct inode *inode, struct posix_acl *acl, int type)
> * inode->i_mutex: down
> */
> int
> -ext2_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> +ext2_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct posix_acl *acl, int type)
> {
> int error;
> diff --git a/fs/ext2/acl.h b/fs/ext2/acl.h
> index 4a8443a2b8ec..e68bc3545608 100644
> --- a/fs/ext2/acl.h
> +++ b/fs/ext2/acl.h
> @@ -56,7 +56,7 @@ static inline int ext2_acl_count(size_t size)
>
> /* acl.c */
> extern struct posix_acl *ext2_get_acl(struct inode *inode, int type, bool rcu);
> -extern int ext2_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> +extern int ext2_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct posix_acl *acl, int type);
> extern int ext2_init_acl (struct inode *, struct inode *);
>
> diff --git a/fs/ext4/acl.c b/fs/ext4/acl.c
> index 3bffe862f954..59fac55a2426 100644
> --- a/fs/ext4/acl.c
> +++ b/fs/ext4/acl.c
> @@ -225,7 +225,7 @@ __ext4_set_acl(handle_t *handle, struct inode *inode, int type,
> }
>
> int
> -ext4_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> +ext4_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct posix_acl *acl, int type)
> {
> handle_t *handle;
> diff --git a/fs/ext4/acl.h b/fs/ext4/acl.h
> index 0c5a79c3b5d4..a14838c5bc42 100644
> --- a/fs/ext4/acl.h
> +++ b/fs/ext4/acl.h
> @@ -56,7 +56,7 @@ static inline int ext4_acl_count(size_t size)
>
> /* acl.c */
> struct posix_acl *ext4_get_acl(struct inode *inode, int type, bool rcu);
> -int ext4_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> +int ext4_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct posix_acl *acl, int type);
> extern int ext4_init_acl(handle_t *, struct inode *, struct inode *);
>
> diff --git a/fs/f2fs/acl.c b/fs/f2fs/acl.c
> index e7e0084d0a5f..22ca39e0aad6 100644
> --- a/fs/f2fs/acl.c
> +++ b/fs/f2fs/acl.c
> @@ -289,7 +289,7 @@ static int __f2fs_set_acl(const struct mnt_idmap *idmap,
> return error;
> }
>
> -int f2fs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> +int f2fs_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct posix_acl *acl, int type)
> {
> struct inode *inode = d_inode(dentry);
> diff --git a/fs/f2fs/acl.h b/fs/f2fs/acl.h
> index 20e87e63c089..01ec74b6daf2 100644
> --- a/fs/f2fs/acl.h
> +++ b/fs/f2fs/acl.h
> @@ -34,7 +34,7 @@ struct f2fs_acl_header {
> #ifdef CONFIG_F2FS_FS_POSIX_ACL
>
> struct posix_acl *f2fs_get_acl(struct inode *, int, bool);
> -int f2fs_set_acl(struct mnt_idmap *, struct dentry *,
> +int f2fs_set_acl(const struct mnt_idmap *, struct dentry *,
> struct posix_acl *, int);
> int f2fs_init_acl(struct inode *, struct inode *, struct folio *ifolio,
> struct folio *dfolio);
> diff --git a/fs/fuse/acl.c b/fs/fuse/acl.c
> index 31fb50e16aed..c3813fff4f27 100644
> --- a/fs/fuse/acl.c
> +++ b/fs/fuse/acl.c
> @@ -90,7 +90,7 @@ struct posix_acl *fuse_get_inode_acl(struct inode *inode, int type, bool rcu)
> return __fuse_get_acl(fc, inode, type, rcu);
> }
>
> -int fuse_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> +int fuse_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct posix_acl *acl, int type)
> {
> struct inode *inode = d_inode(dentry);
> diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
> index 6ca56757869c..561ada21ea86 100644
> --- a/fs/fuse/fuse_i.h
> +++ b/fs/fuse/fuse_i.h
> @@ -1207,7 +1207,7 @@ struct posix_acl;
> struct posix_acl *fuse_get_inode_acl(struct inode *inode, int type, bool rcu);
> struct posix_acl *fuse_get_acl(struct mnt_idmap *idmap,
> struct dentry *dentry, int type);
> -int fuse_set_acl(struct mnt_idmap *, struct dentry *dentry,
> +int fuse_set_acl(const struct mnt_idmap *, struct dentry *dentry,
> struct posix_acl *acl, int type);
>
> /* readdir.c */
> diff --git a/fs/gfs2/acl.c b/fs/gfs2/acl.c
> index a5b60778b91c..7b94efbbe8e3 100644
> --- a/fs/gfs2/acl.c
> +++ b/fs/gfs2/acl.c
> @@ -102,7 +102,7 @@ int __gfs2_set_acl(struct inode *inode, struct posix_acl *acl, int type)
> return error;
> }
>
> -int gfs2_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> +int gfs2_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct posix_acl *acl, int type)
> {
> struct inode *inode = d_inode(dentry);
> diff --git a/fs/gfs2/acl.h b/fs/gfs2/acl.h
> index 82f5b09c04e6..d19d41755936 100644
> --- a/fs/gfs2/acl.h
> +++ b/fs/gfs2/acl.h
> @@ -13,7 +13,7 @@
>
> struct posix_acl *gfs2_get_acl(struct inode *inode, int type, bool rcu);
> int __gfs2_set_acl(struct inode *inode, struct posix_acl *acl, int type);
> -int gfs2_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> +int gfs2_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct posix_acl *acl, int type);
>
> #endif /* __ACL_DOT_H__ */
> diff --git a/fs/internal.h b/fs/internal.h
> index a502b1fbacd2..8ba0a1613d20 100644
> --- a/fs/internal.h
> +++ b/fs/internal.h
> @@ -302,12 +302,12 @@ int import_xattr_name(struct xattr_name *kname, const char __user *name);
> int may_write_xattr(const struct mnt_idmap *idmap, struct inode *inode);
>
> #ifdef CONFIG_FS_POSIX_ACL
> -int do_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> +int do_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> const char *acl_name, const void *kvalue, size_t size);
> ssize_t do_get_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> const char *acl_name, void *kvalue, size_t size);
> #else
> -static inline int do_set_acl(struct mnt_idmap *idmap,
> +static inline int do_set_acl(const struct mnt_idmap *idmap,
> struct dentry *dentry, const char *acl_name,
> const void *kvalue, size_t size)
> {
> diff --git a/fs/jffs2/acl.c b/fs/jffs2/acl.c
> index f0f8a4f57add..7548f44bf327 100644
> --- a/fs/jffs2/acl.c
> +++ b/fs/jffs2/acl.c
> @@ -228,7 +228,7 @@ static int __jffs2_set_acl(struct inode *inode, int xprefix, struct posix_acl *a
> return rc;
> }
>
> -int jffs2_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> +int jffs2_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct posix_acl *acl, int type)
> {
> int rc, xprefix;
> diff --git a/fs/jffs2/acl.h b/fs/jffs2/acl.h
> index e976b8cb82cf..bc5df521633f 100644
> --- a/fs/jffs2/acl.h
> +++ b/fs/jffs2/acl.h
> @@ -28,7 +28,7 @@ struct jffs2_acl_header {
> #ifdef CONFIG_JFFS2_FS_POSIX_ACL
>
> struct posix_acl *jffs2_get_acl(struct inode *inode, int type, bool rcu);
> -int jffs2_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> +int jffs2_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct posix_acl *acl, int type);
> extern int jffs2_init_acl_pre(struct inode *, struct inode *, umode_t *);
> extern int jffs2_init_acl_post(struct inode *);
> diff --git a/fs/jfs/acl.c b/fs/jfs/acl.c
> index 16b71a23ff1e..6e0a7feb6c80 100644
> --- a/fs/jfs/acl.c
> +++ b/fs/jfs/acl.c
> @@ -89,7 +89,7 @@ static int __jfs_set_acl(tid_t tid, struct inode *inode, int type,
> return rc;
> }
>
> -int jfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> +int jfs_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct posix_acl *acl, int type)
> {
> int rc;
> diff --git a/fs/jfs/jfs_acl.h b/fs/jfs/jfs_acl.h
> index f892e54d0fcd..bda26b333519 100644
> --- a/fs/jfs/jfs_acl.h
> +++ b/fs/jfs/jfs_acl.h
> @@ -8,7 +8,7 @@
> #ifdef CONFIG_JFS_POSIX_ACL
>
> struct posix_acl *jfs_get_acl(struct inode *inode, int type, bool rcu);
> -int jfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> +int jfs_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct posix_acl *acl, int type);
> int jfs_init_acl(tid_t, struct inode *, struct inode *);
>
> diff --git a/fs/nfs/nfs3_fs.h b/fs/nfs/nfs3_fs.h
> index b333ea119ef5..ffcabadb3546 100644
> --- a/fs/nfs/nfs3_fs.h
> +++ b/fs/nfs/nfs3_fs.h
> @@ -12,7 +12,7 @@
> */
> #ifdef CONFIG_NFS_V3_ACL
> extern struct posix_acl *nfs3_get_acl(struct inode *inode, int type, bool rcu);
> -extern int nfs3_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> +extern int nfs3_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct posix_acl *acl, int type);
> extern int nfs3_proc_setacls(struct inode *inode, struct posix_acl *acl,
> struct posix_acl *dfacl);
> diff --git a/fs/nfs/nfs3acl.c b/fs/nfs/nfs3acl.c
> index a126eb31f62f..2549a1985b9a 100644
> --- a/fs/nfs/nfs3acl.c
> +++ b/fs/nfs/nfs3acl.c
> @@ -254,7 +254,7 @@ int nfs3_proc_setacls(struct inode *inode, struct posix_acl *acl,
>
> }
>
> -int nfs3_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> +int nfs3_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct posix_acl *acl, int type)
> {
> struct posix_acl *orig = acl, *dfacl = NULL, *alloc;
> diff --git a/fs/ntfs/ea.c b/fs/ntfs/ea.c
> index 7fd323912510..063cc15f1626 100644
> --- a/fs/ntfs/ea.c
> +++ b/fs/ntfs/ea.c
> @@ -1080,7 +1080,7 @@ static noinline int ntfs_set_acl_ex(const struct mnt_idmap *idmap,
> return err;
> }
>
> -int ntfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> +int ntfs_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct posix_acl *acl, int type)
> {
> return ntfs_set_acl_ex(idmap, d_inode(dentry), acl, type, false);
> diff --git a/fs/ntfs/ea.h b/fs/ntfs/ea.h
> index 9d17abc2e491..6d98e7487a2c 100644
> --- a/fs/ntfs/ea.h
> +++ b/fs/ntfs/ea.h
> @@ -19,7 +19,7 @@ ssize_t ntfs_listxattr(struct dentry *dentry, char *buffer, size_t size);
> #ifdef CONFIG_NTFS_FS_POSIX_ACL
> struct posix_acl *ntfs_get_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> int type);
> -int ntfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> +int ntfs_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct posix_acl *acl, int type);
> int ntfs_init_acl(const struct mnt_idmap *idmap, struct inode *inode,
> struct inode *dir);
> diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h
> index e494bed87679..0a5e81d420f0 100644
> --- a/fs/ntfs3/ntfs_fs.h
> +++ b/fs/ntfs3/ntfs_fs.h
> @@ -965,7 +965,7 @@ unsigned long ntfs_names_hash(const u16 *name, size_t len, const u16 *upcase,
> #ifdef CONFIG_NTFS3_FS_POSIX_ACL
> struct posix_acl *ntfs_get_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> int type);
> -int ntfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> +int ntfs_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct posix_acl *acl, int type);
> int ntfs_init_acl(const struct mnt_idmap *idmap, struct inode *inode,
> struct inode *dir);
> @@ -974,7 +974,7 @@ int ntfs_init_acl(const struct mnt_idmap *idmap, struct inode *inode,
> #define ntfs_set_acl NULL
> #endif
>
> -int ntfs_acl_chmod(struct mnt_idmap *idmap, struct dentry *dentry);
> +int ntfs_acl_chmod(const struct mnt_idmap *idmap, struct dentry *dentry);
> ssize_t ntfs_listxattr(struct dentry *dentry, char *buffer, size_t size);
> extern const struct xattr_handler *const ntfs_xattr_handlers[];
>
> diff --git a/fs/ntfs3/xattr.c b/fs/ntfs3/xattr.c
> index 5644167de863..2d17b80999ca 100644
> --- a/fs/ntfs3/xattr.c
> +++ b/fs/ntfs3/xattr.c
> @@ -677,7 +677,7 @@ static noinline int ntfs_set_acl_ex(const struct mnt_idmap *idmap,
> /*
> * ntfs_set_acl - inode_operations::set_acl
> */
> -int ntfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> +int ntfs_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct posix_acl *acl, int type)
> {
> return ntfs_set_acl_ex(idmap, d_inode(dentry), acl, type, false);
> @@ -722,7 +722,7 @@ int ntfs_init_acl(const struct mnt_idmap *idmap, struct inode *inode,
> /*
> * ntfs_acl_chmod - Helper for ntfs_setattr().
> */
> -int ntfs_acl_chmod(struct mnt_idmap *idmap, struct dentry *dentry)
> +int ntfs_acl_chmod(const struct mnt_idmap *idmap, struct dentry *dentry)
> {
> struct inode *inode = d_inode(dentry);
> struct super_block *sb = inode->i_sb;
> diff --git a/fs/ocfs2/acl.c b/fs/ocfs2/acl.c
> index 090ec60fb576..801a2f56ad08 100644
> --- a/fs/ocfs2/acl.c
> +++ b/fs/ocfs2/acl.c
> @@ -260,7 +260,7 @@ static int ocfs2_set_acl(handle_t *handle,
> return ret;
> }
>
> -int ocfs2_iop_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> +int ocfs2_iop_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct posix_acl *acl, int type)
> {
> struct buffer_head *bh = NULL;
> diff --git a/fs/ocfs2/acl.h b/fs/ocfs2/acl.h
> index a91f9ce278d6..1ed05899cce1 100644
> --- a/fs/ocfs2/acl.h
> +++ b/fs/ocfs2/acl.h
> @@ -17,7 +17,7 @@ struct ocfs2_acl_entry {
> };
>
> struct posix_acl *ocfs2_iop_get_acl(struct inode *inode, int type, bool rcu);
> -int ocfs2_iop_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> +int ocfs2_iop_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct posix_acl *acl, int type);
> extern int ocfs2_acl_chmod(struct inode *, struct buffer_head *);
> struct ocfs2_acl_state {
> diff --git a/fs/orangefs/acl.c b/fs/orangefs/acl.c
> index a01ef0c1b1bf..f31196e4bfaa 100644
> --- a/fs/orangefs/acl.c
> +++ b/fs/orangefs/acl.c
> @@ -112,7 +112,7 @@ int __orangefs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
> return error;
> }
>
> -int orangefs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> +int orangefs_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct posix_acl *acl, int type)
> {
> int error;
> diff --git a/fs/orangefs/orangefs-kernel.h b/fs/orangefs/orangefs-kernel.h
> index c582ceffb26e..a5c9e7be4005 100644
> --- a/fs/orangefs/orangefs-kernel.h
> +++ b/fs/orangefs/orangefs-kernel.h
> @@ -98,7 +98,7 @@ enum orangefs_vfs_op_states {
> 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,
> +extern int orangefs_set_acl(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct posix_acl *acl,
> int type);
> int __orangefs_set_acl(struct inode *inode, struct posix_acl *acl, int type);
> diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
> index 5f4e8b6d9722..18e4cbe154cf 100644
> --- a/fs/overlayfs/inode.c
> +++ b/fs/overlayfs/inode.c
> @@ -536,7 +536,7 @@ static int ovl_set_or_remove_acl(struct dentry *dentry, struct inode *inode,
> return err;
> }
>
> -int ovl_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> +int ovl_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct posix_acl *acl, int type)
> {
> int err;
> diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h
> index 46a5cf5dae4c..8b335993bf56 100644
> --- a/fs/overlayfs/overlayfs.h
> +++ b/fs/overlayfs/overlayfs.h
> @@ -819,7 +819,7 @@ static inline struct posix_acl *ovl_get_acl(struct mnt_idmap *idmap,
> {
> return do_ovl_get_acl(idmap, d_inode(dentry), type, false, false);
> }
> -int ovl_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> +int ovl_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct posix_acl *acl, int type);
> struct posix_acl *ovl_get_acl_path(const struct path *path,
> const char *acl_name, bool noperm);
> diff --git a/fs/posix_acl.c b/fs/posix_acl.c
> index b279804ebf56..cec7fb557278 100644
> --- a/fs/posix_acl.c
> +++ b/fs/posix_acl.c
> @@ -608,7 +608,7 @@ EXPORT_SYMBOL(__posix_acl_chmod);
> * performed on the raw inode simply pass @nop_mnt_idmap.
> */
> int
> - posix_acl_chmod(struct mnt_idmap *idmap, struct dentry *dentry,
> + posix_acl_chmod(const struct mnt_idmap *idmap, struct dentry *dentry,
> umode_t mode)
> {
> struct inode *inode = d_inode(dentry);
> @@ -937,7 +937,7 @@ static ssize_t vfs_posix_acl_to_xattr(const struct mnt_idmap *idmap,
> }
>
> int
> -set_posix_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> +set_posix_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> int type, struct posix_acl *acl)
> {
> struct inode *inode = d_inode(dentry);
> @@ -1018,7 +1018,7 @@ const struct xattr_handler nop_posix_acl_default = {
> };
> EXPORT_SYMBOL_GPL(nop_posix_acl_default);
>
> -int simple_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> +int simple_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct posix_acl *acl, int type)
> {
> int error;
> @@ -1091,7 +1091,7 @@ static int vfs_set_acl_idmapped_mnt(const struct mnt_idmap *idmap,
> *
> * Return: On success 0, on error negative errno.
> */
> -int vfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> +int vfs_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> const char *acl_name, struct posix_acl *kacl)
> {
> int acl_type;
> @@ -1212,7 +1212,7 @@ EXPORT_SYMBOL_GPL(vfs_get_acl);
> *
> * Return: On success 0, on error negative errno.
> */
> -int vfs_remove_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> +int vfs_remove_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> const char *acl_name)
> {
> int acl_type;
> @@ -1265,7 +1265,7 @@ int vfs_remove_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> }
> EXPORT_SYMBOL_GPL(vfs_remove_acl);
>
> -int do_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> +int do_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> const char *acl_name, const void *kvalue, size_t size)
> {
> int error;
> diff --git a/fs/smb/client/cifsacl.c b/fs/smb/client/cifsacl.c
> index 12005f46307d..0a05b6b0be5f 100644
> --- a/fs/smb/client/cifsacl.c
> +++ b/fs/smb/client/cifsacl.c
> @@ -1931,7 +1931,7 @@ struct posix_acl *cifs_get_acl(struct mnt_idmap *idmap,
> #endif
> }
>
> -int cifs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> +int cifs_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct posix_acl *acl, int type)
> {
> #if defined(CONFIG_CIFS_ALLOW_INSECURE_LEGACY) && defined(CONFIG_CIFS_POSIX)
> diff --git a/fs/smb/client/cifsproto.h b/fs/smb/client/cifsproto.h
> index 00168839c123..565697c233a9 100644
> --- a/fs/smb/client/cifsproto.h
> +++ b/fs/smb/client/cifsproto.h
> @@ -214,7 +214,7 @@ struct smb_ntsd *get_cifs_acl_by_fid(struct cifs_sb_info *cifs_sb,
> u32 *pacllen, u32 info);
> struct posix_acl *cifs_get_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> int type);
> -int cifs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> +int cifs_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct posix_acl *acl, int type);
> int set_cifs_acl(struct smb_ntsd *pnntsd, __u32 acllen, struct inode *inode,
> const char *path, int aclflag);
> diff --git a/fs/smb/server/vfs.c b/fs/smb/server/vfs.c
> index 3c4d18a4e8d5..75edff8dde31 100644
> --- a/fs/smb/server/vfs.c
> +++ b/fs/smb/server/vfs.c
> @@ -1471,7 +1471,7 @@ struct dentry *ksmbd_vfs_kern_path_create(struct ksmbd_work *work,
> return dent;
> }
>
> -int ksmbd_vfs_remove_acl_xattrs(struct mnt_idmap *idmap,
> +int ksmbd_vfs_remove_acl_xattrs(const struct mnt_idmap *idmap,
> const struct path *path)
> {
> char *name, *xattr_list = NULL;
> @@ -2200,7 +2200,7 @@ void ksmbd_vfs_posix_lock_unblock(struct file_lock *flock)
> locks_delete_block(flock);
> }
>
> -int ksmbd_vfs_set_init_posix_acl(struct mnt_idmap *idmap,
> +int ksmbd_vfs_set_init_posix_acl(const struct mnt_idmap *idmap,
> const struct path *path)
> {
> struct posix_acl_state acl_state;
> diff --git a/fs/smb/server/vfs.h b/fs/smb/server/vfs.h
> index 5e34fc61b48b..67cc48e583c8 100644
> --- a/fs/smb/server/vfs.h
> +++ b/fs/smb/server/vfs.h
> @@ -152,7 +152,7 @@ int ksmbd_vfs_fill_dentry_attrs(struct ksmbd_work *work,
> struct ksmbd_kstat *ksmbd_kstat);
> void ksmbd_vfs_posix_lock_wait(struct file_lock *flock);
> void ksmbd_vfs_posix_lock_unblock(struct file_lock *flock);
> -int ksmbd_vfs_remove_acl_xattrs(struct mnt_idmap *idmap,
> +int ksmbd_vfs_remove_acl_xattrs(const struct mnt_idmap *idmap,
> const struct path *path);
> int ksmbd_vfs_remove_sd_xattrs(const struct mnt_idmap *idmap, const struct path *path);
> int ksmbd_vfs_set_sd_xattr(struct ksmbd_conn *conn,
> @@ -171,7 +171,7 @@ int ksmbd_vfs_set_dos_attrib_xattr(const struct mnt_idmap *idmap,
> int ksmbd_vfs_get_dos_attrib_xattr(const struct mnt_idmap *idmap,
> struct dentry *dentry,
> struct xattr_dos_attrib *da);
> -int ksmbd_vfs_set_init_posix_acl(struct mnt_idmap *idmap,
> +int ksmbd_vfs_set_init_posix_acl(const struct mnt_idmap *idmap,
> const struct path *path);
> int ksmbd_vfs_inherit_posix_acl(const struct mnt_idmap *idmap,
> const struct path *path,
> diff --git a/fs/xattr.c b/fs/xattr.c
> index acdaafb0c7c1..758a7ffe3a86 100644
> --- a/fs/xattr.c
> +++ b/fs/xattr.c
> @@ -652,7 +652,7 @@ int setxattr_copy(const char __user *name, struct kernel_xattr_ctx *ctx)
> return error;
> }
>
> -static int do_setxattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +static int do_setxattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct kernel_xattr_ctx *ctx)
> {
> if (is_posix_acl_xattr(ctx->kname->name))
> @@ -1029,7 +1029,7 @@ SYSCALL_DEFINE3(flistxattr, int, fd, char __user *, list, size_t, size)
> * Extended attribute REMOVE operations
> */
> static long
> -removexattr(struct mnt_idmap *idmap, struct dentry *d, const char *name)
> +removexattr(const struct mnt_idmap *idmap, struct dentry *d, const char *name)
> {
> if (is_posix_acl_xattr(name))
> return vfs_remove_acl(idmap, d, name);
> diff --git a/fs/xfs/xfs_acl.c b/fs/xfs/xfs_acl.c
> index fdfca6fc75b6..20d87b52c4fc 100644
> --- a/fs/xfs/xfs_acl.c
> +++ b/fs/xfs/xfs_acl.c
> @@ -243,7 +243,7 @@ xfs_acl_set_mode(
> }
>
> int
> -xfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> +xfs_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct posix_acl *acl, int type)
> {
> umode_t mode;
> diff --git a/fs/xfs/xfs_acl.h b/fs/xfs/xfs_acl.h
> index bf7f960997d3..183526bec32c 100644
> --- a/fs/xfs/xfs_acl.h
> +++ b/fs/xfs/xfs_acl.h
> @@ -11,7 +11,7 @@ struct posix_acl;
>
> #ifdef CONFIG_XFS_POSIX_ACL
> extern struct posix_acl *xfs_get_acl(struct inode *inode, int type, bool rcu);
> -extern int xfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> +extern int xfs_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct posix_acl *acl, int type);
> extern int __xfs_set_acl(struct inode *inode, struct posix_acl *acl, int type);
> void xfs_forget_acl(struct inode *inode, const char *name);
> diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
> index b652f129c85e..25d4d42fbc7f 100644
> --- a/fs/xfs/xfs_iops.c
> +++ b/fs/xfs/xfs_iops.c
> @@ -777,7 +777,7 @@ xfs_vn_change_ok(
> */
> static int
> xfs_setattr_nonsize(
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *dentry,
> struct xfs_inode *ip,
> struct iattr *iattr)
> @@ -903,7 +903,7 @@ xfs_setattr_nonsize(
> */
> int
> xfs_vn_setattr_size(
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *dentry,
> struct iattr *iattr)
> {
> diff --git a/fs/xfs/xfs_iops.h b/fs/xfs/xfs_iops.h
> index 0896f6b8b3b8..328305bba19d 100644
> --- a/fs/xfs/xfs_iops.h
> +++ b/fs/xfs/xfs_iops.h
> @@ -10,7 +10,7 @@ struct xfs_inode;
>
> extern ssize_t xfs_vn_listxattr(struct dentry *, char *data, size_t size);
>
> -int xfs_vn_setattr_size(struct mnt_idmap *idmap,
> +int xfs_vn_setattr_size(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct iattr *vap);
>
> int xfs_inode_init_security(struct inode *inode, struct inode *dir,
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 764ef2d97a5d..9186d9bb2697 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -2028,7 +2028,7 @@ struct inode_operations {
> struct file *, umode_t);
> struct posix_acl *(*get_acl)(struct mnt_idmap *, struct dentry *,
> int);
> - int (*set_acl)(struct mnt_idmap *, struct dentry *,
> + int (*set_acl)(const struct mnt_idmap *, struct dentry *,
> struct posix_acl *, int);
> int (*fileattr_set)(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct file_kattr *fa);
> diff --git a/include/linux/posix_acl.h b/include/linux/posix_acl.h
> index 7c6cfcae0a9d..9220fe0c965d 100644
> --- a/include/linux/posix_acl.h
> +++ b/include/linux/posix_acl.h
> @@ -74,20 +74,20 @@ extern int __posix_acl_create(struct posix_acl **, gfp_t, umode_t *);
> extern int __posix_acl_chmod(struct posix_acl **, gfp_t, umode_t);
>
> extern struct posix_acl *get_posix_acl(struct inode *, int);
> -int set_posix_acl(struct mnt_idmap *, struct dentry *, int,
> +int set_posix_acl(const struct mnt_idmap *, struct dentry *, int,
> struct posix_acl *);
>
> struct posix_acl *get_cached_acl_rcu(struct inode *inode, int type);
> struct posix_acl *posix_acl_clone(const struct posix_acl *acl, gfp_t flags);
>
> #ifdef CONFIG_FS_POSIX_ACL
> -int posix_acl_chmod(struct mnt_idmap *, struct dentry *, umode_t);
> +int posix_acl_chmod(const struct mnt_idmap *, struct dentry *, umode_t);
> extern int posix_acl_create(struct inode *, umode_t *, struct posix_acl **,
> struct posix_acl **);
> int posix_acl_update_mode(const struct mnt_idmap *, struct inode *, umode_t *,
> struct posix_acl **);
>
> -int simple_set_acl(struct mnt_idmap *, struct dentry *,
> +int simple_set_acl(const struct mnt_idmap *, struct dentry *,
> struct posix_acl *, int);
> extern int simple_acl_create(struct inode *, struct inode *);
>
> @@ -105,16 +105,16 @@ static inline void cache_no_acl(struct inode *inode)
> inode->i_default_acl = NULL;
> }
>
> -int vfs_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> +int vfs_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> const char *acl_name, struct posix_acl *kacl);
> struct posix_acl *vfs_get_acl(struct mnt_idmap *idmap,
> struct dentry *dentry, const char *acl_name);
> -int vfs_remove_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> +int vfs_remove_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> const char *acl_name);
> int posix_acl_listxattr(struct inode *inode, char **buffer,
> ssize_t *remaining_size);
> #else
> -static inline int posix_acl_chmod(struct mnt_idmap *idmap,
> +static inline int posix_acl_chmod(const struct mnt_idmap *idmap,
> struct dentry *dentry, umode_t mode)
> {
> return 0;
> @@ -141,7 +141,7 @@ static inline void forget_all_cached_acls(struct inode *inode)
> {
> }
>
> -static inline int vfs_set_acl(struct mnt_idmap *idmap,
> +static inline int vfs_set_acl(const struct mnt_idmap *idmap,
> struct dentry *dentry, const char *name,
> struct posix_acl *acl)
> {
> @@ -155,7 +155,7 @@ static inline struct posix_acl *vfs_get_acl(struct mnt_idmap *idmap,
> return ERR_PTR(-EOPNOTSUPP);
> }
>
> -static inline int vfs_remove_acl(struct mnt_idmap *idmap,
> +static inline int vfs_remove_acl(const struct mnt_idmap *idmap,
> struct dentry *dentry, const char *acl_name)
> {
> return -EOPNOTSUPP;
>
> --
> 2.53.0
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 62+ messages in thread
* [PATCH 16/27] fs: port ->get_acl() to pass const mnt_idmap
2026-09-01 12:14 [PATCH 00/27] fs: port to const struct mnt_idmap Christian Brauner
` (14 preceding siblings ...)
2026-09-01 12:14 ` [PATCH 15/27] fs: port ->set_acl() " Christian Brauner
@ 2026-09-01 12:14 ` Christian Brauner
2026-09-02 15:45 ` Jan Kara
2026-09-01 12:14 ` [PATCH 17/27] fs: port ->tmpfile() " Christian Brauner
` (10 subsequent siblings)
26 siblings, 1 reply; 62+ messages in thread
From: Christian Brauner @ 2026-09-01 12:14 UTC (permalink / raw)
To: linux-fsdevel
Cc: Alexander Viro, Jan Kara, Christoph Hellwig, Seth Forshee,
Paul Moore, linux-security-module, Mimi Zohar, linux-integrity,
Ilya Dryomov, ceph-devel, Carlos Maiolino, linux-xfs,
Miklos Szeredi, Amir Goldstein, linux-unionfs, Namjae Jeon,
linux-cifs, linux-kernel, Christian Brauner (Amutable)
Convert to const struct mnt_idmap.
A mount's idmapping is immutable. The only thing that is allowed to be
modified afterwards is the reference count and that is hidden behind
mnt_idmap_get() and mnt_idmap_put(). Everything else only ever reads
from the idmapping. This is the same model that struct cred uses and the
idmapping is also rather sensitive.
So make the idmap argument const wherever we can. The conversion is done
from the bottom up so callers can continue to pass a non-const pointer
to a const parameter until the conversion is finished.
No functional changes.
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
---
Documentation/filesystems/locking.rst | 2 +-
Documentation/filesystems/vfs.rst | 2 +-
fs/9p/acl.c | 2 +-
fs/9p/acl.h | 2 +-
fs/ecryptfs/inode.c | 2 +-
fs/fuse/acl.c | 2 +-
fs/fuse/fuse_i.h | 2 +-
fs/internal.h | 4 ++--
fs/ntfs/ea.c | 2 +-
fs/ntfs/ea.h | 2 +-
fs/ntfs3/ntfs_fs.h | 2 +-
fs/ntfs3/xattr.c | 2 +-
fs/overlayfs/overlayfs.h | 2 +-
fs/posix_acl.c | 6 +++---
fs/smb/client/cifsacl.c | 2 +-
fs/smb/client/cifsproto.h | 2 +-
fs/xattr.c | 2 +-
include/linux/fs.h | 2 +-
include/linux/posix_acl.h | 4 ++--
19 files changed, 23 insertions(+), 23 deletions(-)
diff --git a/Documentation/filesystems/locking.rst b/Documentation/filesystems/locking.rst
index b95cd4992896..167988321a8c 100644
--- a/Documentation/filesystems/locking.rst
+++ b/Documentation/filesystems/locking.rst
@@ -91,7 +91,7 @@ prototypes::
int (*fileattr_set)(const struct mnt_idmap *idmap,
struct dentry *dentry, struct file_kattr *fa);
int (*fileattr_get)(struct dentry *dentry, struct file_kattr *fa);
- struct posix_acl * (*get_acl)(struct mnt_idmap *, struct dentry *, int);
+ struct posix_acl * (*get_acl)(const struct mnt_idmap *, struct dentry *, int);
struct offset_ctx *(*get_offset_ctx)(struct inode *inode);
locking rules:
diff --git a/Documentation/filesystems/vfs.rst b/Documentation/filesystems/vfs.rst
index d0dd2be3885b..6adb1061a9b6 100644
--- a/Documentation/filesystems/vfs.rst
+++ b/Documentation/filesystems/vfs.rst
@@ -439,7 +439,7 @@ As of kernel 2.6.22, the following members are defined:
int (*atomic_open)(struct inode *, struct dentry *, struct file *,
unsigned open_flag, umode_t create_mode);
int (*tmpfile) (struct mnt_idmap *, struct inode *, struct file *, umode_t);
- struct posix_acl * (*get_acl)(struct mnt_idmap *, struct dentry *, int);
+ struct posix_acl * (*get_acl)(const struct mnt_idmap *, struct dentry *, int);
int (*set_acl)(const struct mnt_idmap *, struct dentry *, struct posix_acl *, int);
int (*fileattr_set)(const struct mnt_idmap *idmap,
struct dentry *dentry, struct file_kattr *fa);
diff --git a/fs/9p/acl.c b/fs/9p/acl.c
index d09a41336d0d..c6c7c47d32b9 100644
--- a/fs/9p/acl.c
+++ b/fs/9p/acl.c
@@ -140,7 +140,7 @@ struct posix_acl *v9fs_iop_get_inode_acl(struct inode *inode, int type, bool rcu
}
-struct posix_acl *v9fs_iop_get_acl(struct mnt_idmap *idmap,
+struct posix_acl *v9fs_iop_get_acl(const struct mnt_idmap *idmap,
struct dentry *dentry, int type)
{
struct v9fs_session_info *v9ses;
diff --git a/fs/9p/acl.h b/fs/9p/acl.h
index 7de74704c465..2d1b24abcd3f 100644
--- a/fs/9p/acl.h
+++ b/fs/9p/acl.h
@@ -10,7 +10,7 @@
int v9fs_get_acl(struct inode *inode, struct p9_fid *fid);
struct posix_acl *v9fs_iop_get_inode_acl(struct inode *inode, int type,
bool rcu);
-struct posix_acl *v9fs_iop_get_acl(struct mnt_idmap *idmap,
+struct posix_acl *v9fs_iop_get_acl(const struct mnt_idmap *idmap,
struct dentry *dentry, int type);
int v9fs_iop_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
struct posix_acl *acl, int type);
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index 1e5146485214..bd1187661d6d 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -1090,7 +1090,7 @@ static int ecryptfs_fileattr_set(const struct mnt_idmap *idmap,
return rc;
}
-static struct posix_acl *ecryptfs_get_acl(struct mnt_idmap *idmap,
+static struct posix_acl *ecryptfs_get_acl(const struct mnt_idmap *idmap,
struct dentry *dentry, int type)
{
return vfs_get_acl(idmap, ecryptfs_dentry_to_lower(dentry),
diff --git a/fs/fuse/acl.c b/fs/fuse/acl.c
index c3813fff4f27..738abed9a816 100644
--- a/fs/fuse/acl.c
+++ b/fs/fuse/acl.c
@@ -62,7 +62,7 @@ static inline bool fuse_no_acl(const struct fuse_conn *fc,
return !fc->posix_acl && (i_user_ns(inode) != &init_user_ns);
}
-struct posix_acl *fuse_get_acl(struct mnt_idmap *idmap,
+struct posix_acl *fuse_get_acl(const struct mnt_idmap *idmap,
struct dentry *dentry, int type)
{
struct inode *inode = d_inode(dentry);
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index 561ada21ea86..9bf4c738bd74 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -1205,7 +1205,7 @@ 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);
-struct posix_acl *fuse_get_acl(struct mnt_idmap *idmap,
+struct posix_acl *fuse_get_acl(const struct mnt_idmap *idmap,
struct dentry *dentry, int type);
int fuse_set_acl(const struct mnt_idmap *, struct dentry *dentry,
struct posix_acl *acl, int type);
diff --git a/fs/internal.h b/fs/internal.h
index 8ba0a1613d20..8a1c7c05c5a2 100644
--- a/fs/internal.h
+++ b/fs/internal.h
@@ -304,7 +304,7 @@ int may_write_xattr(const struct mnt_idmap *idmap, struct inode *inode);
#ifdef CONFIG_FS_POSIX_ACL
int do_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
const char *acl_name, const void *kvalue, size_t size);
-ssize_t do_get_acl(struct mnt_idmap *idmap, struct dentry *dentry,
+ssize_t do_get_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
const char *acl_name, void *kvalue, size_t size);
#else
static inline int do_set_acl(const struct mnt_idmap *idmap,
@@ -313,7 +313,7 @@ static inline int do_set_acl(const struct mnt_idmap *idmap,
{
return -EOPNOTSUPP;
}
-static inline ssize_t do_get_acl(struct mnt_idmap *idmap,
+static inline ssize_t do_get_acl(const struct mnt_idmap *idmap,
struct dentry *dentry, const char *acl_name,
void *kvalue, size_t size)
{
diff --git a/fs/ntfs/ea.c b/fs/ntfs/ea.c
index 063cc15f1626..ed31f0e9f5d2 100644
--- a/fs/ntfs/ea.c
+++ b/fs/ntfs/ea.c
@@ -954,7 +954,7 @@ const struct xattr_handler * const ntfs_xattr_handlers[] = {
// clang-format on
#ifdef CONFIG_NTFS_FS_POSIX_ACL
-struct posix_acl *ntfs_get_acl(struct mnt_idmap *idmap, struct dentry *dentry,
+struct posix_acl *ntfs_get_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
int type)
{
struct inode *inode = d_inode(dentry);
diff --git a/fs/ntfs/ea.h b/fs/ntfs/ea.h
index 6d98e7487a2c..690fafe181fb 100644
--- a/fs/ntfs/ea.h
+++ b/fs/ntfs/ea.h
@@ -17,7 +17,7 @@ int ntfs_ea_set_wsl_inode(struct inode *inode, dev_t rdev, __le16 *ea_size,
ssize_t ntfs_listxattr(struct dentry *dentry, char *buffer, size_t size);
#ifdef CONFIG_NTFS_FS_POSIX_ACL
-struct posix_acl *ntfs_get_acl(struct mnt_idmap *idmap, struct dentry *dentry,
+struct posix_acl *ntfs_get_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
int type);
int ntfs_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
struct posix_acl *acl, int type);
diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h
index 0a5e81d420f0..d89609a17886 100644
--- a/fs/ntfs3/ntfs_fs.h
+++ b/fs/ntfs3/ntfs_fs.h
@@ -963,7 +963,7 @@ unsigned long ntfs_names_hash(const u16 *name, size_t len, const u16 *upcase,
/* globals from xattr.c */
#ifdef CONFIG_NTFS3_FS_POSIX_ACL
-struct posix_acl *ntfs_get_acl(struct mnt_idmap *idmap, struct dentry *dentry,
+struct posix_acl *ntfs_get_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
int type);
int ntfs_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
struct posix_acl *acl, int type);
diff --git a/fs/ntfs3/xattr.c b/fs/ntfs3/xattr.c
index 2d17b80999ca..941d516ab8dd 100644
--- a/fs/ntfs3/xattr.c
+++ b/fs/ntfs3/xattr.c
@@ -543,7 +543,7 @@ static noinline int ntfs_set_ea(struct inode *inode, const char *name,
/*
* ntfs_get_acl - inode_operations::get_acl
*/
-struct posix_acl *ntfs_get_acl(struct mnt_idmap *idmap, struct dentry *dentry,
+struct posix_acl *ntfs_get_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
int type)
{
struct inode *inode = d_inode(dentry);
diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h
index 8b335993bf56..1759221dcad5 100644
--- a/fs/overlayfs/overlayfs.h
+++ b/fs/overlayfs/overlayfs.h
@@ -814,7 +814,7 @@ static inline struct posix_acl *ovl_get_inode_acl(struct inode *inode, int type,
{
return do_ovl_get_acl(&nop_mnt_idmap, inode, type, rcu, true);
}
-static inline struct posix_acl *ovl_get_acl(struct mnt_idmap *idmap,
+static inline struct posix_acl *ovl_get_acl(const struct mnt_idmap *idmap,
struct dentry *dentry, int type)
{
return do_ovl_get_acl(idmap, d_inode(dentry), type, false, false);
diff --git a/fs/posix_acl.c b/fs/posix_acl.c
index cec7fb557278..fe77934ea8f2 100644
--- a/fs/posix_acl.c
+++ b/fs/posix_acl.c
@@ -118,7 +118,7 @@ void forget_all_cached_acls(struct inode *inode)
}
EXPORT_SYMBOL(forget_all_cached_acls);
-static struct posix_acl *__get_acl(struct mnt_idmap *idmap,
+static struct posix_acl *__get_acl(const struct mnt_idmap *idmap,
struct dentry *dentry, struct inode *inode,
int type)
{
@@ -1168,7 +1168,7 @@ EXPORT_SYMBOL_GPL(vfs_set_acl);
*
* Return: On success POSIX ACLs in VFS format, on error negative errno.
*/
-struct posix_acl *vfs_get_acl(struct mnt_idmap *idmap,
+struct posix_acl *vfs_get_acl(const struct mnt_idmap *idmap,
struct dentry *dentry, const char *acl_name)
{
struct inode *inode = d_inode(dentry);
@@ -1286,7 +1286,7 @@ int do_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
return error;
}
-ssize_t do_get_acl(struct mnt_idmap *idmap, struct dentry *dentry,
+ssize_t do_get_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
const char *acl_name, void *kvalue, size_t size)
{
ssize_t error;
diff --git a/fs/smb/client/cifsacl.c b/fs/smb/client/cifsacl.c
index 0a05b6b0be5f..084a4460ca19 100644
--- a/fs/smb/client/cifsacl.c
+++ b/fs/smb/client/cifsacl.c
@@ -1867,7 +1867,7 @@ id_mode_to_cifs_acl(struct inode *inode, const char *path, __u64 *pnmode,
return rc;
}
-struct posix_acl *cifs_get_acl(struct mnt_idmap *idmap,
+struct posix_acl *cifs_get_acl(const struct mnt_idmap *idmap,
struct dentry *dentry, int type)
{
#if defined(CONFIG_CIFS_ALLOW_INSECURE_LEGACY) && defined(CONFIG_CIFS_POSIX)
diff --git a/fs/smb/client/cifsproto.h b/fs/smb/client/cifsproto.h
index 565697c233a9..e6beff8aafe0 100644
--- a/fs/smb/client/cifsproto.h
+++ b/fs/smb/client/cifsproto.h
@@ -212,7 +212,7 @@ struct smb_ntsd *get_cifs_acl(struct cifs_sb_info *cifs_sb,
struct smb_ntsd *get_cifs_acl_by_fid(struct cifs_sb_info *cifs_sb,
const struct cifs_fid *cifsfid,
u32 *pacllen, u32 info);
-struct posix_acl *cifs_get_acl(struct mnt_idmap *idmap, struct dentry *dentry,
+struct posix_acl *cifs_get_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
int type);
int cifs_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
struct posix_acl *acl, int type);
diff --git a/fs/xattr.c b/fs/xattr.c
index 758a7ffe3a86..d9f035610f0b 100644
--- a/fs/xattr.c
+++ b/fs/xattr.c
@@ -787,7 +787,7 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
* Extended attribute GET operations
*/
static ssize_t
-do_getxattr(struct mnt_idmap *idmap, struct dentry *d,
+do_getxattr(const struct mnt_idmap *idmap, struct dentry *d,
struct kernel_xattr_ctx *ctx)
{
ssize_t error;
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 9186d9bb2697..9809e7c3aa0d 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2026,7 +2026,7 @@ struct inode_operations {
umode_t create_mode);
int (*tmpfile) (struct mnt_idmap *, struct inode *,
struct file *, umode_t);
- struct posix_acl *(*get_acl)(struct mnt_idmap *, struct dentry *,
+ struct posix_acl *(*get_acl)(const struct mnt_idmap *, struct dentry *,
int);
int (*set_acl)(const struct mnt_idmap *, struct dentry *,
struct posix_acl *, int);
diff --git a/include/linux/posix_acl.h b/include/linux/posix_acl.h
index 9220fe0c965d..caf500bed993 100644
--- a/include/linux/posix_acl.h
+++ b/include/linux/posix_acl.h
@@ -107,7 +107,7 @@ static inline void cache_no_acl(struct inode *inode)
int vfs_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
const char *acl_name, struct posix_acl *kacl);
-struct posix_acl *vfs_get_acl(struct mnt_idmap *idmap,
+struct posix_acl *vfs_get_acl(const struct mnt_idmap *idmap,
struct dentry *dentry, const char *acl_name);
int vfs_remove_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
const char *acl_name);
@@ -148,7 +148,7 @@ static inline int vfs_set_acl(const struct mnt_idmap *idmap,
return -EOPNOTSUPP;
}
-static inline struct posix_acl *vfs_get_acl(struct mnt_idmap *idmap,
+static inline struct posix_acl *vfs_get_acl(const struct mnt_idmap *idmap,
struct dentry *dentry,
const char *acl_name)
{
--
2.53.0
^ permalink raw reply related [flat|nested] 62+ messages in thread* Re: [PATCH 16/27] fs: port ->get_acl() to pass const mnt_idmap
2026-09-01 12:14 ` [PATCH 16/27] fs: port ->get_acl() " Christian Brauner
@ 2026-09-02 15:45 ` Jan Kara
0 siblings, 0 replies; 62+ messages in thread
From: Jan Kara @ 2026-09-02 15:45 UTC (permalink / raw)
To: Christian Brauner
Cc: linux-fsdevel, Alexander Viro, Jan Kara, Christoph Hellwig,
Seth Forshee, Paul Moore, linux-security-module, Mimi Zohar,
linux-integrity, Ilya Dryomov, ceph-devel, Carlos Maiolino,
linux-xfs, Miklos Szeredi, Amir Goldstein, linux-unionfs,
Namjae Jeon, linux-cifs, linux-kernel
On Tue 01-09-26 14:14:41, Christian Brauner wrote:
> Convert to const struct mnt_idmap.
>
> A mount's idmapping is immutable. The only thing that is allowed to be
> modified afterwards is the reference count and that is hidden behind
> mnt_idmap_get() and mnt_idmap_put(). Everything else only ever reads
> from the idmapping. This is the same model that struct cred uses and the
> idmapping is also rather sensitive.
>
> So make the idmap argument const wherever we can. The conversion is done
> from the bottom up so callers can continue to pass a non-const pointer
> to a const parameter until the conversion is finished.
>
> No functional changes.
>
> Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> Documentation/filesystems/locking.rst | 2 +-
> Documentation/filesystems/vfs.rst | 2 +-
> fs/9p/acl.c | 2 +-
> fs/9p/acl.h | 2 +-
> fs/ecryptfs/inode.c | 2 +-
> fs/fuse/acl.c | 2 +-
> fs/fuse/fuse_i.h | 2 +-
> fs/internal.h | 4 ++--
> fs/ntfs/ea.c | 2 +-
> fs/ntfs/ea.h | 2 +-
> fs/ntfs3/ntfs_fs.h | 2 +-
> fs/ntfs3/xattr.c | 2 +-
> fs/overlayfs/overlayfs.h | 2 +-
> fs/posix_acl.c | 6 +++---
> fs/smb/client/cifsacl.c | 2 +-
> fs/smb/client/cifsproto.h | 2 +-
> fs/xattr.c | 2 +-
> include/linux/fs.h | 2 +-
> include/linux/posix_acl.h | 4 ++--
> 19 files changed, 23 insertions(+), 23 deletions(-)
>
> diff --git a/Documentation/filesystems/locking.rst b/Documentation/filesystems/locking.rst
> index b95cd4992896..167988321a8c 100644
> --- a/Documentation/filesystems/locking.rst
> +++ b/Documentation/filesystems/locking.rst
> @@ -91,7 +91,7 @@ prototypes::
> int (*fileattr_set)(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct file_kattr *fa);
> int (*fileattr_get)(struct dentry *dentry, struct file_kattr *fa);
> - struct posix_acl * (*get_acl)(struct mnt_idmap *, struct dentry *, int);
> + struct posix_acl * (*get_acl)(const struct mnt_idmap *, struct dentry *, int);
> struct offset_ctx *(*get_offset_ctx)(struct inode *inode);
>
> locking rules:
> diff --git a/Documentation/filesystems/vfs.rst b/Documentation/filesystems/vfs.rst
> index d0dd2be3885b..6adb1061a9b6 100644
> --- a/Documentation/filesystems/vfs.rst
> +++ b/Documentation/filesystems/vfs.rst
> @@ -439,7 +439,7 @@ As of kernel 2.6.22, the following members are defined:
> int (*atomic_open)(struct inode *, struct dentry *, struct file *,
> unsigned open_flag, umode_t create_mode);
> int (*tmpfile) (struct mnt_idmap *, struct inode *, struct file *, umode_t);
> - struct posix_acl * (*get_acl)(struct mnt_idmap *, struct dentry *, int);
> + struct posix_acl * (*get_acl)(const struct mnt_idmap *, struct dentry *, int);
> int (*set_acl)(const struct mnt_idmap *, struct dentry *, struct posix_acl *, int);
> int (*fileattr_set)(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct file_kattr *fa);
> diff --git a/fs/9p/acl.c b/fs/9p/acl.c
> index d09a41336d0d..c6c7c47d32b9 100644
> --- a/fs/9p/acl.c
> +++ b/fs/9p/acl.c
> @@ -140,7 +140,7 @@ struct posix_acl *v9fs_iop_get_inode_acl(struct inode *inode, int type, bool rcu
>
> }
>
> -struct posix_acl *v9fs_iop_get_acl(struct mnt_idmap *idmap,
> +struct posix_acl *v9fs_iop_get_acl(const struct mnt_idmap *idmap,
> struct dentry *dentry, int type)
> {
> struct v9fs_session_info *v9ses;
> diff --git a/fs/9p/acl.h b/fs/9p/acl.h
> index 7de74704c465..2d1b24abcd3f 100644
> --- a/fs/9p/acl.h
> +++ b/fs/9p/acl.h
> @@ -10,7 +10,7 @@
> int v9fs_get_acl(struct inode *inode, struct p9_fid *fid);
> struct posix_acl *v9fs_iop_get_inode_acl(struct inode *inode, int type,
> bool rcu);
> -struct posix_acl *v9fs_iop_get_acl(struct mnt_idmap *idmap,
> +struct posix_acl *v9fs_iop_get_acl(const struct mnt_idmap *idmap,
> struct dentry *dentry, int type);
> int v9fs_iop_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct posix_acl *acl, int type);
> diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
> index 1e5146485214..bd1187661d6d 100644
> --- a/fs/ecryptfs/inode.c
> +++ b/fs/ecryptfs/inode.c
> @@ -1090,7 +1090,7 @@ static int ecryptfs_fileattr_set(const struct mnt_idmap *idmap,
> return rc;
> }
>
> -static struct posix_acl *ecryptfs_get_acl(struct mnt_idmap *idmap,
> +static struct posix_acl *ecryptfs_get_acl(const struct mnt_idmap *idmap,
> struct dentry *dentry, int type)
> {
> return vfs_get_acl(idmap, ecryptfs_dentry_to_lower(dentry),
> diff --git a/fs/fuse/acl.c b/fs/fuse/acl.c
> index c3813fff4f27..738abed9a816 100644
> --- a/fs/fuse/acl.c
> +++ b/fs/fuse/acl.c
> @@ -62,7 +62,7 @@ static inline bool fuse_no_acl(const struct fuse_conn *fc,
> return !fc->posix_acl && (i_user_ns(inode) != &init_user_ns);
> }
>
> -struct posix_acl *fuse_get_acl(struct mnt_idmap *idmap,
> +struct posix_acl *fuse_get_acl(const struct mnt_idmap *idmap,
> struct dentry *dentry, int type)
> {
> struct inode *inode = d_inode(dentry);
> diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
> index 561ada21ea86..9bf4c738bd74 100644
> --- a/fs/fuse/fuse_i.h
> +++ b/fs/fuse/fuse_i.h
> @@ -1205,7 +1205,7 @@ 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);
> -struct posix_acl *fuse_get_acl(struct mnt_idmap *idmap,
> +struct posix_acl *fuse_get_acl(const struct mnt_idmap *idmap,
> struct dentry *dentry, int type);
> int fuse_set_acl(const struct mnt_idmap *, struct dentry *dentry,
> struct posix_acl *acl, int type);
> diff --git a/fs/internal.h b/fs/internal.h
> index 8ba0a1613d20..8a1c7c05c5a2 100644
> --- a/fs/internal.h
> +++ b/fs/internal.h
> @@ -304,7 +304,7 @@ int may_write_xattr(const struct mnt_idmap *idmap, struct inode *inode);
> #ifdef CONFIG_FS_POSIX_ACL
> int do_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> const char *acl_name, const void *kvalue, size_t size);
> -ssize_t do_get_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> +ssize_t do_get_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> const char *acl_name, void *kvalue, size_t size);
> #else
> static inline int do_set_acl(const struct mnt_idmap *idmap,
> @@ -313,7 +313,7 @@ static inline int do_set_acl(const struct mnt_idmap *idmap,
> {
> return -EOPNOTSUPP;
> }
> -static inline ssize_t do_get_acl(struct mnt_idmap *idmap,
> +static inline ssize_t do_get_acl(const struct mnt_idmap *idmap,
> struct dentry *dentry, const char *acl_name,
> void *kvalue, size_t size)
> {
> diff --git a/fs/ntfs/ea.c b/fs/ntfs/ea.c
> index 063cc15f1626..ed31f0e9f5d2 100644
> --- a/fs/ntfs/ea.c
> +++ b/fs/ntfs/ea.c
> @@ -954,7 +954,7 @@ const struct xattr_handler * const ntfs_xattr_handlers[] = {
> // clang-format on
>
> #ifdef CONFIG_NTFS_FS_POSIX_ACL
> -struct posix_acl *ntfs_get_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> +struct posix_acl *ntfs_get_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> int type)
> {
> struct inode *inode = d_inode(dentry);
> diff --git a/fs/ntfs/ea.h b/fs/ntfs/ea.h
> index 6d98e7487a2c..690fafe181fb 100644
> --- a/fs/ntfs/ea.h
> +++ b/fs/ntfs/ea.h
> @@ -17,7 +17,7 @@ int ntfs_ea_set_wsl_inode(struct inode *inode, dev_t rdev, __le16 *ea_size,
> ssize_t ntfs_listxattr(struct dentry *dentry, char *buffer, size_t size);
>
> #ifdef CONFIG_NTFS_FS_POSIX_ACL
> -struct posix_acl *ntfs_get_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> +struct posix_acl *ntfs_get_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> int type);
> int ntfs_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct posix_acl *acl, int type);
> diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h
> index 0a5e81d420f0..d89609a17886 100644
> --- a/fs/ntfs3/ntfs_fs.h
> +++ b/fs/ntfs3/ntfs_fs.h
> @@ -963,7 +963,7 @@ unsigned long ntfs_names_hash(const u16 *name, size_t len, const u16 *upcase,
>
> /* globals from xattr.c */
> #ifdef CONFIG_NTFS3_FS_POSIX_ACL
> -struct posix_acl *ntfs_get_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> +struct posix_acl *ntfs_get_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> int type);
> int ntfs_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct posix_acl *acl, int type);
> diff --git a/fs/ntfs3/xattr.c b/fs/ntfs3/xattr.c
> index 2d17b80999ca..941d516ab8dd 100644
> --- a/fs/ntfs3/xattr.c
> +++ b/fs/ntfs3/xattr.c
> @@ -543,7 +543,7 @@ static noinline int ntfs_set_ea(struct inode *inode, const char *name,
> /*
> * ntfs_get_acl - inode_operations::get_acl
> */
> -struct posix_acl *ntfs_get_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> +struct posix_acl *ntfs_get_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> int type)
> {
> struct inode *inode = d_inode(dentry);
> diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h
> index 8b335993bf56..1759221dcad5 100644
> --- a/fs/overlayfs/overlayfs.h
> +++ b/fs/overlayfs/overlayfs.h
> @@ -814,7 +814,7 @@ static inline struct posix_acl *ovl_get_inode_acl(struct inode *inode, int type,
> {
> return do_ovl_get_acl(&nop_mnt_idmap, inode, type, rcu, true);
> }
> -static inline struct posix_acl *ovl_get_acl(struct mnt_idmap *idmap,
> +static inline struct posix_acl *ovl_get_acl(const struct mnt_idmap *idmap,
> struct dentry *dentry, int type)
> {
> return do_ovl_get_acl(idmap, d_inode(dentry), type, false, false);
> diff --git a/fs/posix_acl.c b/fs/posix_acl.c
> index cec7fb557278..fe77934ea8f2 100644
> --- a/fs/posix_acl.c
> +++ b/fs/posix_acl.c
> @@ -118,7 +118,7 @@ void forget_all_cached_acls(struct inode *inode)
> }
> EXPORT_SYMBOL(forget_all_cached_acls);
>
> -static struct posix_acl *__get_acl(struct mnt_idmap *idmap,
> +static struct posix_acl *__get_acl(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct inode *inode,
> int type)
> {
> @@ -1168,7 +1168,7 @@ EXPORT_SYMBOL_GPL(vfs_set_acl);
> *
> * Return: On success POSIX ACLs in VFS format, on error negative errno.
> */
> -struct posix_acl *vfs_get_acl(struct mnt_idmap *idmap,
> +struct posix_acl *vfs_get_acl(const struct mnt_idmap *idmap,
> struct dentry *dentry, const char *acl_name)
> {
> struct inode *inode = d_inode(dentry);
> @@ -1286,7 +1286,7 @@ int do_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> return error;
> }
>
> -ssize_t do_get_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> +ssize_t do_get_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> const char *acl_name, void *kvalue, size_t size)
> {
> ssize_t error;
> diff --git a/fs/smb/client/cifsacl.c b/fs/smb/client/cifsacl.c
> index 0a05b6b0be5f..084a4460ca19 100644
> --- a/fs/smb/client/cifsacl.c
> +++ b/fs/smb/client/cifsacl.c
> @@ -1867,7 +1867,7 @@ id_mode_to_cifs_acl(struct inode *inode, const char *path, __u64 *pnmode,
> return rc;
> }
>
> -struct posix_acl *cifs_get_acl(struct mnt_idmap *idmap,
> +struct posix_acl *cifs_get_acl(const struct mnt_idmap *idmap,
> struct dentry *dentry, int type)
> {
> #if defined(CONFIG_CIFS_ALLOW_INSECURE_LEGACY) && defined(CONFIG_CIFS_POSIX)
> diff --git a/fs/smb/client/cifsproto.h b/fs/smb/client/cifsproto.h
> index 565697c233a9..e6beff8aafe0 100644
> --- a/fs/smb/client/cifsproto.h
> +++ b/fs/smb/client/cifsproto.h
> @@ -212,7 +212,7 @@ struct smb_ntsd *get_cifs_acl(struct cifs_sb_info *cifs_sb,
> struct smb_ntsd *get_cifs_acl_by_fid(struct cifs_sb_info *cifs_sb,
> const struct cifs_fid *cifsfid,
> u32 *pacllen, u32 info);
> -struct posix_acl *cifs_get_acl(struct mnt_idmap *idmap, struct dentry *dentry,
> +struct posix_acl *cifs_get_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> int type);
> int cifs_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct posix_acl *acl, int type);
> diff --git a/fs/xattr.c b/fs/xattr.c
> index 758a7ffe3a86..d9f035610f0b 100644
> --- a/fs/xattr.c
> +++ b/fs/xattr.c
> @@ -787,7 +787,7 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
> * Extended attribute GET operations
> */
> static ssize_t
> -do_getxattr(struct mnt_idmap *idmap, struct dentry *d,
> +do_getxattr(const struct mnt_idmap *idmap, struct dentry *d,
> struct kernel_xattr_ctx *ctx)
> {
> ssize_t error;
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 9186d9bb2697..9809e7c3aa0d 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -2026,7 +2026,7 @@ struct inode_operations {
> umode_t create_mode);
> int (*tmpfile) (struct mnt_idmap *, struct inode *,
> struct file *, umode_t);
> - struct posix_acl *(*get_acl)(struct mnt_idmap *, struct dentry *,
> + struct posix_acl *(*get_acl)(const struct mnt_idmap *, struct dentry *,
> int);
> int (*set_acl)(const struct mnt_idmap *, struct dentry *,
> struct posix_acl *, int);
> diff --git a/include/linux/posix_acl.h b/include/linux/posix_acl.h
> index 9220fe0c965d..caf500bed993 100644
> --- a/include/linux/posix_acl.h
> +++ b/include/linux/posix_acl.h
> @@ -107,7 +107,7 @@ static inline void cache_no_acl(struct inode *inode)
>
> int vfs_set_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> const char *acl_name, struct posix_acl *kacl);
> -struct posix_acl *vfs_get_acl(struct mnt_idmap *idmap,
> +struct posix_acl *vfs_get_acl(const struct mnt_idmap *idmap,
> struct dentry *dentry, const char *acl_name);
> int vfs_remove_acl(const struct mnt_idmap *idmap, struct dentry *dentry,
> const char *acl_name);
> @@ -148,7 +148,7 @@ static inline int vfs_set_acl(const struct mnt_idmap *idmap,
> return -EOPNOTSUPP;
> }
>
> -static inline struct posix_acl *vfs_get_acl(struct mnt_idmap *idmap,
> +static inline struct posix_acl *vfs_get_acl(const struct mnt_idmap *idmap,
> struct dentry *dentry,
> const char *acl_name)
> {
>
> --
> 2.53.0
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 62+ messages in thread
* [PATCH 17/27] fs: port ->tmpfile() to pass const mnt_idmap
2026-09-01 12:14 [PATCH 00/27] fs: port to const struct mnt_idmap Christian Brauner
` (15 preceding siblings ...)
2026-09-01 12:14 ` [PATCH 16/27] fs: port ->get_acl() " Christian Brauner
@ 2026-09-01 12:14 ` 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
` (9 subsequent siblings)
26 siblings, 2 replies; 62+ messages in thread
From: Christian Brauner @ 2026-09-01 12:14 UTC (permalink / raw)
To: linux-fsdevel
Cc: Alexander Viro, Jan Kara, Christoph Hellwig, Seth Forshee,
Paul Moore, linux-security-module, Mimi Zohar, linux-integrity,
Ilya Dryomov, ceph-devel, Carlos Maiolino, linux-xfs,
Miklos Szeredi, Amir Goldstein, linux-unionfs, Namjae Jeon,
linux-cifs, linux-kernel, Christian Brauner (Amutable)
Convert to const struct mnt_idmap.
A mount's idmapping is immutable. The only thing that is allowed to be
modified afterwards is the reference count and that is hidden behind
mnt_idmap_get() and mnt_idmap_put(). Everything else only ever reads
from the idmapping. This is the same model that struct cred uses and the
idmapping is also rather sensitive.
So make the idmap argument const wherever we can. The conversion is done
from the bottom up so callers can continue to pass a non-const pointer
to a const parameter until the conversion is finished.
No functional changes.
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
---
Documentation/filesystems/locking.rst | 2 +-
Documentation/filesystems/vfs.rst | 2 +-
fs/bad_inode.c | 2 +-
fs/btrfs/inode.c | 2 +-
fs/ext2/namei.c | 2 +-
fs/ext4/namei.c | 2 +-
fs/f2fs/namei.c | 2 +-
fs/fuse/dir.c | 2 +-
fs/hugetlbfs/inode.c | 2 +-
fs/minix/namei.c | 2 +-
fs/overlayfs/dir.c | 2 +-
fs/ramfs/inode.c | 2 +-
fs/smb/client/cifsfs.h | 2 +-
fs/smb/client/dir.c | 2 +-
fs/ubifs/dir.c | 2 +-
fs/udf/namei.c | 2 +-
fs/xfs/xfs_iops.c | 2 +-
include/linux/fs.h | 2 +-
include/linux/lsm_hook_defs.h | 2 +-
include/linux/security.h | 4 ++--
mm/shmem.c | 2 +-
security/integrity/ima/ima_main.c | 2 +-
security/security.c | 2 +-
23 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/Documentation/filesystems/locking.rst b/Documentation/filesystems/locking.rst
index 167988321a8c..e4948ddc0a5f 100644
--- a/Documentation/filesystems/locking.rst
+++ b/Documentation/filesystems/locking.rst
@@ -86,7 +86,7 @@ prototypes::
int (*atomic_open)(struct inode *, struct dentry *,
struct file *, unsigned open_flag,
umode_t create_mode);
- int (*tmpfile) (struct mnt_idmap *, struct inode *,
+ int (*tmpfile) (const struct mnt_idmap *, struct inode *,
struct file *, umode_t);
int (*fileattr_set)(const struct mnt_idmap *idmap,
struct dentry *dentry, struct file_kattr *fa);
diff --git a/Documentation/filesystems/vfs.rst b/Documentation/filesystems/vfs.rst
index 6adb1061a9b6..e960257ef14a 100644
--- a/Documentation/filesystems/vfs.rst
+++ b/Documentation/filesystems/vfs.rst
@@ -438,7 +438,7 @@ As of kernel 2.6.22, the following members are defined:
void (*sync_lazytime)(struct inode *inode);
int (*atomic_open)(struct inode *, struct dentry *, struct file *,
unsigned open_flag, umode_t create_mode);
- int (*tmpfile) (struct mnt_idmap *, struct inode *, struct file *, umode_t);
+ int (*tmpfile) (const struct mnt_idmap *, struct inode *, struct file *, umode_t);
struct posix_acl * (*get_acl)(const struct mnt_idmap *, struct dentry *, int);
int (*set_acl)(const struct mnt_idmap *, struct dentry *, struct posix_acl *, int);
int (*fileattr_set)(const struct mnt_idmap *idmap,
diff --git a/fs/bad_inode.c b/fs/bad_inode.c
index 6e116810f66d..d8c0ce62cc63 100644
--- a/fs/bad_inode.c
+++ b/fs/bad_inode.c
@@ -146,7 +146,7 @@ static int bad_inode_atomic_open(struct inode *inode, struct dentry *dentry,
return -EIO;
}
-static int bad_inode_tmpfile(struct mnt_idmap *idmap,
+static int bad_inode_tmpfile(const struct mnt_idmap *idmap,
struct inode *inode, struct file *file,
umode_t mode)
{
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 7bf38f069116..092057508ae9 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -9391,7 +9391,7 @@ static int btrfs_permission(const struct mnt_idmap *idmap,
return generic_permission(idmap, inode, mask);
}
-static int btrfs_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
+static int btrfs_tmpfile(const struct mnt_idmap *idmap, struct inode *dir,
struct file *file, umode_t mode)
{
struct btrfs_fs_info *fs_info = inode_to_fs_info(dir);
diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c
index 8666233ec63b..108dc52cedfc 100644
--- a/fs/ext2/namei.c
+++ b/fs/ext2/namei.c
@@ -117,7 +117,7 @@ static int ext2_create (struct mnt_idmap * idmap,
return ext2_add_nondir(dentry, inode);
}
-static int ext2_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
+static int ext2_tmpfile(const struct mnt_idmap *idmap, struct inode *dir,
struct file *file, umode_t mode)
{
struct inode *inode = ext2_new_inode(dir, mode, NULL);
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index edc12599e64d..0bff01fb052a 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -2881,7 +2881,7 @@ static int ext4_mknod(struct mnt_idmap *idmap, struct inode *dir,
return err;
}
-static int ext4_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
+static int ext4_tmpfile(const struct mnt_idmap *idmap, struct inode *dir,
struct file *file, umode_t mode)
{
handle_t *handle;
diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
index e33780294713..3adc2345a204 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -928,7 +928,7 @@ static int __f2fs_tmpfile(const struct mnt_idmap *idmap, struct inode *dir,
return err;
}
-static int f2fs_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
+static int f2fs_tmpfile(const struct mnt_idmap *idmap, struct inode *dir,
struct file *file, umode_t mode)
{
struct f2fs_sb_info *sbi = F2FS_I_SB(dir);
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 0dbe3c6560f8..14dc9318cd57 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -1098,7 +1098,7 @@ static int fuse_create(struct mnt_idmap *idmap, struct inode *dir,
return fuse_mknod(idmap, dir, entry, mode, 0);
}
-static int fuse_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
+static int fuse_tmpfile(const struct mnt_idmap *idmap, struct inode *dir,
struct file *file, umode_t mode)
{
struct fuse_conn *fc = get_fuse_conn(dir);
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 4bd3adc20a47..8a07a3f18c05 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -984,7 +984,7 @@ static int hugetlbfs_create(struct mnt_idmap *idmap,
return hugetlbfs_mknod(idmap, dir, dentry, mode | S_IFREG, 0);
}
-static int hugetlbfs_tmpfile(struct mnt_idmap *idmap,
+static int hugetlbfs_tmpfile(const struct mnt_idmap *idmap,
struct inode *dir, struct file *file,
umode_t mode)
{
diff --git a/fs/minix/namei.c b/fs/minix/namei.c
index 5525ba367ed7..0575dea16a3b 100644
--- a/fs/minix/namei.c
+++ b/fs/minix/namei.c
@@ -50,7 +50,7 @@ static int minix_mknod(struct mnt_idmap *idmap, struct inode *dir,
return add_nondir(dentry, inode);
}
-static int minix_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
+static int minix_tmpfile(const struct mnt_idmap *idmap, struct inode *dir,
struct file *file, umode_t mode)
{
struct inode *inode = minix_new_inode(dir, mode);
diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
index a022dc7781bf..4f3f1e2bafff 100644
--- a/fs/overlayfs/dir.c
+++ b/fs/overlayfs/dir.c
@@ -1420,7 +1420,7 @@ static int ovl_dummy_open(struct inode *inode, struct file *file)
return 0;
}
-static int ovl_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
+static int ovl_tmpfile(const struct mnt_idmap *idmap, struct inode *dir,
struct file *file, umode_t mode)
{
int err;
diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c
index 0a88ede48e0a..fc9a79af4840 100644
--- a/fs/ramfs/inode.c
+++ b/fs/ramfs/inode.c
@@ -163,7 +163,7 @@ static int ramfs_symlink(struct mnt_idmap *idmap, struct inode *dir,
return error;
}
-static int ramfs_tmpfile(struct mnt_idmap *idmap,
+static int ramfs_tmpfile(const struct mnt_idmap *idmap,
struct inode *dir, struct file *file, umode_t mode)
{
struct inode *inode;
diff --git a/fs/smb/client/cifsfs.h b/fs/smb/client/cifsfs.h
index 0c85daa8386e..255f478d3a18 100644
--- a/fs/smb/client/cifsfs.h
+++ b/fs/smb/client/cifsfs.h
@@ -57,7 +57,7 @@ int cifs_create(struct mnt_idmap *idmap, struct inode *dir,
struct dentry *direntry, umode_t mode);
int cifs_atomic_open(struct inode *dir, struct dentry *direntry,
struct file *file, unsigned int oflags, umode_t mode);
-int cifs_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
+int cifs_tmpfile(const struct mnt_idmap *idmap, struct inode *dir,
struct file *file, umode_t mode);
struct dentry *cifs_lookup(struct inode *parent_dir_inode,
struct dentry *direntry, unsigned int flags);
diff --git a/fs/smb/client/dir.c b/fs/smb/client/dir.c
index 6fa6d48fdfd3..56a3e1966257 100644
--- a/fs/smb/client/dir.c
+++ b/fs/smb/client/dir.c
@@ -1059,7 +1059,7 @@ static int set_tmpfile_attr(const unsigned int xid, unsigned int oflags,
* The initial dentry state is unhashed-negative. On success, dentry will
* become unhashed-positive by calling d_instantiate().
*/
-int cifs_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
+int cifs_tmpfile(const struct mnt_idmap *idmap, struct inode *dir,
struct file *file, umode_t mode)
{
struct dentry *dentry = file->f_path.dentry;
diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
index 23ec924162d6..0e1a4de9bb18 100644
--- a/fs/ubifs/dir.c
+++ b/fs/ubifs/dir.c
@@ -440,7 +440,7 @@ static void unlock_2_inodes(struct inode *inode1, struct inode *inode2)
mutex_unlock(&ubifs_inode(inode1)->ui_mutex);
}
-static int ubifs_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
+static int ubifs_tmpfile(const struct mnt_idmap *idmap, struct inode *dir,
struct file *file, umode_t mode)
{
struct dentry *dentry = file->f_path.dentry;
diff --git a/fs/udf/namei.c b/fs/udf/namei.c
index b90841ac0a40..8b5873b53324 100644
--- a/fs/udf/namei.c
+++ b/fs/udf/namei.c
@@ -386,7 +386,7 @@ static int udf_create(struct mnt_idmap *idmap, struct inode *dir,
return udf_add_nondir(dentry, inode);
}
-static int udf_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
+static int udf_tmpfile(const struct mnt_idmap *idmap, struct inode *dir,
struct file *file, umode_t mode)
{
struct inode *inode = udf_new_inode(dir, mode);
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index 25d4d42fbc7f..06ca999d0927 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -1250,7 +1250,7 @@ xfs_vn_fiemap(
STATIC int
xfs_vn_tmpfile(
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct inode *dir,
struct file *file,
umode_t mode)
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 9809e7c3aa0d..92161c224856 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2024,7 +2024,7 @@ struct inode_operations {
int (*atomic_open)(struct inode *, struct dentry *,
struct file *, unsigned open_flag,
umode_t create_mode);
- int (*tmpfile) (struct mnt_idmap *, struct inode *,
+ int (*tmpfile) (const struct mnt_idmap *, struct inode *,
struct file *, umode_t);
struct posix_acl *(*get_acl)(const struct mnt_idmap *, struct dentry *,
int);
diff --git a/include/linux/lsm_hook_defs.h b/include/linux/lsm_hook_defs.h
index e8638f7d2245..470de3fb22c1 100644
--- a/include/linux/lsm_hook_defs.h
+++ b/include/linux/lsm_hook_defs.h
@@ -122,7 +122,7 @@ LSM_HOOK(int, 0, inode_init_security_anon, struct inode *inode,
const struct qstr *name, const struct inode *context_inode)
LSM_HOOK(int, 0, inode_create, struct inode *dir, struct dentry *dentry,
umode_t mode)
-LSM_HOOK(void, LSM_RET_VOID, inode_post_create_tmpfile, struct mnt_idmap *idmap,
+LSM_HOOK(void, LSM_RET_VOID, inode_post_create_tmpfile, const struct mnt_idmap *idmap,
struct inode *inode)
LSM_HOOK(int, 0, inode_link, struct dentry *old_dentry, struct inode *dir,
struct dentry *new_dentry)
diff --git a/include/linux/security.h b/include/linux/security.h
index d5832750418a..b07a85e6aed4 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -405,7 +405,7 @@ int security_inode_init_security_anon(struct inode *inode,
const struct qstr *name,
const struct inode *context_inode);
int security_inode_create(struct inode *dir, struct dentry *dentry, umode_t mode);
-void security_inode_post_create_tmpfile(struct mnt_idmap *idmap,
+void security_inode_post_create_tmpfile(const struct mnt_idmap *idmap,
struct inode *inode);
int security_inode_link(struct dentry *old_dentry, struct inode *dir,
struct dentry *new_dentry);
@@ -910,7 +910,7 @@ static inline int security_inode_create(struct inode *dir,
}
static inline void
-security_inode_post_create_tmpfile(struct mnt_idmap *idmap, struct inode *inode)
+security_inode_post_create_tmpfile(const struct mnt_idmap *idmap, struct inode *inode)
{ }
static inline int security_inode_link(struct dentry *old_dentry,
diff --git a/mm/shmem.c b/mm/shmem.c
index 097699ea2762..a107940660a8 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -3857,7 +3857,7 @@ shmem_mknod(struct mnt_idmap *idmap, struct inode *dir,
}
static int
-shmem_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
+shmem_tmpfile(const struct mnt_idmap *idmap, struct inode *dir,
struct file *file, umode_t mode)
{
struct inode *inode;
diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c
index 8d9c92dc8825..72ecacda7528 100644
--- a/security/integrity/ima/ima_main.c
+++ b/security/integrity/ima/ima_main.c
@@ -846,7 +846,7 @@ EXPORT_SYMBOL_GPL(ima_inode_hash);
* Skip calling process_measurement(), but indicate which newly, created
* tmpfiles are in policy.
*/
-static void ima_post_create_tmpfile(struct mnt_idmap *idmap,
+static void ima_post_create_tmpfile(const struct mnt_idmap *idmap,
struct inode *inode)
{
diff --git a/security/security.c b/security/security.c
index e3a14c958bc4..4e4ef1c496ad 100644
--- a/security/security.c
+++ b/security/security.c
@@ -1638,7 +1638,7 @@ EXPORT_SYMBOL_GPL(security_inode_create);
*
* Update inode security data after a tmpfile has been created.
*/
-void security_inode_post_create_tmpfile(struct mnt_idmap *idmap,
+void security_inode_post_create_tmpfile(const struct mnt_idmap *idmap,
struct inode *inode)
{
if (unlikely(IS_PRIVATE(inode)))
--
2.53.0
^ permalink raw reply related [flat|nested] 62+ messages in thread* Re: [PATCH 17/27] fs: port ->tmpfile() to pass const mnt_idmap
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
1 sibling, 0 replies; 62+ messages in thread
From: Jan Kara @ 2026-09-02 15:47 UTC (permalink / raw)
To: Christian Brauner
Cc: linux-fsdevel, Alexander Viro, Jan Kara, Christoph Hellwig,
Seth Forshee, Paul Moore, linux-security-module, Mimi Zohar,
linux-integrity, Ilya Dryomov, ceph-devel, Carlos Maiolino,
linux-xfs, Miklos Szeredi, Amir Goldstein, linux-unionfs,
Namjae Jeon, linux-cifs, linux-kernel
On Tue 01-09-26 14:14:42, Christian Brauner wrote:
> Convert to const struct mnt_idmap.
>
> A mount's idmapping is immutable. The only thing that is allowed to be
> modified afterwards is the reference count and that is hidden behind
> mnt_idmap_get() and mnt_idmap_put(). Everything else only ever reads
> from the idmapping. This is the same model that struct cred uses and the
> idmapping is also rather sensitive.
>
> So make the idmap argument const wherever we can. The conversion is done
> from the bottom up so callers can continue to pass a non-const pointer
> to a const parameter until the conversion is finished.
>
> No functional changes.
>
> Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> Documentation/filesystems/locking.rst | 2 +-
> Documentation/filesystems/vfs.rst | 2 +-
> fs/bad_inode.c | 2 +-
> fs/btrfs/inode.c | 2 +-
> fs/ext2/namei.c | 2 +-
> fs/ext4/namei.c | 2 +-
> fs/f2fs/namei.c | 2 +-
> fs/fuse/dir.c | 2 +-
> fs/hugetlbfs/inode.c | 2 +-
> fs/minix/namei.c | 2 +-
> fs/overlayfs/dir.c | 2 +-
> fs/ramfs/inode.c | 2 +-
> fs/smb/client/cifsfs.h | 2 +-
> fs/smb/client/dir.c | 2 +-
> fs/ubifs/dir.c | 2 +-
> fs/udf/namei.c | 2 +-
> fs/xfs/xfs_iops.c | 2 +-
> include/linux/fs.h | 2 +-
> include/linux/lsm_hook_defs.h | 2 +-
> include/linux/security.h | 4 ++--
> mm/shmem.c | 2 +-
> security/integrity/ima/ima_main.c | 2 +-
> security/security.c | 2 +-
> 23 files changed, 24 insertions(+), 24 deletions(-)
>
> diff --git a/Documentation/filesystems/locking.rst b/Documentation/filesystems/locking.rst
> index 167988321a8c..e4948ddc0a5f 100644
> --- a/Documentation/filesystems/locking.rst
> +++ b/Documentation/filesystems/locking.rst
> @@ -86,7 +86,7 @@ prototypes::
> int (*atomic_open)(struct inode *, struct dentry *,
> struct file *, unsigned open_flag,
> umode_t create_mode);
> - int (*tmpfile) (struct mnt_idmap *, struct inode *,
> + int (*tmpfile) (const struct mnt_idmap *, struct inode *,
> struct file *, umode_t);
> int (*fileattr_set)(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct file_kattr *fa);
> diff --git a/Documentation/filesystems/vfs.rst b/Documentation/filesystems/vfs.rst
> index 6adb1061a9b6..e960257ef14a 100644
> --- a/Documentation/filesystems/vfs.rst
> +++ b/Documentation/filesystems/vfs.rst
> @@ -438,7 +438,7 @@ As of kernel 2.6.22, the following members are defined:
> void (*sync_lazytime)(struct inode *inode);
> int (*atomic_open)(struct inode *, struct dentry *, struct file *,
> unsigned open_flag, umode_t create_mode);
> - int (*tmpfile) (struct mnt_idmap *, struct inode *, struct file *, umode_t);
> + int (*tmpfile) (const struct mnt_idmap *, struct inode *, struct file *, umode_t);
> struct posix_acl * (*get_acl)(const struct mnt_idmap *, struct dentry *, int);
> int (*set_acl)(const struct mnt_idmap *, struct dentry *, struct posix_acl *, int);
> int (*fileattr_set)(const struct mnt_idmap *idmap,
> diff --git a/fs/bad_inode.c b/fs/bad_inode.c
> index 6e116810f66d..d8c0ce62cc63 100644
> --- a/fs/bad_inode.c
> +++ b/fs/bad_inode.c
> @@ -146,7 +146,7 @@ static int bad_inode_atomic_open(struct inode *inode, struct dentry *dentry,
> return -EIO;
> }
>
> -static int bad_inode_tmpfile(struct mnt_idmap *idmap,
> +static int bad_inode_tmpfile(const struct mnt_idmap *idmap,
> struct inode *inode, struct file *file,
> umode_t mode)
> {
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index 7bf38f069116..092057508ae9 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -9391,7 +9391,7 @@ static int btrfs_permission(const struct mnt_idmap *idmap,
> return generic_permission(idmap, inode, mask);
> }
>
> -static int btrfs_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
> +static int btrfs_tmpfile(const struct mnt_idmap *idmap, struct inode *dir,
> struct file *file, umode_t mode)
> {
> struct btrfs_fs_info *fs_info = inode_to_fs_info(dir);
> diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c
> index 8666233ec63b..108dc52cedfc 100644
> --- a/fs/ext2/namei.c
> +++ b/fs/ext2/namei.c
> @@ -117,7 +117,7 @@ static int ext2_create (struct mnt_idmap * idmap,
> return ext2_add_nondir(dentry, inode);
> }
>
> -static int ext2_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
> +static int ext2_tmpfile(const struct mnt_idmap *idmap, struct inode *dir,
> struct file *file, umode_t mode)
> {
> struct inode *inode = ext2_new_inode(dir, mode, NULL);
> diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
> index edc12599e64d..0bff01fb052a 100644
> --- a/fs/ext4/namei.c
> +++ b/fs/ext4/namei.c
> @@ -2881,7 +2881,7 @@ static int ext4_mknod(struct mnt_idmap *idmap, struct inode *dir,
> return err;
> }
>
> -static int ext4_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
> +static int ext4_tmpfile(const struct mnt_idmap *idmap, struct inode *dir,
> struct file *file, umode_t mode)
> {
> handle_t *handle;
> diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
> index e33780294713..3adc2345a204 100644
> --- a/fs/f2fs/namei.c
> +++ b/fs/f2fs/namei.c
> @@ -928,7 +928,7 @@ static int __f2fs_tmpfile(const struct mnt_idmap *idmap, struct inode *dir,
> return err;
> }
>
> -static int f2fs_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
> +static int f2fs_tmpfile(const struct mnt_idmap *idmap, struct inode *dir,
> struct file *file, umode_t mode)
> {
> struct f2fs_sb_info *sbi = F2FS_I_SB(dir);
> diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
> index 0dbe3c6560f8..14dc9318cd57 100644
> --- a/fs/fuse/dir.c
> +++ b/fs/fuse/dir.c
> @@ -1098,7 +1098,7 @@ static int fuse_create(struct mnt_idmap *idmap, struct inode *dir,
> return fuse_mknod(idmap, dir, entry, mode, 0);
> }
>
> -static int fuse_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
> +static int fuse_tmpfile(const struct mnt_idmap *idmap, struct inode *dir,
> struct file *file, umode_t mode)
> {
> struct fuse_conn *fc = get_fuse_conn(dir);
> diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
> index 4bd3adc20a47..8a07a3f18c05 100644
> --- a/fs/hugetlbfs/inode.c
> +++ b/fs/hugetlbfs/inode.c
> @@ -984,7 +984,7 @@ static int hugetlbfs_create(struct mnt_idmap *idmap,
> return hugetlbfs_mknod(idmap, dir, dentry, mode | S_IFREG, 0);
> }
>
> -static int hugetlbfs_tmpfile(struct mnt_idmap *idmap,
> +static int hugetlbfs_tmpfile(const struct mnt_idmap *idmap,
> struct inode *dir, struct file *file,
> umode_t mode)
> {
> diff --git a/fs/minix/namei.c b/fs/minix/namei.c
> index 5525ba367ed7..0575dea16a3b 100644
> --- a/fs/minix/namei.c
> +++ b/fs/minix/namei.c
> @@ -50,7 +50,7 @@ static int minix_mknod(struct mnt_idmap *idmap, struct inode *dir,
> return add_nondir(dentry, inode);
> }
>
> -static int minix_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
> +static int minix_tmpfile(const struct mnt_idmap *idmap, struct inode *dir,
> struct file *file, umode_t mode)
> {
> struct inode *inode = minix_new_inode(dir, mode);
> diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
> index a022dc7781bf..4f3f1e2bafff 100644
> --- a/fs/overlayfs/dir.c
> +++ b/fs/overlayfs/dir.c
> @@ -1420,7 +1420,7 @@ static int ovl_dummy_open(struct inode *inode, struct file *file)
> return 0;
> }
>
> -static int ovl_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
> +static int ovl_tmpfile(const struct mnt_idmap *idmap, struct inode *dir,
> struct file *file, umode_t mode)
> {
> int err;
> diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c
> index 0a88ede48e0a..fc9a79af4840 100644
> --- a/fs/ramfs/inode.c
> +++ b/fs/ramfs/inode.c
> @@ -163,7 +163,7 @@ static int ramfs_symlink(struct mnt_idmap *idmap, struct inode *dir,
> return error;
> }
>
> -static int ramfs_tmpfile(struct mnt_idmap *idmap,
> +static int ramfs_tmpfile(const struct mnt_idmap *idmap,
> struct inode *dir, struct file *file, umode_t mode)
> {
> struct inode *inode;
> diff --git a/fs/smb/client/cifsfs.h b/fs/smb/client/cifsfs.h
> index 0c85daa8386e..255f478d3a18 100644
> --- a/fs/smb/client/cifsfs.h
> +++ b/fs/smb/client/cifsfs.h
> @@ -57,7 +57,7 @@ int cifs_create(struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *direntry, umode_t mode);
> int cifs_atomic_open(struct inode *dir, struct dentry *direntry,
> struct file *file, unsigned int oflags, umode_t mode);
> -int cifs_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
> +int cifs_tmpfile(const struct mnt_idmap *idmap, struct inode *dir,
> struct file *file, umode_t mode);
> struct dentry *cifs_lookup(struct inode *parent_dir_inode,
> struct dentry *direntry, unsigned int flags);
> diff --git a/fs/smb/client/dir.c b/fs/smb/client/dir.c
> index 6fa6d48fdfd3..56a3e1966257 100644
> --- a/fs/smb/client/dir.c
> +++ b/fs/smb/client/dir.c
> @@ -1059,7 +1059,7 @@ static int set_tmpfile_attr(const unsigned int xid, unsigned int oflags,
> * The initial dentry state is unhashed-negative. On success, dentry will
> * become unhashed-positive by calling d_instantiate().
> */
> -int cifs_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
> +int cifs_tmpfile(const struct mnt_idmap *idmap, struct inode *dir,
> struct file *file, umode_t mode)
> {
> struct dentry *dentry = file->f_path.dentry;
> diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
> index 23ec924162d6..0e1a4de9bb18 100644
> --- a/fs/ubifs/dir.c
> +++ b/fs/ubifs/dir.c
> @@ -440,7 +440,7 @@ static void unlock_2_inodes(struct inode *inode1, struct inode *inode2)
> mutex_unlock(&ubifs_inode(inode1)->ui_mutex);
> }
>
> -static int ubifs_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
> +static int ubifs_tmpfile(const struct mnt_idmap *idmap, struct inode *dir,
> struct file *file, umode_t mode)
> {
> struct dentry *dentry = file->f_path.dentry;
> diff --git a/fs/udf/namei.c b/fs/udf/namei.c
> index b90841ac0a40..8b5873b53324 100644
> --- a/fs/udf/namei.c
> +++ b/fs/udf/namei.c
> @@ -386,7 +386,7 @@ static int udf_create(struct mnt_idmap *idmap, struct inode *dir,
> return udf_add_nondir(dentry, inode);
> }
>
> -static int udf_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
> +static int udf_tmpfile(const struct mnt_idmap *idmap, struct inode *dir,
> struct file *file, umode_t mode)
> {
> struct inode *inode = udf_new_inode(dir, mode);
> diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
> index 25d4d42fbc7f..06ca999d0927 100644
> --- a/fs/xfs/xfs_iops.c
> +++ b/fs/xfs/xfs_iops.c
> @@ -1250,7 +1250,7 @@ xfs_vn_fiemap(
>
> STATIC int
> xfs_vn_tmpfile(
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct inode *dir,
> struct file *file,
> umode_t mode)
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 9809e7c3aa0d..92161c224856 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -2024,7 +2024,7 @@ struct inode_operations {
> int (*atomic_open)(struct inode *, struct dentry *,
> struct file *, unsigned open_flag,
> umode_t create_mode);
> - int (*tmpfile) (struct mnt_idmap *, struct inode *,
> + int (*tmpfile) (const struct mnt_idmap *, struct inode *,
> struct file *, umode_t);
> struct posix_acl *(*get_acl)(const struct mnt_idmap *, struct dentry *,
> int);
> diff --git a/include/linux/lsm_hook_defs.h b/include/linux/lsm_hook_defs.h
> index e8638f7d2245..470de3fb22c1 100644
> --- a/include/linux/lsm_hook_defs.h
> +++ b/include/linux/lsm_hook_defs.h
> @@ -122,7 +122,7 @@ LSM_HOOK(int, 0, inode_init_security_anon, struct inode *inode,
> const struct qstr *name, const struct inode *context_inode)
> LSM_HOOK(int, 0, inode_create, struct inode *dir, struct dentry *dentry,
> umode_t mode)
> -LSM_HOOK(void, LSM_RET_VOID, inode_post_create_tmpfile, struct mnt_idmap *idmap,
> +LSM_HOOK(void, LSM_RET_VOID, inode_post_create_tmpfile, const struct mnt_idmap *idmap,
> struct inode *inode)
> LSM_HOOK(int, 0, inode_link, struct dentry *old_dentry, struct inode *dir,
> struct dentry *new_dentry)
> diff --git a/include/linux/security.h b/include/linux/security.h
> index d5832750418a..b07a85e6aed4 100644
> --- a/include/linux/security.h
> +++ b/include/linux/security.h
> @@ -405,7 +405,7 @@ int security_inode_init_security_anon(struct inode *inode,
> const struct qstr *name,
> const struct inode *context_inode);
> int security_inode_create(struct inode *dir, struct dentry *dentry, umode_t mode);
> -void security_inode_post_create_tmpfile(struct mnt_idmap *idmap,
> +void security_inode_post_create_tmpfile(const struct mnt_idmap *idmap,
> struct inode *inode);
> int security_inode_link(struct dentry *old_dentry, struct inode *dir,
> struct dentry *new_dentry);
> @@ -910,7 +910,7 @@ static inline int security_inode_create(struct inode *dir,
> }
>
> static inline void
> -security_inode_post_create_tmpfile(struct mnt_idmap *idmap, struct inode *inode)
> +security_inode_post_create_tmpfile(const struct mnt_idmap *idmap, struct inode *inode)
> { }
>
> static inline int security_inode_link(struct dentry *old_dentry,
> diff --git a/mm/shmem.c b/mm/shmem.c
> index 097699ea2762..a107940660a8 100644
> --- a/mm/shmem.c
> +++ b/mm/shmem.c
> @@ -3857,7 +3857,7 @@ shmem_mknod(struct mnt_idmap *idmap, struct inode *dir,
> }
>
> static int
> -shmem_tmpfile(struct mnt_idmap *idmap, struct inode *dir,
> +shmem_tmpfile(const struct mnt_idmap *idmap, struct inode *dir,
> struct file *file, umode_t mode)
> {
> struct inode *inode;
> diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c
> index 8d9c92dc8825..72ecacda7528 100644
> --- a/security/integrity/ima/ima_main.c
> +++ b/security/integrity/ima/ima_main.c
> @@ -846,7 +846,7 @@ EXPORT_SYMBOL_GPL(ima_inode_hash);
> * Skip calling process_measurement(), but indicate which newly, created
> * tmpfiles are in policy.
> */
> -static void ima_post_create_tmpfile(struct mnt_idmap *idmap,
> +static void ima_post_create_tmpfile(const struct mnt_idmap *idmap,
> struct inode *inode)
>
> {
> diff --git a/security/security.c b/security/security.c
> index e3a14c958bc4..4e4ef1c496ad 100644
> --- a/security/security.c
> +++ b/security/security.c
> @@ -1638,7 +1638,7 @@ EXPORT_SYMBOL_GPL(security_inode_create);
> *
> * Update inode security data after a tmpfile has been created.
> */
> -void security_inode_post_create_tmpfile(struct mnt_idmap *idmap,
> +void security_inode_post_create_tmpfile(const struct mnt_idmap *idmap,
> struct inode *inode)
> {
> if (unlikely(IS_PRIVATE(inode)))
>
> --
> 2.53.0
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 62+ messages in thread* Re: [PATCH 17/27] fs: port ->tmpfile() to pass const mnt_idmap
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
1 sibling, 0 replies; 62+ messages in thread
From: Paul Moore @ 2026-09-02 19:34 UTC (permalink / raw)
To: Christian Brauner, linux-fsdevel
Cc: Alexander Viro, Jan Kara, Christoph Hellwig, Seth Forshee,
linux-security-module, Mimi Zohar, linux-integrity, Ilya Dryomov,
ceph-devel, Carlos Maiolino, linux-xfs, Miklos Szeredi,
Amir Goldstein, linux-unionfs, Namjae Jeon, linux-cifs,
linux-kernel, Christian Brauner (Amutable)
On Sep 1, 2026 Christian Brauner <brauner@kernel.org> wrote:
>
> Convert to const struct mnt_idmap.
>
> A mount's idmapping is immutable. The only thing that is allowed to be
> modified afterwards is the reference count and that is hidden behind
> mnt_idmap_get() and mnt_idmap_put(). Everything else only ever reads
> from the idmapping. This is the same model that struct cred uses and the
> idmapping is also rather sensitive.
>
> So make the idmap argument const wherever we can. The conversion is done
> from the bottom up so callers can continue to pass a non-const pointer
> to a const parameter until the conversion is finished.
>
> No functional changes.
>
> Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
> Reviewed-by: Jan Kara <jack@suse.cz>
> ---
> Documentation/filesystems/locking.rst | 2 +-
> Documentation/filesystems/vfs.rst | 2 +-
> fs/bad_inode.c | 2 +-
> fs/btrfs/inode.c | 2 +-
> fs/ext2/namei.c | 2 +-
> fs/ext4/namei.c | 2 +-
> fs/f2fs/namei.c | 2 +-
> fs/fuse/dir.c | 2 +-
> fs/hugetlbfs/inode.c | 2 +-
> fs/minix/namei.c | 2 +-
> fs/overlayfs/dir.c | 2 +-
> fs/ramfs/inode.c | 2 +-
> fs/smb/client/cifsfs.h | 2 +-
> fs/smb/client/dir.c | 2 +-
> fs/ubifs/dir.c | 2 +-
> fs/udf/namei.c | 2 +-
> fs/xfs/xfs_iops.c | 2 +-
> include/linux/fs.h | 2 +-
> include/linux/lsm_hook_defs.h | 2 +-
> include/linux/security.h | 4 ++--
> mm/shmem.c | 2 +-
> security/integrity/ima/ima_main.c | 2 +-
> security/security.c | 2 +-
> 23 files changed, 24 insertions(+), 24 deletions(-)
Acked-by: Paul Moore <paul@paul-moore.com> (LSM)
--
paul-moore.com
^ permalink raw reply [flat|nested] 62+ messages in thread
* [PATCH 18/27] fs: port ->mknod() to pass const mnt_idmap
2026-09-01 12:14 [PATCH 00/27] fs: port to const struct mnt_idmap Christian Brauner
` (16 preceding siblings ...)
2026-09-01 12:14 ` [PATCH 17/27] fs: port ->tmpfile() " Christian Brauner
@ 2026-09-01 12:14 ` 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
` (8 subsequent siblings)
26 siblings, 2 replies; 62+ messages in thread
From: Christian Brauner @ 2026-09-01 12:14 UTC (permalink / raw)
To: linux-fsdevel
Cc: Alexander Viro, Jan Kara, Christoph Hellwig, Seth Forshee,
Paul Moore, linux-security-module, Mimi Zohar, linux-integrity,
Ilya Dryomov, ceph-devel, Carlos Maiolino, linux-xfs,
Miklos Szeredi, Amir Goldstein, linux-unionfs, Namjae Jeon,
linux-cifs, linux-kernel, Christian Brauner (Amutable)
Convert to const struct mnt_idmap.
A mount's idmapping is immutable. The only thing that is allowed to be
modified afterwards is the reference count and that is hidden behind
mnt_idmap_get() and mnt_idmap_put(). Everything else only ever reads
from the idmapping. This is the same model that struct cred uses and the
idmapping is also rather sensitive.
So make the idmap argument const wherever we can. The conversion is done
from the bottom up so callers can continue to pass a non-const pointer
to a const parameter until the conversion is finished.
No functional changes.
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
---
Documentation/filesystems/locking.rst | 2 +-
Documentation/filesystems/vfs.rst | 2 +-
fs/9p/vfs_inode.c | 2 +-
fs/9p/vfs_inode_dotl.c | 4 ++--
fs/bad_inode.c | 2 +-
fs/btrfs/inode.c | 2 +-
fs/ceph/dir.c | 2 +-
fs/ecryptfs/inode.c | 2 +-
fs/ext2/namei.c | 2 +-
fs/ext4/namei.c | 2 +-
fs/f2fs/namei.c | 2 +-
fs/fuse/dir.c | 4 ++--
fs/gfs2/inode.c | 2 +-
fs/hfsplus/dir.c | 2 +-
fs/hostfs/hostfs_kern.c | 2 +-
fs/hpfs/namei.c | 2 +-
fs/hugetlbfs/inode.c | 2 +-
fs/jffs2/dir.c | 4 ++--
fs/jfs/namei.c | 2 +-
fs/minix/namei.c | 2 +-
fs/nfs/dir.c | 2 +-
fs/nfs/internal.h | 2 +-
fs/nilfs2/namei.c | 2 +-
fs/ntfs/namei.c | 2 +-
fs/ntfs3/namei.c | 2 +-
fs/ocfs2/namei.c | 2 +-
fs/overlayfs/dir.c | 2 +-
fs/ramfs/inode.c | 2 +-
fs/smb/client/cifsfs.h | 2 +-
fs/smb/client/dir.c | 2 +-
fs/ubifs/dir.c | 2 +-
fs/udf/namei.c | 2 +-
fs/ufs/namei.c | 2 +-
fs/xfs/xfs_iops.c | 2 +-
include/linux/fs.h | 2 +-
include/linux/lsm_hook_defs.h | 2 +-
include/linux/security.h | 4 ++--
mm/shmem.c | 4 ++--
security/integrity/evm/evm_main.c | 2 +-
security/integrity/ima/ima_main.c | 2 +-
security/security.c | 2 +-
41 files changed, 46 insertions(+), 46 deletions(-)
diff --git a/Documentation/filesystems/locking.rst b/Documentation/filesystems/locking.rst
index e4948ddc0a5f..1cfdad9286d5 100644
--- a/Documentation/filesystems/locking.rst
+++ b/Documentation/filesystems/locking.rst
@@ -68,7 +68,7 @@ prototypes::
int (*symlink) (struct mnt_idmap *, struct inode *,struct dentry *,const char *);
struct dentry *(*mkdir) (struct mnt_idmap *, struct inode *,struct dentry *,umode_t);
int (*rmdir) (struct inode *,struct dentry *);
- int (*mknod) (struct mnt_idmap *, struct inode *,struct dentry *,umode_t,dev_t);
+ int (*mknod) (const struct mnt_idmap *, struct inode *,struct dentry *,umode_t,dev_t);
int (*rename) (struct mnt_idmap *, struct inode *, struct dentry *,
struct inode *, struct dentry *, unsigned int);
int (*readlink) (struct dentry *, char __user *,int);
diff --git a/Documentation/filesystems/vfs.rst b/Documentation/filesystems/vfs.rst
index e960257ef14a..d7ab34e101eb 100644
--- a/Documentation/filesystems/vfs.rst
+++ b/Documentation/filesystems/vfs.rst
@@ -422,7 +422,7 @@ As of kernel 2.6.22, the following members are defined:
int (*symlink) (struct mnt_idmap *, struct inode *,struct dentry *,const char *);
struct dentry *(*mkdir) (struct mnt_idmap *, struct inode *,struct dentry *,umode_t);
int (*rmdir) (struct inode *,struct dentry *);
- int (*mknod) (struct mnt_idmap *, struct inode *,struct dentry *,umode_t,dev_t);
+ int (*mknod) (const struct mnt_idmap *, struct inode *,struct dentry *,umode_t,dev_t);
int (*rename) (struct mnt_idmap *, struct inode *, struct dentry *,
struct inode *, struct dentry *, unsigned int);
int (*readlink) (struct dentry *, char __user *,int);
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index 3829554ca369..81fb5f8ec7e9 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -1304,7 +1304,7 @@ v9fs_vfs_link(struct dentry *old_dentry, struct inode *dir,
*/
static int
-v9fs_vfs_mknod(struct mnt_idmap *idmap, struct inode *dir,
+v9fs_vfs_mknod(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode, dev_t rdev)
{
struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dir);
diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c
index 116b29e95f21..634c4f5665c3 100644
--- a/fs/9p/vfs_inode_dotl.c
+++ b/fs/9p/vfs_inode_dotl.c
@@ -29,7 +29,7 @@
#include "acl.h"
static int
-v9fs_vfs_mknod_dotl(struct mnt_idmap *idmap, struct inode *dir,
+v9fs_vfs_mknod_dotl(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t omode, dev_t rdev);
/**
@@ -809,7 +809,7 @@ v9fs_vfs_link_dotl(struct dentry *old_dentry, struct inode *dir,
*
*/
static int
-v9fs_vfs_mknod_dotl(struct mnt_idmap *idmap, struct inode *dir,
+v9fs_vfs_mknod_dotl(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t omode, dev_t rdev)
{
int err;
diff --git a/fs/bad_inode.c b/fs/bad_inode.c
index d8c0ce62cc63..9b7baf1367a6 100644
--- a/fs/bad_inode.c
+++ b/fs/bad_inode.c
@@ -69,7 +69,7 @@ static int bad_inode_rmdir (struct inode *dir, struct dentry *dentry)
return -EIO;
}
-static int bad_inode_mknod(struct mnt_idmap *idmap, struct inode *dir,
+static int bad_inode_mknod(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode, dev_t rdev)
{
return -EIO;
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 092057508ae9..32b5648fdf81 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -7004,7 +7004,7 @@ static int btrfs_create_common(struct inode *dir, struct dentry *dentry,
return ret;
}
-static int btrfs_mknod(struct mnt_idmap *idmap, struct inode *dir,
+static int btrfs_mknod(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode, dev_t rdev)
{
struct inode *inode;
diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
index 2e5c0ccb1b34..0f3c54dc97c6 100644
--- a/fs/ceph/dir.c
+++ b/fs/ceph/dir.c
@@ -921,7 +921,7 @@ int ceph_handle_notrace_create(struct inode *dir, struct dentry *dentry)
return PTR_ERR(result);
}
-static int ceph_mknod(struct mnt_idmap *idmap, struct inode *dir,
+static int ceph_mknod(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode, dev_t rdev)
{
struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(dir->i_sb);
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index bd1187661d6d..411aa024d4b8 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -562,7 +562,7 @@ static int ecryptfs_rmdir(struct inode *dir, struct dentry *dentry)
}
static int
-ecryptfs_mknod(struct mnt_idmap *idmap, struct inode *dir,
+ecryptfs_mknod(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode, dev_t dev)
{
int rc;
diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c
index 108dc52cedfc..f175b59cccd7 100644
--- a/fs/ext2/namei.c
+++ b/fs/ext2/namei.c
@@ -131,7 +131,7 @@ static int ext2_tmpfile(const struct mnt_idmap *idmap, struct inode *dir,
return finish_open_simple(file, 0);
}
-static int ext2_mknod (struct mnt_idmap * idmap, struct inode * dir,
+static int ext2_mknod (const struct mnt_idmap * idmap, struct inode * dir,
struct dentry *dentry, umode_t mode, dev_t rdev)
{
struct inode * inode;
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index 0bff01fb052a..d7a58d82f320 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -2847,7 +2847,7 @@ static int ext4_create(struct mnt_idmap *idmap, struct inode *dir,
return err;
}
-static int ext4_mknod(struct mnt_idmap *idmap, struct inode *dir,
+static int ext4_mknod(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode, dev_t rdev)
{
handle_t *handle;
diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
index 3adc2345a204..0773f64396f8 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -810,7 +810,7 @@ static int f2fs_rmdir(struct inode *dir, struct dentry *dentry)
return -ENOTEMPTY;
}
-static int f2fs_mknod(struct mnt_idmap *idmap, struct inode *dir,
+static int f2fs_mknod(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode, dev_t rdev)
{
struct f2fs_sb_info *sbi = F2FS_I_SB(dir);
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 14dc9318cd57..3250598e06f2 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -934,7 +934,7 @@ static int fuse_create_open(const struct mnt_idmap *idmap, struct inode *dir,
return err;
}
-static int fuse_mknod(struct mnt_idmap *, struct inode *, struct dentry *,
+static int fuse_mknod(const struct mnt_idmap *, struct inode *, struct dentry *,
umode_t, dev_t);
static int fuse_atomic_open(struct inode *dir, struct dentry *entry,
struct file *file, unsigned flags,
@@ -1069,7 +1069,7 @@ static int create_new_nondir(const struct mnt_idmap *idmap, struct fuse_mount *f
return PTR_ERR(create_new_entry(idmap, fm, args, dir, entry, mode));
}
-static int fuse_mknod(struct mnt_idmap *idmap, struct inode *dir,
+static int fuse_mknod(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *entry, umode_t mode, dev_t rdev)
{
struct fuse_mknod_in inarg;
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index 1b1d22abe1d4..733f74603eaf 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -1363,7 +1363,7 @@ static struct dentry *gfs2_mkdir(struct mnt_idmap *idmap, struct inode *dir,
*
*/
-static int gfs2_mknod(struct mnt_idmap *idmap, struct inode *dir,
+static int gfs2_mknod(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode, dev_t dev)
{
return gfs2_create_inode(dir, dentry, NULL, mode, dev, NULL, 0, 0);
diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c
index 51fcba2e6d40..7d31211cee97 100644
--- a/fs/hfsplus/dir.c
+++ b/fs/hfsplus/dir.c
@@ -511,7 +511,7 @@ static int hfsplus_symlink(struct mnt_idmap *idmap, struct inode *dir,
return res;
}
-static int hfsplus_mknod(struct mnt_idmap *idmap, struct inode *dir,
+static int hfsplus_mknod(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode, dev_t rdev)
{
struct hfsplus_sb_info *sbi = HFSPLUS_SB(dir->i_sb);
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
index 0d5c5f11f913..71d15396235a 100644
--- a/fs/hostfs/hostfs_kern.c
+++ b/fs/hostfs/hostfs_kern.c
@@ -719,7 +719,7 @@ static int hostfs_rmdir(struct inode *ino, struct dentry *dentry)
return err;
}
-static int hostfs_mknod(struct mnt_idmap *idmap, struct inode *dir,
+static int hostfs_mknod(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode, dev_t dev)
{
struct inode *inode;
diff --git a/fs/hpfs/namei.c b/fs/hpfs/namei.c
index 9446f4038874..ed749e1684d2 100644
--- a/fs/hpfs/namei.c
+++ b/fs/hpfs/namei.c
@@ -215,7 +215,7 @@ static int hpfs_create(struct mnt_idmap *idmap, struct inode *dir,
return err;
}
-static int hpfs_mknod(struct mnt_idmap *idmap, struct inode *dir,
+static int hpfs_mknod(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode, dev_t rdev)
{
const unsigned char *name = dentry->d_name.name;
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 8a07a3f18c05..0c9cb8d953ab 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -954,7 +954,7 @@ static struct inode *hugetlbfs_get_inode(struct super_block *sb,
/*
* File creation. Allocate an inode, and we're done..
*/
-static int hugetlbfs_mknod(struct mnt_idmap *idmap, struct inode *dir,
+static int hugetlbfs_mknod(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode, dev_t dev)
{
struct inode *inode;
diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c
index 656c920864c5..6d4b26d625c7 100644
--- a/fs/jffs2/dir.c
+++ b/fs/jffs2/dir.c
@@ -36,7 +36,7 @@ static int jffs2_symlink (struct mnt_idmap *, struct inode *,
static struct dentry *jffs2_mkdir (struct mnt_idmap *, struct inode *,struct dentry *,
umode_t);
static int jffs2_rmdir (struct inode *,struct dentry *);
-static int jffs2_mknod (struct mnt_idmap *, struct inode *,struct dentry *,
+static int jffs2_mknod (const struct mnt_idmap *, struct inode *,struct dentry *,
umode_t,dev_t);
static int jffs2_rename (struct mnt_idmap *, struct inode *,
struct dentry *, struct inode *, struct dentry *,
@@ -620,7 +620,7 @@ static int jffs2_rmdir (struct inode *dir_i, struct dentry *dentry)
return ret;
}
-static int jffs2_mknod (struct mnt_idmap *idmap, struct inode *dir_i,
+static int jffs2_mknod (const struct mnt_idmap *idmap, struct inode *dir_i,
struct dentry *dentry, umode_t mode, dev_t rdev)
{
struct jffs2_inode_info *f, *dir_f;
diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c
index 8a36c218f0f7..82a5dbdaf93d 100644
--- a/fs/jfs/namei.c
+++ b/fs/jfs/namei.c
@@ -1355,7 +1355,7 @@ static int jfs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
*
* FUNCTION: Create a special file (device)
*/
-static int jfs_mknod(struct mnt_idmap *idmap, struct inode *dir,
+static int jfs_mknod(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode, dev_t rdev)
{
struct jfs_inode_info *jfs_ip;
diff --git a/fs/minix/namei.c b/fs/minix/namei.c
index 0575dea16a3b..57b3c2c5b688 100644
--- a/fs/minix/namei.c
+++ b/fs/minix/namei.c
@@ -33,7 +33,7 @@ static struct dentry *minix_lookup(struct inode * dir, struct dentry *dentry, un
return d_splice_alias(inode, dentry);
}
-static int minix_mknod(struct mnt_idmap *idmap, struct inode *dir,
+static int minix_mknod(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode, dev_t rdev)
{
struct inode *inode;
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 7574bc2fb677..10c48672a79d 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -2448,7 +2448,7 @@ EXPORT_SYMBOL_GPL(nfs_create);
* See comments for nfs_proc_create regarding failed operations.
*/
int
-nfs_mknod(struct mnt_idmap *idmap, struct inode *dir,
+nfs_mknod(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode, dev_t rdev)
{
struct iattr attr;
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index abc81f5ae578..ec37568d197b 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -405,7 +405,7 @@ int nfs_unlink(struct inode *, struct dentry *);
int nfs_symlink(struct mnt_idmap *, struct inode *, struct dentry *,
const char *);
int nfs_link(struct dentry *, struct inode *, struct dentry *);
-int nfs_mknod(struct mnt_idmap *, struct inode *, struct dentry *, umode_t,
+int nfs_mknod(const struct mnt_idmap *, struct inode *, struct dentry *, umode_t,
dev_t);
int nfs_rename(struct mnt_idmap *, struct inode *, struct dentry *,
struct inode *, struct dentry *, unsigned int);
diff --git a/fs/nilfs2/namei.c b/fs/nilfs2/namei.c
index e037e0c6e31a..ea3df1d5ec29 100644
--- a/fs/nilfs2/namei.c
+++ b/fs/nilfs2/namei.c
@@ -113,7 +113,7 @@ static int nilfs_create(struct mnt_idmap *idmap, struct inode *dir,
}
static int
-nilfs_mknod(struct mnt_idmap *idmap, struct inode *dir,
+nilfs_mknod(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode, dev_t rdev)
{
struct inode *inode;
diff --git a/fs/ntfs/namei.c b/fs/ntfs/namei.c
index e2cf1ab6935a..82da5f14efa4 100644
--- a/fs/ntfs/namei.c
+++ b/fs/ntfs/namei.c
@@ -1447,7 +1447,7 @@ static int ntfs_symlink(struct mnt_idmap *idmap, struct inode *dir,
return err;
}
-static int ntfs_mknod(struct mnt_idmap *idmap, struct inode *dir,
+static int ntfs_mknod(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode, dev_t rdev)
{
struct super_block *sb = dir->i_sb;
diff --git a/fs/ntfs3/namei.c b/fs/ntfs3/namei.c
index ec59bbabd3c5..dfafadcd8fda 100644
--- a/fs/ntfs3/namei.c
+++ b/fs/ntfs3/namei.c
@@ -121,7 +121,7 @@ static int ntfs_create(struct mnt_idmap *idmap, struct inode *dir,
/*
* ntfs_mknod - inode_operations::mknod
*/
-static int ntfs_mknod(struct mnt_idmap *idmap, struct inode *dir,
+static int ntfs_mknod(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode, dev_t rdev)
{
return ntfs_create_inode(idmap, dir, dentry, NULL, mode, rdev, NULL, 0,
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index e9c7774ccf91..6cd77f295939 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -227,7 +227,7 @@ static void ocfs2_cleanup_add_entry_failure(struct ocfs2_super *osb,
iput(inode);
}
-static int ocfs2_mknod(struct mnt_idmap *idmap,
+static int ocfs2_mknod(const struct mnt_idmap *idmap,
struct inode *dir,
struct dentry *dentry,
umode_t mode,
diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
index 4f3f1e2bafff..6d4b511dc3ca 100644
--- a/fs/overlayfs/dir.c
+++ b/fs/overlayfs/dir.c
@@ -742,7 +742,7 @@ static struct dentry *ovl_mkdir(struct mnt_idmap *idmap, struct inode *dir,
return ERR_PTR(ovl_create_object(idmap, dentry, (mode & 07777) | S_IFDIR, 0, NULL));
}
-static int ovl_mknod(struct mnt_idmap *idmap, struct inode *dir,
+static int ovl_mknod(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode, dev_t rdev)
{
/* Don't allow creation of "whiteout" on overlay */
diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c
index fc9a79af4840..5b09860dc69b 100644
--- a/fs/ramfs/inode.c
+++ b/fs/ramfs/inode.c
@@ -95,7 +95,7 @@ struct inode *ramfs_get_inode(struct super_block *sb,
*/
/* SMP-safe */
static int
-ramfs_mknod(struct mnt_idmap *idmap, struct inode *dir,
+ramfs_mknod(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode, dev_t dev)
{
struct inode * inode = ramfs_get_inode(dir->i_sb, dir, mode, dev);
diff --git a/fs/smb/client/cifsfs.h b/fs/smb/client/cifsfs.h
index 255f478d3a18..db7aebb8599e 100644
--- a/fs/smb/client/cifsfs.h
+++ b/fs/smb/client/cifsfs.h
@@ -64,7 +64,7 @@ struct dentry *cifs_lookup(struct inode *parent_dir_inode,
int cifs_unlink(struct inode *dir, struct dentry *dentry);
int cifs_hardlink(struct dentry *old_file, struct inode *inode,
struct dentry *direntry);
-int cifs_mknod(struct mnt_idmap *idmap, struct inode *inode,
+int cifs_mknod(const struct mnt_idmap *idmap, struct inode *inode,
struct dentry *direntry, umode_t mode, dev_t device_number);
struct dentry *cifs_mkdir(struct mnt_idmap *idmap, struct inode *inode,
struct dentry *direntry, umode_t mode);
diff --git a/fs/smb/client/dir.c b/fs/smb/client/dir.c
index 56a3e1966257..95da43ad7c02 100644
--- a/fs/smb/client/dir.c
+++ b/fs/smb/client/dir.c
@@ -696,7 +696,7 @@ int cifs_create(struct mnt_idmap *idmap, struct inode *dir,
return rc;
}
-int cifs_mknod(struct mnt_idmap *idmap, struct inode *inode,
+int cifs_mknod(const struct mnt_idmap *idmap, struct inode *inode,
struct dentry *direntry, umode_t mode, dev_t device_number)
{
int rc = -EPERM;
diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
index 0e1a4de9bb18..50068515f680 100644
--- a/fs/ubifs/dir.c
+++ b/fs/ubifs/dir.c
@@ -1077,7 +1077,7 @@ static struct dentry *ubifs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
return ERR_PTR(err);
}
-static int ubifs_mknod(struct mnt_idmap *idmap, struct inode *dir,
+static int ubifs_mknod(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode, dev_t rdev)
{
struct inode *inode;
diff --git a/fs/udf/namei.c b/fs/udf/namei.c
index 8b5873b53324..4f7200e6046e 100644
--- a/fs/udf/namei.c
+++ b/fs/udf/namei.c
@@ -403,7 +403,7 @@ static int udf_tmpfile(const struct mnt_idmap *idmap, struct inode *dir,
return finish_open_simple(file, 0);
}
-static int udf_mknod(struct mnt_idmap *idmap, struct inode *dir,
+static int udf_mknod(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode, dev_t rdev)
{
struct inode *inode;
diff --git a/fs/ufs/namei.c b/fs/ufs/namei.c
index 6703f3bcf76f..a38975b3885e 100644
--- a/fs/ufs/namei.c
+++ b/fs/ufs/namei.c
@@ -85,7 +85,7 @@ static int ufs_create (struct mnt_idmap * idmap,
return ufs_add_nondir(dentry, inode);
}
-static int ufs_mknod(struct mnt_idmap *idmap, struct inode *dir,
+static int ufs_mknod(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode, dev_t rdev)
{
struct inode *inode;
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index 06ca999d0927..13e57b0e7cae 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -279,7 +279,7 @@ xfs_generic_create(
STATIC int
xfs_vn_mknod(
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct inode *dir,
struct dentry *dentry,
umode_t mode,
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 92161c224856..4ca59a110d17 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2008,7 +2008,7 @@ struct inode_operations {
struct dentry *(*mkdir) (struct mnt_idmap *, struct inode *,
struct dentry *, umode_t);
int (*rmdir) (struct inode *,struct dentry *);
- int (*mknod) (struct mnt_idmap *, struct inode *,struct dentry *,
+ int (*mknod) (const struct mnt_idmap *, struct inode *,struct dentry *,
umode_t,dev_t);
int (*rename) (struct mnt_idmap *, struct inode *, struct dentry *,
struct inode *, struct dentry *, unsigned int);
diff --git a/include/linux/lsm_hook_defs.h b/include/linux/lsm_hook_defs.h
index 470de3fb22c1..ad05971e6137 100644
--- a/include/linux/lsm_hook_defs.h
+++ b/include/linux/lsm_hook_defs.h
@@ -94,7 +94,7 @@ LSM_HOOK(int, 0, path_mkdir, const struct path *dir, struct dentry *dentry,
LSM_HOOK(int, 0, path_rmdir, const struct path *dir, struct dentry *dentry)
LSM_HOOK(int, 0, path_mknod, const struct path *dir, struct dentry *dentry,
umode_t mode, unsigned int dev)
-LSM_HOOK(void, LSM_RET_VOID, path_post_mknod, struct mnt_idmap *idmap,
+LSM_HOOK(void, LSM_RET_VOID, path_post_mknod, const struct mnt_idmap *idmap,
struct dentry *dentry)
LSM_HOOK(int, 0, path_truncate, const struct path *path)
LSM_HOOK(int, 0, path_symlink, const struct path *dir, struct dentry *dentry,
diff --git a/include/linux/security.h b/include/linux/security.h
index b07a85e6aed4..d4100396da27 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -2085,7 +2085,7 @@ int security_path_mkdir(const struct path *dir, struct dentry *dentry, umode_t m
int security_path_rmdir(const struct path *dir, struct dentry *dentry);
int security_path_mknod(const struct path *dir, struct dentry *dentry, umode_t mode,
unsigned int dev);
-void security_path_post_mknod(struct mnt_idmap *idmap, struct dentry *dentry);
+void security_path_post_mknod(const struct mnt_idmap *idmap, struct dentry *dentry);
int security_path_truncate(const struct path *path);
int security_path_symlink(const struct path *dir, struct dentry *dentry,
const char *old_name);
@@ -2120,7 +2120,7 @@ static inline int security_path_mknod(const struct path *dir, struct dentry *den
return 0;
}
-static inline void security_path_post_mknod(struct mnt_idmap *idmap,
+static inline void security_path_post_mknod(const struct mnt_idmap *idmap,
struct dentry *dentry)
{ }
diff --git a/mm/shmem.c b/mm/shmem.c
index a107940660a8..16a4ea914bdb 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -3818,7 +3818,7 @@ static int shmem_statfs(struct dentry *dentry, struct kstatfs *buf)
* File creation. Allocate an inode, and we're done..
*/
static int
-shmem_mknod(struct mnt_idmap *idmap, struct inode *dir,
+shmem_mknod(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode, dev_t dev)
{
struct inode *inode;
@@ -3970,7 +3970,7 @@ static int shmem_rmdir(struct inode *dir, struct dentry *dentry)
return shmem_unlink(dir, dentry);
}
-static int shmem_whiteout(struct mnt_idmap *idmap,
+static int shmem_whiteout(const struct mnt_idmap *idmap,
struct inode *old_dir, struct dentry *old_dentry)
{
struct dentry *whiteout;
diff --git a/security/integrity/evm/evm_main.c b/security/integrity/evm/evm_main.c
index 94928549bfab..10a0b39dd9b7 100644
--- a/security/integrity/evm/evm_main.c
+++ b/security/integrity/evm/evm_main.c
@@ -1140,7 +1140,7 @@ static void evm_file_release(struct file *file)
iint->flags &= ~EVM_NEW_FILE;
}
-static void evm_post_path_mknod(struct mnt_idmap *idmap, struct dentry *dentry)
+static void evm_post_path_mknod(const struct mnt_idmap *idmap, struct dentry *dentry)
{
struct inode *inode = d_backing_inode(dentry);
struct evm_iint_cache *iint = evm_iint_inode(inode);
diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c
index 72ecacda7528..7ac38a98b1f9 100644
--- a/security/integrity/ima/ima_main.c
+++ b/security/integrity/ima/ima_main.c
@@ -879,7 +879,7 @@ static void ima_post_create_tmpfile(const struct mnt_idmap *idmap,
* Mark files created via the mknodat syscall as new, so that the
* file data can be written later.
*/
-static void ima_post_path_mknod(struct mnt_idmap *idmap, struct dentry *dentry)
+static void ima_post_path_mknod(const struct mnt_idmap *idmap, struct dentry *dentry)
{
struct ima_iint_cache *iint;
struct inode *inode = dentry->d_inode;
diff --git a/security/security.c b/security/security.c
index 4e4ef1c496ad..9a3ae6746fb3 100644
--- a/security/security.c
+++ b/security/security.c
@@ -1425,7 +1425,7 @@ EXPORT_SYMBOL(security_path_mknod);
*
* Update inode security field after a regular file has been created.
*/
-void security_path_post_mknod(struct mnt_idmap *idmap, struct dentry *dentry)
+void security_path_post_mknod(const struct mnt_idmap *idmap, struct dentry *dentry)
{
if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
return;
--
2.53.0
^ permalink raw reply related [flat|nested] 62+ messages in thread* Re: [PATCH 18/27] fs: port ->mknod() to pass const mnt_idmap
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
1 sibling, 0 replies; 62+ messages in thread
From: Jan Kara @ 2026-09-02 15:49 UTC (permalink / raw)
To: Christian Brauner
Cc: linux-fsdevel, Alexander Viro, Jan Kara, Christoph Hellwig,
Seth Forshee, Paul Moore, linux-security-module, Mimi Zohar,
linux-integrity, Ilya Dryomov, ceph-devel, Carlos Maiolino,
linux-xfs, Miklos Szeredi, Amir Goldstein, linux-unionfs,
Namjae Jeon, linux-cifs, linux-kernel
On Tue 01-09-26 14:14:43, Christian Brauner wrote:
> Convert to const struct mnt_idmap.
>
> A mount's idmapping is immutable. The only thing that is allowed to be
> modified afterwards is the reference count and that is hidden behind
> mnt_idmap_get() and mnt_idmap_put(). Everything else only ever reads
> from the idmapping. This is the same model that struct cred uses and the
> idmapping is also rather sensitive.
>
> So make the idmap argument const wherever we can. The conversion is done
> from the bottom up so callers can continue to pass a non-const pointer
> to a const parameter until the conversion is finished.
>
> No functional changes.
>
> Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> Documentation/filesystems/locking.rst | 2 +-
> Documentation/filesystems/vfs.rst | 2 +-
> fs/9p/vfs_inode.c | 2 +-
> fs/9p/vfs_inode_dotl.c | 4 ++--
> fs/bad_inode.c | 2 +-
> fs/btrfs/inode.c | 2 +-
> fs/ceph/dir.c | 2 +-
> fs/ecryptfs/inode.c | 2 +-
> fs/ext2/namei.c | 2 +-
> fs/ext4/namei.c | 2 +-
> fs/f2fs/namei.c | 2 +-
> fs/fuse/dir.c | 4 ++--
> fs/gfs2/inode.c | 2 +-
> fs/hfsplus/dir.c | 2 +-
> fs/hostfs/hostfs_kern.c | 2 +-
> fs/hpfs/namei.c | 2 +-
> fs/hugetlbfs/inode.c | 2 +-
> fs/jffs2/dir.c | 4 ++--
> fs/jfs/namei.c | 2 +-
> fs/minix/namei.c | 2 +-
> fs/nfs/dir.c | 2 +-
> fs/nfs/internal.h | 2 +-
> fs/nilfs2/namei.c | 2 +-
> fs/ntfs/namei.c | 2 +-
> fs/ntfs3/namei.c | 2 +-
> fs/ocfs2/namei.c | 2 +-
> fs/overlayfs/dir.c | 2 +-
> fs/ramfs/inode.c | 2 +-
> fs/smb/client/cifsfs.h | 2 +-
> fs/smb/client/dir.c | 2 +-
> fs/ubifs/dir.c | 2 +-
> fs/udf/namei.c | 2 +-
> fs/ufs/namei.c | 2 +-
> fs/xfs/xfs_iops.c | 2 +-
> include/linux/fs.h | 2 +-
> include/linux/lsm_hook_defs.h | 2 +-
> include/linux/security.h | 4 ++--
> mm/shmem.c | 4 ++--
> security/integrity/evm/evm_main.c | 2 +-
> security/integrity/ima/ima_main.c | 2 +-
> security/security.c | 2 +-
> 41 files changed, 46 insertions(+), 46 deletions(-)
>
> diff --git a/Documentation/filesystems/locking.rst b/Documentation/filesystems/locking.rst
> index e4948ddc0a5f..1cfdad9286d5 100644
> --- a/Documentation/filesystems/locking.rst
> +++ b/Documentation/filesystems/locking.rst
> @@ -68,7 +68,7 @@ prototypes::
> int (*symlink) (struct mnt_idmap *, struct inode *,struct dentry *,const char *);
> struct dentry *(*mkdir) (struct mnt_idmap *, struct inode *,struct dentry *,umode_t);
> int (*rmdir) (struct inode *,struct dentry *);
> - int (*mknod) (struct mnt_idmap *, struct inode *,struct dentry *,umode_t,dev_t);
> + int (*mknod) (const struct mnt_idmap *, struct inode *,struct dentry *,umode_t,dev_t);
> int (*rename) (struct mnt_idmap *, struct inode *, struct dentry *,
> struct inode *, struct dentry *, unsigned int);
> int (*readlink) (struct dentry *, char __user *,int);
> diff --git a/Documentation/filesystems/vfs.rst b/Documentation/filesystems/vfs.rst
> index e960257ef14a..d7ab34e101eb 100644
> --- a/Documentation/filesystems/vfs.rst
> +++ b/Documentation/filesystems/vfs.rst
> @@ -422,7 +422,7 @@ As of kernel 2.6.22, the following members are defined:
> int (*symlink) (struct mnt_idmap *, struct inode *,struct dentry *,const char *);
> struct dentry *(*mkdir) (struct mnt_idmap *, struct inode *,struct dentry *,umode_t);
> int (*rmdir) (struct inode *,struct dentry *);
> - int (*mknod) (struct mnt_idmap *, struct inode *,struct dentry *,umode_t,dev_t);
> + int (*mknod) (const struct mnt_idmap *, struct inode *,struct dentry *,umode_t,dev_t);
> int (*rename) (struct mnt_idmap *, struct inode *, struct dentry *,
> struct inode *, struct dentry *, unsigned int);
> int (*readlink) (struct dentry *, char __user *,int);
> diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
> index 3829554ca369..81fb5f8ec7e9 100644
> --- a/fs/9p/vfs_inode.c
> +++ b/fs/9p/vfs_inode.c
> @@ -1304,7 +1304,7 @@ v9fs_vfs_link(struct dentry *old_dentry, struct inode *dir,
> */
>
> static int
> -v9fs_vfs_mknod(struct mnt_idmap *idmap, struct inode *dir,
> +v9fs_vfs_mknod(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode, dev_t rdev)
> {
> struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dir);
> diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c
> index 116b29e95f21..634c4f5665c3 100644
> --- a/fs/9p/vfs_inode_dotl.c
> +++ b/fs/9p/vfs_inode_dotl.c
> @@ -29,7 +29,7 @@
> #include "acl.h"
>
> static int
> -v9fs_vfs_mknod_dotl(struct mnt_idmap *idmap, struct inode *dir,
> +v9fs_vfs_mknod_dotl(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t omode, dev_t rdev);
>
> /**
> @@ -809,7 +809,7 @@ v9fs_vfs_link_dotl(struct dentry *old_dentry, struct inode *dir,
> *
> */
> static int
> -v9fs_vfs_mknod_dotl(struct mnt_idmap *idmap, struct inode *dir,
> +v9fs_vfs_mknod_dotl(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t omode, dev_t rdev)
> {
> int err;
> diff --git a/fs/bad_inode.c b/fs/bad_inode.c
> index d8c0ce62cc63..9b7baf1367a6 100644
> --- a/fs/bad_inode.c
> +++ b/fs/bad_inode.c
> @@ -69,7 +69,7 @@ static int bad_inode_rmdir (struct inode *dir, struct dentry *dentry)
> return -EIO;
> }
>
> -static int bad_inode_mknod(struct mnt_idmap *idmap, struct inode *dir,
> +static int bad_inode_mknod(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode, dev_t rdev)
> {
> return -EIO;
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index 092057508ae9..32b5648fdf81 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -7004,7 +7004,7 @@ static int btrfs_create_common(struct inode *dir, struct dentry *dentry,
> return ret;
> }
>
> -static int btrfs_mknod(struct mnt_idmap *idmap, struct inode *dir,
> +static int btrfs_mknod(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode, dev_t rdev)
> {
> struct inode *inode;
> diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
> index 2e5c0ccb1b34..0f3c54dc97c6 100644
> --- a/fs/ceph/dir.c
> +++ b/fs/ceph/dir.c
> @@ -921,7 +921,7 @@ int ceph_handle_notrace_create(struct inode *dir, struct dentry *dentry)
> return PTR_ERR(result);
> }
>
> -static int ceph_mknod(struct mnt_idmap *idmap, struct inode *dir,
> +static int ceph_mknod(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode, dev_t rdev)
> {
> struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(dir->i_sb);
> diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
> index bd1187661d6d..411aa024d4b8 100644
> --- a/fs/ecryptfs/inode.c
> +++ b/fs/ecryptfs/inode.c
> @@ -562,7 +562,7 @@ static int ecryptfs_rmdir(struct inode *dir, struct dentry *dentry)
> }
>
> static int
> -ecryptfs_mknod(struct mnt_idmap *idmap, struct inode *dir,
> +ecryptfs_mknod(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode, dev_t dev)
> {
> int rc;
> diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c
> index 108dc52cedfc..f175b59cccd7 100644
> --- a/fs/ext2/namei.c
> +++ b/fs/ext2/namei.c
> @@ -131,7 +131,7 @@ static int ext2_tmpfile(const struct mnt_idmap *idmap, struct inode *dir,
> return finish_open_simple(file, 0);
> }
>
> -static int ext2_mknod (struct mnt_idmap * idmap, struct inode * dir,
> +static int ext2_mknod (const struct mnt_idmap * idmap, struct inode * dir,
> struct dentry *dentry, umode_t mode, dev_t rdev)
> {
> struct inode * inode;
> diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
> index 0bff01fb052a..d7a58d82f320 100644
> --- a/fs/ext4/namei.c
> +++ b/fs/ext4/namei.c
> @@ -2847,7 +2847,7 @@ static int ext4_create(struct mnt_idmap *idmap, struct inode *dir,
> return err;
> }
>
> -static int ext4_mknod(struct mnt_idmap *idmap, struct inode *dir,
> +static int ext4_mknod(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode, dev_t rdev)
> {
> handle_t *handle;
> diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
> index 3adc2345a204..0773f64396f8 100644
> --- a/fs/f2fs/namei.c
> +++ b/fs/f2fs/namei.c
> @@ -810,7 +810,7 @@ static int f2fs_rmdir(struct inode *dir, struct dentry *dentry)
> return -ENOTEMPTY;
> }
>
> -static int f2fs_mknod(struct mnt_idmap *idmap, struct inode *dir,
> +static int f2fs_mknod(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode, dev_t rdev)
> {
> struct f2fs_sb_info *sbi = F2FS_I_SB(dir);
> diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
> index 14dc9318cd57..3250598e06f2 100644
> --- a/fs/fuse/dir.c
> +++ b/fs/fuse/dir.c
> @@ -934,7 +934,7 @@ static int fuse_create_open(const struct mnt_idmap *idmap, struct inode *dir,
> return err;
> }
>
> -static int fuse_mknod(struct mnt_idmap *, struct inode *, struct dentry *,
> +static int fuse_mknod(const struct mnt_idmap *, struct inode *, struct dentry *,
> umode_t, dev_t);
> static int fuse_atomic_open(struct inode *dir, struct dentry *entry,
> struct file *file, unsigned flags,
> @@ -1069,7 +1069,7 @@ static int create_new_nondir(const struct mnt_idmap *idmap, struct fuse_mount *f
> return PTR_ERR(create_new_entry(idmap, fm, args, dir, entry, mode));
> }
>
> -static int fuse_mknod(struct mnt_idmap *idmap, struct inode *dir,
> +static int fuse_mknod(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *entry, umode_t mode, dev_t rdev)
> {
> struct fuse_mknod_in inarg;
> diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
> index 1b1d22abe1d4..733f74603eaf 100644
> --- a/fs/gfs2/inode.c
> +++ b/fs/gfs2/inode.c
> @@ -1363,7 +1363,7 @@ static struct dentry *gfs2_mkdir(struct mnt_idmap *idmap, struct inode *dir,
> *
> */
>
> -static int gfs2_mknod(struct mnt_idmap *idmap, struct inode *dir,
> +static int gfs2_mknod(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode, dev_t dev)
> {
> return gfs2_create_inode(dir, dentry, NULL, mode, dev, NULL, 0, 0);
> diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c
> index 51fcba2e6d40..7d31211cee97 100644
> --- a/fs/hfsplus/dir.c
> +++ b/fs/hfsplus/dir.c
> @@ -511,7 +511,7 @@ static int hfsplus_symlink(struct mnt_idmap *idmap, struct inode *dir,
> return res;
> }
>
> -static int hfsplus_mknod(struct mnt_idmap *idmap, struct inode *dir,
> +static int hfsplus_mknod(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode, dev_t rdev)
> {
> struct hfsplus_sb_info *sbi = HFSPLUS_SB(dir->i_sb);
> diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
> index 0d5c5f11f913..71d15396235a 100644
> --- a/fs/hostfs/hostfs_kern.c
> +++ b/fs/hostfs/hostfs_kern.c
> @@ -719,7 +719,7 @@ static int hostfs_rmdir(struct inode *ino, struct dentry *dentry)
> return err;
> }
>
> -static int hostfs_mknod(struct mnt_idmap *idmap, struct inode *dir,
> +static int hostfs_mknod(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode, dev_t dev)
> {
> struct inode *inode;
> diff --git a/fs/hpfs/namei.c b/fs/hpfs/namei.c
> index 9446f4038874..ed749e1684d2 100644
> --- a/fs/hpfs/namei.c
> +++ b/fs/hpfs/namei.c
> @@ -215,7 +215,7 @@ static int hpfs_create(struct mnt_idmap *idmap, struct inode *dir,
> return err;
> }
>
> -static int hpfs_mknod(struct mnt_idmap *idmap, struct inode *dir,
> +static int hpfs_mknod(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode, dev_t rdev)
> {
> const unsigned char *name = dentry->d_name.name;
> diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
> index 8a07a3f18c05..0c9cb8d953ab 100644
> --- a/fs/hugetlbfs/inode.c
> +++ b/fs/hugetlbfs/inode.c
> @@ -954,7 +954,7 @@ static struct inode *hugetlbfs_get_inode(struct super_block *sb,
> /*
> * File creation. Allocate an inode, and we're done..
> */
> -static int hugetlbfs_mknod(struct mnt_idmap *idmap, struct inode *dir,
> +static int hugetlbfs_mknod(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode, dev_t dev)
> {
> struct inode *inode;
> diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c
> index 656c920864c5..6d4b26d625c7 100644
> --- a/fs/jffs2/dir.c
> +++ b/fs/jffs2/dir.c
> @@ -36,7 +36,7 @@ static int jffs2_symlink (struct mnt_idmap *, struct inode *,
> static struct dentry *jffs2_mkdir (struct mnt_idmap *, struct inode *,struct dentry *,
> umode_t);
> static int jffs2_rmdir (struct inode *,struct dentry *);
> -static int jffs2_mknod (struct mnt_idmap *, struct inode *,struct dentry *,
> +static int jffs2_mknod (const struct mnt_idmap *, struct inode *,struct dentry *,
> umode_t,dev_t);
> static int jffs2_rename (struct mnt_idmap *, struct inode *,
> struct dentry *, struct inode *, struct dentry *,
> @@ -620,7 +620,7 @@ static int jffs2_rmdir (struct inode *dir_i, struct dentry *dentry)
> return ret;
> }
>
> -static int jffs2_mknod (struct mnt_idmap *idmap, struct inode *dir_i,
> +static int jffs2_mknod (const struct mnt_idmap *idmap, struct inode *dir_i,
> struct dentry *dentry, umode_t mode, dev_t rdev)
> {
> struct jffs2_inode_info *f, *dir_f;
> diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c
> index 8a36c218f0f7..82a5dbdaf93d 100644
> --- a/fs/jfs/namei.c
> +++ b/fs/jfs/namei.c
> @@ -1355,7 +1355,7 @@ static int jfs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
> *
> * FUNCTION: Create a special file (device)
> */
> -static int jfs_mknod(struct mnt_idmap *idmap, struct inode *dir,
> +static int jfs_mknod(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode, dev_t rdev)
> {
> struct jfs_inode_info *jfs_ip;
> diff --git a/fs/minix/namei.c b/fs/minix/namei.c
> index 0575dea16a3b..57b3c2c5b688 100644
> --- a/fs/minix/namei.c
> +++ b/fs/minix/namei.c
> @@ -33,7 +33,7 @@ static struct dentry *minix_lookup(struct inode * dir, struct dentry *dentry, un
> return d_splice_alias(inode, dentry);
> }
>
> -static int minix_mknod(struct mnt_idmap *idmap, struct inode *dir,
> +static int minix_mknod(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode, dev_t rdev)
> {
> struct inode *inode;
> diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
> index 7574bc2fb677..10c48672a79d 100644
> --- a/fs/nfs/dir.c
> +++ b/fs/nfs/dir.c
> @@ -2448,7 +2448,7 @@ EXPORT_SYMBOL_GPL(nfs_create);
> * See comments for nfs_proc_create regarding failed operations.
> */
> int
> -nfs_mknod(struct mnt_idmap *idmap, struct inode *dir,
> +nfs_mknod(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode, dev_t rdev)
> {
> struct iattr attr;
> diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
> index abc81f5ae578..ec37568d197b 100644
> --- a/fs/nfs/internal.h
> +++ b/fs/nfs/internal.h
> @@ -405,7 +405,7 @@ int nfs_unlink(struct inode *, struct dentry *);
> int nfs_symlink(struct mnt_idmap *, struct inode *, struct dentry *,
> const char *);
> int nfs_link(struct dentry *, struct inode *, struct dentry *);
> -int nfs_mknod(struct mnt_idmap *, struct inode *, struct dentry *, umode_t,
> +int nfs_mknod(const struct mnt_idmap *, struct inode *, struct dentry *, umode_t,
> dev_t);
> int nfs_rename(struct mnt_idmap *, struct inode *, struct dentry *,
> struct inode *, struct dentry *, unsigned int);
> diff --git a/fs/nilfs2/namei.c b/fs/nilfs2/namei.c
> index e037e0c6e31a..ea3df1d5ec29 100644
> --- a/fs/nilfs2/namei.c
> +++ b/fs/nilfs2/namei.c
> @@ -113,7 +113,7 @@ static int nilfs_create(struct mnt_idmap *idmap, struct inode *dir,
> }
>
> static int
> -nilfs_mknod(struct mnt_idmap *idmap, struct inode *dir,
> +nilfs_mknod(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode, dev_t rdev)
> {
> struct inode *inode;
> diff --git a/fs/ntfs/namei.c b/fs/ntfs/namei.c
> index e2cf1ab6935a..82da5f14efa4 100644
> --- a/fs/ntfs/namei.c
> +++ b/fs/ntfs/namei.c
> @@ -1447,7 +1447,7 @@ static int ntfs_symlink(struct mnt_idmap *idmap, struct inode *dir,
> return err;
> }
>
> -static int ntfs_mknod(struct mnt_idmap *idmap, struct inode *dir,
> +static int ntfs_mknod(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode, dev_t rdev)
> {
> struct super_block *sb = dir->i_sb;
> diff --git a/fs/ntfs3/namei.c b/fs/ntfs3/namei.c
> index ec59bbabd3c5..dfafadcd8fda 100644
> --- a/fs/ntfs3/namei.c
> +++ b/fs/ntfs3/namei.c
> @@ -121,7 +121,7 @@ static int ntfs_create(struct mnt_idmap *idmap, struct inode *dir,
> /*
> * ntfs_mknod - inode_operations::mknod
> */
> -static int ntfs_mknod(struct mnt_idmap *idmap, struct inode *dir,
> +static int ntfs_mknod(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode, dev_t rdev)
> {
> return ntfs_create_inode(idmap, dir, dentry, NULL, mode, rdev, NULL, 0,
> diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
> index e9c7774ccf91..6cd77f295939 100644
> --- a/fs/ocfs2/namei.c
> +++ b/fs/ocfs2/namei.c
> @@ -227,7 +227,7 @@ static void ocfs2_cleanup_add_entry_failure(struct ocfs2_super *osb,
> iput(inode);
> }
>
> -static int ocfs2_mknod(struct mnt_idmap *idmap,
> +static int ocfs2_mknod(const struct mnt_idmap *idmap,
> struct inode *dir,
> struct dentry *dentry,
> umode_t mode,
> diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
> index 4f3f1e2bafff..6d4b511dc3ca 100644
> --- a/fs/overlayfs/dir.c
> +++ b/fs/overlayfs/dir.c
> @@ -742,7 +742,7 @@ static struct dentry *ovl_mkdir(struct mnt_idmap *idmap, struct inode *dir,
> return ERR_PTR(ovl_create_object(idmap, dentry, (mode & 07777) | S_IFDIR, 0, NULL));
> }
>
> -static int ovl_mknod(struct mnt_idmap *idmap, struct inode *dir,
> +static int ovl_mknod(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode, dev_t rdev)
> {
> /* Don't allow creation of "whiteout" on overlay */
> diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c
> index fc9a79af4840..5b09860dc69b 100644
> --- a/fs/ramfs/inode.c
> +++ b/fs/ramfs/inode.c
> @@ -95,7 +95,7 @@ struct inode *ramfs_get_inode(struct super_block *sb,
> */
> /* SMP-safe */
> static int
> -ramfs_mknod(struct mnt_idmap *idmap, struct inode *dir,
> +ramfs_mknod(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode, dev_t dev)
> {
> struct inode * inode = ramfs_get_inode(dir->i_sb, dir, mode, dev);
> diff --git a/fs/smb/client/cifsfs.h b/fs/smb/client/cifsfs.h
> index 255f478d3a18..db7aebb8599e 100644
> --- a/fs/smb/client/cifsfs.h
> +++ b/fs/smb/client/cifsfs.h
> @@ -64,7 +64,7 @@ struct dentry *cifs_lookup(struct inode *parent_dir_inode,
> int cifs_unlink(struct inode *dir, struct dentry *dentry);
> int cifs_hardlink(struct dentry *old_file, struct inode *inode,
> struct dentry *direntry);
> -int cifs_mknod(struct mnt_idmap *idmap, struct inode *inode,
> +int cifs_mknod(const struct mnt_idmap *idmap, struct inode *inode,
> struct dentry *direntry, umode_t mode, dev_t device_number);
> struct dentry *cifs_mkdir(struct mnt_idmap *idmap, struct inode *inode,
> struct dentry *direntry, umode_t mode);
> diff --git a/fs/smb/client/dir.c b/fs/smb/client/dir.c
> index 56a3e1966257..95da43ad7c02 100644
> --- a/fs/smb/client/dir.c
> +++ b/fs/smb/client/dir.c
> @@ -696,7 +696,7 @@ int cifs_create(struct mnt_idmap *idmap, struct inode *dir,
> return rc;
> }
>
> -int cifs_mknod(struct mnt_idmap *idmap, struct inode *inode,
> +int cifs_mknod(const struct mnt_idmap *idmap, struct inode *inode,
> struct dentry *direntry, umode_t mode, dev_t device_number)
> {
> int rc = -EPERM;
> diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
> index 0e1a4de9bb18..50068515f680 100644
> --- a/fs/ubifs/dir.c
> +++ b/fs/ubifs/dir.c
> @@ -1077,7 +1077,7 @@ static struct dentry *ubifs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
> return ERR_PTR(err);
> }
>
> -static int ubifs_mknod(struct mnt_idmap *idmap, struct inode *dir,
> +static int ubifs_mknod(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode, dev_t rdev)
> {
> struct inode *inode;
> diff --git a/fs/udf/namei.c b/fs/udf/namei.c
> index 8b5873b53324..4f7200e6046e 100644
> --- a/fs/udf/namei.c
> +++ b/fs/udf/namei.c
> @@ -403,7 +403,7 @@ static int udf_tmpfile(const struct mnt_idmap *idmap, struct inode *dir,
> return finish_open_simple(file, 0);
> }
>
> -static int udf_mknod(struct mnt_idmap *idmap, struct inode *dir,
> +static int udf_mknod(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode, dev_t rdev)
> {
> struct inode *inode;
> diff --git a/fs/ufs/namei.c b/fs/ufs/namei.c
> index 6703f3bcf76f..a38975b3885e 100644
> --- a/fs/ufs/namei.c
> +++ b/fs/ufs/namei.c
> @@ -85,7 +85,7 @@ static int ufs_create (struct mnt_idmap * idmap,
> return ufs_add_nondir(dentry, inode);
> }
>
> -static int ufs_mknod(struct mnt_idmap *idmap, struct inode *dir,
> +static int ufs_mknod(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode, dev_t rdev)
> {
> struct inode *inode;
> diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
> index 06ca999d0927..13e57b0e7cae 100644
> --- a/fs/xfs/xfs_iops.c
> +++ b/fs/xfs/xfs_iops.c
> @@ -279,7 +279,7 @@ xfs_generic_create(
>
> STATIC int
> xfs_vn_mknod(
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct inode *dir,
> struct dentry *dentry,
> umode_t mode,
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 92161c224856..4ca59a110d17 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -2008,7 +2008,7 @@ struct inode_operations {
> struct dentry *(*mkdir) (struct mnt_idmap *, struct inode *,
> struct dentry *, umode_t);
> int (*rmdir) (struct inode *,struct dentry *);
> - int (*mknod) (struct mnt_idmap *, struct inode *,struct dentry *,
> + int (*mknod) (const struct mnt_idmap *, struct inode *,struct dentry *,
> umode_t,dev_t);
> int (*rename) (struct mnt_idmap *, struct inode *, struct dentry *,
> struct inode *, struct dentry *, unsigned int);
> diff --git a/include/linux/lsm_hook_defs.h b/include/linux/lsm_hook_defs.h
> index 470de3fb22c1..ad05971e6137 100644
> --- a/include/linux/lsm_hook_defs.h
> +++ b/include/linux/lsm_hook_defs.h
> @@ -94,7 +94,7 @@ LSM_HOOK(int, 0, path_mkdir, const struct path *dir, struct dentry *dentry,
> LSM_HOOK(int, 0, path_rmdir, const struct path *dir, struct dentry *dentry)
> LSM_HOOK(int, 0, path_mknod, const struct path *dir, struct dentry *dentry,
> umode_t mode, unsigned int dev)
> -LSM_HOOK(void, LSM_RET_VOID, path_post_mknod, struct mnt_idmap *idmap,
> +LSM_HOOK(void, LSM_RET_VOID, path_post_mknod, const struct mnt_idmap *idmap,
> struct dentry *dentry)
> LSM_HOOK(int, 0, path_truncate, const struct path *path)
> LSM_HOOK(int, 0, path_symlink, const struct path *dir, struct dentry *dentry,
> diff --git a/include/linux/security.h b/include/linux/security.h
> index b07a85e6aed4..d4100396da27 100644
> --- a/include/linux/security.h
> +++ b/include/linux/security.h
> @@ -2085,7 +2085,7 @@ int security_path_mkdir(const struct path *dir, struct dentry *dentry, umode_t m
> int security_path_rmdir(const struct path *dir, struct dentry *dentry);
> int security_path_mknod(const struct path *dir, struct dentry *dentry, umode_t mode,
> unsigned int dev);
> -void security_path_post_mknod(struct mnt_idmap *idmap, struct dentry *dentry);
> +void security_path_post_mknod(const struct mnt_idmap *idmap, struct dentry *dentry);
> int security_path_truncate(const struct path *path);
> int security_path_symlink(const struct path *dir, struct dentry *dentry,
> const char *old_name);
> @@ -2120,7 +2120,7 @@ static inline int security_path_mknod(const struct path *dir, struct dentry *den
> return 0;
> }
>
> -static inline void security_path_post_mknod(struct mnt_idmap *idmap,
> +static inline void security_path_post_mknod(const struct mnt_idmap *idmap,
> struct dentry *dentry)
> { }
>
> diff --git a/mm/shmem.c b/mm/shmem.c
> index a107940660a8..16a4ea914bdb 100644
> --- a/mm/shmem.c
> +++ b/mm/shmem.c
> @@ -3818,7 +3818,7 @@ static int shmem_statfs(struct dentry *dentry, struct kstatfs *buf)
> * File creation. Allocate an inode, and we're done..
> */
> static int
> -shmem_mknod(struct mnt_idmap *idmap, struct inode *dir,
> +shmem_mknod(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode, dev_t dev)
> {
> struct inode *inode;
> @@ -3970,7 +3970,7 @@ static int shmem_rmdir(struct inode *dir, struct dentry *dentry)
> return shmem_unlink(dir, dentry);
> }
>
> -static int shmem_whiteout(struct mnt_idmap *idmap,
> +static int shmem_whiteout(const struct mnt_idmap *idmap,
> struct inode *old_dir, struct dentry *old_dentry)
> {
> struct dentry *whiteout;
> diff --git a/security/integrity/evm/evm_main.c b/security/integrity/evm/evm_main.c
> index 94928549bfab..10a0b39dd9b7 100644
> --- a/security/integrity/evm/evm_main.c
> +++ b/security/integrity/evm/evm_main.c
> @@ -1140,7 +1140,7 @@ static void evm_file_release(struct file *file)
> iint->flags &= ~EVM_NEW_FILE;
> }
>
> -static void evm_post_path_mknod(struct mnt_idmap *idmap, struct dentry *dentry)
> +static void evm_post_path_mknod(const struct mnt_idmap *idmap, struct dentry *dentry)
> {
> struct inode *inode = d_backing_inode(dentry);
> struct evm_iint_cache *iint = evm_iint_inode(inode);
> diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c
> index 72ecacda7528..7ac38a98b1f9 100644
> --- a/security/integrity/ima/ima_main.c
> +++ b/security/integrity/ima/ima_main.c
> @@ -879,7 +879,7 @@ static void ima_post_create_tmpfile(const struct mnt_idmap *idmap,
> * Mark files created via the mknodat syscall as new, so that the
> * file data can be written later.
> */
> -static void ima_post_path_mknod(struct mnt_idmap *idmap, struct dentry *dentry)
> +static void ima_post_path_mknod(const struct mnt_idmap *idmap, struct dentry *dentry)
> {
> struct ima_iint_cache *iint;
> struct inode *inode = dentry->d_inode;
> diff --git a/security/security.c b/security/security.c
> index 4e4ef1c496ad..9a3ae6746fb3 100644
> --- a/security/security.c
> +++ b/security/security.c
> @@ -1425,7 +1425,7 @@ EXPORT_SYMBOL(security_path_mknod);
> *
> * Update inode security field after a regular file has been created.
> */
> -void security_path_post_mknod(struct mnt_idmap *idmap, struct dentry *dentry)
> +void security_path_post_mknod(const struct mnt_idmap *idmap, struct dentry *dentry)
> {
> if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
> return;
>
> --
> 2.53.0
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 62+ messages in thread* Re: [PATCH 18/27] fs: port ->mknod() to pass const mnt_idmap
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
1 sibling, 0 replies; 62+ messages in thread
From: Paul Moore @ 2026-09-02 19:34 UTC (permalink / raw)
To: Christian Brauner, linux-fsdevel
Cc: Alexander Viro, Jan Kara, Christoph Hellwig, Seth Forshee,
linux-security-module, Mimi Zohar, linux-integrity, Ilya Dryomov,
ceph-devel, Carlos Maiolino, linux-xfs, Miklos Szeredi,
Amir Goldstein, linux-unionfs, Namjae Jeon, linux-cifs,
linux-kernel, Christian Brauner (Amutable)
On Sep 1, 2026 Christian Brauner <brauner@kernel.org> wrote:
>
> Convert to const struct mnt_idmap.
>
> A mount's idmapping is immutable. The only thing that is allowed to be
> modified afterwards is the reference count and that is hidden behind
> mnt_idmap_get() and mnt_idmap_put(). Everything else only ever reads
> from the idmapping. This is the same model that struct cred uses and the
> idmapping is also rather sensitive.
>
> So make the idmap argument const wherever we can. The conversion is done
> from the bottom up so callers can continue to pass a non-const pointer
> to a const parameter until the conversion is finished.
>
> No functional changes.
>
> Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
> Reviewed-by: Jan Kara <jack@suse.cz>
> ---
> Documentation/filesystems/locking.rst | 2 +-
> Documentation/filesystems/vfs.rst | 2 +-
> fs/9p/vfs_inode.c | 2 +-
> fs/9p/vfs_inode_dotl.c | 4 ++--
> fs/bad_inode.c | 2 +-
> fs/btrfs/inode.c | 2 +-
> fs/ceph/dir.c | 2 +-
> fs/ecryptfs/inode.c | 2 +-
> fs/ext2/namei.c | 2 +-
> fs/ext4/namei.c | 2 +-
> fs/f2fs/namei.c | 2 +-
> fs/fuse/dir.c | 4 ++--
> fs/gfs2/inode.c | 2 +-
> fs/hfsplus/dir.c | 2 +-
> fs/hostfs/hostfs_kern.c | 2 +-
> fs/hpfs/namei.c | 2 +-
> fs/hugetlbfs/inode.c | 2 +-
> fs/jffs2/dir.c | 4 ++--
> fs/jfs/namei.c | 2 +-
> fs/minix/namei.c | 2 +-
> fs/nfs/dir.c | 2 +-
> fs/nfs/internal.h | 2 +-
> fs/nilfs2/namei.c | 2 +-
> fs/ntfs/namei.c | 2 +-
> fs/ntfs3/namei.c | 2 +-
> fs/ocfs2/namei.c | 2 +-
> fs/overlayfs/dir.c | 2 +-
> fs/ramfs/inode.c | 2 +-
> fs/smb/client/cifsfs.h | 2 +-
> fs/smb/client/dir.c | 2 +-
> fs/ubifs/dir.c | 2 +-
> fs/udf/namei.c | 2 +-
> fs/ufs/namei.c | 2 +-
> fs/xfs/xfs_iops.c | 2 +-
> include/linux/fs.h | 2 +-
> include/linux/lsm_hook_defs.h | 2 +-
> include/linux/security.h | 4 ++--
> mm/shmem.c | 4 ++--
> security/integrity/evm/evm_main.c | 2 +-
> security/integrity/ima/ima_main.c | 2 +-
> security/security.c | 2 +-
> 41 files changed, 46 insertions(+), 46 deletions(-)
Acked-by: Paul Moore <paul@paul-moore.com> (LSM)
--
paul-moore.com
^ permalink raw reply [flat|nested] 62+ messages in thread
* [PATCH 19/27] fs: port ->rename() to pass const mnt_idmap
2026-09-01 12:14 [PATCH 00/27] fs: port to const struct mnt_idmap Christian Brauner
` (17 preceding siblings ...)
2026-09-01 12:14 ` [PATCH 18/27] fs: port ->mknod() " Christian Brauner
@ 2026-09-01 12:14 ` Christian Brauner
2026-09-02 15:50 ` Jan Kara
2026-09-01 12:14 ` [PATCH 20/27] fs: port ->mkdir() " Christian Brauner
` (7 subsequent siblings)
26 siblings, 1 reply; 62+ messages in thread
From: Christian Brauner @ 2026-09-01 12:14 UTC (permalink / raw)
To: linux-fsdevel
Cc: Alexander Viro, Jan Kara, Christoph Hellwig, Seth Forshee,
Paul Moore, linux-security-module, Mimi Zohar, linux-integrity,
Ilya Dryomov, ceph-devel, Carlos Maiolino, linux-xfs,
Miklos Szeredi, Amir Goldstein, linux-unionfs, Namjae Jeon,
linux-cifs, linux-kernel, Christian Brauner (Amutable)
Convert to const struct mnt_idmap.
A mount's idmapping is immutable. The only thing that is allowed to be
modified afterwards is the reference count and that is hidden behind
mnt_idmap_get() and mnt_idmap_put(). Everything else only ever reads
from the idmapping. This is the same model that struct cred uses and the
idmapping is also rather sensitive.
So make the idmap argument const wherever we can. The conversion is done
from the bottom up so callers can continue to pass a non-const pointer
to a const parameter until the conversion is finished.
No functional changes.
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
---
Documentation/filesystems/locking.rst | 2 +-
Documentation/filesystems/vfs.rst | 2 +-
drivers/android/binder/rust_binderfs.c | 2 +-
drivers/android/binderfs.c | 2 +-
fs/9p/v9fs.h | 2 +-
fs/9p/vfs_inode.c | 2 +-
fs/affs/affs.h | 2 +-
fs/affs/namei.c | 2 +-
fs/afs/dir.c | 4 ++--
fs/bad_inode.c | 2 +-
fs/bfs/dir.c | 2 +-
fs/btrfs/inode.c | 2 +-
fs/ceph/dir.c | 2 +-
fs/coda/dir.c | 2 +-
fs/ecryptfs/inode.c | 2 +-
fs/exfat/namei.c | 2 +-
fs/ext2/namei.c | 2 +-
fs/ext4/namei.c | 2 +-
fs/f2fs/namei.c | 2 +-
fs/fat/namei_msdos.c | 2 +-
fs/fat/namei_vfat.c | 2 +-
fs/fuse/dir.c | 2 +-
fs/gfs2/inode.c | 2 +-
fs/hfs/dir.c | 2 +-
fs/hfsplus/dir.c | 2 +-
fs/hostfs/hostfs_kern.c | 2 +-
fs/hpfs/namei.c | 2 +-
fs/jffs2/dir.c | 4 ++--
fs/jfs/namei.c | 2 +-
fs/kernfs/dir.c | 2 +-
fs/libfs.c | 2 +-
fs/minix/namei.c | 2 +-
fs/nfs/dir.c | 2 +-
fs/nfs/internal.h | 2 +-
fs/nilfs2/namei.c | 2 +-
fs/ntfs/namei.c | 2 +-
fs/ntfs3/namei.c | 2 +-
fs/ocfs2/namei.c | 2 +-
fs/omfs/dir.c | 2 +-
fs/orangefs/namei.c | 2 +-
fs/overlayfs/dir.c | 2 +-
fs/smb/client/cifsfs.h | 2 +-
fs/smb/client/inode.c | 2 +-
fs/ubifs/dir.c | 2 +-
fs/udf/namei.c | 2 +-
fs/ufs/namei.c | 2 +-
fs/vboxsf/dir.c | 2 +-
fs/xfs/xfs_iops.c | 2 +-
include/linux/fs.h | 4 ++--
mm/shmem.c | 2 +-
50 files changed, 53 insertions(+), 53 deletions(-)
diff --git a/Documentation/filesystems/locking.rst b/Documentation/filesystems/locking.rst
index 1cfdad9286d5..97f8aaff311e 100644
--- a/Documentation/filesystems/locking.rst
+++ b/Documentation/filesystems/locking.rst
@@ -69,7 +69,7 @@ prototypes::
struct dentry *(*mkdir) (struct mnt_idmap *, struct inode *,struct dentry *,umode_t);
int (*rmdir) (struct inode *,struct dentry *);
int (*mknod) (const struct mnt_idmap *, struct inode *,struct dentry *,umode_t,dev_t);
- int (*rename) (struct mnt_idmap *, struct inode *, struct dentry *,
+ int (*rename) (const struct mnt_idmap *, struct inode *, struct dentry *,
struct inode *, struct dentry *, unsigned int);
int (*readlink) (struct dentry *, char __user *,int);
const char *(*get_link) (struct dentry *, struct inode *, struct delayed_call *);
diff --git a/Documentation/filesystems/vfs.rst b/Documentation/filesystems/vfs.rst
index d7ab34e101eb..90f8a0b74249 100644
--- a/Documentation/filesystems/vfs.rst
+++ b/Documentation/filesystems/vfs.rst
@@ -423,7 +423,7 @@ As of kernel 2.6.22, the following members are defined:
struct dentry *(*mkdir) (struct mnt_idmap *, struct inode *,struct dentry *,umode_t);
int (*rmdir) (struct inode *,struct dentry *);
int (*mknod) (const struct mnt_idmap *, struct inode *,struct dentry *,umode_t,dev_t);
- int (*rename) (struct mnt_idmap *, struct inode *, struct dentry *,
+ int (*rename) (const struct mnt_idmap *, struct inode *, struct dentry *,
struct inode *, struct dentry *, unsigned int);
int (*readlink) (struct dentry *, char __user *,int);
const char *(*get_link) (struct dentry *, struct inode *,
diff --git a/drivers/android/binder/rust_binderfs.c b/drivers/android/binder/rust_binderfs.c
index 300cc65562d1..e98e6ca163df 100644
--- a/drivers/android/binder/rust_binderfs.c
+++ b/drivers/android/binder/rust_binderfs.c
@@ -338,7 +338,7 @@ static inline bool is_binderfs_control_device(const struct dentry *dentry)
return info->control_dentry == dentry;
}
-static int binderfs_rename(struct mnt_idmap *idmap,
+static int binderfs_rename(const struct mnt_idmap *idmap,
struct inode *old_dir, struct dentry *old_dentry,
struct inode *new_dir, struct dentry *new_dentry,
unsigned int flags)
diff --git a/drivers/android/binderfs.c b/drivers/android/binderfs.c
index 361d69f756f5..087eae6ca8ec 100644
--- a/drivers/android/binderfs.c
+++ b/drivers/android/binderfs.c
@@ -344,7 +344,7 @@ static inline bool is_binderfs_control_device(const struct dentry *dentry)
return info->control_dentry == dentry;
}
-static int binderfs_rename(struct mnt_idmap *idmap,
+static int binderfs_rename(const struct mnt_idmap *idmap,
struct inode *old_dir, struct dentry *old_dentry,
struct inode *new_dir, struct dentry *new_dentry,
unsigned int flags)
diff --git a/fs/9p/v9fs.h b/fs/9p/v9fs.h
index a462bcbfc7da..54a4a4ec5c15 100644
--- a/fs/9p/v9fs.h
+++ b/fs/9p/v9fs.h
@@ -188,7 +188,7 @@ extern struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry,
unsigned int flags);
extern int v9fs_vfs_unlink(struct inode *i, struct dentry *d);
extern int v9fs_vfs_rmdir(struct inode *i, struct dentry *d);
-extern int v9fs_vfs_rename(struct mnt_idmap *idmap,
+extern int v9fs_vfs_rename(const struct mnt_idmap *idmap,
struct inode *old_dir, struct dentry *old_dentry,
struct inode *new_dir, struct dentry *new_dentry,
unsigned int flags);
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index 81fb5f8ec7e9..7d4d5a4481fa 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -858,7 +858,7 @@ int v9fs_vfs_rmdir(struct inode *i, struct dentry *d)
*/
int
-v9fs_vfs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
+v9fs_vfs_rename(const struct mnt_idmap *idmap, struct inode *old_dir,
struct dentry *old_dentry, struct inode *new_dir,
struct dentry *new_dentry, unsigned int flags)
{
diff --git a/fs/affs/affs.h b/fs/affs/affs.h
index d1c506c1f310..a4b1e449aafc 100644
--- a/fs/affs/affs.h
+++ b/fs/affs/affs.h
@@ -176,7 +176,7 @@ extern int affs_link(struct dentry *olddentry, struct inode *dir,
extern int affs_symlink(struct mnt_idmap *idmap,
struct inode *dir, struct dentry *dentry,
const char *symname);
-extern int affs_rename2(struct mnt_idmap *idmap,
+extern int affs_rename2(const struct mnt_idmap *idmap,
struct inode *old_dir, struct dentry *old_dentry,
struct inode *new_dir, struct dentry *new_dentry,
unsigned int flags);
diff --git a/fs/affs/namei.c b/fs/affs/namei.c
index 6cb52efafe5f..c9cc0ad5c330 100644
--- a/fs/affs/namei.c
+++ b/fs/affs/namei.c
@@ -503,7 +503,7 @@ affs_xrename(struct inode *old_dir, struct dentry *old_dentry,
return retval;
}
-int affs_rename2(struct mnt_idmap *idmap, struct inode *old_dir,
+int affs_rename2(const struct mnt_idmap *idmap, struct inode *old_dir,
struct dentry *old_dentry, struct inode *new_dir,
struct dentry *new_dentry, unsigned int flags)
{
diff --git a/fs/afs/dir.c b/fs/afs/dir.c
index 81565366d937..fee48c544c61 100644
--- a/fs/afs/dir.c
+++ b/fs/afs/dir.c
@@ -43,7 +43,7 @@ static int afs_link(struct dentry *from, struct inode *dir,
struct dentry *dentry);
static int afs_symlink(struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, const char *content);
-static int afs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
+static int afs_rename(const struct mnt_idmap *idmap, struct inode *old_dir,
struct dentry *old_dentry, struct inode *new_dir,
struct dentry *new_dentry, unsigned int flags);
static int afs_dir_writepages(struct address_space *mapping,
@@ -2067,7 +2067,7 @@ static const struct afs_operation_ops afs_rename_exchange_operation = {
/*
* rename a file in an AFS filesystem and/or move it between directories
*/
-static int afs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
+static int afs_rename(const struct mnt_idmap *idmap, struct inode *old_dir,
struct dentry *old_dentry, struct inode *new_dir,
struct dentry *new_dentry, unsigned int flags)
{
diff --git a/fs/bad_inode.c b/fs/bad_inode.c
index 9b7baf1367a6..c5c76e9dcf82 100644
--- a/fs/bad_inode.c
+++ b/fs/bad_inode.c
@@ -75,7 +75,7 @@ static int bad_inode_mknod(const struct mnt_idmap *idmap, struct inode *dir,
return -EIO;
}
-static int bad_inode_rename2(struct mnt_idmap *idmap,
+static int bad_inode_rename2(const struct mnt_idmap *idmap,
struct inode *old_dir, struct dentry *old_dentry,
struct inode *new_dir, struct dentry *new_dentry,
unsigned int flags)
diff --git a/fs/bfs/dir.c b/fs/bfs/dir.c
index 91a4871fa051..80534d04db9d 100644
--- a/fs/bfs/dir.c
+++ b/fs/bfs/dir.c
@@ -199,7 +199,7 @@ static int bfs_unlink(struct inode *dir, struct dentry *dentry)
return error;
}
-static int bfs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
+static int bfs_rename(const struct mnt_idmap *idmap, struct inode *old_dir,
struct dentry *old_dentry, struct inode *new_dir,
struct dentry *new_dentry, unsigned int flags)
{
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 32b5648fdf81..e77c791f6efa 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -8835,7 +8835,7 @@ static int btrfs_rename(const struct mnt_idmap *idmap,
return ret;
}
-static int btrfs_rename2(struct mnt_idmap *idmap, struct inode *old_dir,
+static int btrfs_rename2(const struct mnt_idmap *idmap, struct inode *old_dir,
struct dentry *old_dentry, struct inode *new_dir,
struct dentry *new_dentry, unsigned int flags)
{
diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
index 0f3c54dc97c6..864b6949fb9f 100644
--- a/fs/ceph/dir.c
+++ b/fs/ceph/dir.c
@@ -1478,7 +1478,7 @@ static int ceph_unlink(struct inode *dir, struct dentry *dentry)
return err;
}
-static int ceph_rename(struct mnt_idmap *idmap, struct inode *old_dir,
+static int ceph_rename(const struct mnt_idmap *idmap, struct inode *old_dir,
struct dentry *old_dentry, struct inode *new_dir,
struct dentry *new_dentry, unsigned int flags)
{
diff --git a/fs/coda/dir.c b/fs/coda/dir.c
index e8db5960b61b..a888a7ef30e5 100644
--- a/fs/coda/dir.c
+++ b/fs/coda/dir.c
@@ -300,7 +300,7 @@ static int coda_rmdir(struct inode *dir, struct dentry *de)
}
/* rename */
-static int coda_rename(struct mnt_idmap *idmap, struct inode *old_dir,
+static int coda_rename(const struct mnt_idmap *idmap, struct inode *old_dir,
struct dentry *old_dentry, struct inode *new_dir,
struct dentry *new_dentry, unsigned int flags)
{
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index 411aa024d4b8..7f5396e27752 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -590,7 +590,7 @@ ecryptfs_mknod(const struct mnt_idmap *idmap, struct inode *dir,
}
static int
-ecryptfs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
+ecryptfs_rename(const struct mnt_idmap *idmap, struct inode *old_dir,
struct dentry *old_dentry, struct inode *new_dir,
struct dentry *new_dentry, unsigned int flags)
{
diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c
index a4dc83b5949c..863a8c506fe8 100644
--- a/fs/exfat/namei.c
+++ b/fs/exfat/namei.c
@@ -1263,7 +1263,7 @@ static int __exfat_rename(struct inode *old_parent_inode,
return ret;
}
-static int exfat_rename(struct mnt_idmap *idmap,
+static int exfat_rename(const struct mnt_idmap *idmap,
struct inode *old_dir, struct dentry *old_dentry,
struct inode *new_dir, struct dentry *new_dentry,
unsigned int flags)
diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c
index f175b59cccd7..19e298533699 100644
--- a/fs/ext2/namei.c
+++ b/fs/ext2/namei.c
@@ -316,7 +316,7 @@ static int ext2_rmdir (struct inode * dir, struct dentry *dentry)
return err;
}
-static int ext2_rename (struct mnt_idmap * idmap,
+static int ext2_rename (const struct mnt_idmap * idmap,
struct inode * old_dir, struct dentry * old_dentry,
struct inode * new_dir, struct dentry * new_dentry,
unsigned int flags)
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index d7a58d82f320..1fbc2efe23ba 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -4191,7 +4191,7 @@ static int ext4_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
return retval;
}
-static int ext4_rename2(struct mnt_idmap *idmap,
+static int ext4_rename2(const struct mnt_idmap *idmap,
struct inode *old_dir, struct dentry *old_dentry,
struct inode *new_dir, struct dentry *new_dentry,
unsigned int flags)
diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
index 0773f64396f8..87b588b1d34f 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -1341,7 +1341,7 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
return err;
}
-static int f2fs_rename2(struct mnt_idmap *idmap,
+static int f2fs_rename2(const struct mnt_idmap *idmap,
struct inode *old_dir, struct dentry *old_dentry,
struct inode *new_dir, struct dentry *new_dentry,
unsigned int flags)
diff --git a/fs/fat/namei_msdos.c b/fs/fat/namei_msdos.c
index d46d1a3851f2..1af607cf47cf 100644
--- a/fs/fat/namei_msdos.c
+++ b/fs/fat/namei_msdos.c
@@ -600,7 +600,7 @@ static int do_msdos_rename(struct inode *old_dir, unsigned char *old_name,
}
/***** Rename, a wrapper for rename_same_dir & rename_diff_dir */
-static int msdos_rename(struct mnt_idmap *idmap,
+static int msdos_rename(const struct mnt_idmap *idmap,
struct inode *old_dir, struct dentry *old_dentry,
struct inode *new_dir, struct dentry *new_dentry,
unsigned int flags)
diff --git a/fs/fat/namei_vfat.c b/fs/fat/namei_vfat.c
index da3e89c0b16a..d0b161f43a8b 100644
--- a/fs/fat/namei_vfat.c
+++ b/fs/fat/namei_vfat.c
@@ -1160,7 +1160,7 @@ static int vfat_rename_exchange(struct inode *old_dir, struct dentry *old_dentry
goto out;
}
-static int vfat_rename2(struct mnt_idmap *idmap, struct inode *old_dir,
+static int vfat_rename2(const struct mnt_idmap *idmap, struct inode *old_dir,
struct dentry *old_dentry, struct inode *new_dir,
struct dentry *new_dentry, unsigned int flags)
{
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 3250598e06f2..51ff444dcf94 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -1307,7 +1307,7 @@ static int fuse_rename_common(const struct mnt_idmap *idmap, struct inode *olddi
return err;
}
-static int fuse_rename2(struct mnt_idmap *idmap, struct inode *olddir,
+static int fuse_rename2(const struct mnt_idmap *idmap, struct inode *olddir,
struct dentry *oldent, struct inode *newdir,
struct dentry *newent, unsigned int flags)
{
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index 733f74603eaf..0c00fef40af1 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -1877,7 +1877,7 @@ static int gfs2_exchange(struct inode *odir, struct dentry *odentry,
return error;
}
-static int gfs2_rename2(struct mnt_idmap *idmap, struct inode *odir,
+static int gfs2_rename2(const struct mnt_idmap *idmap, struct inode *odir,
struct dentry *odentry, struct inode *ndir,
struct dentry *ndentry, unsigned int flags)
{
diff --git a/fs/hfs/dir.c b/fs/hfs/dir.c
index e1f1fb351464..2958ca702be2 100644
--- a/fs/hfs/dir.c
+++ b/fs/hfs/dir.c
@@ -281,7 +281,7 @@ static int hfs_remove(struct inode *dir, struct dentry *dentry)
* new file/directory.
* XXX: how do you handle must_be dir?
*/
-static int hfs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
+static int hfs_rename(const struct mnt_idmap *idmap, struct inode *old_dir,
struct dentry *old_dentry, struct inode *new_dir,
struct dentry *new_dentry, unsigned int flags)
{
diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c
index 7d31211cee97..d26b87066bd0 100644
--- a/fs/hfsplus/dir.c
+++ b/fs/hfsplus/dir.c
@@ -573,7 +573,7 @@ static struct dentry *hfsplus_mkdir(struct mnt_idmap *idmap, struct inode *dir,
return ERR_PTR(hfsplus_mknod(&nop_mnt_idmap, dir, dentry, mode, 0));
}
-static int hfsplus_rename(struct mnt_idmap *idmap,
+static int hfsplus_rename(const struct mnt_idmap *idmap,
struct inode *old_dir, struct dentry *old_dentry,
struct inode *new_dir, struct dentry *new_dentry,
unsigned int flags)
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
index 71d15396235a..9028c9f27730 100644
--- a/fs/hostfs/hostfs_kern.c
+++ b/fs/hostfs/hostfs_kern.c
@@ -745,7 +745,7 @@ static int hostfs_mknod(const struct mnt_idmap *idmap, struct inode *dir,
return 0;
}
-static int hostfs_rename2(struct mnt_idmap *idmap,
+static int hostfs_rename2(const struct mnt_idmap *idmap,
struct inode *old_dir, struct dentry *old_dentry,
struct inode *new_dir, struct dentry *new_dentry,
unsigned int flags)
diff --git a/fs/hpfs/namei.c b/fs/hpfs/namei.c
index ed749e1684d2..dfa8e5b7311f 100644
--- a/fs/hpfs/namei.c
+++ b/fs/hpfs/namei.c
@@ -500,7 +500,7 @@ const struct address_space_operations hpfs_symlink_aops = {
.read_folio = hpfs_symlink_read_folio
};
-static int hpfs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
+static int hpfs_rename(const struct mnt_idmap *idmap, struct inode *old_dir,
struct dentry *old_dentry, struct inode *new_dir,
struct dentry *new_dentry, unsigned int flags)
{
diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c
index 6d4b26d625c7..c56cd87a2a73 100644
--- a/fs/jffs2/dir.c
+++ b/fs/jffs2/dir.c
@@ -38,7 +38,7 @@ static struct dentry *jffs2_mkdir (struct mnt_idmap *, struct inode *,struct den
static int jffs2_rmdir (struct inode *,struct dentry *);
static int jffs2_mknod (const struct mnt_idmap *, struct inode *,struct dentry *,
umode_t,dev_t);
-static int jffs2_rename (struct mnt_idmap *, struct inode *,
+static int jffs2_rename (const struct mnt_idmap *, struct inode *,
struct dentry *, struct inode *, struct dentry *,
unsigned int);
@@ -769,7 +769,7 @@ static int jffs2_mknod (const struct mnt_idmap *idmap, struct inode *dir_i,
return ret;
}
-static int jffs2_rename (struct mnt_idmap *idmap,
+static int jffs2_rename (const struct mnt_idmap *idmap,
struct inode *old_dir_i, struct dentry *old_dentry,
struct inode *new_dir_i, struct dentry *new_dentry,
unsigned int flags)
diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c
index 82a5dbdaf93d..a384ced308af 100644
--- a/fs/jfs/namei.c
+++ b/fs/jfs/namei.c
@@ -1066,7 +1066,7 @@ static int jfs_symlink(struct mnt_idmap *idmap, struct inode *dip,
*
* FUNCTION: rename a file or directory
*/
-static int jfs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
+static int jfs_rename(const struct mnt_idmap *idmap, struct inode *old_dir,
struct dentry *old_dentry, struct inode *new_dir,
struct dentry *new_dentry, unsigned int flags)
{
diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c
index 82bbaeb326aa..d2e978e4ea6f 100644
--- a/fs/kernfs/dir.c
+++ b/fs/kernfs/dir.c
@@ -1326,7 +1326,7 @@ static int kernfs_iop_rmdir(struct inode *dir, struct dentry *dentry)
return ret;
}
-static int kernfs_iop_rename(struct mnt_idmap *idmap,
+static int kernfs_iop_rename(const struct mnt_idmap *idmap,
struct inode *old_dir, struct dentry *old_dentry,
struct inode *new_dir, struct dentry *new_dentry,
unsigned int flags)
diff --git a/fs/libfs.c b/fs/libfs.c
index 27d7dc16fcb0..8b379230b64f 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -867,7 +867,7 @@ int simple_rename_exchange(struct inode *old_dir, struct dentry *old_dentry,
}
EXPORT_SYMBOL_GPL(simple_rename_exchange);
-int simple_rename(struct mnt_idmap *idmap, struct inode *old_dir,
+int simple_rename(const struct mnt_idmap *idmap, struct inode *old_dir,
struct dentry *old_dentry, struct inode *new_dir,
struct dentry *new_dentry, unsigned int flags)
{
diff --git a/fs/minix/namei.c b/fs/minix/namei.c
index 57b3c2c5b688..f7aaa19eeac0 100644
--- a/fs/minix/namei.c
+++ b/fs/minix/namei.c
@@ -187,7 +187,7 @@ static int minix_rmdir(struct inode * dir, struct dentry *dentry)
return err;
}
-static int minix_rename(struct mnt_idmap *idmap,
+static int minix_rename(const struct mnt_idmap *idmap,
struct inode *old_dir, struct dentry *old_dentry,
struct inode *new_dir, struct dentry *new_dentry,
unsigned int flags)
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 10c48672a79d..1161c809c9f1 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -2771,7 +2771,7 @@ static bool nfs_rename_is_unsafe_cross_dir(struct dentry *old_dentry,
* If these conditions are met, we can drop the dentries before doing
* the rename.
*/
-int nfs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
+int nfs_rename(const struct mnt_idmap *idmap, struct inode *old_dir,
struct dentry *old_dentry, struct inode *new_dir,
struct dentry *new_dentry, unsigned int flags)
{
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index ec37568d197b..c7928c16352d 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -407,7 +407,7 @@ int nfs_symlink(struct mnt_idmap *, struct inode *, struct dentry *,
int nfs_link(struct dentry *, struct inode *, struct dentry *);
int nfs_mknod(const struct mnt_idmap *, struct inode *, struct dentry *, umode_t,
dev_t);
-int nfs_rename(struct mnt_idmap *, struct inode *, struct dentry *,
+int nfs_rename(const struct mnt_idmap *, struct inode *, struct dentry *,
struct inode *, struct dentry *, unsigned int);
#ifdef CONFIG_NFS_V4_2
diff --git a/fs/nilfs2/namei.c b/fs/nilfs2/namei.c
index ea3df1d5ec29..bfc7c4a06743 100644
--- a/fs/nilfs2/namei.c
+++ b/fs/nilfs2/namei.c
@@ -358,7 +358,7 @@ static int nilfs_rmdir(struct inode *dir, struct dentry *dentry)
return err;
}
-static int nilfs_rename(struct mnt_idmap *idmap,
+static int nilfs_rename(const struct mnt_idmap *idmap,
struct inode *old_dir, struct dentry *old_dentry,
struct inode *new_dir, struct dentry *new_dentry,
unsigned int flags)
diff --git a/fs/ntfs/namei.c b/fs/ntfs/namei.c
index 82da5f14efa4..431ab27472ab 100644
--- a/fs/ntfs/namei.c
+++ b/fs/ntfs/namei.c
@@ -1248,7 +1248,7 @@ static int __ntfs_link(struct ntfs_inode *ni, struct ntfs_inode *dir_ni,
return err;
}
-static int ntfs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
+static int ntfs_rename(const struct mnt_idmap *idmap, struct inode *old_dir,
struct dentry *old_dentry, struct inode *new_dir,
struct dentry *new_dentry, unsigned int flags)
{
diff --git a/fs/ntfs3/namei.c b/fs/ntfs3/namei.c
index dfafadcd8fda..0d9c8bf79947 100644
--- a/fs/ntfs3/namei.c
+++ b/fs/ntfs3/namei.c
@@ -262,7 +262,7 @@ static int ntfs_rmdir(struct inode *dir, struct dentry *dentry)
/*
* ntfs_rename - inode_operations::rename
*/
-static int ntfs_rename(struct mnt_idmap *idmap, struct inode *dir,
+static int ntfs_rename(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, struct inode *new_dir,
struct dentry *new_dentry, u32 flags)
{
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index 6cd77f295939..05c007213fab 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -1211,7 +1211,7 @@ static void ocfs2_double_unlock(struct inode *inode1, struct inode *inode2)
ocfs2_inode_unlock(inode2, 1);
}
-static int ocfs2_rename(struct mnt_idmap *idmap,
+static int ocfs2_rename(const struct mnt_idmap *idmap,
struct inode *old_dir,
struct dentry *old_dentry,
struct inode *new_dir,
diff --git a/fs/omfs/dir.c b/fs/omfs/dir.c
index 692297cf84e7..99e0a7c8e03b 100644
--- a/fs/omfs/dir.c
+++ b/fs/omfs/dir.c
@@ -370,7 +370,7 @@ static bool omfs_fill_chain(struct inode *dir, struct dir_context *ctx,
return true;
}
-static int omfs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
+static int omfs_rename(const struct mnt_idmap *idmap, struct inode *old_dir,
struct dentry *old_dentry, struct inode *new_dir,
struct dentry *new_dentry, unsigned int flags)
{
diff --git a/fs/orangefs/namei.c b/fs/orangefs/namei.c
index 8ebc34e112d5..40105ce80bb8 100644
--- a/fs/orangefs/namei.c
+++ b/fs/orangefs/namei.c
@@ -364,7 +364,7 @@ static struct dentry *orangefs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
return ret ? ERR_PTR(ret) : NULL;
}
-static int orangefs_rename(struct mnt_idmap *idmap,
+static int orangefs_rename(const struct mnt_idmap *idmap,
struct inode *old_dir,
struct dentry *old_dentry,
struct inode *new_dir,
diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
index 6d4b511dc3ca..cb2b5a8d28bd 100644
--- a/fs/overlayfs/dir.c
+++ b/fs/overlayfs/dir.c
@@ -1344,7 +1344,7 @@ static void ovl_rename_end(struct ovl_renamedata *ovlrd)
ovl_drop_write(ovlrd->old_dentry);
}
-static int ovl_rename(struct mnt_idmap *idmap, struct inode *olddir,
+static int ovl_rename(const struct mnt_idmap *idmap, struct inode *olddir,
struct dentry *old, struct inode *newdir,
struct dentry *new, unsigned int flags)
{
diff --git a/fs/smb/client/cifsfs.h b/fs/smb/client/cifsfs.h
index db7aebb8599e..e50edcbb2cd3 100644
--- a/fs/smb/client/cifsfs.h
+++ b/fs/smb/client/cifsfs.h
@@ -69,7 +69,7 @@ int cifs_mknod(const struct mnt_idmap *idmap, struct inode *inode,
struct dentry *cifs_mkdir(struct mnt_idmap *idmap, struct inode *inode,
struct dentry *direntry, umode_t mode);
int cifs_rmdir(struct inode *inode, struct dentry *direntry);
-int cifs_rename2(struct mnt_idmap *idmap, struct inode *source_dir,
+int cifs_rename2(const struct mnt_idmap *idmap, struct inode *source_dir,
struct dentry *source_dentry, struct inode *target_dir,
struct dentry *target_dentry, unsigned int flags);
int cifs_revalidate_file_attr(struct file *filp);
diff --git a/fs/smb/client/inode.c b/fs/smb/client/inode.c
index 12ed8db10e00..eec3a46f6e41 100644
--- a/fs/smb/client/inode.c
+++ b/fs/smb/client/inode.c
@@ -2526,7 +2526,7 @@ cifs_do_rename(const unsigned int xid, struct dentry *from_dentry,
}
int
-cifs_rename2(struct mnt_idmap *idmap, struct inode *source_dir,
+cifs_rename2(const struct mnt_idmap *idmap, struct inode *source_dir,
struct dentry *source_dentry, struct inode *target_dir,
struct dentry *target_dentry, unsigned int flags)
{
diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
index 50068515f680..bff6489c4a5c 100644
--- a/fs/ubifs/dir.c
+++ b/fs/ubifs/dir.c
@@ -1642,7 +1642,7 @@ static int ubifs_xrename(struct inode *old_dir, struct dentry *old_dentry,
return err;
}
-static int ubifs_rename(struct mnt_idmap *idmap,
+static int ubifs_rename(const struct mnt_idmap *idmap,
struct inode *old_dir, struct dentry *old_dentry,
struct inode *new_dir, struct dentry *new_dentry,
unsigned int flags)
diff --git a/fs/udf/namei.c b/fs/udf/namei.c
index 4f7200e6046e..3fe746911581 100644
--- a/fs/udf/namei.c
+++ b/fs/udf/namei.c
@@ -762,7 +762,7 @@ static int udf_link(struct dentry *old_dentry, struct inode *dir,
/* Anybody can rename anything with this: the permission checks are left to the
* higher-level routines.
*/
-static int udf_rename(struct mnt_idmap *idmap, struct inode *old_dir,
+static int udf_rename(const struct mnt_idmap *idmap, struct inode *old_dir,
struct dentry *old_dentry, struct inode *new_dir,
struct dentry *new_dentry, unsigned int flags)
{
diff --git a/fs/ufs/namei.c b/fs/ufs/namei.c
index a38975b3885e..951c92d37d56 100644
--- a/fs/ufs/namei.c
+++ b/fs/ufs/namei.c
@@ -240,7 +240,7 @@ static int ufs_rmdir (struct inode * dir, struct dentry *dentry)
return err;
}
-static int ufs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
+static int ufs_rename(const struct mnt_idmap *idmap, struct inode *old_dir,
struct dentry *old_dentry, struct inode *new_dir,
struct dentry *new_dentry, unsigned int flags)
{
diff --git a/fs/vboxsf/dir.c b/fs/vboxsf/dir.c
index 0b9eab157432..81b92c6cb201 100644
--- a/fs/vboxsf/dir.c
+++ b/fs/vboxsf/dir.c
@@ -382,7 +382,7 @@ static int vboxsf_dir_unlink(struct inode *parent, struct dentry *dentry)
return 0;
}
-static int vboxsf_dir_rename(struct mnt_idmap *idmap,
+static int vboxsf_dir_rename(const struct mnt_idmap *idmap,
struct inode *old_parent,
struct dentry *old_dentry,
struct inode *new_parent,
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index 13e57b0e7cae..26f9eb41599d 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -466,7 +466,7 @@ xfs_vn_symlink(
STATIC int
xfs_vn_rename(
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct inode *odir,
struct dentry *odentry,
struct inode *ndir,
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 4ca59a110d17..2f2a0088e693 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2010,7 +2010,7 @@ struct inode_operations {
int (*rmdir) (struct inode *,struct dentry *);
int (*mknod) (const struct mnt_idmap *, struct inode *,struct dentry *,
umode_t,dev_t);
- int (*rename) (struct mnt_idmap *, struct inode *, struct dentry *,
+ int (*rename) (const struct mnt_idmap *, struct inode *, struct dentry *,
struct inode *, struct dentry *, unsigned int);
int (*setattr) (struct mnt_idmap *, struct dentry *, struct iattr *);
int (*getattr) (struct mnt_idmap *, const struct path *,
@@ -3276,7 +3276,7 @@ void simple_rename_timestamp(struct inode *old_dir, struct dentry *old_dentry,
struct inode *new_dir, struct dentry *new_dentry);
extern int simple_rename_exchange(struct inode *old_dir, struct dentry *old_dentry,
struct inode *new_dir, struct dentry *new_dentry);
-extern int simple_rename(struct mnt_idmap *, struct inode *,
+extern int simple_rename(const struct mnt_idmap *, struct inode *,
struct dentry *, struct inode *, struct dentry *,
unsigned int);
extern void simple_recursive_removal(struct dentry *,
diff --git a/mm/shmem.c b/mm/shmem.c
index 16a4ea914bdb..ab5b2cd34c28 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -3991,7 +3991,7 @@ static int shmem_whiteout(const struct mnt_idmap *idmap,
* it exists so that the VFS layer correctly free's it when it
* gets overwritten.
*/
-static int shmem_rename2(struct mnt_idmap *idmap,
+static int shmem_rename2(const struct mnt_idmap *idmap,
struct inode *old_dir, struct dentry *old_dentry,
struct inode *new_dir, struct dentry *new_dentry,
unsigned int flags)
--
2.53.0
^ permalink raw reply related [flat|nested] 62+ messages in thread* Re: [PATCH 19/27] fs: port ->rename() to pass const mnt_idmap
2026-09-01 12:14 ` [PATCH 19/27] fs: port ->rename() " Christian Brauner
@ 2026-09-02 15:50 ` Jan Kara
0 siblings, 0 replies; 62+ messages in thread
From: Jan Kara @ 2026-09-02 15:50 UTC (permalink / raw)
To: Christian Brauner
Cc: linux-fsdevel, Alexander Viro, Jan Kara, Christoph Hellwig,
Seth Forshee, Paul Moore, linux-security-module, Mimi Zohar,
linux-integrity, Ilya Dryomov, ceph-devel, Carlos Maiolino,
linux-xfs, Miklos Szeredi, Amir Goldstein, linux-unionfs,
Namjae Jeon, linux-cifs, linux-kernel
On Tue 01-09-26 14:14:44, Christian Brauner wrote:
> Convert to const struct mnt_idmap.
>
> A mount's idmapping is immutable. The only thing that is allowed to be
> modified afterwards is the reference count and that is hidden behind
> mnt_idmap_get() and mnt_idmap_put(). Everything else only ever reads
> from the idmapping. This is the same model that struct cred uses and the
> idmapping is also rather sensitive.
>
> So make the idmap argument const wherever we can. The conversion is done
> from the bottom up so callers can continue to pass a non-const pointer
> to a const parameter until the conversion is finished.
>
> No functional changes.
>
> Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> Documentation/filesystems/locking.rst | 2 +-
> Documentation/filesystems/vfs.rst | 2 +-
> drivers/android/binder/rust_binderfs.c | 2 +-
> drivers/android/binderfs.c | 2 +-
> fs/9p/v9fs.h | 2 +-
> fs/9p/vfs_inode.c | 2 +-
> fs/affs/affs.h | 2 +-
> fs/affs/namei.c | 2 +-
> fs/afs/dir.c | 4 ++--
> fs/bad_inode.c | 2 +-
> fs/bfs/dir.c | 2 +-
> fs/btrfs/inode.c | 2 +-
> fs/ceph/dir.c | 2 +-
> fs/coda/dir.c | 2 +-
> fs/ecryptfs/inode.c | 2 +-
> fs/exfat/namei.c | 2 +-
> fs/ext2/namei.c | 2 +-
> fs/ext4/namei.c | 2 +-
> fs/f2fs/namei.c | 2 +-
> fs/fat/namei_msdos.c | 2 +-
> fs/fat/namei_vfat.c | 2 +-
> fs/fuse/dir.c | 2 +-
> fs/gfs2/inode.c | 2 +-
> fs/hfs/dir.c | 2 +-
> fs/hfsplus/dir.c | 2 +-
> fs/hostfs/hostfs_kern.c | 2 +-
> fs/hpfs/namei.c | 2 +-
> fs/jffs2/dir.c | 4 ++--
> fs/jfs/namei.c | 2 +-
> fs/kernfs/dir.c | 2 +-
> fs/libfs.c | 2 +-
> fs/minix/namei.c | 2 +-
> fs/nfs/dir.c | 2 +-
> fs/nfs/internal.h | 2 +-
> fs/nilfs2/namei.c | 2 +-
> fs/ntfs/namei.c | 2 +-
> fs/ntfs3/namei.c | 2 +-
> fs/ocfs2/namei.c | 2 +-
> fs/omfs/dir.c | 2 +-
> fs/orangefs/namei.c | 2 +-
> fs/overlayfs/dir.c | 2 +-
> fs/smb/client/cifsfs.h | 2 +-
> fs/smb/client/inode.c | 2 +-
> fs/ubifs/dir.c | 2 +-
> fs/udf/namei.c | 2 +-
> fs/ufs/namei.c | 2 +-
> fs/vboxsf/dir.c | 2 +-
> fs/xfs/xfs_iops.c | 2 +-
> include/linux/fs.h | 4 ++--
> mm/shmem.c | 2 +-
> 50 files changed, 53 insertions(+), 53 deletions(-)
>
> diff --git a/Documentation/filesystems/locking.rst b/Documentation/filesystems/locking.rst
> index 1cfdad9286d5..97f8aaff311e 100644
> --- a/Documentation/filesystems/locking.rst
> +++ b/Documentation/filesystems/locking.rst
> @@ -69,7 +69,7 @@ prototypes::
> struct dentry *(*mkdir) (struct mnt_idmap *, struct inode *,struct dentry *,umode_t);
> int (*rmdir) (struct inode *,struct dentry *);
> int (*mknod) (const struct mnt_idmap *, struct inode *,struct dentry *,umode_t,dev_t);
> - int (*rename) (struct mnt_idmap *, struct inode *, struct dentry *,
> + int (*rename) (const struct mnt_idmap *, struct inode *, struct dentry *,
> struct inode *, struct dentry *, unsigned int);
> int (*readlink) (struct dentry *, char __user *,int);
> const char *(*get_link) (struct dentry *, struct inode *, struct delayed_call *);
> diff --git a/Documentation/filesystems/vfs.rst b/Documentation/filesystems/vfs.rst
> index d7ab34e101eb..90f8a0b74249 100644
> --- a/Documentation/filesystems/vfs.rst
> +++ b/Documentation/filesystems/vfs.rst
> @@ -423,7 +423,7 @@ As of kernel 2.6.22, the following members are defined:
> struct dentry *(*mkdir) (struct mnt_idmap *, struct inode *,struct dentry *,umode_t);
> int (*rmdir) (struct inode *,struct dentry *);
> int (*mknod) (const struct mnt_idmap *, struct inode *,struct dentry *,umode_t,dev_t);
> - int (*rename) (struct mnt_idmap *, struct inode *, struct dentry *,
> + int (*rename) (const struct mnt_idmap *, struct inode *, struct dentry *,
> struct inode *, struct dentry *, unsigned int);
> int (*readlink) (struct dentry *, char __user *,int);
> const char *(*get_link) (struct dentry *, struct inode *,
> diff --git a/drivers/android/binder/rust_binderfs.c b/drivers/android/binder/rust_binderfs.c
> index 300cc65562d1..e98e6ca163df 100644
> --- a/drivers/android/binder/rust_binderfs.c
> +++ b/drivers/android/binder/rust_binderfs.c
> @@ -338,7 +338,7 @@ static inline bool is_binderfs_control_device(const struct dentry *dentry)
> return info->control_dentry == dentry;
> }
>
> -static int binderfs_rename(struct mnt_idmap *idmap,
> +static int binderfs_rename(const struct mnt_idmap *idmap,
> struct inode *old_dir, struct dentry *old_dentry,
> struct inode *new_dir, struct dentry *new_dentry,
> unsigned int flags)
> diff --git a/drivers/android/binderfs.c b/drivers/android/binderfs.c
> index 361d69f756f5..087eae6ca8ec 100644
> --- a/drivers/android/binderfs.c
> +++ b/drivers/android/binderfs.c
> @@ -344,7 +344,7 @@ static inline bool is_binderfs_control_device(const struct dentry *dentry)
> return info->control_dentry == dentry;
> }
>
> -static int binderfs_rename(struct mnt_idmap *idmap,
> +static int binderfs_rename(const struct mnt_idmap *idmap,
> struct inode *old_dir, struct dentry *old_dentry,
> struct inode *new_dir, struct dentry *new_dentry,
> unsigned int flags)
> diff --git a/fs/9p/v9fs.h b/fs/9p/v9fs.h
> index a462bcbfc7da..54a4a4ec5c15 100644
> --- a/fs/9p/v9fs.h
> +++ b/fs/9p/v9fs.h
> @@ -188,7 +188,7 @@ extern struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry,
> unsigned int flags);
> extern int v9fs_vfs_unlink(struct inode *i, struct dentry *d);
> extern int v9fs_vfs_rmdir(struct inode *i, struct dentry *d);
> -extern int v9fs_vfs_rename(struct mnt_idmap *idmap,
> +extern int v9fs_vfs_rename(const struct mnt_idmap *idmap,
> struct inode *old_dir, struct dentry *old_dentry,
> struct inode *new_dir, struct dentry *new_dentry,
> unsigned int flags);
> diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
> index 81fb5f8ec7e9..7d4d5a4481fa 100644
> --- a/fs/9p/vfs_inode.c
> +++ b/fs/9p/vfs_inode.c
> @@ -858,7 +858,7 @@ int v9fs_vfs_rmdir(struct inode *i, struct dentry *d)
> */
>
> int
> -v9fs_vfs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
> +v9fs_vfs_rename(const struct mnt_idmap *idmap, struct inode *old_dir,
> struct dentry *old_dentry, struct inode *new_dir,
> struct dentry *new_dentry, unsigned int flags)
> {
> diff --git a/fs/affs/affs.h b/fs/affs/affs.h
> index d1c506c1f310..a4b1e449aafc 100644
> --- a/fs/affs/affs.h
> +++ b/fs/affs/affs.h
> @@ -176,7 +176,7 @@ extern int affs_link(struct dentry *olddentry, struct inode *dir,
> extern int affs_symlink(struct mnt_idmap *idmap,
> struct inode *dir, struct dentry *dentry,
> const char *symname);
> -extern int affs_rename2(struct mnt_idmap *idmap,
> +extern int affs_rename2(const struct mnt_idmap *idmap,
> struct inode *old_dir, struct dentry *old_dentry,
> struct inode *new_dir, struct dentry *new_dentry,
> unsigned int flags);
> diff --git a/fs/affs/namei.c b/fs/affs/namei.c
> index 6cb52efafe5f..c9cc0ad5c330 100644
> --- a/fs/affs/namei.c
> +++ b/fs/affs/namei.c
> @@ -503,7 +503,7 @@ affs_xrename(struct inode *old_dir, struct dentry *old_dentry,
> return retval;
> }
>
> -int affs_rename2(struct mnt_idmap *idmap, struct inode *old_dir,
> +int affs_rename2(const struct mnt_idmap *idmap, struct inode *old_dir,
> struct dentry *old_dentry, struct inode *new_dir,
> struct dentry *new_dentry, unsigned int flags)
> {
> diff --git a/fs/afs/dir.c b/fs/afs/dir.c
> index 81565366d937..fee48c544c61 100644
> --- a/fs/afs/dir.c
> +++ b/fs/afs/dir.c
> @@ -43,7 +43,7 @@ static int afs_link(struct dentry *from, struct inode *dir,
> struct dentry *dentry);
> static int afs_symlink(struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, const char *content);
> -static int afs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
> +static int afs_rename(const struct mnt_idmap *idmap, struct inode *old_dir,
> struct dentry *old_dentry, struct inode *new_dir,
> struct dentry *new_dentry, unsigned int flags);
> static int afs_dir_writepages(struct address_space *mapping,
> @@ -2067,7 +2067,7 @@ static const struct afs_operation_ops afs_rename_exchange_operation = {
> /*
> * rename a file in an AFS filesystem and/or move it between directories
> */
> -static int afs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
> +static int afs_rename(const struct mnt_idmap *idmap, struct inode *old_dir,
> struct dentry *old_dentry, struct inode *new_dir,
> struct dentry *new_dentry, unsigned int flags)
> {
> diff --git a/fs/bad_inode.c b/fs/bad_inode.c
> index 9b7baf1367a6..c5c76e9dcf82 100644
> --- a/fs/bad_inode.c
> +++ b/fs/bad_inode.c
> @@ -75,7 +75,7 @@ static int bad_inode_mknod(const struct mnt_idmap *idmap, struct inode *dir,
> return -EIO;
> }
>
> -static int bad_inode_rename2(struct mnt_idmap *idmap,
> +static int bad_inode_rename2(const struct mnt_idmap *idmap,
> struct inode *old_dir, struct dentry *old_dentry,
> struct inode *new_dir, struct dentry *new_dentry,
> unsigned int flags)
> diff --git a/fs/bfs/dir.c b/fs/bfs/dir.c
> index 91a4871fa051..80534d04db9d 100644
> --- a/fs/bfs/dir.c
> +++ b/fs/bfs/dir.c
> @@ -199,7 +199,7 @@ static int bfs_unlink(struct inode *dir, struct dentry *dentry)
> return error;
> }
>
> -static int bfs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
> +static int bfs_rename(const struct mnt_idmap *idmap, struct inode *old_dir,
> struct dentry *old_dentry, struct inode *new_dir,
> struct dentry *new_dentry, unsigned int flags)
> {
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index 32b5648fdf81..e77c791f6efa 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -8835,7 +8835,7 @@ static int btrfs_rename(const struct mnt_idmap *idmap,
> return ret;
> }
>
> -static int btrfs_rename2(struct mnt_idmap *idmap, struct inode *old_dir,
> +static int btrfs_rename2(const struct mnt_idmap *idmap, struct inode *old_dir,
> struct dentry *old_dentry, struct inode *new_dir,
> struct dentry *new_dentry, unsigned int flags)
> {
> diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
> index 0f3c54dc97c6..864b6949fb9f 100644
> --- a/fs/ceph/dir.c
> +++ b/fs/ceph/dir.c
> @@ -1478,7 +1478,7 @@ static int ceph_unlink(struct inode *dir, struct dentry *dentry)
> return err;
> }
>
> -static int ceph_rename(struct mnt_idmap *idmap, struct inode *old_dir,
> +static int ceph_rename(const struct mnt_idmap *idmap, struct inode *old_dir,
> struct dentry *old_dentry, struct inode *new_dir,
> struct dentry *new_dentry, unsigned int flags)
> {
> diff --git a/fs/coda/dir.c b/fs/coda/dir.c
> index e8db5960b61b..a888a7ef30e5 100644
> --- a/fs/coda/dir.c
> +++ b/fs/coda/dir.c
> @@ -300,7 +300,7 @@ static int coda_rmdir(struct inode *dir, struct dentry *de)
> }
>
> /* rename */
> -static int coda_rename(struct mnt_idmap *idmap, struct inode *old_dir,
> +static int coda_rename(const struct mnt_idmap *idmap, struct inode *old_dir,
> struct dentry *old_dentry, struct inode *new_dir,
> struct dentry *new_dentry, unsigned int flags)
> {
> diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
> index 411aa024d4b8..7f5396e27752 100644
> --- a/fs/ecryptfs/inode.c
> +++ b/fs/ecryptfs/inode.c
> @@ -590,7 +590,7 @@ ecryptfs_mknod(const struct mnt_idmap *idmap, struct inode *dir,
> }
>
> static int
> -ecryptfs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
> +ecryptfs_rename(const struct mnt_idmap *idmap, struct inode *old_dir,
> struct dentry *old_dentry, struct inode *new_dir,
> struct dentry *new_dentry, unsigned int flags)
> {
> diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c
> index a4dc83b5949c..863a8c506fe8 100644
> --- a/fs/exfat/namei.c
> +++ b/fs/exfat/namei.c
> @@ -1263,7 +1263,7 @@ static int __exfat_rename(struct inode *old_parent_inode,
> return ret;
> }
>
> -static int exfat_rename(struct mnt_idmap *idmap,
> +static int exfat_rename(const struct mnt_idmap *idmap,
> struct inode *old_dir, struct dentry *old_dentry,
> struct inode *new_dir, struct dentry *new_dentry,
> unsigned int flags)
> diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c
> index f175b59cccd7..19e298533699 100644
> --- a/fs/ext2/namei.c
> +++ b/fs/ext2/namei.c
> @@ -316,7 +316,7 @@ static int ext2_rmdir (struct inode * dir, struct dentry *dentry)
> return err;
> }
>
> -static int ext2_rename (struct mnt_idmap * idmap,
> +static int ext2_rename (const struct mnt_idmap * idmap,
> struct inode * old_dir, struct dentry * old_dentry,
> struct inode * new_dir, struct dentry * new_dentry,
> unsigned int flags)
> diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
> index d7a58d82f320..1fbc2efe23ba 100644
> --- a/fs/ext4/namei.c
> +++ b/fs/ext4/namei.c
> @@ -4191,7 +4191,7 @@ static int ext4_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
> return retval;
> }
>
> -static int ext4_rename2(struct mnt_idmap *idmap,
> +static int ext4_rename2(const struct mnt_idmap *idmap,
> struct inode *old_dir, struct dentry *old_dentry,
> struct inode *new_dir, struct dentry *new_dentry,
> unsigned int flags)
> diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
> index 0773f64396f8..87b588b1d34f 100644
> --- a/fs/f2fs/namei.c
> +++ b/fs/f2fs/namei.c
> @@ -1341,7 +1341,7 @@ static int f2fs_cross_rename(struct inode *old_dir, struct dentry *old_dentry,
> return err;
> }
>
> -static int f2fs_rename2(struct mnt_idmap *idmap,
> +static int f2fs_rename2(const struct mnt_idmap *idmap,
> struct inode *old_dir, struct dentry *old_dentry,
> struct inode *new_dir, struct dentry *new_dentry,
> unsigned int flags)
> diff --git a/fs/fat/namei_msdos.c b/fs/fat/namei_msdos.c
> index d46d1a3851f2..1af607cf47cf 100644
> --- a/fs/fat/namei_msdos.c
> +++ b/fs/fat/namei_msdos.c
> @@ -600,7 +600,7 @@ static int do_msdos_rename(struct inode *old_dir, unsigned char *old_name,
> }
>
> /***** Rename, a wrapper for rename_same_dir & rename_diff_dir */
> -static int msdos_rename(struct mnt_idmap *idmap,
> +static int msdos_rename(const struct mnt_idmap *idmap,
> struct inode *old_dir, struct dentry *old_dentry,
> struct inode *new_dir, struct dentry *new_dentry,
> unsigned int flags)
> diff --git a/fs/fat/namei_vfat.c b/fs/fat/namei_vfat.c
> index da3e89c0b16a..d0b161f43a8b 100644
> --- a/fs/fat/namei_vfat.c
> +++ b/fs/fat/namei_vfat.c
> @@ -1160,7 +1160,7 @@ static int vfat_rename_exchange(struct inode *old_dir, struct dentry *old_dentry
> goto out;
> }
>
> -static int vfat_rename2(struct mnt_idmap *idmap, struct inode *old_dir,
> +static int vfat_rename2(const struct mnt_idmap *idmap, struct inode *old_dir,
> struct dentry *old_dentry, struct inode *new_dir,
> struct dentry *new_dentry, unsigned int flags)
> {
> diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
> index 3250598e06f2..51ff444dcf94 100644
> --- a/fs/fuse/dir.c
> +++ b/fs/fuse/dir.c
> @@ -1307,7 +1307,7 @@ static int fuse_rename_common(const struct mnt_idmap *idmap, struct inode *olddi
> return err;
> }
>
> -static int fuse_rename2(struct mnt_idmap *idmap, struct inode *olddir,
> +static int fuse_rename2(const struct mnt_idmap *idmap, struct inode *olddir,
> struct dentry *oldent, struct inode *newdir,
> struct dentry *newent, unsigned int flags)
> {
> diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
> index 733f74603eaf..0c00fef40af1 100644
> --- a/fs/gfs2/inode.c
> +++ b/fs/gfs2/inode.c
> @@ -1877,7 +1877,7 @@ static int gfs2_exchange(struct inode *odir, struct dentry *odentry,
> return error;
> }
>
> -static int gfs2_rename2(struct mnt_idmap *idmap, struct inode *odir,
> +static int gfs2_rename2(const struct mnt_idmap *idmap, struct inode *odir,
> struct dentry *odentry, struct inode *ndir,
> struct dentry *ndentry, unsigned int flags)
> {
> diff --git a/fs/hfs/dir.c b/fs/hfs/dir.c
> index e1f1fb351464..2958ca702be2 100644
> --- a/fs/hfs/dir.c
> +++ b/fs/hfs/dir.c
> @@ -281,7 +281,7 @@ static int hfs_remove(struct inode *dir, struct dentry *dentry)
> * new file/directory.
> * XXX: how do you handle must_be dir?
> */
> -static int hfs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
> +static int hfs_rename(const struct mnt_idmap *idmap, struct inode *old_dir,
> struct dentry *old_dentry, struct inode *new_dir,
> struct dentry *new_dentry, unsigned int flags)
> {
> diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c
> index 7d31211cee97..d26b87066bd0 100644
> --- a/fs/hfsplus/dir.c
> +++ b/fs/hfsplus/dir.c
> @@ -573,7 +573,7 @@ static struct dentry *hfsplus_mkdir(struct mnt_idmap *idmap, struct inode *dir,
> return ERR_PTR(hfsplus_mknod(&nop_mnt_idmap, dir, dentry, mode, 0));
> }
>
> -static int hfsplus_rename(struct mnt_idmap *idmap,
> +static int hfsplus_rename(const struct mnt_idmap *idmap,
> struct inode *old_dir, struct dentry *old_dentry,
> struct inode *new_dir, struct dentry *new_dentry,
> unsigned int flags)
> diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
> index 71d15396235a..9028c9f27730 100644
> --- a/fs/hostfs/hostfs_kern.c
> +++ b/fs/hostfs/hostfs_kern.c
> @@ -745,7 +745,7 @@ static int hostfs_mknod(const struct mnt_idmap *idmap, struct inode *dir,
> return 0;
> }
>
> -static int hostfs_rename2(struct mnt_idmap *idmap,
> +static int hostfs_rename2(const struct mnt_idmap *idmap,
> struct inode *old_dir, struct dentry *old_dentry,
> struct inode *new_dir, struct dentry *new_dentry,
> unsigned int flags)
> diff --git a/fs/hpfs/namei.c b/fs/hpfs/namei.c
> index ed749e1684d2..dfa8e5b7311f 100644
> --- a/fs/hpfs/namei.c
> +++ b/fs/hpfs/namei.c
> @@ -500,7 +500,7 @@ const struct address_space_operations hpfs_symlink_aops = {
> .read_folio = hpfs_symlink_read_folio
> };
>
> -static int hpfs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
> +static int hpfs_rename(const struct mnt_idmap *idmap, struct inode *old_dir,
> struct dentry *old_dentry, struct inode *new_dir,
> struct dentry *new_dentry, unsigned int flags)
> {
> diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c
> index 6d4b26d625c7..c56cd87a2a73 100644
> --- a/fs/jffs2/dir.c
> +++ b/fs/jffs2/dir.c
> @@ -38,7 +38,7 @@ static struct dentry *jffs2_mkdir (struct mnt_idmap *, struct inode *,struct den
> static int jffs2_rmdir (struct inode *,struct dentry *);
> static int jffs2_mknod (const struct mnt_idmap *, struct inode *,struct dentry *,
> umode_t,dev_t);
> -static int jffs2_rename (struct mnt_idmap *, struct inode *,
> +static int jffs2_rename (const struct mnt_idmap *, struct inode *,
> struct dentry *, struct inode *, struct dentry *,
> unsigned int);
>
> @@ -769,7 +769,7 @@ static int jffs2_mknod (const struct mnt_idmap *idmap, struct inode *dir_i,
> return ret;
> }
>
> -static int jffs2_rename (struct mnt_idmap *idmap,
> +static int jffs2_rename (const struct mnt_idmap *idmap,
> struct inode *old_dir_i, struct dentry *old_dentry,
> struct inode *new_dir_i, struct dentry *new_dentry,
> unsigned int flags)
> diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c
> index 82a5dbdaf93d..a384ced308af 100644
> --- a/fs/jfs/namei.c
> +++ b/fs/jfs/namei.c
> @@ -1066,7 +1066,7 @@ static int jfs_symlink(struct mnt_idmap *idmap, struct inode *dip,
> *
> * FUNCTION: rename a file or directory
> */
> -static int jfs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
> +static int jfs_rename(const struct mnt_idmap *idmap, struct inode *old_dir,
> struct dentry *old_dentry, struct inode *new_dir,
> struct dentry *new_dentry, unsigned int flags)
> {
> diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c
> index 82bbaeb326aa..d2e978e4ea6f 100644
> --- a/fs/kernfs/dir.c
> +++ b/fs/kernfs/dir.c
> @@ -1326,7 +1326,7 @@ static int kernfs_iop_rmdir(struct inode *dir, struct dentry *dentry)
> return ret;
> }
>
> -static int kernfs_iop_rename(struct mnt_idmap *idmap,
> +static int kernfs_iop_rename(const struct mnt_idmap *idmap,
> struct inode *old_dir, struct dentry *old_dentry,
> struct inode *new_dir, struct dentry *new_dentry,
> unsigned int flags)
> diff --git a/fs/libfs.c b/fs/libfs.c
> index 27d7dc16fcb0..8b379230b64f 100644
> --- a/fs/libfs.c
> +++ b/fs/libfs.c
> @@ -867,7 +867,7 @@ int simple_rename_exchange(struct inode *old_dir, struct dentry *old_dentry,
> }
> EXPORT_SYMBOL_GPL(simple_rename_exchange);
>
> -int simple_rename(struct mnt_idmap *idmap, struct inode *old_dir,
> +int simple_rename(const struct mnt_idmap *idmap, struct inode *old_dir,
> struct dentry *old_dentry, struct inode *new_dir,
> struct dentry *new_dentry, unsigned int flags)
> {
> diff --git a/fs/minix/namei.c b/fs/minix/namei.c
> index 57b3c2c5b688..f7aaa19eeac0 100644
> --- a/fs/minix/namei.c
> +++ b/fs/minix/namei.c
> @@ -187,7 +187,7 @@ static int minix_rmdir(struct inode * dir, struct dentry *dentry)
> return err;
> }
>
> -static int minix_rename(struct mnt_idmap *idmap,
> +static int minix_rename(const struct mnt_idmap *idmap,
> struct inode *old_dir, struct dentry *old_dentry,
> struct inode *new_dir, struct dentry *new_dentry,
> unsigned int flags)
> diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
> index 10c48672a79d..1161c809c9f1 100644
> --- a/fs/nfs/dir.c
> +++ b/fs/nfs/dir.c
> @@ -2771,7 +2771,7 @@ static bool nfs_rename_is_unsafe_cross_dir(struct dentry *old_dentry,
> * If these conditions are met, we can drop the dentries before doing
> * the rename.
> */
> -int nfs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
> +int nfs_rename(const struct mnt_idmap *idmap, struct inode *old_dir,
> struct dentry *old_dentry, struct inode *new_dir,
> struct dentry *new_dentry, unsigned int flags)
> {
> diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
> index ec37568d197b..c7928c16352d 100644
> --- a/fs/nfs/internal.h
> +++ b/fs/nfs/internal.h
> @@ -407,7 +407,7 @@ int nfs_symlink(struct mnt_idmap *, struct inode *, struct dentry *,
> int nfs_link(struct dentry *, struct inode *, struct dentry *);
> int nfs_mknod(const struct mnt_idmap *, struct inode *, struct dentry *, umode_t,
> dev_t);
> -int nfs_rename(struct mnt_idmap *, struct inode *, struct dentry *,
> +int nfs_rename(const struct mnt_idmap *, struct inode *, struct dentry *,
> struct inode *, struct dentry *, unsigned int);
>
> #ifdef CONFIG_NFS_V4_2
> diff --git a/fs/nilfs2/namei.c b/fs/nilfs2/namei.c
> index ea3df1d5ec29..bfc7c4a06743 100644
> --- a/fs/nilfs2/namei.c
> +++ b/fs/nilfs2/namei.c
> @@ -358,7 +358,7 @@ static int nilfs_rmdir(struct inode *dir, struct dentry *dentry)
> return err;
> }
>
> -static int nilfs_rename(struct mnt_idmap *idmap,
> +static int nilfs_rename(const struct mnt_idmap *idmap,
> struct inode *old_dir, struct dentry *old_dentry,
> struct inode *new_dir, struct dentry *new_dentry,
> unsigned int flags)
> diff --git a/fs/ntfs/namei.c b/fs/ntfs/namei.c
> index 82da5f14efa4..431ab27472ab 100644
> --- a/fs/ntfs/namei.c
> +++ b/fs/ntfs/namei.c
> @@ -1248,7 +1248,7 @@ static int __ntfs_link(struct ntfs_inode *ni, struct ntfs_inode *dir_ni,
> return err;
> }
>
> -static int ntfs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
> +static int ntfs_rename(const struct mnt_idmap *idmap, struct inode *old_dir,
> struct dentry *old_dentry, struct inode *new_dir,
> struct dentry *new_dentry, unsigned int flags)
> {
> diff --git a/fs/ntfs3/namei.c b/fs/ntfs3/namei.c
> index dfafadcd8fda..0d9c8bf79947 100644
> --- a/fs/ntfs3/namei.c
> +++ b/fs/ntfs3/namei.c
> @@ -262,7 +262,7 @@ static int ntfs_rmdir(struct inode *dir, struct dentry *dentry)
> /*
> * ntfs_rename - inode_operations::rename
> */
> -static int ntfs_rename(struct mnt_idmap *idmap, struct inode *dir,
> +static int ntfs_rename(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, struct inode *new_dir,
> struct dentry *new_dentry, u32 flags)
> {
> diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
> index 6cd77f295939..05c007213fab 100644
> --- a/fs/ocfs2/namei.c
> +++ b/fs/ocfs2/namei.c
> @@ -1211,7 +1211,7 @@ static void ocfs2_double_unlock(struct inode *inode1, struct inode *inode2)
> ocfs2_inode_unlock(inode2, 1);
> }
>
> -static int ocfs2_rename(struct mnt_idmap *idmap,
> +static int ocfs2_rename(const struct mnt_idmap *idmap,
> struct inode *old_dir,
> struct dentry *old_dentry,
> struct inode *new_dir,
> diff --git a/fs/omfs/dir.c b/fs/omfs/dir.c
> index 692297cf84e7..99e0a7c8e03b 100644
> --- a/fs/omfs/dir.c
> +++ b/fs/omfs/dir.c
> @@ -370,7 +370,7 @@ static bool omfs_fill_chain(struct inode *dir, struct dir_context *ctx,
> return true;
> }
>
> -static int omfs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
> +static int omfs_rename(const struct mnt_idmap *idmap, struct inode *old_dir,
> struct dentry *old_dentry, struct inode *new_dir,
> struct dentry *new_dentry, unsigned int flags)
> {
> diff --git a/fs/orangefs/namei.c b/fs/orangefs/namei.c
> index 8ebc34e112d5..40105ce80bb8 100644
> --- a/fs/orangefs/namei.c
> +++ b/fs/orangefs/namei.c
> @@ -364,7 +364,7 @@ static struct dentry *orangefs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
> return ret ? ERR_PTR(ret) : NULL;
> }
>
> -static int orangefs_rename(struct mnt_idmap *idmap,
> +static int orangefs_rename(const struct mnt_idmap *idmap,
> struct inode *old_dir,
> struct dentry *old_dentry,
> struct inode *new_dir,
> diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
> index 6d4b511dc3ca..cb2b5a8d28bd 100644
> --- a/fs/overlayfs/dir.c
> +++ b/fs/overlayfs/dir.c
> @@ -1344,7 +1344,7 @@ static void ovl_rename_end(struct ovl_renamedata *ovlrd)
> ovl_drop_write(ovlrd->old_dentry);
> }
>
> -static int ovl_rename(struct mnt_idmap *idmap, struct inode *olddir,
> +static int ovl_rename(const struct mnt_idmap *idmap, struct inode *olddir,
> struct dentry *old, struct inode *newdir,
> struct dentry *new, unsigned int flags)
> {
> diff --git a/fs/smb/client/cifsfs.h b/fs/smb/client/cifsfs.h
> index db7aebb8599e..e50edcbb2cd3 100644
> --- a/fs/smb/client/cifsfs.h
> +++ b/fs/smb/client/cifsfs.h
> @@ -69,7 +69,7 @@ int cifs_mknod(const struct mnt_idmap *idmap, struct inode *inode,
> struct dentry *cifs_mkdir(struct mnt_idmap *idmap, struct inode *inode,
> struct dentry *direntry, umode_t mode);
> int cifs_rmdir(struct inode *inode, struct dentry *direntry);
> -int cifs_rename2(struct mnt_idmap *idmap, struct inode *source_dir,
> +int cifs_rename2(const struct mnt_idmap *idmap, struct inode *source_dir,
> struct dentry *source_dentry, struct inode *target_dir,
> struct dentry *target_dentry, unsigned int flags);
> int cifs_revalidate_file_attr(struct file *filp);
> diff --git a/fs/smb/client/inode.c b/fs/smb/client/inode.c
> index 12ed8db10e00..eec3a46f6e41 100644
> --- a/fs/smb/client/inode.c
> +++ b/fs/smb/client/inode.c
> @@ -2526,7 +2526,7 @@ cifs_do_rename(const unsigned int xid, struct dentry *from_dentry,
> }
>
> int
> -cifs_rename2(struct mnt_idmap *idmap, struct inode *source_dir,
> +cifs_rename2(const struct mnt_idmap *idmap, struct inode *source_dir,
> struct dentry *source_dentry, struct inode *target_dir,
> struct dentry *target_dentry, unsigned int flags)
> {
> diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
> index 50068515f680..bff6489c4a5c 100644
> --- a/fs/ubifs/dir.c
> +++ b/fs/ubifs/dir.c
> @@ -1642,7 +1642,7 @@ static int ubifs_xrename(struct inode *old_dir, struct dentry *old_dentry,
> return err;
> }
>
> -static int ubifs_rename(struct mnt_idmap *idmap,
> +static int ubifs_rename(const struct mnt_idmap *idmap,
> struct inode *old_dir, struct dentry *old_dentry,
> struct inode *new_dir, struct dentry *new_dentry,
> unsigned int flags)
> diff --git a/fs/udf/namei.c b/fs/udf/namei.c
> index 4f7200e6046e..3fe746911581 100644
> --- a/fs/udf/namei.c
> +++ b/fs/udf/namei.c
> @@ -762,7 +762,7 @@ static int udf_link(struct dentry *old_dentry, struct inode *dir,
> /* Anybody can rename anything with this: the permission checks are left to the
> * higher-level routines.
> */
> -static int udf_rename(struct mnt_idmap *idmap, struct inode *old_dir,
> +static int udf_rename(const struct mnt_idmap *idmap, struct inode *old_dir,
> struct dentry *old_dentry, struct inode *new_dir,
> struct dentry *new_dentry, unsigned int flags)
> {
> diff --git a/fs/ufs/namei.c b/fs/ufs/namei.c
> index a38975b3885e..951c92d37d56 100644
> --- a/fs/ufs/namei.c
> +++ b/fs/ufs/namei.c
> @@ -240,7 +240,7 @@ static int ufs_rmdir (struct inode * dir, struct dentry *dentry)
> return err;
> }
>
> -static int ufs_rename(struct mnt_idmap *idmap, struct inode *old_dir,
> +static int ufs_rename(const struct mnt_idmap *idmap, struct inode *old_dir,
> struct dentry *old_dentry, struct inode *new_dir,
> struct dentry *new_dentry, unsigned int flags)
> {
> diff --git a/fs/vboxsf/dir.c b/fs/vboxsf/dir.c
> index 0b9eab157432..81b92c6cb201 100644
> --- a/fs/vboxsf/dir.c
> +++ b/fs/vboxsf/dir.c
> @@ -382,7 +382,7 @@ static int vboxsf_dir_unlink(struct inode *parent, struct dentry *dentry)
> return 0;
> }
>
> -static int vboxsf_dir_rename(struct mnt_idmap *idmap,
> +static int vboxsf_dir_rename(const struct mnt_idmap *idmap,
> struct inode *old_parent,
> struct dentry *old_dentry,
> struct inode *new_parent,
> diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
> index 13e57b0e7cae..26f9eb41599d 100644
> --- a/fs/xfs/xfs_iops.c
> +++ b/fs/xfs/xfs_iops.c
> @@ -466,7 +466,7 @@ xfs_vn_symlink(
>
> STATIC int
> xfs_vn_rename(
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct inode *odir,
> struct dentry *odentry,
> struct inode *ndir,
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 4ca59a110d17..2f2a0088e693 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -2010,7 +2010,7 @@ struct inode_operations {
> int (*rmdir) (struct inode *,struct dentry *);
> int (*mknod) (const struct mnt_idmap *, struct inode *,struct dentry *,
> umode_t,dev_t);
> - int (*rename) (struct mnt_idmap *, struct inode *, struct dentry *,
> + int (*rename) (const struct mnt_idmap *, struct inode *, struct dentry *,
> struct inode *, struct dentry *, unsigned int);
> int (*setattr) (struct mnt_idmap *, struct dentry *, struct iattr *);
> int (*getattr) (struct mnt_idmap *, const struct path *,
> @@ -3276,7 +3276,7 @@ void simple_rename_timestamp(struct inode *old_dir, struct dentry *old_dentry,
> struct inode *new_dir, struct dentry *new_dentry);
> extern int simple_rename_exchange(struct inode *old_dir, struct dentry *old_dentry,
> struct inode *new_dir, struct dentry *new_dentry);
> -extern int simple_rename(struct mnt_idmap *, struct inode *,
> +extern int simple_rename(const struct mnt_idmap *, struct inode *,
> struct dentry *, struct inode *, struct dentry *,
> unsigned int);
> extern void simple_recursive_removal(struct dentry *,
> diff --git a/mm/shmem.c b/mm/shmem.c
> index 16a4ea914bdb..ab5b2cd34c28 100644
> --- a/mm/shmem.c
> +++ b/mm/shmem.c
> @@ -3991,7 +3991,7 @@ static int shmem_whiteout(const struct mnt_idmap *idmap,
> * it exists so that the VFS layer correctly free's it when it
> * gets overwritten.
> */
> -static int shmem_rename2(struct mnt_idmap *idmap,
> +static int shmem_rename2(const struct mnt_idmap *idmap,
> struct inode *old_dir, struct dentry *old_dentry,
> struct inode *new_dir, struct dentry *new_dentry,
> unsigned int flags)
>
> --
> 2.53.0
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 62+ messages in thread
* [PATCH 20/27] fs: port ->mkdir() to pass const mnt_idmap
2026-09-01 12:14 [PATCH 00/27] fs: port to const struct mnt_idmap Christian Brauner
` (18 preceding siblings ...)
2026-09-01 12:14 ` [PATCH 19/27] fs: port ->rename() " Christian Brauner
@ 2026-09-01 12:14 ` Christian Brauner
2026-09-02 15:52 ` Jan Kara
2026-09-01 12:14 ` [PATCH 21/27] fs: port ->symlink() " Christian Brauner
` (6 subsequent siblings)
26 siblings, 1 reply; 62+ messages in thread
From: Christian Brauner @ 2026-09-01 12:14 UTC (permalink / raw)
To: linux-fsdevel
Cc: Alexander Viro, Jan Kara, Christoph Hellwig, Seth Forshee,
Paul Moore, linux-security-module, Mimi Zohar, linux-integrity,
Ilya Dryomov, ceph-devel, Carlos Maiolino, linux-xfs,
Miklos Szeredi, Amir Goldstein, linux-unionfs, Namjae Jeon,
linux-cifs, linux-kernel, Christian Brauner (Amutable)
Convert to const struct mnt_idmap.
A mount's idmapping is immutable. The only thing that is allowed to be
modified afterwards is the reference count and that is hidden behind
mnt_idmap_get() and mnt_idmap_put(). Everything else only ever reads
from the idmapping. This is the same model that struct cred uses and the
idmapping is also rather sensitive.
So make the idmap argument const wherever we can. The conversion is done
from the bottom up so callers can continue to pass a non-const pointer
to a const parameter until the conversion is finished.
No functional changes.
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
---
Documentation/filesystems/locking.rst | 2 +-
Documentation/filesystems/vfs.rst | 2 +-
fs/9p/vfs_inode.c | 2 +-
fs/9p/vfs_inode_dotl.c | 2 +-
fs/affs/affs.h | 2 +-
fs/affs/namei.c | 2 +-
fs/afs/dir.c | 4 ++--
fs/autofs/root.c | 4 ++--
fs/bad_inode.c | 2 +-
fs/btrfs/inode.c | 2 +-
fs/ceph/dir.c | 2 +-
fs/coda/dir.c | 2 +-
fs/configfs/dir.c | 2 +-
fs/ecryptfs/inode.c | 2 +-
fs/exfat/namei.c | 2 +-
fs/ext2/namei.c | 2 +-
fs/ext4/namei.c | 2 +-
fs/f2fs/namei.c | 2 +-
fs/fat/namei_msdos.c | 2 +-
fs/fat/namei_vfat.c | 2 +-
fs/fuse/dir.c | 2 +-
fs/gfs2/inode.c | 2 +-
fs/hfs/dir.c | 2 +-
fs/hfsplus/dir.c | 2 +-
fs/hostfs/hostfs_kern.c | 2 +-
fs/hpfs/namei.c | 2 +-
fs/hugetlbfs/inode.c | 2 +-
fs/jffs2/dir.c | 4 ++--
fs/jfs/namei.c | 2 +-
fs/kernfs/dir.c | 2 +-
fs/minix/namei.c | 2 +-
fs/nfs/dir.c | 2 +-
fs/nfs/internal.h | 2 +-
fs/nilfs2/namei.c | 2 +-
fs/ntfs/namei.c | 2 +-
fs/ntfs3/namei.c | 2 +-
fs/ocfs2/dlmfs/dlmfs.c | 2 +-
fs/ocfs2/namei.c | 2 +-
fs/omfs/dir.c | 2 +-
fs/orangefs/namei.c | 2 +-
fs/overlayfs/dir.c | 2 +-
fs/ramfs/inode.c | 2 +-
fs/smb/client/cifsfs.h | 2 +-
fs/smb/client/inode.c | 2 +-
fs/tracefs/inode.c | 2 +-
fs/ubifs/dir.c | 2 +-
fs/udf/namei.c | 2 +-
fs/ufs/namei.c | 2 +-
fs/vboxsf/dir.c | 2 +-
fs/xfs/xfs_iops.c | 2 +-
include/linux/fs.h | 2 +-
kernel/bpf/inode.c | 2 +-
mm/shmem.c | 2 +-
security/apparmor/apparmorfs.c | 2 +-
54 files changed, 57 insertions(+), 57 deletions(-)
diff --git a/Documentation/filesystems/locking.rst b/Documentation/filesystems/locking.rst
index 97f8aaff311e..e0851f1859b3 100644
--- a/Documentation/filesystems/locking.rst
+++ b/Documentation/filesystems/locking.rst
@@ -66,7 +66,7 @@ prototypes::
int (*link) (struct dentry *,struct inode *,struct dentry *);
int (*unlink) (struct inode *,struct dentry *);
int (*symlink) (struct mnt_idmap *, struct inode *,struct dentry *,const char *);
- struct dentry *(*mkdir) (struct mnt_idmap *, struct inode *,struct dentry *,umode_t);
+ struct dentry *(*mkdir) (const struct mnt_idmap *, struct inode *,struct dentry *,umode_t);
int (*rmdir) (struct inode *,struct dentry *);
int (*mknod) (const struct mnt_idmap *, struct inode *,struct dentry *,umode_t,dev_t);
int (*rename) (const struct mnt_idmap *, struct inode *, struct dentry *,
diff --git a/Documentation/filesystems/vfs.rst b/Documentation/filesystems/vfs.rst
index 90f8a0b74249..b16105a81cfe 100644
--- a/Documentation/filesystems/vfs.rst
+++ b/Documentation/filesystems/vfs.rst
@@ -420,7 +420,7 @@ As of kernel 2.6.22, the following members are defined:
int (*link) (struct dentry *,struct inode *,struct dentry *);
int (*unlink) (struct inode *,struct dentry *);
int (*symlink) (struct mnt_idmap *, struct inode *,struct dentry *,const char *);
- struct dentry *(*mkdir) (struct mnt_idmap *, struct inode *,struct dentry *,umode_t);
+ struct dentry *(*mkdir) (const struct mnt_idmap *, struct inode *,struct dentry *,umode_t);
int (*rmdir) (struct inode *,struct dentry *);
int (*mknod) (const struct mnt_idmap *, struct inode *,struct dentry *,umode_t,dev_t);
int (*rename) (const struct mnt_idmap *, struct inode *, struct dentry *,
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index 7d4d5a4481fa..a448e9a9a014 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -679,7 +679,7 @@ v9fs_vfs_create(struct mnt_idmap *idmap, struct inode *dir,
*
*/
-static struct dentry *v9fs_vfs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
+static struct dentry *v9fs_vfs_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
u32 perm;
diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c
index 634c4f5665c3..3c21006203d2 100644
--- a/fs/9p/vfs_inode_dotl.c
+++ b/fs/9p/vfs_inode_dotl.c
@@ -344,7 +344,7 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry,
*
*/
-static struct dentry *v9fs_vfs_mkdir_dotl(struct mnt_idmap *idmap,
+static struct dentry *v9fs_vfs_mkdir_dotl(const struct mnt_idmap *idmap,
struct inode *dir, struct dentry *dentry,
umode_t omode)
{
diff --git a/fs/affs/affs.h b/fs/affs/affs.h
index a4b1e449aafc..3dd795ce446e 100644
--- a/fs/affs/affs.h
+++ b/fs/affs/affs.h
@@ -168,7 +168,7 @@ extern struct dentry *affs_lookup(struct inode *dir, struct dentry *dentry, unsi
extern int affs_unlink(struct inode *dir, struct dentry *dentry);
extern int affs_create(struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode);
-extern struct dentry *affs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
+extern struct dentry *affs_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode);
extern int affs_rmdir(struct inode *dir, struct dentry *dentry);
extern int affs_link(struct dentry *olddentry, struct inode *dir,
diff --git a/fs/affs/namei.c b/fs/affs/namei.c
index c9cc0ad5c330..d17f0ba7c33c 100644
--- a/fs/affs/namei.c
+++ b/fs/affs/namei.c
@@ -274,7 +274,7 @@ affs_create(struct mnt_idmap *idmap, struct inode *dir,
}
struct dentry *
-affs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
+affs_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
struct inode *inode;
diff --git a/fs/afs/dir.c b/fs/afs/dir.c
index fee48c544c61..6a3cac50dc61 100644
--- a/fs/afs/dir.c
+++ b/fs/afs/dir.c
@@ -35,7 +35,7 @@ static bool afs_lookup_filldir(struct dir_context *ctx, const char *name, int nl
#define AFS_LOOKUP ((filldir_t)0x137UL)
static int afs_create(struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode);
-static struct dentry *afs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
+static struct dentry *afs_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode);
static int afs_rmdir(struct inode *dir, struct dentry *dentry);
static int afs_unlink(struct inode *dir, struct dentry *dentry);
@@ -1310,7 +1310,7 @@ static const struct afs_operation_ops afs_mkdir_operation = {
/*
* create a directory on an AFS filesystem
*/
-static struct dentry *afs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
+static struct dentry *afs_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
struct afs_operation *op;
diff --git a/fs/autofs/root.c b/fs/autofs/root.c
index 3158df448025..c6de44473d6d 100644
--- a/fs/autofs/root.c
+++ b/fs/autofs/root.c
@@ -16,7 +16,7 @@ static int autofs_dir_symlink(struct mnt_idmap *, struct inode *,
struct dentry *, const char *);
static int autofs_dir_unlink(struct inode *, struct dentry *);
static int autofs_dir_rmdir(struct inode *, struct dentry *);
-static struct dentry *autofs_dir_mkdir(struct mnt_idmap *, struct inode *,
+static struct dentry *autofs_dir_mkdir(const struct mnt_idmap *, struct inode *,
struct dentry *, umode_t);
static long autofs_root_ioctl(struct file *, unsigned int, unsigned long);
#ifdef CONFIG_COMPAT
@@ -724,7 +724,7 @@ static int autofs_dir_rmdir(struct inode *dir, struct dentry *dentry)
return 0;
}
-static struct dentry *autofs_dir_mkdir(struct mnt_idmap *idmap,
+static struct dentry *autofs_dir_mkdir(const struct mnt_idmap *idmap,
struct inode *dir, struct dentry *dentry,
umode_t mode)
{
diff --git a/fs/bad_inode.c b/fs/bad_inode.c
index c5c76e9dcf82..f0c56db22223 100644
--- a/fs/bad_inode.c
+++ b/fs/bad_inode.c
@@ -58,7 +58,7 @@ static int bad_inode_symlink(struct mnt_idmap *idmap,
return -EIO;
}
-static struct dentry *bad_inode_mkdir(struct mnt_idmap *idmap, struct inode *dir,
+static struct dentry *bad_inode_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
return ERR_PTR(-EIO);
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index e77c791f6efa..dc7e4b68410c 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -7115,7 +7115,7 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir,
return ret;
}
-static struct dentry *btrfs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
+static struct dentry *btrfs_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
struct inode *inode;
diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
index 864b6949fb9f..dd75d4c0a11e 100644
--- a/fs/ceph/dir.c
+++ b/fs/ceph/dir.c
@@ -1106,7 +1106,7 @@ static int ceph_symlink(struct mnt_idmap *idmap, struct inode *dir,
return err;
}
-static struct dentry *ceph_mkdir(struct mnt_idmap *idmap, struct inode *dir,
+static struct dentry *ceph_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(dir->i_sb);
diff --git a/fs/coda/dir.c b/fs/coda/dir.c
index a888a7ef30e5..3a2fa1e13ef8 100644
--- a/fs/coda/dir.c
+++ b/fs/coda/dir.c
@@ -166,7 +166,7 @@ static int coda_create(struct mnt_idmap *idmap, struct inode *dir,
return error;
}
-static struct dentry *coda_mkdir(struct mnt_idmap *idmap, struct inode *dir,
+static struct dentry *coda_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *de, umode_t mode)
{
struct inode *inode;
diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
index 3c88f13f1ca2..e0ca643db1ac 100644
--- a/fs/configfs/dir.c
+++ b/fs/configfs/dir.c
@@ -1286,7 +1286,7 @@ int configfs_depend_item_unlocked(struct configfs_subsystem *caller_subsys,
}
EXPORT_SYMBOL(configfs_depend_item_unlocked);
-static struct dentry *configfs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
+static struct dentry *configfs_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
int ret = 0;
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index 7f5396e27752..f5340d2b42f4 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -503,7 +503,7 @@ static int ecryptfs_symlink(struct mnt_idmap *idmap,
return rc;
}
-static struct dentry *ecryptfs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
+static struct dentry *ecryptfs_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
int rc;
diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c
index 863a8c506fe8..4accf96ea7f9 100644
--- a/fs/exfat/namei.c
+++ b/fs/exfat/namei.c
@@ -825,7 +825,7 @@ static int exfat_unlink(struct inode *dir, struct dentry *dentry)
return err;
}
-static struct dentry *exfat_mkdir(struct mnt_idmap *idmap, struct inode *dir,
+static struct dentry *exfat_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
struct super_block *sb = dir->i_sb;
diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c
index 19e298533699..0b66e7d37464 100644
--- a/fs/ext2/namei.c
+++ b/fs/ext2/namei.c
@@ -223,7 +223,7 @@ static int ext2_link (struct dentry * old_dentry, struct inode * dir,
return err;
}
-static struct dentry *ext2_mkdir(struct mnt_idmap * idmap,
+static struct dentry *ext2_mkdir(const struct mnt_idmap * idmap,
struct inode * dir, struct dentry * dentry,
umode_t mode)
{
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index 1fbc2efe23ba..4c0ce31c3ce8 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -2994,7 +2994,7 @@ int ext4_init_new_dir(handle_t *handle, struct inode *dir,
return err;
}
-static struct dentry *ext4_mkdir(struct mnt_idmap *idmap, struct inode *dir,
+static struct dentry *ext4_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
handle_t *handle;
diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
index 87b588b1d34f..c888f02d89fe 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -751,7 +751,7 @@ static int f2fs_symlink(struct mnt_idmap *idmap, struct inode *dir,
goto out;
}
-static struct dentry *f2fs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
+static struct dentry *f2fs_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
struct f2fs_sb_info *sbi = F2FS_I_SB(dir);
diff --git a/fs/fat/namei_msdos.c b/fs/fat/namei_msdos.c
index 1af607cf47cf..9ee899391f4f 100644
--- a/fs/fat/namei_msdos.c
+++ b/fs/fat/namei_msdos.c
@@ -345,7 +345,7 @@ static int msdos_rmdir(struct inode *dir, struct dentry *dentry)
}
/***** Make a directory */
-static struct dentry *msdos_mkdir(struct mnt_idmap *idmap, struct inode *dir,
+static struct dentry *msdos_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
struct super_block *sb = dir->i_sb;
diff --git a/fs/fat/namei_vfat.c b/fs/fat/namei_vfat.c
index d0b161f43a8b..a3f3320fe630 100644
--- a/fs/fat/namei_vfat.c
+++ b/fs/fat/namei_vfat.c
@@ -846,7 +846,7 @@ static int vfat_unlink(struct inode *dir, struct dentry *dentry)
return err;
}
-static struct dentry *vfat_mkdir(struct mnt_idmap *idmap, struct inode *dir,
+static struct dentry *vfat_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
struct super_block *sb = dir->i_sb;
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 51ff444dcf94..88da9010b0ce 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -1116,7 +1116,7 @@ static int fuse_tmpfile(const struct mnt_idmap *idmap, struct inode *dir,
return err;
}
-static struct dentry *fuse_mkdir(struct mnt_idmap *idmap, struct inode *dir,
+static struct dentry *fuse_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *entry, umode_t mode)
{
struct fuse_mkdir_in inarg;
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index 0c00fef40af1..6a1d405aa6e9 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -1345,7 +1345,7 @@ static int gfs2_symlink(struct mnt_idmap *idmap, struct inode *dir,
* Returns: the dentry, or ERR_PTR(errno)
*/
-static struct dentry *gfs2_mkdir(struct mnt_idmap *idmap, struct inode *dir,
+static struct dentry *gfs2_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
unsigned dsize = gfs2_max_stuffed_size(GFS2_I(dir));
diff --git a/fs/hfs/dir.c b/fs/hfs/dir.c
index 2958ca702be2..d60399c62e99 100644
--- a/fs/hfs/dir.c
+++ b/fs/hfs/dir.c
@@ -213,7 +213,7 @@ static int hfs_create(struct mnt_idmap *idmap, struct inode *dir,
* in a directory, given the inode for the parent directory and the
* name (and its length) of the new directory.
*/
-static struct dentry *hfs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
+static struct dentry *hfs_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
struct inode *inode;
diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c
index d26b87066bd0..651b9f73b567 100644
--- a/fs/hfsplus/dir.c
+++ b/fs/hfsplus/dir.c
@@ -567,7 +567,7 @@ static int hfsplus_create(struct mnt_idmap *idmap, struct inode *dir,
return hfsplus_mknod(&nop_mnt_idmap, dir, dentry, mode, 0);
}
-static struct dentry *hfsplus_mkdir(struct mnt_idmap *idmap, struct inode *dir,
+static struct dentry *hfsplus_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
return ERR_PTR(hfsplus_mknod(&nop_mnt_idmap, dir, dentry, mode, 0));
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
index 9028c9f27730..2eec9ebe1587 100644
--- a/fs/hostfs/hostfs_kern.c
+++ b/fs/hostfs/hostfs_kern.c
@@ -686,7 +686,7 @@ static int hostfs_symlink(struct mnt_idmap *idmap, struct inode *ino,
return err;
}
-static struct dentry *hostfs_mkdir(struct mnt_idmap *idmap, struct inode *ino,
+static struct dentry *hostfs_mkdir(const struct mnt_idmap *idmap, struct inode *ino,
struct dentry *dentry, umode_t mode)
{
struct inode *inode;
diff --git a/fs/hpfs/namei.c b/fs/hpfs/namei.c
index dfa8e5b7311f..280459b00e56 100644
--- a/fs/hpfs/namei.c
+++ b/fs/hpfs/namei.c
@@ -19,7 +19,7 @@ static void hpfs_update_directory_times(struct inode *dir)
hpfs_write_inode_nolock(dir);
}
-static struct dentry *hpfs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
+static struct dentry *hpfs_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
const unsigned char *name = dentry->d_name.name;
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 0c9cb8d953ab..6298a30e7343 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -967,7 +967,7 @@ static int hugetlbfs_mknod(const struct mnt_idmap *idmap, struct inode *dir,
return 0;
}
-static struct dentry *hugetlbfs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
+static struct dentry *hugetlbfs_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
int retval = hugetlbfs_mknod(idmap, dir, dentry,
diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c
index c56cd87a2a73..b4f808825738 100644
--- a/fs/jffs2/dir.c
+++ b/fs/jffs2/dir.c
@@ -33,7 +33,7 @@ static int jffs2_link (struct dentry *,struct inode *,struct dentry *);
static int jffs2_unlink (struct inode *,struct dentry *);
static int jffs2_symlink (struct mnt_idmap *, struct inode *,
struct dentry *, const char *);
-static struct dentry *jffs2_mkdir (struct mnt_idmap *, struct inode *,struct dentry *,
+static struct dentry *jffs2_mkdir (const struct mnt_idmap *, struct inode *,struct dentry *,
umode_t);
static int jffs2_rmdir (struct inode *,struct dentry *);
static int jffs2_mknod (const struct mnt_idmap *, struct inode *,struct dentry *,
@@ -448,7 +448,7 @@ static int jffs2_symlink (struct mnt_idmap *idmap, struct inode *dir_i,
}
-static struct dentry *jffs2_mkdir (struct mnt_idmap *idmap, struct inode *dir_i,
+static struct dentry *jffs2_mkdir (const struct mnt_idmap *idmap, struct inode *dir_i,
struct dentry *dentry, umode_t mode)
{
struct jffs2_inode_info *f, *dir_f;
diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c
index a384ced308af..305eb2cab105 100644
--- a/fs/jfs/namei.c
+++ b/fs/jfs/namei.c
@@ -193,7 +193,7 @@ static int jfs_create(struct mnt_idmap *idmap, struct inode *dip,
* note:
* EACCES: user needs search+write permission on the parent directory
*/
-static struct dentry *jfs_mkdir(struct mnt_idmap *idmap, struct inode *dip,
+static struct dentry *jfs_mkdir(const struct mnt_idmap *idmap, struct inode *dip,
struct dentry *dentry, umode_t mode)
{
int rc = 0;
diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c
index d2e978e4ea6f..943d6ee3e505 100644
--- a/fs/kernfs/dir.c
+++ b/fs/kernfs/dir.c
@@ -1288,7 +1288,7 @@ static struct dentry *kernfs_iop_lookup(struct inode *dir,
return d_splice_alias(inode, dentry);
}
-static struct dentry *kernfs_iop_mkdir(struct mnt_idmap *idmap,
+static struct dentry *kernfs_iop_mkdir(const struct mnt_idmap *idmap,
struct inode *dir, struct dentry *dentry,
umode_t mode)
{
diff --git a/fs/minix/namei.c b/fs/minix/namei.c
index f7aaa19eeac0..abf4575f24b1 100644
--- a/fs/minix/namei.c
+++ b/fs/minix/namei.c
@@ -104,7 +104,7 @@ static int minix_link(struct dentry * old_dentry, struct inode * dir,
return add_nondir(dentry, inode);
}
-static struct dentry *minix_mkdir(struct mnt_idmap *idmap, struct inode *dir,
+static struct dentry *minix_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
struct inode * inode;
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index 1161c809c9f1..dfa9dab7fdcc 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -2475,7 +2475,7 @@ EXPORT_SYMBOL_GPL(nfs_mknod);
/*
* See comments for nfs_proc_create regarding failed operations.
*/
-struct dentry *nfs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
+struct dentry *nfs_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
struct iattr attr;
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index c7928c16352d..da6db93b1730 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -398,7 +398,7 @@ struct dentry *nfs_lookup(struct inode *, struct dentry *, unsigned int);
void nfs_d_prune_case_insensitive_aliases(struct inode *inode);
int nfs_create(struct mnt_idmap *, struct inode *, struct dentry *,
umode_t);
-struct dentry *nfs_mkdir(struct mnt_idmap *, struct inode *, struct dentry *,
+struct dentry *nfs_mkdir(const struct mnt_idmap *, struct inode *, struct dentry *,
umode_t);
int nfs_rmdir(struct inode *, struct dentry *);
int nfs_unlink(struct inode *, struct dentry *);
diff --git a/fs/nilfs2/namei.c b/fs/nilfs2/namei.c
index bfc7c4a06743..b21fd2d8cb4a 100644
--- a/fs/nilfs2/namei.c
+++ b/fs/nilfs2/namei.c
@@ -218,7 +218,7 @@ static int nilfs_link(struct dentry *old_dentry, struct inode *dir,
return err;
}
-static struct dentry *nilfs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
+static struct dentry *nilfs_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
struct inode *inode;
diff --git a/fs/ntfs/namei.c b/fs/ntfs/namei.c
index 431ab27472ab..cbefeabe81b3 100644
--- a/fs/ntfs/namei.c
+++ b/fs/ntfs/namei.c
@@ -1049,7 +1049,7 @@ static int ntfs_unlink(struct inode *dir, struct dentry *dentry)
return err;
}
-static struct dentry *ntfs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
+static struct dentry *ntfs_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
struct super_block *sb = dir->i_sb;
diff --git a/fs/ntfs3/namei.c b/fs/ntfs3/namei.c
index 0d9c8bf79947..db02a2fb69c1 100644
--- a/fs/ntfs3/namei.c
+++ b/fs/ntfs3/namei.c
@@ -228,7 +228,7 @@ static int ntfs_symlink(struct mnt_idmap *idmap, struct inode *dir,
/*
* ntfs_mkdir - inode_operations::mkdir
*/
-static struct dentry *ntfs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
+static struct dentry *ntfs_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
return ERR_PTR(ntfs_create_inode(idmap, dir, dentry, NULL,
diff --git a/fs/ocfs2/dlmfs/dlmfs.c b/fs/ocfs2/dlmfs/dlmfs.c
index 53df5dd10ad0..5e544d8ded42 100644
--- a/fs/ocfs2/dlmfs/dlmfs.c
+++ b/fs/ocfs2/dlmfs/dlmfs.c
@@ -402,7 +402,7 @@ static struct inode *dlmfs_get_inode(struct inode *parent,
* File creation. Allocate an inode, and we're done..
*/
/* SMP-safe */
-static struct dentry *dlmfs_mkdir(struct mnt_idmap * idmap,
+static struct dentry *dlmfs_mkdir(const struct mnt_idmap * idmap,
struct inode * dir,
struct dentry * dentry,
umode_t mode)
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index 05c007213fab..89ac6fae34f8 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -655,7 +655,7 @@ static int ocfs2_mknod_locked(struct ocfs2_super *osb,
suballoc_loc, suballoc_bit);
}
-static struct dentry *ocfs2_mkdir(struct mnt_idmap *idmap,
+static struct dentry *ocfs2_mkdir(const struct mnt_idmap *idmap,
struct inode *dir,
struct dentry *dentry,
umode_t mode)
diff --git a/fs/omfs/dir.c b/fs/omfs/dir.c
index 99e0a7c8e03b..a476675e8e61 100644
--- a/fs/omfs/dir.c
+++ b/fs/omfs/dir.c
@@ -279,7 +279,7 @@ static int omfs_add_node(struct inode *dir, struct dentry *dentry, umode_t mode)
return err;
}
-static struct dentry *omfs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
+static struct dentry *omfs_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
return ERR_PTR(omfs_add_node(dir, dentry, mode));
diff --git a/fs/orangefs/namei.c b/fs/orangefs/namei.c
index 40105ce80bb8..749dfc0735a6 100644
--- a/fs/orangefs/namei.c
+++ b/fs/orangefs/namei.c
@@ -296,7 +296,7 @@ static int orangefs_symlink(struct mnt_idmap *idmap,
return ret;
}
-static struct dentry *orangefs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
+static struct dentry *orangefs_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
struct orangefs_inode_s *parent = ORANGEFS_I(dir);
diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
index cb2b5a8d28bd..6e206220a97f 100644
--- a/fs/overlayfs/dir.c
+++ b/fs/overlayfs/dir.c
@@ -736,7 +736,7 @@ static int ovl_create(struct mnt_idmap *idmap, struct inode *dir,
return ovl_create_object(idmap, dentry, (mode & 07777) | S_IFREG, 0, NULL);
}
-static struct dentry *ovl_mkdir(struct mnt_idmap *idmap, struct inode *dir,
+static struct dentry *ovl_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
return ERR_PTR(ovl_create_object(idmap, dentry, (mode & 07777) | S_IFDIR, 0, NULL));
diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c
index 5b09860dc69b..363093354a90 100644
--- a/fs/ramfs/inode.c
+++ b/fs/ramfs/inode.c
@@ -118,7 +118,7 @@ ramfs_mknod(const struct mnt_idmap *idmap, struct inode *dir,
return error;
}
-static struct dentry *ramfs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
+static struct dentry *ramfs_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
int retval = ramfs_mknod(&nop_mnt_idmap, dir, dentry, mode, 0);
diff --git a/fs/smb/client/cifsfs.h b/fs/smb/client/cifsfs.h
index e50edcbb2cd3..908f65001578 100644
--- a/fs/smb/client/cifsfs.h
+++ b/fs/smb/client/cifsfs.h
@@ -66,7 +66,7 @@ int cifs_hardlink(struct dentry *old_file, struct inode *inode,
struct dentry *direntry);
int cifs_mknod(const struct mnt_idmap *idmap, struct inode *inode,
struct dentry *direntry, umode_t mode, dev_t device_number);
-struct dentry *cifs_mkdir(struct mnt_idmap *idmap, struct inode *inode,
+struct dentry *cifs_mkdir(const struct mnt_idmap *idmap, struct inode *inode,
struct dentry *direntry, umode_t mode);
int cifs_rmdir(struct inode *inode, struct dentry *direntry);
int cifs_rename2(const struct mnt_idmap *idmap, struct inode *source_dir,
diff --git a/fs/smb/client/inode.c b/fs/smb/client/inode.c
index eec3a46f6e41..e3610e456bd4 100644
--- a/fs/smb/client/inode.c
+++ b/fs/smb/client/inode.c
@@ -2276,7 +2276,7 @@ cifs_posix_mkdir(struct inode *inode, struct dentry *dentry, umode_t mode,
}
#endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
-struct dentry *cifs_mkdir(struct mnt_idmap *idmap, struct inode *inode,
+struct dentry *cifs_mkdir(const struct mnt_idmap *idmap, struct inode *inode,
struct dentry *direntry, umode_t mode)
{
int rc = 0;
diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c
index 7cf32384ad50..995b8d0f8d33 100644
--- a/fs/tracefs/inode.c
+++ b/fs/tracefs/inode.c
@@ -94,7 +94,7 @@ static struct tracefs_dir_ops {
int (*rmdir)(const char *name);
} tracefs_ops __ro_after_init;
-static struct dentry *tracefs_syscall_mkdir(struct mnt_idmap *idmap,
+static struct dentry *tracefs_syscall_mkdir(const struct mnt_idmap *idmap,
struct inode *inode, struct dentry *dentry,
umode_t mode)
{
diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
index bff6489c4a5c..c7723f80e258 100644
--- a/fs/ubifs/dir.c
+++ b/fs/ubifs/dir.c
@@ -1002,7 +1002,7 @@ static int ubifs_rmdir(struct inode *dir, struct dentry *dentry)
return err;
}
-static struct dentry *ubifs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
+static struct dentry *ubifs_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
struct inode *inode;
diff --git a/fs/udf/namei.c b/fs/udf/namei.c
index 3fe746911581..7ee11e527377 100644
--- a/fs/udf/namei.c
+++ b/fs/udf/namei.c
@@ -419,7 +419,7 @@ static int udf_mknod(const struct mnt_idmap *idmap, struct inode *dir,
return udf_add_nondir(dentry, inode);
}
-static struct dentry *udf_mkdir(struct mnt_idmap *idmap, struct inode *dir,
+static struct dentry *udf_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
struct inode *inode;
diff --git a/fs/ufs/namei.c b/fs/ufs/namei.c
index 951c92d37d56..4aee6c3d0f75 100644
--- a/fs/ufs/namei.c
+++ b/fs/ufs/namei.c
@@ -165,7 +165,7 @@ static int ufs_link (struct dentry * old_dentry, struct inode * dir,
return error;
}
-static struct dentry *ufs_mkdir(struct mnt_idmap * idmap, struct inode * dir,
+static struct dentry *ufs_mkdir(const struct mnt_idmap * idmap, struct inode * dir,
struct dentry * dentry, umode_t mode)
{
struct inode * inode;
diff --git a/fs/vboxsf/dir.c b/fs/vboxsf/dir.c
index 81b92c6cb201..851e4be5eb0d 100644
--- a/fs/vboxsf/dir.c
+++ b/fs/vboxsf/dir.c
@@ -303,7 +303,7 @@ static int vboxsf_dir_mkfile(struct mnt_idmap *idmap,
return vboxsf_dir_create(parent, dentry, mode, false, true, NULL);
}
-static struct dentry *vboxsf_dir_mkdir(struct mnt_idmap *idmap,
+static struct dentry *vboxsf_dir_mkdir(const struct mnt_idmap *idmap,
struct inode *parent, struct dentry *dentry,
umode_t mode)
{
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index 26f9eb41599d..495c7f3dece0 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -300,7 +300,7 @@ xfs_vn_create(
STATIC struct dentry *
xfs_vn_mkdir(
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct inode *dir,
struct dentry *dentry,
umode_t mode)
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 2f2a0088e693..b02ae54727cb 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2005,7 +2005,7 @@ struct inode_operations {
int (*unlink) (struct inode *,struct dentry *);
int (*symlink) (struct mnt_idmap *, struct inode *,struct dentry *,
const char *);
- struct dentry *(*mkdir) (struct mnt_idmap *, struct inode *,
+ struct dentry *(*mkdir) (const struct mnt_idmap *, struct inode *,
struct dentry *, umode_t);
int (*rmdir) (struct inode *,struct dentry *);
int (*mknod) (const struct mnt_idmap *, struct inode *,struct dentry *,
diff --git a/kernel/bpf/inode.c b/kernel/bpf/inode.c
index 11174037a9ca..871825d36c8c 100644
--- a/kernel/bpf/inode.c
+++ b/kernel/bpf/inode.c
@@ -176,7 +176,7 @@ static void bpf_dentry_finalize(struct dentry *dentry, struct inode *inode,
inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir));
}
-static struct dentry *bpf_mkdir(struct mnt_idmap *idmap, struct inode *dir,
+static struct dentry *bpf_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
struct inode *inode;
diff --git a/mm/shmem.c b/mm/shmem.c
index ab5b2cd34c28..e76359582406 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -3885,7 +3885,7 @@ shmem_tmpfile(const struct mnt_idmap *idmap, struct inode *dir,
return error;
}
-static struct dentry *shmem_mkdir(struct mnt_idmap *idmap, struct inode *dir,
+static struct dentry *shmem_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
int error;
diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c
index 5b42140e12e8..d1386722537d 100644
--- a/security/apparmor/apparmorfs.c
+++ b/security/apparmor/apparmorfs.c
@@ -2073,7 +2073,7 @@ int __aafs_profile_mkdir(struct aa_profile *profile, struct dentry *parent)
return error;
}
-static struct dentry *ns_mkdir_op(struct mnt_idmap *idmap, struct inode *dir,
+static struct dentry *ns_mkdir_op(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
struct aa_ns *ns, *parent;
--
2.53.0
^ permalink raw reply related [flat|nested] 62+ messages in thread* Re: [PATCH 20/27] fs: port ->mkdir() to pass const mnt_idmap
2026-09-01 12:14 ` [PATCH 20/27] fs: port ->mkdir() " Christian Brauner
@ 2026-09-02 15:52 ` Jan Kara
0 siblings, 0 replies; 62+ messages in thread
From: Jan Kara @ 2026-09-02 15:52 UTC (permalink / raw)
To: Christian Brauner
Cc: linux-fsdevel, Alexander Viro, Jan Kara, Christoph Hellwig,
Seth Forshee, Paul Moore, linux-security-module, Mimi Zohar,
linux-integrity, Ilya Dryomov, ceph-devel, Carlos Maiolino,
linux-xfs, Miklos Szeredi, Amir Goldstein, linux-unionfs,
Namjae Jeon, linux-cifs, linux-kernel
On Tue 01-09-26 14:14:45, Christian Brauner wrote:
> Convert to const struct mnt_idmap.
>
> A mount's idmapping is immutable. The only thing that is allowed to be
> modified afterwards is the reference count and that is hidden behind
> mnt_idmap_get() and mnt_idmap_put(). Everything else only ever reads
> from the idmapping. This is the same model that struct cred uses and the
> idmapping is also rather sensitive.
>
> So make the idmap argument const wherever we can. The conversion is done
> from the bottom up so callers can continue to pass a non-const pointer
> to a const parameter until the conversion is finished.
>
> No functional changes.
>
> Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> Documentation/filesystems/locking.rst | 2 +-
> Documentation/filesystems/vfs.rst | 2 +-
> fs/9p/vfs_inode.c | 2 +-
> fs/9p/vfs_inode_dotl.c | 2 +-
> fs/affs/affs.h | 2 +-
> fs/affs/namei.c | 2 +-
> fs/afs/dir.c | 4 ++--
> fs/autofs/root.c | 4 ++--
> fs/bad_inode.c | 2 +-
> fs/btrfs/inode.c | 2 +-
> fs/ceph/dir.c | 2 +-
> fs/coda/dir.c | 2 +-
> fs/configfs/dir.c | 2 +-
> fs/ecryptfs/inode.c | 2 +-
> fs/exfat/namei.c | 2 +-
> fs/ext2/namei.c | 2 +-
> fs/ext4/namei.c | 2 +-
> fs/f2fs/namei.c | 2 +-
> fs/fat/namei_msdos.c | 2 +-
> fs/fat/namei_vfat.c | 2 +-
> fs/fuse/dir.c | 2 +-
> fs/gfs2/inode.c | 2 +-
> fs/hfs/dir.c | 2 +-
> fs/hfsplus/dir.c | 2 +-
> fs/hostfs/hostfs_kern.c | 2 +-
> fs/hpfs/namei.c | 2 +-
> fs/hugetlbfs/inode.c | 2 +-
> fs/jffs2/dir.c | 4 ++--
> fs/jfs/namei.c | 2 +-
> fs/kernfs/dir.c | 2 +-
> fs/minix/namei.c | 2 +-
> fs/nfs/dir.c | 2 +-
> fs/nfs/internal.h | 2 +-
> fs/nilfs2/namei.c | 2 +-
> fs/ntfs/namei.c | 2 +-
> fs/ntfs3/namei.c | 2 +-
> fs/ocfs2/dlmfs/dlmfs.c | 2 +-
> fs/ocfs2/namei.c | 2 +-
> fs/omfs/dir.c | 2 +-
> fs/orangefs/namei.c | 2 +-
> fs/overlayfs/dir.c | 2 +-
> fs/ramfs/inode.c | 2 +-
> fs/smb/client/cifsfs.h | 2 +-
> fs/smb/client/inode.c | 2 +-
> fs/tracefs/inode.c | 2 +-
> fs/ubifs/dir.c | 2 +-
> fs/udf/namei.c | 2 +-
> fs/ufs/namei.c | 2 +-
> fs/vboxsf/dir.c | 2 +-
> fs/xfs/xfs_iops.c | 2 +-
> include/linux/fs.h | 2 +-
> kernel/bpf/inode.c | 2 +-
> mm/shmem.c | 2 +-
> security/apparmor/apparmorfs.c | 2 +-
> 54 files changed, 57 insertions(+), 57 deletions(-)
>
> diff --git a/Documentation/filesystems/locking.rst b/Documentation/filesystems/locking.rst
> index 97f8aaff311e..e0851f1859b3 100644
> --- a/Documentation/filesystems/locking.rst
> +++ b/Documentation/filesystems/locking.rst
> @@ -66,7 +66,7 @@ prototypes::
> int (*link) (struct dentry *,struct inode *,struct dentry *);
> int (*unlink) (struct inode *,struct dentry *);
> int (*symlink) (struct mnt_idmap *, struct inode *,struct dentry *,const char *);
> - struct dentry *(*mkdir) (struct mnt_idmap *, struct inode *,struct dentry *,umode_t);
> + struct dentry *(*mkdir) (const struct mnt_idmap *, struct inode *,struct dentry *,umode_t);
> int (*rmdir) (struct inode *,struct dentry *);
> int (*mknod) (const struct mnt_idmap *, struct inode *,struct dentry *,umode_t,dev_t);
> int (*rename) (const struct mnt_idmap *, struct inode *, struct dentry *,
> diff --git a/Documentation/filesystems/vfs.rst b/Documentation/filesystems/vfs.rst
> index 90f8a0b74249..b16105a81cfe 100644
> --- a/Documentation/filesystems/vfs.rst
> +++ b/Documentation/filesystems/vfs.rst
> @@ -420,7 +420,7 @@ As of kernel 2.6.22, the following members are defined:
> int (*link) (struct dentry *,struct inode *,struct dentry *);
> int (*unlink) (struct inode *,struct dentry *);
> int (*symlink) (struct mnt_idmap *, struct inode *,struct dentry *,const char *);
> - struct dentry *(*mkdir) (struct mnt_idmap *, struct inode *,struct dentry *,umode_t);
> + struct dentry *(*mkdir) (const struct mnt_idmap *, struct inode *,struct dentry *,umode_t);
> int (*rmdir) (struct inode *,struct dentry *);
> int (*mknod) (const struct mnt_idmap *, struct inode *,struct dentry *,umode_t,dev_t);
> int (*rename) (const struct mnt_idmap *, struct inode *, struct dentry *,
> diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
> index 7d4d5a4481fa..a448e9a9a014 100644
> --- a/fs/9p/vfs_inode.c
> +++ b/fs/9p/vfs_inode.c
> @@ -679,7 +679,7 @@ v9fs_vfs_create(struct mnt_idmap *idmap, struct inode *dir,
> *
> */
>
> -static struct dentry *v9fs_vfs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
> +static struct dentry *v9fs_vfs_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> u32 perm;
> diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c
> index 634c4f5665c3..3c21006203d2 100644
> --- a/fs/9p/vfs_inode_dotl.c
> +++ b/fs/9p/vfs_inode_dotl.c
> @@ -344,7 +344,7 @@ v9fs_vfs_atomic_open_dotl(struct inode *dir, struct dentry *dentry,
> *
> */
>
> -static struct dentry *v9fs_vfs_mkdir_dotl(struct mnt_idmap *idmap,
> +static struct dentry *v9fs_vfs_mkdir_dotl(const struct mnt_idmap *idmap,
> struct inode *dir, struct dentry *dentry,
> umode_t omode)
> {
> diff --git a/fs/affs/affs.h b/fs/affs/affs.h
> index a4b1e449aafc..3dd795ce446e 100644
> --- a/fs/affs/affs.h
> +++ b/fs/affs/affs.h
> @@ -168,7 +168,7 @@ extern struct dentry *affs_lookup(struct inode *dir, struct dentry *dentry, unsi
> extern int affs_unlink(struct inode *dir, struct dentry *dentry);
> extern int affs_create(struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode);
> -extern struct dentry *affs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
> +extern struct dentry *affs_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode);
> extern int affs_rmdir(struct inode *dir, struct dentry *dentry);
> extern int affs_link(struct dentry *olddentry, struct inode *dir,
> diff --git a/fs/affs/namei.c b/fs/affs/namei.c
> index c9cc0ad5c330..d17f0ba7c33c 100644
> --- a/fs/affs/namei.c
> +++ b/fs/affs/namei.c
> @@ -274,7 +274,7 @@ affs_create(struct mnt_idmap *idmap, struct inode *dir,
> }
>
> struct dentry *
> -affs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
> +affs_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> struct inode *inode;
> diff --git a/fs/afs/dir.c b/fs/afs/dir.c
> index fee48c544c61..6a3cac50dc61 100644
> --- a/fs/afs/dir.c
> +++ b/fs/afs/dir.c
> @@ -35,7 +35,7 @@ static bool afs_lookup_filldir(struct dir_context *ctx, const char *name, int nl
> #define AFS_LOOKUP ((filldir_t)0x137UL)
> static int afs_create(struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode);
> -static struct dentry *afs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
> +static struct dentry *afs_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode);
> static int afs_rmdir(struct inode *dir, struct dentry *dentry);
> static int afs_unlink(struct inode *dir, struct dentry *dentry);
> @@ -1310,7 +1310,7 @@ static const struct afs_operation_ops afs_mkdir_operation = {
> /*
> * create a directory on an AFS filesystem
> */
> -static struct dentry *afs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
> +static struct dentry *afs_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> struct afs_operation *op;
> diff --git a/fs/autofs/root.c b/fs/autofs/root.c
> index 3158df448025..c6de44473d6d 100644
> --- a/fs/autofs/root.c
> +++ b/fs/autofs/root.c
> @@ -16,7 +16,7 @@ static int autofs_dir_symlink(struct mnt_idmap *, struct inode *,
> struct dentry *, const char *);
> static int autofs_dir_unlink(struct inode *, struct dentry *);
> static int autofs_dir_rmdir(struct inode *, struct dentry *);
> -static struct dentry *autofs_dir_mkdir(struct mnt_idmap *, struct inode *,
> +static struct dentry *autofs_dir_mkdir(const struct mnt_idmap *, struct inode *,
> struct dentry *, umode_t);
> static long autofs_root_ioctl(struct file *, unsigned int, unsigned long);
> #ifdef CONFIG_COMPAT
> @@ -724,7 +724,7 @@ static int autofs_dir_rmdir(struct inode *dir, struct dentry *dentry)
> return 0;
> }
>
> -static struct dentry *autofs_dir_mkdir(struct mnt_idmap *idmap,
> +static struct dentry *autofs_dir_mkdir(const struct mnt_idmap *idmap,
> struct inode *dir, struct dentry *dentry,
> umode_t mode)
> {
> diff --git a/fs/bad_inode.c b/fs/bad_inode.c
> index c5c76e9dcf82..f0c56db22223 100644
> --- a/fs/bad_inode.c
> +++ b/fs/bad_inode.c
> @@ -58,7 +58,7 @@ static int bad_inode_symlink(struct mnt_idmap *idmap,
> return -EIO;
> }
>
> -static struct dentry *bad_inode_mkdir(struct mnt_idmap *idmap, struct inode *dir,
> +static struct dentry *bad_inode_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> return ERR_PTR(-EIO);
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index e77c791f6efa..dc7e4b68410c 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -7115,7 +7115,7 @@ static int btrfs_link(struct dentry *old_dentry, struct inode *dir,
> return ret;
> }
>
> -static struct dentry *btrfs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
> +static struct dentry *btrfs_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> struct inode *inode;
> diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
> index 864b6949fb9f..dd75d4c0a11e 100644
> --- a/fs/ceph/dir.c
> +++ b/fs/ceph/dir.c
> @@ -1106,7 +1106,7 @@ static int ceph_symlink(struct mnt_idmap *idmap, struct inode *dir,
> return err;
> }
>
> -static struct dentry *ceph_mkdir(struct mnt_idmap *idmap, struct inode *dir,
> +static struct dentry *ceph_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(dir->i_sb);
> diff --git a/fs/coda/dir.c b/fs/coda/dir.c
> index a888a7ef30e5..3a2fa1e13ef8 100644
> --- a/fs/coda/dir.c
> +++ b/fs/coda/dir.c
> @@ -166,7 +166,7 @@ static int coda_create(struct mnt_idmap *idmap, struct inode *dir,
> return error;
> }
>
> -static struct dentry *coda_mkdir(struct mnt_idmap *idmap, struct inode *dir,
> +static struct dentry *coda_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *de, umode_t mode)
> {
> struct inode *inode;
> diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
> index 3c88f13f1ca2..e0ca643db1ac 100644
> --- a/fs/configfs/dir.c
> +++ b/fs/configfs/dir.c
> @@ -1286,7 +1286,7 @@ int configfs_depend_item_unlocked(struct configfs_subsystem *caller_subsys,
> }
> EXPORT_SYMBOL(configfs_depend_item_unlocked);
>
> -static struct dentry *configfs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
> +static struct dentry *configfs_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> int ret = 0;
> diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
> index 7f5396e27752..f5340d2b42f4 100644
> --- a/fs/ecryptfs/inode.c
> +++ b/fs/ecryptfs/inode.c
> @@ -503,7 +503,7 @@ static int ecryptfs_symlink(struct mnt_idmap *idmap,
> return rc;
> }
>
> -static struct dentry *ecryptfs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
> +static struct dentry *ecryptfs_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> int rc;
> diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c
> index 863a8c506fe8..4accf96ea7f9 100644
> --- a/fs/exfat/namei.c
> +++ b/fs/exfat/namei.c
> @@ -825,7 +825,7 @@ static int exfat_unlink(struct inode *dir, struct dentry *dentry)
> return err;
> }
>
> -static struct dentry *exfat_mkdir(struct mnt_idmap *idmap, struct inode *dir,
> +static struct dentry *exfat_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> struct super_block *sb = dir->i_sb;
> diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c
> index 19e298533699..0b66e7d37464 100644
> --- a/fs/ext2/namei.c
> +++ b/fs/ext2/namei.c
> @@ -223,7 +223,7 @@ static int ext2_link (struct dentry * old_dentry, struct inode * dir,
> return err;
> }
>
> -static struct dentry *ext2_mkdir(struct mnt_idmap * idmap,
> +static struct dentry *ext2_mkdir(const struct mnt_idmap * idmap,
> struct inode * dir, struct dentry * dentry,
> umode_t mode)
> {
> diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
> index 1fbc2efe23ba..4c0ce31c3ce8 100644
> --- a/fs/ext4/namei.c
> +++ b/fs/ext4/namei.c
> @@ -2994,7 +2994,7 @@ int ext4_init_new_dir(handle_t *handle, struct inode *dir,
> return err;
> }
>
> -static struct dentry *ext4_mkdir(struct mnt_idmap *idmap, struct inode *dir,
> +static struct dentry *ext4_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> handle_t *handle;
> diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
> index 87b588b1d34f..c888f02d89fe 100644
> --- a/fs/f2fs/namei.c
> +++ b/fs/f2fs/namei.c
> @@ -751,7 +751,7 @@ static int f2fs_symlink(struct mnt_idmap *idmap, struct inode *dir,
> goto out;
> }
>
> -static struct dentry *f2fs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
> +static struct dentry *f2fs_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> struct f2fs_sb_info *sbi = F2FS_I_SB(dir);
> diff --git a/fs/fat/namei_msdos.c b/fs/fat/namei_msdos.c
> index 1af607cf47cf..9ee899391f4f 100644
> --- a/fs/fat/namei_msdos.c
> +++ b/fs/fat/namei_msdos.c
> @@ -345,7 +345,7 @@ static int msdos_rmdir(struct inode *dir, struct dentry *dentry)
> }
>
> /***** Make a directory */
> -static struct dentry *msdos_mkdir(struct mnt_idmap *idmap, struct inode *dir,
> +static struct dentry *msdos_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> struct super_block *sb = dir->i_sb;
> diff --git a/fs/fat/namei_vfat.c b/fs/fat/namei_vfat.c
> index d0b161f43a8b..a3f3320fe630 100644
> --- a/fs/fat/namei_vfat.c
> +++ b/fs/fat/namei_vfat.c
> @@ -846,7 +846,7 @@ static int vfat_unlink(struct inode *dir, struct dentry *dentry)
> return err;
> }
>
> -static struct dentry *vfat_mkdir(struct mnt_idmap *idmap, struct inode *dir,
> +static struct dentry *vfat_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> struct super_block *sb = dir->i_sb;
> diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
> index 51ff444dcf94..88da9010b0ce 100644
> --- a/fs/fuse/dir.c
> +++ b/fs/fuse/dir.c
> @@ -1116,7 +1116,7 @@ static int fuse_tmpfile(const struct mnt_idmap *idmap, struct inode *dir,
> return err;
> }
>
> -static struct dentry *fuse_mkdir(struct mnt_idmap *idmap, struct inode *dir,
> +static struct dentry *fuse_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *entry, umode_t mode)
> {
> struct fuse_mkdir_in inarg;
> diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
> index 0c00fef40af1..6a1d405aa6e9 100644
> --- a/fs/gfs2/inode.c
> +++ b/fs/gfs2/inode.c
> @@ -1345,7 +1345,7 @@ static int gfs2_symlink(struct mnt_idmap *idmap, struct inode *dir,
> * Returns: the dentry, or ERR_PTR(errno)
> */
>
> -static struct dentry *gfs2_mkdir(struct mnt_idmap *idmap, struct inode *dir,
> +static struct dentry *gfs2_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> unsigned dsize = gfs2_max_stuffed_size(GFS2_I(dir));
> diff --git a/fs/hfs/dir.c b/fs/hfs/dir.c
> index 2958ca702be2..d60399c62e99 100644
> --- a/fs/hfs/dir.c
> +++ b/fs/hfs/dir.c
> @@ -213,7 +213,7 @@ static int hfs_create(struct mnt_idmap *idmap, struct inode *dir,
> * in a directory, given the inode for the parent directory and the
> * name (and its length) of the new directory.
> */
> -static struct dentry *hfs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
> +static struct dentry *hfs_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> struct inode *inode;
> diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c
> index d26b87066bd0..651b9f73b567 100644
> --- a/fs/hfsplus/dir.c
> +++ b/fs/hfsplus/dir.c
> @@ -567,7 +567,7 @@ static int hfsplus_create(struct mnt_idmap *idmap, struct inode *dir,
> return hfsplus_mknod(&nop_mnt_idmap, dir, dentry, mode, 0);
> }
>
> -static struct dentry *hfsplus_mkdir(struct mnt_idmap *idmap, struct inode *dir,
> +static struct dentry *hfsplus_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> return ERR_PTR(hfsplus_mknod(&nop_mnt_idmap, dir, dentry, mode, 0));
> diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
> index 9028c9f27730..2eec9ebe1587 100644
> --- a/fs/hostfs/hostfs_kern.c
> +++ b/fs/hostfs/hostfs_kern.c
> @@ -686,7 +686,7 @@ static int hostfs_symlink(struct mnt_idmap *idmap, struct inode *ino,
> return err;
> }
>
> -static struct dentry *hostfs_mkdir(struct mnt_idmap *idmap, struct inode *ino,
> +static struct dentry *hostfs_mkdir(const struct mnt_idmap *idmap, struct inode *ino,
> struct dentry *dentry, umode_t mode)
> {
> struct inode *inode;
> diff --git a/fs/hpfs/namei.c b/fs/hpfs/namei.c
> index dfa8e5b7311f..280459b00e56 100644
> --- a/fs/hpfs/namei.c
> +++ b/fs/hpfs/namei.c
> @@ -19,7 +19,7 @@ static void hpfs_update_directory_times(struct inode *dir)
> hpfs_write_inode_nolock(dir);
> }
>
> -static struct dentry *hpfs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
> +static struct dentry *hpfs_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> const unsigned char *name = dentry->d_name.name;
> diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
> index 0c9cb8d953ab..6298a30e7343 100644
> --- a/fs/hugetlbfs/inode.c
> +++ b/fs/hugetlbfs/inode.c
> @@ -967,7 +967,7 @@ static int hugetlbfs_mknod(const struct mnt_idmap *idmap, struct inode *dir,
> return 0;
> }
>
> -static struct dentry *hugetlbfs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
> +static struct dentry *hugetlbfs_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> int retval = hugetlbfs_mknod(idmap, dir, dentry,
> diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c
> index c56cd87a2a73..b4f808825738 100644
> --- a/fs/jffs2/dir.c
> +++ b/fs/jffs2/dir.c
> @@ -33,7 +33,7 @@ static int jffs2_link (struct dentry *,struct inode *,struct dentry *);
> static int jffs2_unlink (struct inode *,struct dentry *);
> static int jffs2_symlink (struct mnt_idmap *, struct inode *,
> struct dentry *, const char *);
> -static struct dentry *jffs2_mkdir (struct mnt_idmap *, struct inode *,struct dentry *,
> +static struct dentry *jffs2_mkdir (const struct mnt_idmap *, struct inode *,struct dentry *,
> umode_t);
> static int jffs2_rmdir (struct inode *,struct dentry *);
> static int jffs2_mknod (const struct mnt_idmap *, struct inode *,struct dentry *,
> @@ -448,7 +448,7 @@ static int jffs2_symlink (struct mnt_idmap *idmap, struct inode *dir_i,
> }
>
>
> -static struct dentry *jffs2_mkdir (struct mnt_idmap *idmap, struct inode *dir_i,
> +static struct dentry *jffs2_mkdir (const struct mnt_idmap *idmap, struct inode *dir_i,
> struct dentry *dentry, umode_t mode)
> {
> struct jffs2_inode_info *f, *dir_f;
> diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c
> index a384ced308af..305eb2cab105 100644
> --- a/fs/jfs/namei.c
> +++ b/fs/jfs/namei.c
> @@ -193,7 +193,7 @@ static int jfs_create(struct mnt_idmap *idmap, struct inode *dip,
> * note:
> * EACCES: user needs search+write permission on the parent directory
> */
> -static struct dentry *jfs_mkdir(struct mnt_idmap *idmap, struct inode *dip,
> +static struct dentry *jfs_mkdir(const struct mnt_idmap *idmap, struct inode *dip,
> struct dentry *dentry, umode_t mode)
> {
> int rc = 0;
> diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c
> index d2e978e4ea6f..943d6ee3e505 100644
> --- a/fs/kernfs/dir.c
> +++ b/fs/kernfs/dir.c
> @@ -1288,7 +1288,7 @@ static struct dentry *kernfs_iop_lookup(struct inode *dir,
> return d_splice_alias(inode, dentry);
> }
>
> -static struct dentry *kernfs_iop_mkdir(struct mnt_idmap *idmap,
> +static struct dentry *kernfs_iop_mkdir(const struct mnt_idmap *idmap,
> struct inode *dir, struct dentry *dentry,
> umode_t mode)
> {
> diff --git a/fs/minix/namei.c b/fs/minix/namei.c
> index f7aaa19eeac0..abf4575f24b1 100644
> --- a/fs/minix/namei.c
> +++ b/fs/minix/namei.c
> @@ -104,7 +104,7 @@ static int minix_link(struct dentry * old_dentry, struct inode * dir,
> return add_nondir(dentry, inode);
> }
>
> -static struct dentry *minix_mkdir(struct mnt_idmap *idmap, struct inode *dir,
> +static struct dentry *minix_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> struct inode * inode;
> diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
> index 1161c809c9f1..dfa9dab7fdcc 100644
> --- a/fs/nfs/dir.c
> +++ b/fs/nfs/dir.c
> @@ -2475,7 +2475,7 @@ EXPORT_SYMBOL_GPL(nfs_mknod);
> /*
> * See comments for nfs_proc_create regarding failed operations.
> */
> -struct dentry *nfs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
> +struct dentry *nfs_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> struct iattr attr;
> diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
> index c7928c16352d..da6db93b1730 100644
> --- a/fs/nfs/internal.h
> +++ b/fs/nfs/internal.h
> @@ -398,7 +398,7 @@ struct dentry *nfs_lookup(struct inode *, struct dentry *, unsigned int);
> void nfs_d_prune_case_insensitive_aliases(struct inode *inode);
> int nfs_create(struct mnt_idmap *, struct inode *, struct dentry *,
> umode_t);
> -struct dentry *nfs_mkdir(struct mnt_idmap *, struct inode *, struct dentry *,
> +struct dentry *nfs_mkdir(const struct mnt_idmap *, struct inode *, struct dentry *,
> umode_t);
> int nfs_rmdir(struct inode *, struct dentry *);
> int nfs_unlink(struct inode *, struct dentry *);
> diff --git a/fs/nilfs2/namei.c b/fs/nilfs2/namei.c
> index bfc7c4a06743..b21fd2d8cb4a 100644
> --- a/fs/nilfs2/namei.c
> +++ b/fs/nilfs2/namei.c
> @@ -218,7 +218,7 @@ static int nilfs_link(struct dentry *old_dentry, struct inode *dir,
> return err;
> }
>
> -static struct dentry *nilfs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
> +static struct dentry *nilfs_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> struct inode *inode;
> diff --git a/fs/ntfs/namei.c b/fs/ntfs/namei.c
> index 431ab27472ab..cbefeabe81b3 100644
> --- a/fs/ntfs/namei.c
> +++ b/fs/ntfs/namei.c
> @@ -1049,7 +1049,7 @@ static int ntfs_unlink(struct inode *dir, struct dentry *dentry)
> return err;
> }
>
> -static struct dentry *ntfs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
> +static struct dentry *ntfs_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> struct super_block *sb = dir->i_sb;
> diff --git a/fs/ntfs3/namei.c b/fs/ntfs3/namei.c
> index 0d9c8bf79947..db02a2fb69c1 100644
> --- a/fs/ntfs3/namei.c
> +++ b/fs/ntfs3/namei.c
> @@ -228,7 +228,7 @@ static int ntfs_symlink(struct mnt_idmap *idmap, struct inode *dir,
> /*
> * ntfs_mkdir - inode_operations::mkdir
> */
> -static struct dentry *ntfs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
> +static struct dentry *ntfs_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> return ERR_PTR(ntfs_create_inode(idmap, dir, dentry, NULL,
> diff --git a/fs/ocfs2/dlmfs/dlmfs.c b/fs/ocfs2/dlmfs/dlmfs.c
> index 53df5dd10ad0..5e544d8ded42 100644
> --- a/fs/ocfs2/dlmfs/dlmfs.c
> +++ b/fs/ocfs2/dlmfs/dlmfs.c
> @@ -402,7 +402,7 @@ static struct inode *dlmfs_get_inode(struct inode *parent,
> * File creation. Allocate an inode, and we're done..
> */
> /* SMP-safe */
> -static struct dentry *dlmfs_mkdir(struct mnt_idmap * idmap,
> +static struct dentry *dlmfs_mkdir(const struct mnt_idmap * idmap,
> struct inode * dir,
> struct dentry * dentry,
> umode_t mode)
> diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
> index 05c007213fab..89ac6fae34f8 100644
> --- a/fs/ocfs2/namei.c
> +++ b/fs/ocfs2/namei.c
> @@ -655,7 +655,7 @@ static int ocfs2_mknod_locked(struct ocfs2_super *osb,
> suballoc_loc, suballoc_bit);
> }
>
> -static struct dentry *ocfs2_mkdir(struct mnt_idmap *idmap,
> +static struct dentry *ocfs2_mkdir(const struct mnt_idmap *idmap,
> struct inode *dir,
> struct dentry *dentry,
> umode_t mode)
> diff --git a/fs/omfs/dir.c b/fs/omfs/dir.c
> index 99e0a7c8e03b..a476675e8e61 100644
> --- a/fs/omfs/dir.c
> +++ b/fs/omfs/dir.c
> @@ -279,7 +279,7 @@ static int omfs_add_node(struct inode *dir, struct dentry *dentry, umode_t mode)
> return err;
> }
>
> -static struct dentry *omfs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
> +static struct dentry *omfs_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> return ERR_PTR(omfs_add_node(dir, dentry, mode));
> diff --git a/fs/orangefs/namei.c b/fs/orangefs/namei.c
> index 40105ce80bb8..749dfc0735a6 100644
> --- a/fs/orangefs/namei.c
> +++ b/fs/orangefs/namei.c
> @@ -296,7 +296,7 @@ static int orangefs_symlink(struct mnt_idmap *idmap,
> return ret;
> }
>
> -static struct dentry *orangefs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
> +static struct dentry *orangefs_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> struct orangefs_inode_s *parent = ORANGEFS_I(dir);
> diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
> index cb2b5a8d28bd..6e206220a97f 100644
> --- a/fs/overlayfs/dir.c
> +++ b/fs/overlayfs/dir.c
> @@ -736,7 +736,7 @@ static int ovl_create(struct mnt_idmap *idmap, struct inode *dir,
> return ovl_create_object(idmap, dentry, (mode & 07777) | S_IFREG, 0, NULL);
> }
>
> -static struct dentry *ovl_mkdir(struct mnt_idmap *idmap, struct inode *dir,
> +static struct dentry *ovl_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> return ERR_PTR(ovl_create_object(idmap, dentry, (mode & 07777) | S_IFDIR, 0, NULL));
> diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c
> index 5b09860dc69b..363093354a90 100644
> --- a/fs/ramfs/inode.c
> +++ b/fs/ramfs/inode.c
> @@ -118,7 +118,7 @@ ramfs_mknod(const struct mnt_idmap *idmap, struct inode *dir,
> return error;
> }
>
> -static struct dentry *ramfs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
> +static struct dentry *ramfs_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> int retval = ramfs_mknod(&nop_mnt_idmap, dir, dentry, mode, 0);
> diff --git a/fs/smb/client/cifsfs.h b/fs/smb/client/cifsfs.h
> index e50edcbb2cd3..908f65001578 100644
> --- a/fs/smb/client/cifsfs.h
> +++ b/fs/smb/client/cifsfs.h
> @@ -66,7 +66,7 @@ int cifs_hardlink(struct dentry *old_file, struct inode *inode,
> struct dentry *direntry);
> int cifs_mknod(const struct mnt_idmap *idmap, struct inode *inode,
> struct dentry *direntry, umode_t mode, dev_t device_number);
> -struct dentry *cifs_mkdir(struct mnt_idmap *idmap, struct inode *inode,
> +struct dentry *cifs_mkdir(const struct mnt_idmap *idmap, struct inode *inode,
> struct dentry *direntry, umode_t mode);
> int cifs_rmdir(struct inode *inode, struct dentry *direntry);
> int cifs_rename2(const struct mnt_idmap *idmap, struct inode *source_dir,
> diff --git a/fs/smb/client/inode.c b/fs/smb/client/inode.c
> index eec3a46f6e41..e3610e456bd4 100644
> --- a/fs/smb/client/inode.c
> +++ b/fs/smb/client/inode.c
> @@ -2276,7 +2276,7 @@ cifs_posix_mkdir(struct inode *inode, struct dentry *dentry, umode_t mode,
> }
> #endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */
>
> -struct dentry *cifs_mkdir(struct mnt_idmap *idmap, struct inode *inode,
> +struct dentry *cifs_mkdir(const struct mnt_idmap *idmap, struct inode *inode,
> struct dentry *direntry, umode_t mode)
> {
> int rc = 0;
> diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c
> index 7cf32384ad50..995b8d0f8d33 100644
> --- a/fs/tracefs/inode.c
> +++ b/fs/tracefs/inode.c
> @@ -94,7 +94,7 @@ static struct tracefs_dir_ops {
> int (*rmdir)(const char *name);
> } tracefs_ops __ro_after_init;
>
> -static struct dentry *tracefs_syscall_mkdir(struct mnt_idmap *idmap,
> +static struct dentry *tracefs_syscall_mkdir(const struct mnt_idmap *idmap,
> struct inode *inode, struct dentry *dentry,
> umode_t mode)
> {
> diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
> index bff6489c4a5c..c7723f80e258 100644
> --- a/fs/ubifs/dir.c
> +++ b/fs/ubifs/dir.c
> @@ -1002,7 +1002,7 @@ static int ubifs_rmdir(struct inode *dir, struct dentry *dentry)
> return err;
> }
>
> -static struct dentry *ubifs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
> +static struct dentry *ubifs_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> struct inode *inode;
> diff --git a/fs/udf/namei.c b/fs/udf/namei.c
> index 3fe746911581..7ee11e527377 100644
> --- a/fs/udf/namei.c
> +++ b/fs/udf/namei.c
> @@ -419,7 +419,7 @@ static int udf_mknod(const struct mnt_idmap *idmap, struct inode *dir,
> return udf_add_nondir(dentry, inode);
> }
>
> -static struct dentry *udf_mkdir(struct mnt_idmap *idmap, struct inode *dir,
> +static struct dentry *udf_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> struct inode *inode;
> diff --git a/fs/ufs/namei.c b/fs/ufs/namei.c
> index 951c92d37d56..4aee6c3d0f75 100644
> --- a/fs/ufs/namei.c
> +++ b/fs/ufs/namei.c
> @@ -165,7 +165,7 @@ static int ufs_link (struct dentry * old_dentry, struct inode * dir,
> return error;
> }
>
> -static struct dentry *ufs_mkdir(struct mnt_idmap * idmap, struct inode * dir,
> +static struct dentry *ufs_mkdir(const struct mnt_idmap * idmap, struct inode * dir,
> struct dentry * dentry, umode_t mode)
> {
> struct inode * inode;
> diff --git a/fs/vboxsf/dir.c b/fs/vboxsf/dir.c
> index 81b92c6cb201..851e4be5eb0d 100644
> --- a/fs/vboxsf/dir.c
> +++ b/fs/vboxsf/dir.c
> @@ -303,7 +303,7 @@ static int vboxsf_dir_mkfile(struct mnt_idmap *idmap,
> return vboxsf_dir_create(parent, dentry, mode, false, true, NULL);
> }
>
> -static struct dentry *vboxsf_dir_mkdir(struct mnt_idmap *idmap,
> +static struct dentry *vboxsf_dir_mkdir(const struct mnt_idmap *idmap,
> struct inode *parent, struct dentry *dentry,
> umode_t mode)
> {
> diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
> index 26f9eb41599d..495c7f3dece0 100644
> --- a/fs/xfs/xfs_iops.c
> +++ b/fs/xfs/xfs_iops.c
> @@ -300,7 +300,7 @@ xfs_vn_create(
>
> STATIC struct dentry *
> xfs_vn_mkdir(
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct inode *dir,
> struct dentry *dentry,
> umode_t mode)
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 2f2a0088e693..b02ae54727cb 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -2005,7 +2005,7 @@ struct inode_operations {
> int (*unlink) (struct inode *,struct dentry *);
> int (*symlink) (struct mnt_idmap *, struct inode *,struct dentry *,
> const char *);
> - struct dentry *(*mkdir) (struct mnt_idmap *, struct inode *,
> + struct dentry *(*mkdir) (const struct mnt_idmap *, struct inode *,
> struct dentry *, umode_t);
> int (*rmdir) (struct inode *,struct dentry *);
> int (*mknod) (const struct mnt_idmap *, struct inode *,struct dentry *,
> diff --git a/kernel/bpf/inode.c b/kernel/bpf/inode.c
> index 11174037a9ca..871825d36c8c 100644
> --- a/kernel/bpf/inode.c
> +++ b/kernel/bpf/inode.c
> @@ -176,7 +176,7 @@ static void bpf_dentry_finalize(struct dentry *dentry, struct inode *inode,
> inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir));
> }
>
> -static struct dentry *bpf_mkdir(struct mnt_idmap *idmap, struct inode *dir,
> +static struct dentry *bpf_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> struct inode *inode;
> diff --git a/mm/shmem.c b/mm/shmem.c
> index ab5b2cd34c28..e76359582406 100644
> --- a/mm/shmem.c
> +++ b/mm/shmem.c
> @@ -3885,7 +3885,7 @@ shmem_tmpfile(const struct mnt_idmap *idmap, struct inode *dir,
> return error;
> }
>
> -static struct dentry *shmem_mkdir(struct mnt_idmap *idmap, struct inode *dir,
> +static struct dentry *shmem_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> int error;
> diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c
> index 5b42140e12e8..d1386722537d 100644
> --- a/security/apparmor/apparmorfs.c
> +++ b/security/apparmor/apparmorfs.c
> @@ -2073,7 +2073,7 @@ int __aafs_profile_mkdir(struct aa_profile *profile, struct dentry *parent)
> return error;
> }
>
> -static struct dentry *ns_mkdir_op(struct mnt_idmap *idmap, struct inode *dir,
> +static struct dentry *ns_mkdir_op(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> struct aa_ns *ns, *parent;
>
> --
> 2.53.0
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 62+ messages in thread
* [PATCH 21/27] fs: port ->symlink() to pass const mnt_idmap
2026-09-01 12:14 [PATCH 00/27] fs: port to const struct mnt_idmap Christian Brauner
` (19 preceding siblings ...)
2026-09-01 12:14 ` [PATCH 20/27] fs: port ->mkdir() " Christian Brauner
@ 2026-09-01 12:14 ` Christian Brauner
2026-09-02 15:53 ` Jan Kara
2026-09-01 12:14 ` [PATCH 22/27] fs: port ->create() " Christian Brauner
` (5 subsequent siblings)
26 siblings, 1 reply; 62+ messages in thread
From: Christian Brauner @ 2026-09-01 12:14 UTC (permalink / raw)
To: linux-fsdevel
Cc: Alexander Viro, Jan Kara, Christoph Hellwig, Seth Forshee,
Paul Moore, linux-security-module, Mimi Zohar, linux-integrity,
Ilya Dryomov, ceph-devel, Carlos Maiolino, linux-xfs,
Miklos Szeredi, Amir Goldstein, linux-unionfs, Namjae Jeon,
linux-cifs, linux-kernel, Christian Brauner (Amutable)
Convert to const struct mnt_idmap.
A mount's idmapping is immutable. The only thing that is allowed to be
modified afterwards is the reference count and that is hidden behind
mnt_idmap_get() and mnt_idmap_put(). Everything else only ever reads
from the idmapping. This is the same model that struct cred uses and the
idmapping is also rather sensitive.
So make the idmap argument const wherever we can. The conversion is done
from the bottom up so callers can continue to pass a non-const pointer
to a const parameter until the conversion is finished.
No functional changes.
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
---
Documentation/filesystems/locking.rst | 2 +-
Documentation/filesystems/vfs.rst | 2 +-
fs/9p/vfs_inode.c | 2 +-
fs/9p/vfs_inode_dotl.c | 2 +-
fs/affs/affs.h | 2 +-
fs/affs/namei.c | 2 +-
fs/afs/dir.c | 4 ++--
fs/autofs/root.c | 4 ++--
fs/bad_inode.c | 2 +-
fs/btrfs/inode.c | 2 +-
fs/ceph/dir.c | 2 +-
fs/coda/dir.c | 2 +-
fs/configfs/configfs_internal.h | 2 +-
fs/configfs/symlink.c | 2 +-
fs/ecryptfs/inode.c | 2 +-
fs/ext2/namei.c | 2 +-
fs/ext4/namei.c | 2 +-
fs/f2fs/namei.c | 2 +-
fs/fuse/dir.c | 2 +-
fs/gfs2/inode.c | 2 +-
fs/hfsplus/dir.c | 2 +-
fs/hostfs/hostfs_kern.c | 2 +-
fs/hpfs/namei.c | 2 +-
fs/hugetlbfs/inode.c | 2 +-
fs/jffs2/dir.c | 4 ++--
fs/jfs/namei.c | 2 +-
fs/minix/namei.c | 2 +-
fs/nfs/dir.c | 2 +-
fs/nfs/internal.h | 2 +-
fs/nilfs2/namei.c | 2 +-
fs/ntfs/namei.c | 2 +-
fs/ntfs3/namei.c | 2 +-
fs/ocfs2/namei.c | 2 +-
fs/orangefs/namei.c | 2 +-
fs/overlayfs/dir.c | 2 +-
fs/ramfs/inode.c | 2 +-
fs/smb/client/cifsfs.h | 2 +-
fs/smb/client/link.c | 2 +-
fs/ubifs/dir.c | 2 +-
fs/udf/namei.c | 2 +-
fs/ufs/namei.c | 2 +-
fs/vboxsf/dir.c | 2 +-
fs/xfs/xfs_iops.c | 2 +-
include/linux/fs.h | 2 +-
kernel/bpf/inode.c | 2 +-
mm/shmem.c | 2 +-
46 files changed, 49 insertions(+), 49 deletions(-)
diff --git a/Documentation/filesystems/locking.rst b/Documentation/filesystems/locking.rst
index e0851f1859b3..856b9cc88c76 100644
--- a/Documentation/filesystems/locking.rst
+++ b/Documentation/filesystems/locking.rst
@@ -65,7 +65,7 @@ prototypes::
struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
int (*link) (struct dentry *,struct inode *,struct dentry *);
int (*unlink) (struct inode *,struct dentry *);
- int (*symlink) (struct mnt_idmap *, struct inode *,struct dentry *,const char *);
+ int (*symlink) (const struct mnt_idmap *, struct inode *,struct dentry *,const char *);
struct dentry *(*mkdir) (const struct mnt_idmap *, struct inode *,struct dentry *,umode_t);
int (*rmdir) (struct inode *,struct dentry *);
int (*mknod) (const struct mnt_idmap *, struct inode *,struct dentry *,umode_t,dev_t);
diff --git a/Documentation/filesystems/vfs.rst b/Documentation/filesystems/vfs.rst
index b16105a81cfe..5a9203e98bb6 100644
--- a/Documentation/filesystems/vfs.rst
+++ b/Documentation/filesystems/vfs.rst
@@ -419,7 +419,7 @@ As of kernel 2.6.22, the following members are defined:
struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
int (*link) (struct dentry *,struct inode *,struct dentry *);
int (*unlink) (struct inode *,struct dentry *);
- int (*symlink) (struct mnt_idmap *, struct inode *,struct dentry *,const char *);
+ int (*symlink) (const struct mnt_idmap *, struct inode *,struct dentry *,const char *);
struct dentry *(*mkdir) (const struct mnt_idmap *, struct inode *,struct dentry *,umode_t);
int (*rmdir) (struct inode *,struct dentry *);
int (*mknod) (const struct mnt_idmap *, struct inode *,struct dentry *,umode_t,dev_t);
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index a448e9a9a014..cc52c244bb95 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -1249,7 +1249,7 @@ static int v9fs_vfs_mkspecial(struct inode *dir, struct dentry *dentry,
*/
static int
-v9fs_vfs_symlink(struct mnt_idmap *idmap, struct inode *dir,
+v9fs_vfs_symlink(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, const char *symname)
{
p9_debug(P9_DEBUG_VFS, " %llu,%pd,%s\n",
diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c
index 3c21006203d2..ec58718eec4a 100644
--- a/fs/9p/vfs_inode_dotl.c
+++ b/fs/9p/vfs_inode_dotl.c
@@ -682,7 +682,7 @@ v9fs_stat2inode_dotl(struct p9_stat_dotl *stat, struct inode *inode,
}
static int
-v9fs_vfs_symlink_dotl(struct mnt_idmap *idmap, struct inode *dir,
+v9fs_vfs_symlink_dotl(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, const char *symname)
{
int err;
diff --git a/fs/affs/affs.h b/fs/affs/affs.h
index 3dd795ce446e..b1047766a829 100644
--- a/fs/affs/affs.h
+++ b/fs/affs/affs.h
@@ -173,7 +173,7 @@ extern struct dentry *affs_mkdir(const struct mnt_idmap *idmap, struct inode *di
extern int affs_rmdir(struct inode *dir, struct dentry *dentry);
extern int affs_link(struct dentry *olddentry, struct inode *dir,
struct dentry *dentry);
-extern int affs_symlink(struct mnt_idmap *idmap,
+extern int affs_symlink(const struct mnt_idmap *idmap,
struct inode *dir, struct dentry *dentry,
const char *symname);
extern int affs_rename2(const struct mnt_idmap *idmap,
diff --git a/fs/affs/namei.c b/fs/affs/namei.c
index d17f0ba7c33c..1d609355fc3f 100644
--- a/fs/affs/namei.c
+++ b/fs/affs/namei.c
@@ -313,7 +313,7 @@ affs_rmdir(struct inode *dir, struct dentry *dentry)
}
int
-affs_symlink(struct mnt_idmap *idmap, struct inode *dir,
+affs_symlink(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, const char *symname)
{
struct super_block *sb = dir->i_sb;
diff --git a/fs/afs/dir.c b/fs/afs/dir.c
index 6a3cac50dc61..603dd9323ed2 100644
--- a/fs/afs/dir.c
+++ b/fs/afs/dir.c
@@ -41,7 +41,7 @@ static int afs_rmdir(struct inode *dir, struct dentry *dentry);
static int afs_unlink(struct inode *dir, struct dentry *dentry);
static int afs_link(struct dentry *from, struct inode *dir,
struct dentry *dentry);
-static int afs_symlink(struct mnt_idmap *idmap, struct inode *dir,
+static int afs_symlink(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, const char *content);
static int afs_rename(const struct mnt_idmap *idmap, struct inode *old_dir,
struct dentry *old_dentry, struct inode *new_dir,
@@ -1779,7 +1779,7 @@ static const struct afs_operation_ops afs_symlink_operation = {
/*
* create a symlink in an AFS filesystem
*/
-static int afs_symlink(struct mnt_idmap *idmap, struct inode *dir,
+static int afs_symlink(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, const char *content)
{
struct afs_operation *op;
diff --git a/fs/autofs/root.c b/fs/autofs/root.c
index c6de44473d6d..28f38f5d0236 100644
--- a/fs/autofs/root.c
+++ b/fs/autofs/root.c
@@ -12,7 +12,7 @@
#include "autofs_i.h"
static int autofs_dir_permission(const struct mnt_idmap *, struct inode *, int);
-static int autofs_dir_symlink(struct mnt_idmap *, struct inode *,
+static int autofs_dir_symlink(const struct mnt_idmap *, struct inode *,
struct dentry *, const char *);
static int autofs_dir_unlink(struct inode *, struct dentry *);
static int autofs_dir_rmdir(struct inode *, struct dentry *);
@@ -572,7 +572,7 @@ static int autofs_dir_permission(const struct mnt_idmap *idmap,
return generic_permission(idmap, inode, mask);
}
-static int autofs_dir_symlink(struct mnt_idmap *idmap,
+static int autofs_dir_symlink(const struct mnt_idmap *idmap,
struct inode *dir, struct dentry *dentry,
const char *symname)
{
diff --git a/fs/bad_inode.c b/fs/bad_inode.c
index f0c56db22223..096e6afb5e07 100644
--- a/fs/bad_inode.c
+++ b/fs/bad_inode.c
@@ -51,7 +51,7 @@ static int bad_inode_unlink(struct inode *dir, struct dentry *dentry)
return -EIO;
}
-static int bad_inode_symlink(struct mnt_idmap *idmap,
+static int bad_inode_symlink(const struct mnt_idmap *idmap,
struct inode *dir, struct dentry *dentry,
const char *symname)
{
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index dc7e4b68410c..9b5e3a67122d 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -9023,7 +9023,7 @@ int btrfs_start_delalloc_roots(struct btrfs_fs_info *fs_info, long nr,
return ret;
}
-static int btrfs_symlink(struct mnt_idmap *idmap, struct inode *dir,
+static int btrfs_symlink(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, const char *symname)
{
struct btrfs_fs_info *fs_info = inode_to_fs_info(dir);
diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
index dd75d4c0a11e..5417a9948e98 100644
--- a/fs/ceph/dir.c
+++ b/fs/ceph/dir.c
@@ -1032,7 +1032,7 @@ static int prep_encrypted_symlink_target(struct ceph_mds_request *req,
}
#endif
-static int ceph_symlink(struct mnt_idmap *idmap, struct inode *dir,
+static int ceph_symlink(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, const char *dest)
{
struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(dir->i_sb);
diff --git a/fs/coda/dir.c b/fs/coda/dir.c
index 3a2fa1e13ef8..02b8259b6a0e 100644
--- a/fs/coda/dir.c
+++ b/fs/coda/dir.c
@@ -233,7 +233,7 @@ static int coda_link(struct dentry *source_de, struct inode *dir_inode,
}
-static int coda_symlink(struct mnt_idmap *idmap,
+static int coda_symlink(const struct mnt_idmap *idmap,
struct inode *dir_inode, struct dentry *de,
const char *symname)
{
diff --git a/fs/configfs/configfs_internal.h b/fs/configfs/configfs_internal.h
index acdeea8e2d69..63d70dc05444 100644
--- a/fs/configfs/configfs_internal.h
+++ b/fs/configfs/configfs_internal.h
@@ -90,7 +90,7 @@ extern const struct inode_operations configfs_root_inode_operations;
extern const struct inode_operations configfs_symlink_inode_operations;
extern const struct dentry_operations configfs_dentry_ops;
-extern int configfs_symlink(struct mnt_idmap *idmap,
+extern int configfs_symlink(const struct mnt_idmap *idmap,
struct inode *dir, struct dentry *dentry,
const char *symname);
extern int configfs_unlink(struct inode *dir, struct dentry *dentry);
diff --git a/fs/configfs/symlink.c b/fs/configfs/symlink.c
index 31eb28b27309..a07c346817f5 100644
--- a/fs/configfs/symlink.c
+++ b/fs/configfs/symlink.c
@@ -132,7 +132,7 @@ static int get_target(const char *symname, struct config_item **target,
}
-int configfs_symlink(struct mnt_idmap *idmap, struct inode *dir,
+int configfs_symlink(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, const char *symname)
{
int ret;
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index f5340d2b42f4..f9a3c88c4fbd 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -462,7 +462,7 @@ static int ecryptfs_unlink(struct inode *dir, struct dentry *dentry)
return ecryptfs_do_unlink(dir, dentry, d_inode(dentry));
}
-static int ecryptfs_symlink(struct mnt_idmap *idmap,
+static int ecryptfs_symlink(const struct mnt_idmap *idmap,
struct inode *dir, struct dentry *dentry,
const char *symname)
{
diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c
index 0b66e7d37464..7da42f071eab 100644
--- a/fs/ext2/namei.c
+++ b/fs/ext2/namei.c
@@ -152,7 +152,7 @@ static int ext2_mknod (const struct mnt_idmap * idmap, struct inode * dir,
return err;
}
-static int ext2_symlink (struct mnt_idmap * idmap, struct inode * dir,
+static int ext2_symlink (const struct mnt_idmap * idmap, struct inode * dir,
struct dentry * dentry, const char * symname)
{
struct super_block * sb = dir->i_sb;
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index 4c0ce31c3ce8..6e493b4d205f 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -3360,7 +3360,7 @@ static int ext4_init_symlink_block(handle_t *handle, struct inode *inode,
return err;
}
-static int ext4_symlink(struct mnt_idmap *idmap, struct inode *dir,
+static int ext4_symlink(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, const char *symname)
{
handle_t *handle;
diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
index c888f02d89fe..b2e99822d8b4 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -662,7 +662,7 @@ static const char *f2fs_get_link(struct dentry *dentry,
return link;
}
-static int f2fs_symlink(struct mnt_idmap *idmap, struct inode *dir,
+static int f2fs_symlink(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, const char *symname)
{
struct f2fs_sb_info *sbi = F2FS_I_SB(dir);
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 88da9010b0ce..3d8246ff061e 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -1146,7 +1146,7 @@ static struct dentry *fuse_mkdir(const struct mnt_idmap *idmap, struct inode *di
return create_new_entry(idmap, fm, &args, dir, entry, S_IFDIR);
}
-static int fuse_symlink(struct mnt_idmap *idmap, struct inode *dir,
+static int fuse_symlink(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *entry, const char *link)
{
struct fuse_mount *fm = get_fuse_mount(dir);
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index 6a1d405aa6e9..c8f2b01e8cf5 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -1323,7 +1323,7 @@ static int gfs2_unlink(struct inode *dir, struct dentry *dentry)
* Returns: errno
*/
-static int gfs2_symlink(struct mnt_idmap *idmap, struct inode *dir,
+static int gfs2_symlink(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, const char *symname)
{
unsigned int size;
diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c
index 651b9f73b567..1b59ddb6d1e1 100644
--- a/fs/hfsplus/dir.c
+++ b/fs/hfsplus/dir.c
@@ -460,7 +460,7 @@ static int hfsplus_rmdir(struct inode *dir, struct dentry *dentry)
return res;
}
-static int hfsplus_symlink(struct mnt_idmap *idmap, struct inode *dir,
+static int hfsplus_symlink(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, const char *symname)
{
struct hfsplus_sb_info *sbi = HFSPLUS_SB(dir->i_sb);
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
index 2eec9ebe1587..ef03763aa074 100644
--- a/fs/hostfs/hostfs_kern.c
+++ b/fs/hostfs/hostfs_kern.c
@@ -673,7 +673,7 @@ static int hostfs_unlink(struct inode *ino, struct dentry *dentry)
return err;
}
-static int hostfs_symlink(struct mnt_idmap *idmap, struct inode *ino,
+static int hostfs_symlink(const struct mnt_idmap *idmap, struct inode *ino,
struct dentry *dentry, const char *to)
{
char *file;
diff --git a/fs/hpfs/namei.c b/fs/hpfs/namei.c
index 280459b00e56..44a7fb797633 100644
--- a/fs/hpfs/namei.c
+++ b/fs/hpfs/namei.c
@@ -289,7 +289,7 @@ static int hpfs_mknod(const struct mnt_idmap *idmap, struct inode *dir,
return err;
}
-static int hpfs_symlink(struct mnt_idmap *idmap, struct inode *dir,
+static int hpfs_symlink(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, const char *symlink)
{
const unsigned char *name = dentry->d_name.name;
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 6298a30e7343..9e937602b2ec 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -998,7 +998,7 @@ static int hugetlbfs_tmpfile(const struct mnt_idmap *idmap,
return finish_open_simple(file, 0);
}
-static int hugetlbfs_symlink(struct mnt_idmap *idmap,
+static int hugetlbfs_symlink(const struct mnt_idmap *idmap,
struct inode *dir, struct dentry *dentry,
const char *symname)
{
diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c
index b4f808825738..7d23be0bab72 100644
--- a/fs/jffs2/dir.c
+++ b/fs/jffs2/dir.c
@@ -31,7 +31,7 @@ static struct dentry *jffs2_lookup (struct inode *,struct dentry *,
unsigned int);
static int jffs2_link (struct dentry *,struct inode *,struct dentry *);
static int jffs2_unlink (struct inode *,struct dentry *);
-static int jffs2_symlink (struct mnt_idmap *, struct inode *,
+static int jffs2_symlink (const struct mnt_idmap *, struct inode *,
struct dentry *, const char *);
static struct dentry *jffs2_mkdir (const struct mnt_idmap *, struct inode *,struct dentry *,
umode_t);
@@ -284,7 +284,7 @@ static int jffs2_link (struct dentry *old_dentry, struct inode *dir_i, struct de
/***********************************************************************/
-static int jffs2_symlink (struct mnt_idmap *idmap, struct inode *dir_i,
+static int jffs2_symlink (const struct mnt_idmap *idmap, struct inode *dir_i,
struct dentry *dentry, const char *target)
{
struct jffs2_inode_info *f, *dir_f;
diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c
index 305eb2cab105..6009d65ab53f 100644
--- a/fs/jfs/namei.c
+++ b/fs/jfs/namei.c
@@ -876,7 +876,7 @@ static int jfs_link(struct dentry *old_dentry,
* an intermediate result whose length exceeds PATH_MAX [XPG4.2]
*/
-static int jfs_symlink(struct mnt_idmap *idmap, struct inode *dip,
+static int jfs_symlink(const struct mnt_idmap *idmap, struct inode *dip,
struct dentry *dentry, const char *name)
{
int rc;
diff --git a/fs/minix/namei.c b/fs/minix/namei.c
index abf4575f24b1..11b66a25e92b 100644
--- a/fs/minix/namei.c
+++ b/fs/minix/namei.c
@@ -69,7 +69,7 @@ static int minix_create(struct mnt_idmap *idmap, struct inode *dir,
return minix_mknod(&nop_mnt_idmap, dir, dentry, mode, 0);
}
-static int minix_symlink(struct mnt_idmap *idmap, struct inode *dir,
+static int minix_symlink(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, const char *symname)
{
int i = strlen(symname)+1;
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index dfa9dab7fdcc..a917c008a05a 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -2641,7 +2641,7 @@ EXPORT_SYMBOL_GPL(nfs_unlink);
* now have a new file handle and can instantiate an in-core NFS inode
* and move the raw page into its mapping.
*/
-int nfs_symlink(struct mnt_idmap *idmap, struct inode *dir,
+int nfs_symlink(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, const char *symname)
{
struct folio *folio;
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index da6db93b1730..4c966dac7f7d 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -402,7 +402,7 @@ struct dentry *nfs_mkdir(const struct mnt_idmap *, struct inode *, struct dentry
umode_t);
int nfs_rmdir(struct inode *, struct dentry *);
int nfs_unlink(struct inode *, struct dentry *);
-int nfs_symlink(struct mnt_idmap *, struct inode *, struct dentry *,
+int nfs_symlink(const struct mnt_idmap *, struct inode *, struct dentry *,
const char *);
int nfs_link(struct dentry *, struct inode *, struct dentry *);
int nfs_mknod(const struct mnt_idmap *, struct inode *, struct dentry *, umode_t,
diff --git a/fs/nilfs2/namei.c b/fs/nilfs2/namei.c
index b21fd2d8cb4a..8762fdc16c05 100644
--- a/fs/nilfs2/namei.c
+++ b/fs/nilfs2/namei.c
@@ -138,7 +138,7 @@ nilfs_mknod(const struct mnt_idmap *idmap, struct inode *dir,
return err;
}
-static int nilfs_symlink(struct mnt_idmap *idmap, struct inode *dir,
+static int nilfs_symlink(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, const char *symname)
{
struct nilfs_transaction_info ti;
diff --git a/fs/ntfs/namei.c b/fs/ntfs/namei.c
index cbefeabe81b3..637bc3690844 100644
--- a/fs/ntfs/namei.c
+++ b/fs/ntfs/namei.c
@@ -1399,7 +1399,7 @@ static int ntfs_rename(const struct mnt_idmap *idmap, struct inode *old_dir,
return err;
}
-static int ntfs_symlink(struct mnt_idmap *idmap, struct inode *dir,
+static int ntfs_symlink(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, const char *symname)
{
struct super_block *sb = dir->i_sb;
diff --git a/fs/ntfs3/namei.c b/fs/ntfs3/namei.c
index db02a2fb69c1..289796da6ba5 100644
--- a/fs/ntfs3/namei.c
+++ b/fs/ntfs3/namei.c
@@ -209,7 +209,7 @@ static int ntfs_unlink(struct inode *dir, struct dentry *dentry)
/*
* ntfs_symlink - inode_operations::symlink
*/
-static int ntfs_symlink(struct mnt_idmap *idmap, struct inode *dir,
+static int ntfs_symlink(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, const char *symname)
{
u32 size = strlen(symname);
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index 89ac6fae34f8..dfa2cb2bcb12 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -1815,7 +1815,7 @@ static int ocfs2_create_symlink_data(struct ocfs2_super *osb,
return status;
}
-static int ocfs2_symlink(struct mnt_idmap *idmap,
+static int ocfs2_symlink(const struct mnt_idmap *idmap,
struct inode *dir,
struct dentry *dentry,
const char *symname)
diff --git a/fs/orangefs/namei.c b/fs/orangefs/namei.c
index 749dfc0735a6..f5deb8cdbf2f 100644
--- a/fs/orangefs/namei.c
+++ b/fs/orangefs/namei.c
@@ -211,7 +211,7 @@ static int orangefs_unlink(struct inode *dir, struct dentry *dentry)
return ret;
}
-static int orangefs_symlink(struct mnt_idmap *idmap,
+static int orangefs_symlink(const struct mnt_idmap *idmap,
struct inode *dir,
struct dentry *dentry,
const char *symname)
diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
index 6e206220a97f..f7a3fd3a25b9 100644
--- a/fs/overlayfs/dir.c
+++ b/fs/overlayfs/dir.c
@@ -752,7 +752,7 @@ static int ovl_mknod(const struct mnt_idmap *idmap, struct inode *dir,
return ovl_create_object(idmap, dentry, mode, rdev, NULL);
}
-static int ovl_symlink(struct mnt_idmap *idmap, struct inode *dir,
+static int ovl_symlink(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, const char *link)
{
return ovl_create_object(idmap, dentry, S_IFLNK, 0, link);
diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c
index 363093354a90..cc06d806b214 100644
--- a/fs/ramfs/inode.c
+++ b/fs/ramfs/inode.c
@@ -133,7 +133,7 @@ static int ramfs_create(struct mnt_idmap *idmap, struct inode *dir,
return ramfs_mknod(&nop_mnt_idmap, dir, dentry, mode | S_IFREG, 0);
}
-static int ramfs_symlink(struct mnt_idmap *idmap, struct inode *dir,
+static int ramfs_symlink(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, const char *symname)
{
struct inode *inode;
diff --git a/fs/smb/client/cifsfs.h b/fs/smb/client/cifsfs.h
index 908f65001578..483d2b23fc23 100644
--- a/fs/smb/client/cifsfs.h
+++ b/fs/smb/client/cifsfs.h
@@ -129,7 +129,7 @@ struct vfsmount *cifs_d_automount(struct path *path);
/* Functions related to symlinks */
const char *cifs_get_link(struct dentry *dentry, struct inode *inode,
struct delayed_call *done);
-int cifs_symlink(struct mnt_idmap *idmap, struct inode *inode,
+int cifs_symlink(const struct mnt_idmap *idmap, struct inode *inode,
struct dentry *direntry, const char *symname);
#ifdef CONFIG_CIFS_XATTR
diff --git a/fs/smb/client/link.c b/fs/smb/client/link.c
index 8d5d6aca742a..76df31abeaea 100644
--- a/fs/smb/client/link.c
+++ b/fs/smb/client/link.c
@@ -533,7 +533,7 @@ cifs_hardlink(struct dentry *old_file, struct inode *inode,
}
int
-cifs_symlink(struct mnt_idmap *idmap, struct inode *inode,
+cifs_symlink(const struct mnt_idmap *idmap, struct inode *inode,
struct dentry *direntry, const char *symname)
{
struct cifs_sb_info *cifs_sb = CIFS_SB(inode);
diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
index c7723f80e258..d784283d427f 100644
--- a/fs/ubifs/dir.c
+++ b/fs/ubifs/dir.c
@@ -1170,7 +1170,7 @@ static int ubifs_mknod(const struct mnt_idmap *idmap, struct inode *dir,
return err;
}
-static int ubifs_symlink(struct mnt_idmap *idmap, struct inode *dir,
+static int ubifs_symlink(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, const char *symname)
{
struct inode *inode;
diff --git a/fs/udf/namei.c b/fs/udf/namei.c
index 7ee11e527377..002e79052f92 100644
--- a/fs/udf/namei.c
+++ b/fs/udf/namei.c
@@ -567,7 +567,7 @@ static int udf_unlink(struct inode *dir, struct dentry *dentry)
return ret;
}
-static int udf_symlink(struct mnt_idmap *idmap, struct inode *dir,
+static int udf_symlink(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, const char *symname)
{
struct inode *inode;
diff --git a/fs/ufs/namei.c b/fs/ufs/namei.c
index 4aee6c3d0f75..9231a5cda08e 100644
--- a/fs/ufs/namei.c
+++ b/fs/ufs/namei.c
@@ -105,7 +105,7 @@ static int ufs_mknod(const struct mnt_idmap *idmap, struct inode *dir,
return err;
}
-static int ufs_symlink (struct mnt_idmap * idmap, struct inode * dir,
+static int ufs_symlink (const struct mnt_idmap * idmap, struct inode * dir,
struct dentry * dentry, const char * symname)
{
struct super_block * sb = dir->i_sb;
diff --git a/fs/vboxsf/dir.c b/fs/vboxsf/dir.c
index 851e4be5eb0d..9db16e90f670 100644
--- a/fs/vboxsf/dir.c
+++ b/fs/vboxsf/dir.c
@@ -425,7 +425,7 @@ static int vboxsf_dir_rename(const struct mnt_idmap *idmap,
return err;
}
-static int vboxsf_dir_symlink(struct mnt_idmap *idmap,
+static int vboxsf_dir_symlink(const struct mnt_idmap *idmap,
struct inode *parent, struct dentry *dentry,
const char *symname)
{
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index 495c7f3dece0..fe388619a138 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -425,7 +425,7 @@ xfs_vn_unlink(
STATIC int
xfs_vn_symlink(
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct inode *dir,
struct dentry *dentry,
const char *symname)
diff --git a/include/linux/fs.h b/include/linux/fs.h
index b02ae54727cb..f2c7838644c3 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2003,7 +2003,7 @@ struct inode_operations {
umode_t);
int (*link) (struct dentry *,struct inode *,struct dentry *);
int (*unlink) (struct inode *,struct dentry *);
- int (*symlink) (struct mnt_idmap *, struct inode *,struct dentry *,
+ int (*symlink) (const struct mnt_idmap *, struct inode *,struct dentry *,
const char *);
struct dentry *(*mkdir) (const struct mnt_idmap *, struct inode *,
struct dentry *, umode_t);
diff --git a/kernel/bpf/inode.c b/kernel/bpf/inode.c
index 871825d36c8c..c6f328e4752e 100644
--- a/kernel/bpf/inode.c
+++ b/kernel/bpf/inode.c
@@ -424,7 +424,7 @@ bpf_lookup(struct inode *dir, struct dentry *dentry, unsigned flags)
return simple_lookup(dir, dentry, flags);
}
-static int bpf_symlink(struct mnt_idmap *idmap, struct inode *dir,
+static int bpf_symlink(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, const char *target)
{
struct inode *inode;
diff --git a/mm/shmem.c b/mm/shmem.c
index e76359582406..f633af032a08 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -4047,7 +4047,7 @@ static int shmem_rename2(const struct mnt_idmap *idmap,
return 0;
}
-static int shmem_symlink(struct mnt_idmap *idmap, struct inode *dir,
+static int shmem_symlink(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, const char *symname)
{
int error;
--
2.53.0
^ permalink raw reply related [flat|nested] 62+ messages in thread* Re: [PATCH 21/27] fs: port ->symlink() to pass const mnt_idmap
2026-09-01 12:14 ` [PATCH 21/27] fs: port ->symlink() " Christian Brauner
@ 2026-09-02 15:53 ` Jan Kara
0 siblings, 0 replies; 62+ messages in thread
From: Jan Kara @ 2026-09-02 15:53 UTC (permalink / raw)
To: Christian Brauner
Cc: linux-fsdevel, Alexander Viro, Jan Kara, Christoph Hellwig,
Seth Forshee, Paul Moore, linux-security-module, Mimi Zohar,
linux-integrity, Ilya Dryomov, ceph-devel, Carlos Maiolino,
linux-xfs, Miklos Szeredi, Amir Goldstein, linux-unionfs,
Namjae Jeon, linux-cifs, linux-kernel
On Tue 01-09-26 14:14:46, Christian Brauner wrote:
> Convert to const struct mnt_idmap.
>
> A mount's idmapping is immutable. The only thing that is allowed to be
> modified afterwards is the reference count and that is hidden behind
> mnt_idmap_get() and mnt_idmap_put(). Everything else only ever reads
> from the idmapping. This is the same model that struct cred uses and the
> idmapping is also rather sensitive.
>
> So make the idmap argument const wherever we can. The conversion is done
> from the bottom up so callers can continue to pass a non-const pointer
> to a const parameter until the conversion is finished.
>
> No functional changes.
>
> Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> Documentation/filesystems/locking.rst | 2 +-
> Documentation/filesystems/vfs.rst | 2 +-
> fs/9p/vfs_inode.c | 2 +-
> fs/9p/vfs_inode_dotl.c | 2 +-
> fs/affs/affs.h | 2 +-
> fs/affs/namei.c | 2 +-
> fs/afs/dir.c | 4 ++--
> fs/autofs/root.c | 4 ++--
> fs/bad_inode.c | 2 +-
> fs/btrfs/inode.c | 2 +-
> fs/ceph/dir.c | 2 +-
> fs/coda/dir.c | 2 +-
> fs/configfs/configfs_internal.h | 2 +-
> fs/configfs/symlink.c | 2 +-
> fs/ecryptfs/inode.c | 2 +-
> fs/ext2/namei.c | 2 +-
> fs/ext4/namei.c | 2 +-
> fs/f2fs/namei.c | 2 +-
> fs/fuse/dir.c | 2 +-
> fs/gfs2/inode.c | 2 +-
> fs/hfsplus/dir.c | 2 +-
> fs/hostfs/hostfs_kern.c | 2 +-
> fs/hpfs/namei.c | 2 +-
> fs/hugetlbfs/inode.c | 2 +-
> fs/jffs2/dir.c | 4 ++--
> fs/jfs/namei.c | 2 +-
> fs/minix/namei.c | 2 +-
> fs/nfs/dir.c | 2 +-
> fs/nfs/internal.h | 2 +-
> fs/nilfs2/namei.c | 2 +-
> fs/ntfs/namei.c | 2 +-
> fs/ntfs3/namei.c | 2 +-
> fs/ocfs2/namei.c | 2 +-
> fs/orangefs/namei.c | 2 +-
> fs/overlayfs/dir.c | 2 +-
> fs/ramfs/inode.c | 2 +-
> fs/smb/client/cifsfs.h | 2 +-
> fs/smb/client/link.c | 2 +-
> fs/ubifs/dir.c | 2 +-
> fs/udf/namei.c | 2 +-
> fs/ufs/namei.c | 2 +-
> fs/vboxsf/dir.c | 2 +-
> fs/xfs/xfs_iops.c | 2 +-
> include/linux/fs.h | 2 +-
> kernel/bpf/inode.c | 2 +-
> mm/shmem.c | 2 +-
> 46 files changed, 49 insertions(+), 49 deletions(-)
>
> diff --git a/Documentation/filesystems/locking.rst b/Documentation/filesystems/locking.rst
> index e0851f1859b3..856b9cc88c76 100644
> --- a/Documentation/filesystems/locking.rst
> +++ b/Documentation/filesystems/locking.rst
> @@ -65,7 +65,7 @@ prototypes::
> struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
> int (*link) (struct dentry *,struct inode *,struct dentry *);
> int (*unlink) (struct inode *,struct dentry *);
> - int (*symlink) (struct mnt_idmap *, struct inode *,struct dentry *,const char *);
> + int (*symlink) (const struct mnt_idmap *, struct inode *,struct dentry *,const char *);
> struct dentry *(*mkdir) (const struct mnt_idmap *, struct inode *,struct dentry *,umode_t);
> int (*rmdir) (struct inode *,struct dentry *);
> int (*mknod) (const struct mnt_idmap *, struct inode *,struct dentry *,umode_t,dev_t);
> diff --git a/Documentation/filesystems/vfs.rst b/Documentation/filesystems/vfs.rst
> index b16105a81cfe..5a9203e98bb6 100644
> --- a/Documentation/filesystems/vfs.rst
> +++ b/Documentation/filesystems/vfs.rst
> @@ -419,7 +419,7 @@ As of kernel 2.6.22, the following members are defined:
> struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
> int (*link) (struct dentry *,struct inode *,struct dentry *);
> int (*unlink) (struct inode *,struct dentry *);
> - int (*symlink) (struct mnt_idmap *, struct inode *,struct dentry *,const char *);
> + int (*symlink) (const struct mnt_idmap *, struct inode *,struct dentry *,const char *);
> struct dentry *(*mkdir) (const struct mnt_idmap *, struct inode *,struct dentry *,umode_t);
> int (*rmdir) (struct inode *,struct dentry *);
> int (*mknod) (const struct mnt_idmap *, struct inode *,struct dentry *,umode_t,dev_t);
> diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
> index a448e9a9a014..cc52c244bb95 100644
> --- a/fs/9p/vfs_inode.c
> +++ b/fs/9p/vfs_inode.c
> @@ -1249,7 +1249,7 @@ static int v9fs_vfs_mkspecial(struct inode *dir, struct dentry *dentry,
> */
>
> static int
> -v9fs_vfs_symlink(struct mnt_idmap *idmap, struct inode *dir,
> +v9fs_vfs_symlink(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, const char *symname)
> {
> p9_debug(P9_DEBUG_VFS, " %llu,%pd,%s\n",
> diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c
> index 3c21006203d2..ec58718eec4a 100644
> --- a/fs/9p/vfs_inode_dotl.c
> +++ b/fs/9p/vfs_inode_dotl.c
> @@ -682,7 +682,7 @@ v9fs_stat2inode_dotl(struct p9_stat_dotl *stat, struct inode *inode,
> }
>
> static int
> -v9fs_vfs_symlink_dotl(struct mnt_idmap *idmap, struct inode *dir,
> +v9fs_vfs_symlink_dotl(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, const char *symname)
> {
> int err;
> diff --git a/fs/affs/affs.h b/fs/affs/affs.h
> index 3dd795ce446e..b1047766a829 100644
> --- a/fs/affs/affs.h
> +++ b/fs/affs/affs.h
> @@ -173,7 +173,7 @@ extern struct dentry *affs_mkdir(const struct mnt_idmap *idmap, struct inode *di
> extern int affs_rmdir(struct inode *dir, struct dentry *dentry);
> extern int affs_link(struct dentry *olddentry, struct inode *dir,
> struct dentry *dentry);
> -extern int affs_symlink(struct mnt_idmap *idmap,
> +extern int affs_symlink(const struct mnt_idmap *idmap,
> struct inode *dir, struct dentry *dentry,
> const char *symname);
> extern int affs_rename2(const struct mnt_idmap *idmap,
> diff --git a/fs/affs/namei.c b/fs/affs/namei.c
> index d17f0ba7c33c..1d609355fc3f 100644
> --- a/fs/affs/namei.c
> +++ b/fs/affs/namei.c
> @@ -313,7 +313,7 @@ affs_rmdir(struct inode *dir, struct dentry *dentry)
> }
>
> int
> -affs_symlink(struct mnt_idmap *idmap, struct inode *dir,
> +affs_symlink(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, const char *symname)
> {
> struct super_block *sb = dir->i_sb;
> diff --git a/fs/afs/dir.c b/fs/afs/dir.c
> index 6a3cac50dc61..603dd9323ed2 100644
> --- a/fs/afs/dir.c
> +++ b/fs/afs/dir.c
> @@ -41,7 +41,7 @@ static int afs_rmdir(struct inode *dir, struct dentry *dentry);
> static int afs_unlink(struct inode *dir, struct dentry *dentry);
> static int afs_link(struct dentry *from, struct inode *dir,
> struct dentry *dentry);
> -static int afs_symlink(struct mnt_idmap *idmap, struct inode *dir,
> +static int afs_symlink(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, const char *content);
> static int afs_rename(const struct mnt_idmap *idmap, struct inode *old_dir,
> struct dentry *old_dentry, struct inode *new_dir,
> @@ -1779,7 +1779,7 @@ static const struct afs_operation_ops afs_symlink_operation = {
> /*
> * create a symlink in an AFS filesystem
> */
> -static int afs_symlink(struct mnt_idmap *idmap, struct inode *dir,
> +static int afs_symlink(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, const char *content)
> {
> struct afs_operation *op;
> diff --git a/fs/autofs/root.c b/fs/autofs/root.c
> index c6de44473d6d..28f38f5d0236 100644
> --- a/fs/autofs/root.c
> +++ b/fs/autofs/root.c
> @@ -12,7 +12,7 @@
> #include "autofs_i.h"
>
> static int autofs_dir_permission(const struct mnt_idmap *, struct inode *, int);
> -static int autofs_dir_symlink(struct mnt_idmap *, struct inode *,
> +static int autofs_dir_symlink(const struct mnt_idmap *, struct inode *,
> struct dentry *, const char *);
> static int autofs_dir_unlink(struct inode *, struct dentry *);
> static int autofs_dir_rmdir(struct inode *, struct dentry *);
> @@ -572,7 +572,7 @@ static int autofs_dir_permission(const struct mnt_idmap *idmap,
> return generic_permission(idmap, inode, mask);
> }
>
> -static int autofs_dir_symlink(struct mnt_idmap *idmap,
> +static int autofs_dir_symlink(const struct mnt_idmap *idmap,
> struct inode *dir, struct dentry *dentry,
> const char *symname)
> {
> diff --git a/fs/bad_inode.c b/fs/bad_inode.c
> index f0c56db22223..096e6afb5e07 100644
> --- a/fs/bad_inode.c
> +++ b/fs/bad_inode.c
> @@ -51,7 +51,7 @@ static int bad_inode_unlink(struct inode *dir, struct dentry *dentry)
> return -EIO;
> }
>
> -static int bad_inode_symlink(struct mnt_idmap *idmap,
> +static int bad_inode_symlink(const struct mnt_idmap *idmap,
> struct inode *dir, struct dentry *dentry,
> const char *symname)
> {
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index dc7e4b68410c..9b5e3a67122d 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -9023,7 +9023,7 @@ int btrfs_start_delalloc_roots(struct btrfs_fs_info *fs_info, long nr,
> return ret;
> }
>
> -static int btrfs_symlink(struct mnt_idmap *idmap, struct inode *dir,
> +static int btrfs_symlink(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, const char *symname)
> {
> struct btrfs_fs_info *fs_info = inode_to_fs_info(dir);
> diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
> index dd75d4c0a11e..5417a9948e98 100644
> --- a/fs/ceph/dir.c
> +++ b/fs/ceph/dir.c
> @@ -1032,7 +1032,7 @@ static int prep_encrypted_symlink_target(struct ceph_mds_request *req,
> }
> #endif
>
> -static int ceph_symlink(struct mnt_idmap *idmap, struct inode *dir,
> +static int ceph_symlink(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, const char *dest)
> {
> struct ceph_mds_client *mdsc = ceph_sb_to_mdsc(dir->i_sb);
> diff --git a/fs/coda/dir.c b/fs/coda/dir.c
> index 3a2fa1e13ef8..02b8259b6a0e 100644
> --- a/fs/coda/dir.c
> +++ b/fs/coda/dir.c
> @@ -233,7 +233,7 @@ static int coda_link(struct dentry *source_de, struct inode *dir_inode,
> }
>
>
> -static int coda_symlink(struct mnt_idmap *idmap,
> +static int coda_symlink(const struct mnt_idmap *idmap,
> struct inode *dir_inode, struct dentry *de,
> const char *symname)
> {
> diff --git a/fs/configfs/configfs_internal.h b/fs/configfs/configfs_internal.h
> index acdeea8e2d69..63d70dc05444 100644
> --- a/fs/configfs/configfs_internal.h
> +++ b/fs/configfs/configfs_internal.h
> @@ -90,7 +90,7 @@ extern const struct inode_operations configfs_root_inode_operations;
> extern const struct inode_operations configfs_symlink_inode_operations;
> extern const struct dentry_operations configfs_dentry_ops;
>
> -extern int configfs_symlink(struct mnt_idmap *idmap,
> +extern int configfs_symlink(const struct mnt_idmap *idmap,
> struct inode *dir, struct dentry *dentry,
> const char *symname);
> extern int configfs_unlink(struct inode *dir, struct dentry *dentry);
> diff --git a/fs/configfs/symlink.c b/fs/configfs/symlink.c
> index 31eb28b27309..a07c346817f5 100644
> --- a/fs/configfs/symlink.c
> +++ b/fs/configfs/symlink.c
> @@ -132,7 +132,7 @@ static int get_target(const char *symname, struct config_item **target,
> }
>
>
> -int configfs_symlink(struct mnt_idmap *idmap, struct inode *dir,
> +int configfs_symlink(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, const char *symname)
> {
> int ret;
> diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
> index f5340d2b42f4..f9a3c88c4fbd 100644
> --- a/fs/ecryptfs/inode.c
> +++ b/fs/ecryptfs/inode.c
> @@ -462,7 +462,7 @@ static int ecryptfs_unlink(struct inode *dir, struct dentry *dentry)
> return ecryptfs_do_unlink(dir, dentry, d_inode(dentry));
> }
>
> -static int ecryptfs_symlink(struct mnt_idmap *idmap,
> +static int ecryptfs_symlink(const struct mnt_idmap *idmap,
> struct inode *dir, struct dentry *dentry,
> const char *symname)
> {
> diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c
> index 0b66e7d37464..7da42f071eab 100644
> --- a/fs/ext2/namei.c
> +++ b/fs/ext2/namei.c
> @@ -152,7 +152,7 @@ static int ext2_mknod (const struct mnt_idmap * idmap, struct inode * dir,
> return err;
> }
>
> -static int ext2_symlink (struct mnt_idmap * idmap, struct inode * dir,
> +static int ext2_symlink (const struct mnt_idmap * idmap, struct inode * dir,
> struct dentry * dentry, const char * symname)
> {
> struct super_block * sb = dir->i_sb;
> diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
> index 4c0ce31c3ce8..6e493b4d205f 100644
> --- a/fs/ext4/namei.c
> +++ b/fs/ext4/namei.c
> @@ -3360,7 +3360,7 @@ static int ext4_init_symlink_block(handle_t *handle, struct inode *inode,
> return err;
> }
>
> -static int ext4_symlink(struct mnt_idmap *idmap, struct inode *dir,
> +static int ext4_symlink(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, const char *symname)
> {
> handle_t *handle;
> diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
> index c888f02d89fe..b2e99822d8b4 100644
> --- a/fs/f2fs/namei.c
> +++ b/fs/f2fs/namei.c
> @@ -662,7 +662,7 @@ static const char *f2fs_get_link(struct dentry *dentry,
> return link;
> }
>
> -static int f2fs_symlink(struct mnt_idmap *idmap, struct inode *dir,
> +static int f2fs_symlink(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, const char *symname)
> {
> struct f2fs_sb_info *sbi = F2FS_I_SB(dir);
> diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
> index 88da9010b0ce..3d8246ff061e 100644
> --- a/fs/fuse/dir.c
> +++ b/fs/fuse/dir.c
> @@ -1146,7 +1146,7 @@ static struct dentry *fuse_mkdir(const struct mnt_idmap *idmap, struct inode *di
> return create_new_entry(idmap, fm, &args, dir, entry, S_IFDIR);
> }
>
> -static int fuse_symlink(struct mnt_idmap *idmap, struct inode *dir,
> +static int fuse_symlink(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *entry, const char *link)
> {
> struct fuse_mount *fm = get_fuse_mount(dir);
> diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
> index 6a1d405aa6e9..c8f2b01e8cf5 100644
> --- a/fs/gfs2/inode.c
> +++ b/fs/gfs2/inode.c
> @@ -1323,7 +1323,7 @@ static int gfs2_unlink(struct inode *dir, struct dentry *dentry)
> * Returns: errno
> */
>
> -static int gfs2_symlink(struct mnt_idmap *idmap, struct inode *dir,
> +static int gfs2_symlink(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, const char *symname)
> {
> unsigned int size;
> diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c
> index 651b9f73b567..1b59ddb6d1e1 100644
> --- a/fs/hfsplus/dir.c
> +++ b/fs/hfsplus/dir.c
> @@ -460,7 +460,7 @@ static int hfsplus_rmdir(struct inode *dir, struct dentry *dentry)
> return res;
> }
>
> -static int hfsplus_symlink(struct mnt_idmap *idmap, struct inode *dir,
> +static int hfsplus_symlink(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, const char *symname)
> {
> struct hfsplus_sb_info *sbi = HFSPLUS_SB(dir->i_sb);
> diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
> index 2eec9ebe1587..ef03763aa074 100644
> --- a/fs/hostfs/hostfs_kern.c
> +++ b/fs/hostfs/hostfs_kern.c
> @@ -673,7 +673,7 @@ static int hostfs_unlink(struct inode *ino, struct dentry *dentry)
> return err;
> }
>
> -static int hostfs_symlink(struct mnt_idmap *idmap, struct inode *ino,
> +static int hostfs_symlink(const struct mnt_idmap *idmap, struct inode *ino,
> struct dentry *dentry, const char *to)
> {
> char *file;
> diff --git a/fs/hpfs/namei.c b/fs/hpfs/namei.c
> index 280459b00e56..44a7fb797633 100644
> --- a/fs/hpfs/namei.c
> +++ b/fs/hpfs/namei.c
> @@ -289,7 +289,7 @@ static int hpfs_mknod(const struct mnt_idmap *idmap, struct inode *dir,
> return err;
> }
>
> -static int hpfs_symlink(struct mnt_idmap *idmap, struct inode *dir,
> +static int hpfs_symlink(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, const char *symlink)
> {
> const unsigned char *name = dentry->d_name.name;
> diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
> index 6298a30e7343..9e937602b2ec 100644
> --- a/fs/hugetlbfs/inode.c
> +++ b/fs/hugetlbfs/inode.c
> @@ -998,7 +998,7 @@ static int hugetlbfs_tmpfile(const struct mnt_idmap *idmap,
> return finish_open_simple(file, 0);
> }
>
> -static int hugetlbfs_symlink(struct mnt_idmap *idmap,
> +static int hugetlbfs_symlink(const struct mnt_idmap *idmap,
> struct inode *dir, struct dentry *dentry,
> const char *symname)
> {
> diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c
> index b4f808825738..7d23be0bab72 100644
> --- a/fs/jffs2/dir.c
> +++ b/fs/jffs2/dir.c
> @@ -31,7 +31,7 @@ static struct dentry *jffs2_lookup (struct inode *,struct dentry *,
> unsigned int);
> static int jffs2_link (struct dentry *,struct inode *,struct dentry *);
> static int jffs2_unlink (struct inode *,struct dentry *);
> -static int jffs2_symlink (struct mnt_idmap *, struct inode *,
> +static int jffs2_symlink (const struct mnt_idmap *, struct inode *,
> struct dentry *, const char *);
> static struct dentry *jffs2_mkdir (const struct mnt_idmap *, struct inode *,struct dentry *,
> umode_t);
> @@ -284,7 +284,7 @@ static int jffs2_link (struct dentry *old_dentry, struct inode *dir_i, struct de
>
> /***********************************************************************/
>
> -static int jffs2_symlink (struct mnt_idmap *idmap, struct inode *dir_i,
> +static int jffs2_symlink (const struct mnt_idmap *idmap, struct inode *dir_i,
> struct dentry *dentry, const char *target)
> {
> struct jffs2_inode_info *f, *dir_f;
> diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c
> index 305eb2cab105..6009d65ab53f 100644
> --- a/fs/jfs/namei.c
> +++ b/fs/jfs/namei.c
> @@ -876,7 +876,7 @@ static int jfs_link(struct dentry *old_dentry,
> * an intermediate result whose length exceeds PATH_MAX [XPG4.2]
> */
>
> -static int jfs_symlink(struct mnt_idmap *idmap, struct inode *dip,
> +static int jfs_symlink(const struct mnt_idmap *idmap, struct inode *dip,
> struct dentry *dentry, const char *name)
> {
> int rc;
> diff --git a/fs/minix/namei.c b/fs/minix/namei.c
> index abf4575f24b1..11b66a25e92b 100644
> --- a/fs/minix/namei.c
> +++ b/fs/minix/namei.c
> @@ -69,7 +69,7 @@ static int minix_create(struct mnt_idmap *idmap, struct inode *dir,
> return minix_mknod(&nop_mnt_idmap, dir, dentry, mode, 0);
> }
>
> -static int minix_symlink(struct mnt_idmap *idmap, struct inode *dir,
> +static int minix_symlink(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, const char *symname)
> {
> int i = strlen(symname)+1;
> diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
> index dfa9dab7fdcc..a917c008a05a 100644
> --- a/fs/nfs/dir.c
> +++ b/fs/nfs/dir.c
> @@ -2641,7 +2641,7 @@ EXPORT_SYMBOL_GPL(nfs_unlink);
> * now have a new file handle and can instantiate an in-core NFS inode
> * and move the raw page into its mapping.
> */
> -int nfs_symlink(struct mnt_idmap *idmap, struct inode *dir,
> +int nfs_symlink(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, const char *symname)
> {
> struct folio *folio;
> diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
> index da6db93b1730..4c966dac7f7d 100644
> --- a/fs/nfs/internal.h
> +++ b/fs/nfs/internal.h
> @@ -402,7 +402,7 @@ struct dentry *nfs_mkdir(const struct mnt_idmap *, struct inode *, struct dentry
> umode_t);
> int nfs_rmdir(struct inode *, struct dentry *);
> int nfs_unlink(struct inode *, struct dentry *);
> -int nfs_symlink(struct mnt_idmap *, struct inode *, struct dentry *,
> +int nfs_symlink(const struct mnt_idmap *, struct inode *, struct dentry *,
> const char *);
> int nfs_link(struct dentry *, struct inode *, struct dentry *);
> int nfs_mknod(const struct mnt_idmap *, struct inode *, struct dentry *, umode_t,
> diff --git a/fs/nilfs2/namei.c b/fs/nilfs2/namei.c
> index b21fd2d8cb4a..8762fdc16c05 100644
> --- a/fs/nilfs2/namei.c
> +++ b/fs/nilfs2/namei.c
> @@ -138,7 +138,7 @@ nilfs_mknod(const struct mnt_idmap *idmap, struct inode *dir,
> return err;
> }
>
> -static int nilfs_symlink(struct mnt_idmap *idmap, struct inode *dir,
> +static int nilfs_symlink(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, const char *symname)
> {
> struct nilfs_transaction_info ti;
> diff --git a/fs/ntfs/namei.c b/fs/ntfs/namei.c
> index cbefeabe81b3..637bc3690844 100644
> --- a/fs/ntfs/namei.c
> +++ b/fs/ntfs/namei.c
> @@ -1399,7 +1399,7 @@ static int ntfs_rename(const struct mnt_idmap *idmap, struct inode *old_dir,
> return err;
> }
>
> -static int ntfs_symlink(struct mnt_idmap *idmap, struct inode *dir,
> +static int ntfs_symlink(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, const char *symname)
> {
> struct super_block *sb = dir->i_sb;
> diff --git a/fs/ntfs3/namei.c b/fs/ntfs3/namei.c
> index db02a2fb69c1..289796da6ba5 100644
> --- a/fs/ntfs3/namei.c
> +++ b/fs/ntfs3/namei.c
> @@ -209,7 +209,7 @@ static int ntfs_unlink(struct inode *dir, struct dentry *dentry)
> /*
> * ntfs_symlink - inode_operations::symlink
> */
> -static int ntfs_symlink(struct mnt_idmap *idmap, struct inode *dir,
> +static int ntfs_symlink(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, const char *symname)
> {
> u32 size = strlen(symname);
> diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
> index 89ac6fae34f8..dfa2cb2bcb12 100644
> --- a/fs/ocfs2/namei.c
> +++ b/fs/ocfs2/namei.c
> @@ -1815,7 +1815,7 @@ static int ocfs2_create_symlink_data(struct ocfs2_super *osb,
> return status;
> }
>
> -static int ocfs2_symlink(struct mnt_idmap *idmap,
> +static int ocfs2_symlink(const struct mnt_idmap *idmap,
> struct inode *dir,
> struct dentry *dentry,
> const char *symname)
> diff --git a/fs/orangefs/namei.c b/fs/orangefs/namei.c
> index 749dfc0735a6..f5deb8cdbf2f 100644
> --- a/fs/orangefs/namei.c
> +++ b/fs/orangefs/namei.c
> @@ -211,7 +211,7 @@ static int orangefs_unlink(struct inode *dir, struct dentry *dentry)
> return ret;
> }
>
> -static int orangefs_symlink(struct mnt_idmap *idmap,
> +static int orangefs_symlink(const struct mnt_idmap *idmap,
> struct inode *dir,
> struct dentry *dentry,
> const char *symname)
> diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
> index 6e206220a97f..f7a3fd3a25b9 100644
> --- a/fs/overlayfs/dir.c
> +++ b/fs/overlayfs/dir.c
> @@ -752,7 +752,7 @@ static int ovl_mknod(const struct mnt_idmap *idmap, struct inode *dir,
> return ovl_create_object(idmap, dentry, mode, rdev, NULL);
> }
>
> -static int ovl_symlink(struct mnt_idmap *idmap, struct inode *dir,
> +static int ovl_symlink(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, const char *link)
> {
> return ovl_create_object(idmap, dentry, S_IFLNK, 0, link);
> diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c
> index 363093354a90..cc06d806b214 100644
> --- a/fs/ramfs/inode.c
> +++ b/fs/ramfs/inode.c
> @@ -133,7 +133,7 @@ static int ramfs_create(struct mnt_idmap *idmap, struct inode *dir,
> return ramfs_mknod(&nop_mnt_idmap, dir, dentry, mode | S_IFREG, 0);
> }
>
> -static int ramfs_symlink(struct mnt_idmap *idmap, struct inode *dir,
> +static int ramfs_symlink(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, const char *symname)
> {
> struct inode *inode;
> diff --git a/fs/smb/client/cifsfs.h b/fs/smb/client/cifsfs.h
> index 908f65001578..483d2b23fc23 100644
> --- a/fs/smb/client/cifsfs.h
> +++ b/fs/smb/client/cifsfs.h
> @@ -129,7 +129,7 @@ struct vfsmount *cifs_d_automount(struct path *path);
> /* Functions related to symlinks */
> const char *cifs_get_link(struct dentry *dentry, struct inode *inode,
> struct delayed_call *done);
> -int cifs_symlink(struct mnt_idmap *idmap, struct inode *inode,
> +int cifs_symlink(const struct mnt_idmap *idmap, struct inode *inode,
> struct dentry *direntry, const char *symname);
>
> #ifdef CONFIG_CIFS_XATTR
> diff --git a/fs/smb/client/link.c b/fs/smb/client/link.c
> index 8d5d6aca742a..76df31abeaea 100644
> --- a/fs/smb/client/link.c
> +++ b/fs/smb/client/link.c
> @@ -533,7 +533,7 @@ cifs_hardlink(struct dentry *old_file, struct inode *inode,
> }
>
> int
> -cifs_symlink(struct mnt_idmap *idmap, struct inode *inode,
> +cifs_symlink(const struct mnt_idmap *idmap, struct inode *inode,
> struct dentry *direntry, const char *symname)
> {
> struct cifs_sb_info *cifs_sb = CIFS_SB(inode);
> diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
> index c7723f80e258..d784283d427f 100644
> --- a/fs/ubifs/dir.c
> +++ b/fs/ubifs/dir.c
> @@ -1170,7 +1170,7 @@ static int ubifs_mknod(const struct mnt_idmap *idmap, struct inode *dir,
> return err;
> }
>
> -static int ubifs_symlink(struct mnt_idmap *idmap, struct inode *dir,
> +static int ubifs_symlink(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, const char *symname)
> {
> struct inode *inode;
> diff --git a/fs/udf/namei.c b/fs/udf/namei.c
> index 7ee11e527377..002e79052f92 100644
> --- a/fs/udf/namei.c
> +++ b/fs/udf/namei.c
> @@ -567,7 +567,7 @@ static int udf_unlink(struct inode *dir, struct dentry *dentry)
> return ret;
> }
>
> -static int udf_symlink(struct mnt_idmap *idmap, struct inode *dir,
> +static int udf_symlink(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, const char *symname)
> {
> struct inode *inode;
> diff --git a/fs/ufs/namei.c b/fs/ufs/namei.c
> index 4aee6c3d0f75..9231a5cda08e 100644
> --- a/fs/ufs/namei.c
> +++ b/fs/ufs/namei.c
> @@ -105,7 +105,7 @@ static int ufs_mknod(const struct mnt_idmap *idmap, struct inode *dir,
> return err;
> }
>
> -static int ufs_symlink (struct mnt_idmap * idmap, struct inode * dir,
> +static int ufs_symlink (const struct mnt_idmap * idmap, struct inode * dir,
> struct dentry * dentry, const char * symname)
> {
> struct super_block * sb = dir->i_sb;
> diff --git a/fs/vboxsf/dir.c b/fs/vboxsf/dir.c
> index 851e4be5eb0d..9db16e90f670 100644
> --- a/fs/vboxsf/dir.c
> +++ b/fs/vboxsf/dir.c
> @@ -425,7 +425,7 @@ static int vboxsf_dir_rename(const struct mnt_idmap *idmap,
> return err;
> }
>
> -static int vboxsf_dir_symlink(struct mnt_idmap *idmap,
> +static int vboxsf_dir_symlink(const struct mnt_idmap *idmap,
> struct inode *parent, struct dentry *dentry,
> const char *symname)
> {
> diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
> index 495c7f3dece0..fe388619a138 100644
> --- a/fs/xfs/xfs_iops.c
> +++ b/fs/xfs/xfs_iops.c
> @@ -425,7 +425,7 @@ xfs_vn_unlink(
>
> STATIC int
> xfs_vn_symlink(
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct inode *dir,
> struct dentry *dentry,
> const char *symname)
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index b02ae54727cb..f2c7838644c3 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -2003,7 +2003,7 @@ struct inode_operations {
> umode_t);
> int (*link) (struct dentry *,struct inode *,struct dentry *);
> int (*unlink) (struct inode *,struct dentry *);
> - int (*symlink) (struct mnt_idmap *, struct inode *,struct dentry *,
> + int (*symlink) (const struct mnt_idmap *, struct inode *,struct dentry *,
> const char *);
> struct dentry *(*mkdir) (const struct mnt_idmap *, struct inode *,
> struct dentry *, umode_t);
> diff --git a/kernel/bpf/inode.c b/kernel/bpf/inode.c
> index 871825d36c8c..c6f328e4752e 100644
> --- a/kernel/bpf/inode.c
> +++ b/kernel/bpf/inode.c
> @@ -424,7 +424,7 @@ bpf_lookup(struct inode *dir, struct dentry *dentry, unsigned flags)
> return simple_lookup(dir, dentry, flags);
> }
>
> -static int bpf_symlink(struct mnt_idmap *idmap, struct inode *dir,
> +static int bpf_symlink(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, const char *target)
> {
> struct inode *inode;
> diff --git a/mm/shmem.c b/mm/shmem.c
> index e76359582406..f633af032a08 100644
> --- a/mm/shmem.c
> +++ b/mm/shmem.c
> @@ -4047,7 +4047,7 @@ static int shmem_rename2(const struct mnt_idmap *idmap,
> return 0;
> }
>
> -static int shmem_symlink(struct mnt_idmap *idmap, struct inode *dir,
> +static int shmem_symlink(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, const char *symname)
> {
> int error;
>
> --
> 2.53.0
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 62+ messages in thread
* [PATCH 22/27] fs: port ->create() to pass const mnt_idmap
2026-09-01 12:14 [PATCH 00/27] fs: port to const struct mnt_idmap Christian Brauner
` (20 preceding siblings ...)
2026-09-01 12:14 ` [PATCH 21/27] fs: port ->symlink() " Christian Brauner
@ 2026-09-01 12:14 ` Christian Brauner
2026-09-02 15:55 ` Jan Kara
2026-09-01 12:14 ` [PATCH 23/27] fs: port ->getattr() " Christian Brauner
` (4 subsequent siblings)
26 siblings, 1 reply; 62+ messages in thread
From: Christian Brauner @ 2026-09-01 12:14 UTC (permalink / raw)
To: linux-fsdevel
Cc: Alexander Viro, Jan Kara, Christoph Hellwig, Seth Forshee,
Paul Moore, linux-security-module, Mimi Zohar, linux-integrity,
Ilya Dryomov, ceph-devel, Carlos Maiolino, linux-xfs,
Miklos Szeredi, Amir Goldstein, linux-unionfs, Namjae Jeon,
linux-cifs, linux-kernel, Christian Brauner (Amutable)
Convert to const struct mnt_idmap.
A mount's idmapping is immutable. The only thing that is allowed to be
modified afterwards is the reference count and that is hidden behind
mnt_idmap_get() and mnt_idmap_put(). Everything else only ever reads
from the idmapping. This is the same model that struct cred uses and the
idmapping is also rather sensitive.
So make the idmap argument const wherever we can. The conversion is done
from the bottom up so callers can continue to pass a non-const pointer
to a const parameter until the conversion is finished.
No functional changes.
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
---
Documentation/filesystems/locking.rst | 2 +-
Documentation/filesystems/vfs.rst | 2 +-
fs/9p/vfs_inode.c | 2 +-
fs/9p/vfs_inode_dotl.c | 2 +-
fs/affs/affs.h | 2 +-
fs/affs/namei.c | 2 +-
fs/afs/dir.c | 4 ++--
fs/bad_inode.c | 2 +-
fs/bfs/dir.c | 2 +-
fs/btrfs/inode.c | 2 +-
fs/ceph/dir.c | 2 +-
fs/coda/dir.c | 2 +-
fs/ecryptfs/inode.c | 2 +-
fs/efivarfs/inode.c | 2 +-
fs/exfat/namei.c | 2 +-
fs/ext2/namei.c | 2 +-
fs/ext4/namei.c | 2 +-
fs/f2fs/namei.c | 2 +-
fs/fat/namei_msdos.c | 2 +-
fs/fat/namei_vfat.c | 2 +-
fs/fuse/dir.c | 2 +-
fs/gfs2/inode.c | 2 +-
fs/hfs/dir.c | 2 +-
fs/hfsplus/dir.c | 2 +-
fs/hostfs/hostfs_kern.c | 2 +-
fs/hpfs/namei.c | 2 +-
fs/hugetlbfs/inode.c | 2 +-
fs/jffs2/dir.c | 4 ++--
fs/jfs/namei.c | 2 +-
fs/minix/namei.c | 2 +-
fs/nfs/dir.c | 2 +-
fs/nfs/internal.h | 2 +-
fs/nilfs2/namei.c | 2 +-
fs/ntfs/namei.c | 2 +-
fs/ntfs3/namei.c | 2 +-
fs/ocfs2/dlmfs/dlmfs.c | 2 +-
fs/ocfs2/namei.c | 2 +-
fs/omfs/dir.c | 2 +-
fs/orangefs/namei.c | 2 +-
fs/overlayfs/dir.c | 2 +-
fs/ramfs/inode.c | 2 +-
fs/smb/client/cifsfs.h | 2 +-
fs/smb/client/dir.c | 2 +-
fs/ubifs/dir.c | 2 +-
fs/udf/namei.c | 2 +-
fs/ufs/namei.c | 2 +-
fs/vboxsf/dir.c | 2 +-
fs/xfs/xfs_iops.c | 2 +-
include/linux/fs.h | 2 +-
ipc/mqueue.c | 2 +-
mm/shmem.c | 2 +-
51 files changed, 53 insertions(+), 53 deletions(-)
diff --git a/Documentation/filesystems/locking.rst b/Documentation/filesystems/locking.rst
index 856b9cc88c76..864768700eda 100644
--- a/Documentation/filesystems/locking.rst
+++ b/Documentation/filesystems/locking.rst
@@ -61,7 +61,7 @@ inode_operations
prototypes::
- int (*create) (struct mnt_idmap *, struct inode *,struct dentry *,umode_t);
+ int (*create) (const struct mnt_idmap *, struct inode *,struct dentry *,umode_t);
struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
int (*link) (struct dentry *,struct inode *,struct dentry *);
int (*unlink) (struct inode *,struct dentry *);
diff --git a/Documentation/filesystems/vfs.rst b/Documentation/filesystems/vfs.rst
index 5a9203e98bb6..2ad273cfe547 100644
--- a/Documentation/filesystems/vfs.rst
+++ b/Documentation/filesystems/vfs.rst
@@ -415,7 +415,7 @@ As of kernel 2.6.22, the following members are defined:
.. code-block:: c
struct inode_operations {
- int (*create) (struct mnt_idmap *, struct inode *,struct dentry *, umode_t);
+ int (*create) (const struct mnt_idmap *, struct inode *,struct dentry *, umode_t);
struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
int (*link) (struct dentry *,struct inode *,struct dentry *);
int (*unlink) (struct inode *,struct dentry *);
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index cc52c244bb95..f2d0eef68acf 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -652,7 +652,7 @@ v9fs_create(struct v9fs_session_info *v9ses, struct inode *dir,
*/
static int
-v9fs_vfs_create(struct mnt_idmap *idmap, struct inode *dir,
+v9fs_vfs_create(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dir);
diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c
index ec58718eec4a..c7176719a4f9 100644
--- a/fs/9p/vfs_inode_dotl.c
+++ b/fs/9p/vfs_inode_dotl.c
@@ -216,7 +216,7 @@ int v9fs_open_to_dotl_flags(int flags)
*
*/
static int
-v9fs_vfs_create_dotl(struct mnt_idmap *idmap, struct inode *dir,
+v9fs_vfs_create_dotl(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t omode)
{
return v9fs_vfs_mknod_dotl(idmap, dir, dentry, omode, 0);
diff --git a/fs/affs/affs.h b/fs/affs/affs.h
index b1047766a829..8d4ca16c7891 100644
--- a/fs/affs/affs.h
+++ b/fs/affs/affs.h
@@ -166,7 +166,7 @@ extern const struct export_operations affs_export_ops;
extern int affs_hash_name(struct super_block *sb, const u8 *name, unsigned int len);
extern struct dentry *affs_lookup(struct inode *dir, struct dentry *dentry, unsigned int);
extern int affs_unlink(struct inode *dir, struct dentry *dentry);
-extern int affs_create(struct mnt_idmap *idmap, struct inode *dir,
+extern int affs_create(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode);
extern struct dentry *affs_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode);
diff --git a/fs/affs/namei.c b/fs/affs/namei.c
index 1d609355fc3f..2e32899a32d5 100644
--- a/fs/affs/namei.c
+++ b/fs/affs/namei.c
@@ -242,7 +242,7 @@ affs_unlink(struct inode *dir, struct dentry *dentry)
}
int
-affs_create(struct mnt_idmap *idmap, struct inode *dir,
+affs_create(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
struct super_block *sb = dir->i_sb;
diff --git a/fs/afs/dir.c b/fs/afs/dir.c
index 603dd9323ed2..63d4f15ae168 100644
--- a/fs/afs/dir.c
+++ b/fs/afs/dir.c
@@ -33,7 +33,7 @@ static bool afs_lookup_one_filldir(struct dir_context *ctx, const char *name, in
static bool afs_lookup_filldir(struct dir_context *ctx, const char *name, int nlen,
u64 ino, u32 uniquifier);
#define AFS_LOOKUP ((filldir_t)0x137UL)
-static int afs_create(struct mnt_idmap *idmap, struct inode *dir,
+static int afs_create(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode);
static struct dentry *afs_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode);
@@ -1632,7 +1632,7 @@ static const struct afs_operation_ops afs_create_operation = {
/*
* create a regular file on an AFS filesystem
*/
-static int afs_create(struct mnt_idmap *idmap, struct inode *dir,
+static int afs_create(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
struct afs_operation *op;
diff --git a/fs/bad_inode.c b/fs/bad_inode.c
index 096e6afb5e07..8c7578ea4bd7 100644
--- a/fs/bad_inode.c
+++ b/fs/bad_inode.c
@@ -27,7 +27,7 @@ static const struct file_operations bad_file_ops =
.open = bad_file_open,
};
-static int bad_inode_create(struct mnt_idmap *idmap,
+static int bad_inode_create(const struct mnt_idmap *idmap,
struct inode *dir, struct dentry *dentry,
umode_t mode)
{
diff --git a/fs/bfs/dir.c b/fs/bfs/dir.c
index 80534d04db9d..b944bd62f5d0 100644
--- a/fs/bfs/dir.c
+++ b/fs/bfs/dir.c
@@ -75,7 +75,7 @@ const struct file_operations bfs_dir_operations = {
.llseek = generic_file_llseek,
};
-static int bfs_create(struct mnt_idmap *idmap, struct inode *dir,
+static int bfs_create(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
int err;
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 9b5e3a67122d..61cfa03b6152 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -7018,7 +7018,7 @@ static int btrfs_mknod(const struct mnt_idmap *idmap, struct inode *dir,
return btrfs_create_common(dir, dentry, inode);
}
-static int btrfs_create(struct mnt_idmap *idmap, struct inode *dir,
+static int btrfs_create(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
struct inode *inode;
diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
index 5417a9948e98..d9615d67bf1c 100644
--- a/fs/ceph/dir.c
+++ b/fs/ceph/dir.c
@@ -988,7 +988,7 @@ static int ceph_mknod(const struct mnt_idmap *idmap, struct inode *dir,
return err;
}
-static int ceph_create(struct mnt_idmap *idmap, struct inode *dir,
+static int ceph_create(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
return ceph_mknod(idmap, dir, dentry, mode, 0);
diff --git a/fs/coda/dir.c b/fs/coda/dir.c
index 02b8259b6a0e..a85be5962e62 100644
--- a/fs/coda/dir.c
+++ b/fs/coda/dir.c
@@ -133,7 +133,7 @@ static inline void coda_dir_drop_nlink(struct inode *dir)
}
/* creation routines: create, mknod, mkdir, link, symlink */
-static int coda_create(struct mnt_idmap *idmap, struct inode *dir,
+static int coda_create(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *de, umode_t mode)
{
int error;
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index f9a3c88c4fbd..432f82bc5b0c 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -266,7 +266,7 @@ int ecryptfs_initialize_file(struct dentry *ecryptfs_dentry,
* Returns zero on success; non-zero on error condition
*/
static int
-ecryptfs_create(struct mnt_idmap *idmap,
+ecryptfs_create(const struct mnt_idmap *idmap,
struct inode *directory_inode, struct dentry *ecryptfs_dentry,
umode_t mode)
{
diff --git a/fs/efivarfs/inode.c b/fs/efivarfs/inode.c
index f7dcd72e4a07..d87091b92776 100644
--- a/fs/efivarfs/inode.c
+++ b/fs/efivarfs/inode.c
@@ -74,7 +74,7 @@ static bool efivarfs_valid_name(const char *str, int len)
return uuid_is_valid(s);
}
-static int efivarfs_create(struct mnt_idmap *idmap, struct inode *dir,
+static int efivarfs_create(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
struct inode *inode = NULL;
diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c
index 4accf96ea7f9..5e7836af63b8 100644
--- a/fs/exfat/namei.c
+++ b/fs/exfat/namei.c
@@ -552,7 +552,7 @@ static int exfat_add_entry(struct inode *inode, const char *path,
return ret;
}
-static int exfat_create(struct mnt_idmap *idmap, struct inode *dir,
+static int exfat_create(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
struct super_block *sb = dir->i_sb;
diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c
index 7da42f071eab..bfb6a463a95e 100644
--- a/fs/ext2/namei.c
+++ b/fs/ext2/namei.c
@@ -97,7 +97,7 @@ struct dentry *ext2_get_parent(struct dentry *child)
* If the create succeeds, we fill in the inode information
* with d_instantiate().
*/
-static int ext2_create (struct mnt_idmap * idmap,
+static int ext2_create (const struct mnt_idmap * idmap,
struct inode * dir, struct dentry * dentry,
umode_t mode)
{
diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
index 6e493b4d205f..6e0630a49e48 100644
--- a/fs/ext4/namei.c
+++ b/fs/ext4/namei.c
@@ -2812,7 +2812,7 @@ static int ext4_add_nondir(handle_t *handle,
* If the create succeeds, we fill in the inode information
* with d_instantiate().
*/
-static int ext4_create(struct mnt_idmap *idmap, struct inode *dir,
+static int ext4_create(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
handle_t *handle;
diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
index b2e99822d8b4..9934777eb2a9 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -365,7 +365,7 @@ static struct inode *f2fs_new_inode(const struct mnt_idmap *idmap,
return ERR_PTR(err);
}
-static int f2fs_create(struct mnt_idmap *idmap, struct inode *dir,
+static int f2fs_create(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
struct f2fs_sb_info *sbi = F2FS_I_SB(dir);
diff --git a/fs/fat/namei_msdos.c b/fs/fat/namei_msdos.c
index 9ee899391f4f..dde4215616f9 100644
--- a/fs/fat/namei_msdos.c
+++ b/fs/fat/namei_msdos.c
@@ -263,7 +263,7 @@ static int msdos_add_entry(struct inode *dir, const unsigned char *name,
}
/***** Create a file */
-static int msdos_create(struct mnt_idmap *idmap, struct inode *dir,
+static int msdos_create(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
struct super_block *sb = dir->i_sb;
diff --git a/fs/fat/namei_vfat.c b/fs/fat/namei_vfat.c
index a3f3320fe630..3dc063ba0a73 100644
--- a/fs/fat/namei_vfat.c
+++ b/fs/fat/namei_vfat.c
@@ -753,7 +753,7 @@ static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry,
return ERR_PTR(err);
}
-static int vfat_create(struct mnt_idmap *idmap, struct inode *dir,
+static int vfat_create(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
struct super_block *sb = dir->i_sb;
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 3d8246ff061e..ff941e78918f 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -1092,7 +1092,7 @@ static int fuse_mknod(const struct mnt_idmap *idmap, struct inode *dir,
return create_new_nondir(idmap, fm, &args, dir, entry, mode);
}
-static int fuse_create(struct mnt_idmap *idmap, struct inode *dir,
+static int fuse_create(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *entry, umode_t mode)
{
return fuse_mknod(idmap, dir, entry, mode, 0);
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index c8f2b01e8cf5..e207ab1f5c23 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -967,7 +967,7 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
* Returns: errno
*/
-static int gfs2_create(struct mnt_idmap *idmap, struct inode *dir,
+static int gfs2_create(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
return gfs2_create_inode(dir, dentry, NULL, S_IFREG | mode, 0, NULL, 0, 1);
diff --git a/fs/hfs/dir.c b/fs/hfs/dir.c
index d60399c62e99..f6b97da19788 100644
--- a/fs/hfs/dir.c
+++ b/fs/hfs/dir.c
@@ -183,7 +183,7 @@ static int hfs_dir_release(struct inode *inode, struct file *file)
* a directory and return a corresponding inode, given the inode for
* the directory and the name (and its length) of the new file.
*/
-static int hfs_create(struct mnt_idmap *idmap, struct inode *dir,
+static int hfs_create(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
struct inode *inode;
diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c
index 1b59ddb6d1e1..b3a1193a491f 100644
--- a/fs/hfsplus/dir.c
+++ b/fs/hfsplus/dir.c
@@ -561,7 +561,7 @@ static int hfsplus_mknod(const struct mnt_idmap *idmap, struct inode *dir,
return res;
}
-static int hfsplus_create(struct mnt_idmap *idmap, struct inode *dir,
+static int hfsplus_create(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
return hfsplus_mknod(&nop_mnt_idmap, dir, dentry, mode, 0);
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
index ef03763aa074..c8ad58be047e 100644
--- a/fs/hostfs/hostfs_kern.c
+++ b/fs/hostfs/hostfs_kern.c
@@ -592,7 +592,7 @@ static struct inode *hostfs_iget(struct super_block *sb, char *name)
return inode;
}
-static int hostfs_create(struct mnt_idmap *idmap, struct inode *dir,
+static int hostfs_create(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
struct inode *inode;
diff --git a/fs/hpfs/namei.c b/fs/hpfs/namei.c
index 44a7fb797633..ac9b5e3e83fa 100644
--- a/fs/hpfs/namei.c
+++ b/fs/hpfs/namei.c
@@ -128,7 +128,7 @@ static struct dentry *hpfs_mkdir(const struct mnt_idmap *idmap, struct inode *di
return ERR_PTR(err);
}
-static int hpfs_create(struct mnt_idmap *idmap, struct inode *dir,
+static int hpfs_create(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
const unsigned char *name = dentry->d_name.name;
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 9e937602b2ec..0b95be14d3ee 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -977,7 +977,7 @@ static struct dentry *hugetlbfs_mkdir(const struct mnt_idmap *idmap, struct inod
return ERR_PTR(retval);
}
-static int hugetlbfs_create(struct mnt_idmap *idmap,
+static int hugetlbfs_create(const struct mnt_idmap *idmap,
struct inode *dir, struct dentry *dentry,
umode_t mode)
{
diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c
index 7d23be0bab72..23813f191281 100644
--- a/fs/jffs2/dir.c
+++ b/fs/jffs2/dir.c
@@ -25,7 +25,7 @@
static int jffs2_readdir (struct file *, struct dir_context *);
-static int jffs2_create (struct mnt_idmap *, struct inode *,
+static int jffs2_create (const struct mnt_idmap *, struct inode *,
struct dentry *, umode_t);
static struct dentry *jffs2_lookup (struct inode *,struct dentry *,
unsigned int);
@@ -162,7 +162,7 @@ static int jffs2_readdir(struct file *file, struct dir_context *ctx)
/***********************************************************************/
-static int jffs2_create(struct mnt_idmap *idmap, struct inode *dir_i,
+static int jffs2_create(const struct mnt_idmap *idmap, struct inode *dir_i,
struct dentry *dentry, umode_t mode)
{
struct jffs2_raw_inode *ri;
diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c
index 6009d65ab53f..8ab2e952ce16 100644
--- a/fs/jfs/namei.c
+++ b/fs/jfs/namei.c
@@ -60,7 +60,7 @@ static inline void free_ea_wmap(struct inode *inode)
* RETURN: Errors from subroutines
*
*/
-static int jfs_create(struct mnt_idmap *idmap, struct inode *dip,
+static int jfs_create(const struct mnt_idmap *idmap, struct inode *dip,
struct dentry *dentry, umode_t mode)
{
int rc = 0;
diff --git a/fs/minix/namei.c b/fs/minix/namei.c
index 11b66a25e92b..f450b11b9860 100644
--- a/fs/minix/namei.c
+++ b/fs/minix/namei.c
@@ -63,7 +63,7 @@ static int minix_tmpfile(const struct mnt_idmap *idmap, struct inode *dir,
return finish_open_simple(file, 0);
}
-static int minix_create(struct mnt_idmap *idmap, struct inode *dir,
+static int minix_create(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
return minix_mknod(&nop_mnt_idmap, dir, dentry, mode, 0);
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index a917c008a05a..354f986e60c4 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -2437,7 +2437,7 @@ static int nfs_do_create(struct inode *dir, struct dentry *dentry,
return error;
}
-int nfs_create(struct mnt_idmap *idmap, struct inode *dir,
+int nfs_create(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
return nfs_do_create(dir, dentry, mode, O_EXCL);
diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index 4c966dac7f7d..cbb323c6530d 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -396,7 +396,7 @@ extern unsigned long nfs_access_cache_scan(struct shrinker *shrink,
struct shrink_control *sc);
struct dentry *nfs_lookup(struct inode *, struct dentry *, unsigned int);
void nfs_d_prune_case_insensitive_aliases(struct inode *inode);
-int nfs_create(struct mnt_idmap *, struct inode *, struct dentry *,
+int nfs_create(const struct mnt_idmap *, struct inode *, struct dentry *,
umode_t);
struct dentry *nfs_mkdir(const struct mnt_idmap *, struct inode *, struct dentry *,
umode_t);
diff --git a/fs/nilfs2/namei.c b/fs/nilfs2/namei.c
index 8762fdc16c05..d0ae24f37854 100644
--- a/fs/nilfs2/namei.c
+++ b/fs/nilfs2/namei.c
@@ -85,7 +85,7 @@ nilfs_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags)
* If the create succeeds, we fill in the inode information
* with d_instantiate().
*/
-static int nilfs_create(struct mnt_idmap *idmap, struct inode *dir,
+static int nilfs_create(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
struct inode *inode;
diff --git a/fs/ntfs/namei.c b/fs/ntfs/namei.c
index 637bc3690844..5d222edadf0c 100644
--- a/fs/ntfs/namei.c
+++ b/fs/ntfs/namei.c
@@ -732,7 +732,7 @@ static struct ntfs_inode *__ntfs_create(const struct mnt_idmap *idmap, struct in
return ERR_PTR(err);
}
-static int ntfs_create(struct mnt_idmap *idmap, struct inode *dir,
+static int ntfs_create(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
struct ntfs_volume *vol = NTFS_SB(dir->i_sb);
diff --git a/fs/ntfs3/namei.c b/fs/ntfs3/namei.c
index 289796da6ba5..ae88cb66fb7e 100644
--- a/fs/ntfs3/namei.c
+++ b/fs/ntfs3/namei.c
@@ -111,7 +111,7 @@ static struct dentry *ntfs_lookup(struct inode *dir, struct dentry *dentry,
/*
* ntfs_create - inode_operations::create
*/
-static int ntfs_create(struct mnt_idmap *idmap, struct inode *dir,
+static int ntfs_create(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
return ntfs_create_inode(idmap, dir, dentry, NULL, S_IFREG | mode, 0,
diff --git a/fs/ocfs2/dlmfs/dlmfs.c b/fs/ocfs2/dlmfs/dlmfs.c
index 5e544d8ded42..fef79b21a4a5 100644
--- a/fs/ocfs2/dlmfs/dlmfs.c
+++ b/fs/ocfs2/dlmfs/dlmfs.c
@@ -450,7 +450,7 @@ static struct dentry *dlmfs_mkdir(const struct mnt_idmap * idmap,
return ERR_PTR(status);
}
-static int dlmfs_create(struct mnt_idmap *idmap,
+static int dlmfs_create(const struct mnt_idmap *idmap,
struct inode *dir,
struct dentry *dentry,
umode_t mode)
diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
index dfa2cb2bcb12..4873525be3b1 100644
--- a/fs/ocfs2/namei.c
+++ b/fs/ocfs2/namei.c
@@ -671,7 +671,7 @@ static struct dentry *ocfs2_mkdir(const struct mnt_idmap *idmap,
return ERR_PTR(ret);
}
-static int ocfs2_create(struct mnt_idmap *idmap,
+static int ocfs2_create(const struct mnt_idmap *idmap,
struct inode *dir,
struct dentry *dentry,
umode_t mode)
diff --git a/fs/omfs/dir.c b/fs/omfs/dir.c
index a476675e8e61..18f4b4543cc8 100644
--- a/fs/omfs/dir.c
+++ b/fs/omfs/dir.c
@@ -285,7 +285,7 @@ static struct dentry *omfs_mkdir(const struct mnt_idmap *idmap, struct inode *di
return ERR_PTR(omfs_add_node(dir, dentry, mode));
}
-static int omfs_create(struct mnt_idmap *idmap, struct inode *dir,
+static int omfs_create(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
return omfs_add_node(dir, dentry, mode | S_IFREG);
diff --git a/fs/orangefs/namei.c b/fs/orangefs/namei.c
index f5deb8cdbf2f..32b7769ea49c 100644
--- a/fs/orangefs/namei.c
+++ b/fs/orangefs/namei.c
@@ -15,7 +15,7 @@
/*
* Get a newly allocated inode to go with a negative dentry.
*/
-static int orangefs_create(struct mnt_idmap *idmap,
+static int orangefs_create(const struct mnt_idmap *idmap,
struct inode *dir,
struct dentry *dentry,
umode_t mode)
diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
index f7a3fd3a25b9..1194ccf981c3 100644
--- a/fs/overlayfs/dir.c
+++ b/fs/overlayfs/dir.c
@@ -730,7 +730,7 @@ static int ovl_create_object(const struct mnt_idmap *idmap, struct dentry *dentr
return err;
}
-static int ovl_create(struct mnt_idmap *idmap, struct inode *dir,
+static int ovl_create(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
return ovl_create_object(idmap, dentry, (mode & 07777) | S_IFREG, 0, NULL);
diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c
index cc06d806b214..ef91b933d4e6 100644
--- a/fs/ramfs/inode.c
+++ b/fs/ramfs/inode.c
@@ -127,7 +127,7 @@ static struct dentry *ramfs_mkdir(const struct mnt_idmap *idmap, struct inode *d
return ERR_PTR(retval);
}
-static int ramfs_create(struct mnt_idmap *idmap, struct inode *dir,
+static int ramfs_create(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
return ramfs_mknod(&nop_mnt_idmap, dir, dentry, mode | S_IFREG, 0);
diff --git a/fs/smb/client/cifsfs.h b/fs/smb/client/cifsfs.h
index 483d2b23fc23..cf09d915bedd 100644
--- a/fs/smb/client/cifsfs.h
+++ b/fs/smb/client/cifsfs.h
@@ -53,7 +53,7 @@ void cifs_sb_deactive(struct super_block *sb);
/* Functions related to inodes */
extern const struct inode_operations cifs_dir_inode_ops;
struct inode *cifs_root_iget(struct super_block *sb);
-int cifs_create(struct mnt_idmap *idmap, struct inode *dir,
+int cifs_create(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *direntry, umode_t mode);
int cifs_atomic_open(struct inode *dir, struct dentry *direntry,
struct file *file, unsigned int oflags, umode_t mode);
diff --git a/fs/smb/client/dir.c b/fs/smb/client/dir.c
index 95da43ad7c02..52d30ebe67f3 100644
--- a/fs/smb/client/dir.c
+++ b/fs/smb/client/dir.c
@@ -640,7 +640,7 @@ int cifs_atomic_open(struct inode *dir, struct dentry *direntry,
* The initial dentry state is hashed-negative. On success, dentry will become
* hashed-positive by calling d_instantiate().
*/
-int cifs_create(struct mnt_idmap *idmap, struct inode *dir,
+int cifs_create(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *direntry, umode_t mode)
{
struct cifs_sb_info *cifs_sb = CIFS_SB(dir);
diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
index d784283d427f..57640b6ff72d 100644
--- a/fs/ubifs/dir.c
+++ b/fs/ubifs/dir.c
@@ -302,7 +302,7 @@ static int ubifs_prepare_create(struct inode *dir, struct dentry *dentry,
return fscrypt_setup_filename(dir, &dentry->d_name, 0, nm);
}
-static int ubifs_create(struct mnt_idmap *idmap, struct inode *dir,
+static int ubifs_create(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
struct inode *inode;
diff --git a/fs/udf/namei.c b/fs/udf/namei.c
index 002e79052f92..42d000fe9d6b 100644
--- a/fs/udf/namei.c
+++ b/fs/udf/namei.c
@@ -370,7 +370,7 @@ static int udf_add_nondir(struct dentry *dentry, struct inode *inode)
return 0;
}
-static int udf_create(struct mnt_idmap *idmap, struct inode *dir,
+static int udf_create(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
struct inode *inode = udf_new_inode(dir, mode);
diff --git a/fs/ufs/namei.c b/fs/ufs/namei.c
index 9231a5cda08e..d45347a25741 100644
--- a/fs/ufs/namei.c
+++ b/fs/ufs/namei.c
@@ -69,7 +69,7 @@ static struct dentry *ufs_lookup(struct inode * dir, struct dentry *dentry, unsi
* If the create succeeds, we fill in the inode information
* with d_instantiate().
*/
-static int ufs_create (struct mnt_idmap * idmap,
+static int ufs_create (const struct mnt_idmap * idmap,
struct inode * dir, struct dentry * dentry, umode_t mode)
{
struct inode *inode;
diff --git a/fs/vboxsf/dir.c b/fs/vboxsf/dir.c
index 9db16e90f670..b9c46c769c4e 100644
--- a/fs/vboxsf/dir.c
+++ b/fs/vboxsf/dir.c
@@ -296,7 +296,7 @@ static int vboxsf_dir_create(struct inode *parent, struct dentry *dentry,
return err;
}
-static int vboxsf_dir_mkfile(struct mnt_idmap *idmap,
+static int vboxsf_dir_mkfile(const struct mnt_idmap *idmap,
struct inode *parent, struct dentry *dentry,
umode_t mode)
{
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index fe388619a138..791af2db7124 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -290,7 +290,7 @@ xfs_vn_mknod(
STATIC int
xfs_vn_create(
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct inode *dir,
struct dentry *dentry,
umode_t mode)
diff --git a/include/linux/fs.h b/include/linux/fs.h
index f2c7838644c3..2b9ae72010f0 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1999,7 +1999,7 @@ struct inode_operations {
int (*readlink) (struct dentry *, char __user *,int);
- int (*create) (struct mnt_idmap *, struct inode *,struct dentry *,
+ int (*create) (const struct mnt_idmap *, struct inode *,struct dentry *,
umode_t);
int (*link) (struct dentry *,struct inode *,struct dentry *);
int (*unlink) (struct inode *,struct dentry *);
diff --git a/ipc/mqueue.c b/ipc/mqueue.c
index d1dd36a651b0..e3a1f3b6d00f 100644
--- a/ipc/mqueue.c
+++ b/ipc/mqueue.c
@@ -607,7 +607,7 @@ static int mqueue_create_attr(struct dentry *dentry, umode_t mode, void *arg)
return error;
}
-static int mqueue_create(struct mnt_idmap *idmap, struct inode *dir,
+static int mqueue_create(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
return mqueue_create_attr(dentry, mode, NULL);
diff --git a/mm/shmem.c b/mm/shmem.c
index f633af032a08..656235b2f9c5 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -3897,7 +3897,7 @@ static struct dentry *shmem_mkdir(const struct mnt_idmap *idmap, struct inode *d
return NULL;
}
-static int shmem_create(struct mnt_idmap *idmap, struct inode *dir,
+static int shmem_create(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode)
{
return shmem_mknod(idmap, dir, dentry, mode | S_IFREG, 0);
--
2.53.0
^ permalink raw reply related [flat|nested] 62+ messages in thread* Re: [PATCH 22/27] fs: port ->create() to pass const mnt_idmap
2026-09-01 12:14 ` [PATCH 22/27] fs: port ->create() " Christian Brauner
@ 2026-09-02 15:55 ` Jan Kara
0 siblings, 0 replies; 62+ messages in thread
From: Jan Kara @ 2026-09-02 15:55 UTC (permalink / raw)
To: Christian Brauner
Cc: linux-fsdevel, Alexander Viro, Jan Kara, Christoph Hellwig,
Seth Forshee, Paul Moore, linux-security-module, Mimi Zohar,
linux-integrity, Ilya Dryomov, ceph-devel, Carlos Maiolino,
linux-xfs, Miklos Szeredi, Amir Goldstein, linux-unionfs,
Namjae Jeon, linux-cifs, linux-kernel
On Tue 01-09-26 14:14:47, Christian Brauner wrote:
> Convert to const struct mnt_idmap.
>
> A mount's idmapping is immutable. The only thing that is allowed to be
> modified afterwards is the reference count and that is hidden behind
> mnt_idmap_get() and mnt_idmap_put(). Everything else only ever reads
> from the idmapping. This is the same model that struct cred uses and the
> idmapping is also rather sensitive.
>
> So make the idmap argument const wherever we can. The conversion is done
> from the bottom up so callers can continue to pass a non-const pointer
> to a const parameter until the conversion is finished.
>
> No functional changes.
>
> Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> Documentation/filesystems/locking.rst | 2 +-
> Documentation/filesystems/vfs.rst | 2 +-
> fs/9p/vfs_inode.c | 2 +-
> fs/9p/vfs_inode_dotl.c | 2 +-
> fs/affs/affs.h | 2 +-
> fs/affs/namei.c | 2 +-
> fs/afs/dir.c | 4 ++--
> fs/bad_inode.c | 2 +-
> fs/bfs/dir.c | 2 +-
> fs/btrfs/inode.c | 2 +-
> fs/ceph/dir.c | 2 +-
> fs/coda/dir.c | 2 +-
> fs/ecryptfs/inode.c | 2 +-
> fs/efivarfs/inode.c | 2 +-
> fs/exfat/namei.c | 2 +-
> fs/ext2/namei.c | 2 +-
> fs/ext4/namei.c | 2 +-
> fs/f2fs/namei.c | 2 +-
> fs/fat/namei_msdos.c | 2 +-
> fs/fat/namei_vfat.c | 2 +-
> fs/fuse/dir.c | 2 +-
> fs/gfs2/inode.c | 2 +-
> fs/hfs/dir.c | 2 +-
> fs/hfsplus/dir.c | 2 +-
> fs/hostfs/hostfs_kern.c | 2 +-
> fs/hpfs/namei.c | 2 +-
> fs/hugetlbfs/inode.c | 2 +-
> fs/jffs2/dir.c | 4 ++--
> fs/jfs/namei.c | 2 +-
> fs/minix/namei.c | 2 +-
> fs/nfs/dir.c | 2 +-
> fs/nfs/internal.h | 2 +-
> fs/nilfs2/namei.c | 2 +-
> fs/ntfs/namei.c | 2 +-
> fs/ntfs3/namei.c | 2 +-
> fs/ocfs2/dlmfs/dlmfs.c | 2 +-
> fs/ocfs2/namei.c | 2 +-
> fs/omfs/dir.c | 2 +-
> fs/orangefs/namei.c | 2 +-
> fs/overlayfs/dir.c | 2 +-
> fs/ramfs/inode.c | 2 +-
> fs/smb/client/cifsfs.h | 2 +-
> fs/smb/client/dir.c | 2 +-
> fs/ubifs/dir.c | 2 +-
> fs/udf/namei.c | 2 +-
> fs/ufs/namei.c | 2 +-
> fs/vboxsf/dir.c | 2 +-
> fs/xfs/xfs_iops.c | 2 +-
> include/linux/fs.h | 2 +-
> ipc/mqueue.c | 2 +-
> mm/shmem.c | 2 +-
> 51 files changed, 53 insertions(+), 53 deletions(-)
>
> diff --git a/Documentation/filesystems/locking.rst b/Documentation/filesystems/locking.rst
> index 856b9cc88c76..864768700eda 100644
> --- a/Documentation/filesystems/locking.rst
> +++ b/Documentation/filesystems/locking.rst
> @@ -61,7 +61,7 @@ inode_operations
>
> prototypes::
>
> - int (*create) (struct mnt_idmap *, struct inode *,struct dentry *,umode_t);
> + int (*create) (const struct mnt_idmap *, struct inode *,struct dentry *,umode_t);
> struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
> int (*link) (struct dentry *,struct inode *,struct dentry *);
> int (*unlink) (struct inode *,struct dentry *);
> diff --git a/Documentation/filesystems/vfs.rst b/Documentation/filesystems/vfs.rst
> index 5a9203e98bb6..2ad273cfe547 100644
> --- a/Documentation/filesystems/vfs.rst
> +++ b/Documentation/filesystems/vfs.rst
> @@ -415,7 +415,7 @@ As of kernel 2.6.22, the following members are defined:
> .. code-block:: c
>
> struct inode_operations {
> - int (*create) (struct mnt_idmap *, struct inode *,struct dentry *, umode_t);
> + int (*create) (const struct mnt_idmap *, struct inode *,struct dentry *, umode_t);
> struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
> int (*link) (struct dentry *,struct inode *,struct dentry *);
> int (*unlink) (struct inode *,struct dentry *);
> diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
> index cc52c244bb95..f2d0eef68acf 100644
> --- a/fs/9p/vfs_inode.c
> +++ b/fs/9p/vfs_inode.c
> @@ -652,7 +652,7 @@ v9fs_create(struct v9fs_session_info *v9ses, struct inode *dir,
> */
>
> static int
> -v9fs_vfs_create(struct mnt_idmap *idmap, struct inode *dir,
> +v9fs_vfs_create(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dir);
> diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c
> index ec58718eec4a..c7176719a4f9 100644
> --- a/fs/9p/vfs_inode_dotl.c
> +++ b/fs/9p/vfs_inode_dotl.c
> @@ -216,7 +216,7 @@ int v9fs_open_to_dotl_flags(int flags)
> *
> */
> static int
> -v9fs_vfs_create_dotl(struct mnt_idmap *idmap, struct inode *dir,
> +v9fs_vfs_create_dotl(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t omode)
> {
> return v9fs_vfs_mknod_dotl(idmap, dir, dentry, omode, 0);
> diff --git a/fs/affs/affs.h b/fs/affs/affs.h
> index b1047766a829..8d4ca16c7891 100644
> --- a/fs/affs/affs.h
> +++ b/fs/affs/affs.h
> @@ -166,7 +166,7 @@ extern const struct export_operations affs_export_ops;
> extern int affs_hash_name(struct super_block *sb, const u8 *name, unsigned int len);
> extern struct dentry *affs_lookup(struct inode *dir, struct dentry *dentry, unsigned int);
> extern int affs_unlink(struct inode *dir, struct dentry *dentry);
> -extern int affs_create(struct mnt_idmap *idmap, struct inode *dir,
> +extern int affs_create(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode);
> extern struct dentry *affs_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode);
> diff --git a/fs/affs/namei.c b/fs/affs/namei.c
> index 1d609355fc3f..2e32899a32d5 100644
> --- a/fs/affs/namei.c
> +++ b/fs/affs/namei.c
> @@ -242,7 +242,7 @@ affs_unlink(struct inode *dir, struct dentry *dentry)
> }
>
> int
> -affs_create(struct mnt_idmap *idmap, struct inode *dir,
> +affs_create(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> struct super_block *sb = dir->i_sb;
> diff --git a/fs/afs/dir.c b/fs/afs/dir.c
> index 603dd9323ed2..63d4f15ae168 100644
> --- a/fs/afs/dir.c
> +++ b/fs/afs/dir.c
> @@ -33,7 +33,7 @@ static bool afs_lookup_one_filldir(struct dir_context *ctx, const char *name, in
> static bool afs_lookup_filldir(struct dir_context *ctx, const char *name, int nlen,
> u64 ino, u32 uniquifier);
> #define AFS_LOOKUP ((filldir_t)0x137UL)
> -static int afs_create(struct mnt_idmap *idmap, struct inode *dir,
> +static int afs_create(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode);
> static struct dentry *afs_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode);
> @@ -1632,7 +1632,7 @@ static const struct afs_operation_ops afs_create_operation = {
> /*
> * create a regular file on an AFS filesystem
> */
> -static int afs_create(struct mnt_idmap *idmap, struct inode *dir,
> +static int afs_create(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> struct afs_operation *op;
> diff --git a/fs/bad_inode.c b/fs/bad_inode.c
> index 096e6afb5e07..8c7578ea4bd7 100644
> --- a/fs/bad_inode.c
> +++ b/fs/bad_inode.c
> @@ -27,7 +27,7 @@ static const struct file_operations bad_file_ops =
> .open = bad_file_open,
> };
>
> -static int bad_inode_create(struct mnt_idmap *idmap,
> +static int bad_inode_create(const struct mnt_idmap *idmap,
> struct inode *dir, struct dentry *dentry,
> umode_t mode)
> {
> diff --git a/fs/bfs/dir.c b/fs/bfs/dir.c
> index 80534d04db9d..b944bd62f5d0 100644
> --- a/fs/bfs/dir.c
> +++ b/fs/bfs/dir.c
> @@ -75,7 +75,7 @@ const struct file_operations bfs_dir_operations = {
> .llseek = generic_file_llseek,
> };
>
> -static int bfs_create(struct mnt_idmap *idmap, struct inode *dir,
> +static int bfs_create(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> int err;
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index 9b5e3a67122d..61cfa03b6152 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -7018,7 +7018,7 @@ static int btrfs_mknod(const struct mnt_idmap *idmap, struct inode *dir,
> return btrfs_create_common(dir, dentry, inode);
> }
>
> -static int btrfs_create(struct mnt_idmap *idmap, struct inode *dir,
> +static int btrfs_create(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> struct inode *inode;
> diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
> index 5417a9948e98..d9615d67bf1c 100644
> --- a/fs/ceph/dir.c
> +++ b/fs/ceph/dir.c
> @@ -988,7 +988,7 @@ static int ceph_mknod(const struct mnt_idmap *idmap, struct inode *dir,
> return err;
> }
>
> -static int ceph_create(struct mnt_idmap *idmap, struct inode *dir,
> +static int ceph_create(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> return ceph_mknod(idmap, dir, dentry, mode, 0);
> diff --git a/fs/coda/dir.c b/fs/coda/dir.c
> index 02b8259b6a0e..a85be5962e62 100644
> --- a/fs/coda/dir.c
> +++ b/fs/coda/dir.c
> @@ -133,7 +133,7 @@ static inline void coda_dir_drop_nlink(struct inode *dir)
> }
>
> /* creation routines: create, mknod, mkdir, link, symlink */
> -static int coda_create(struct mnt_idmap *idmap, struct inode *dir,
> +static int coda_create(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *de, umode_t mode)
> {
> int error;
> diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
> index f9a3c88c4fbd..432f82bc5b0c 100644
> --- a/fs/ecryptfs/inode.c
> +++ b/fs/ecryptfs/inode.c
> @@ -266,7 +266,7 @@ int ecryptfs_initialize_file(struct dentry *ecryptfs_dentry,
> * Returns zero on success; non-zero on error condition
> */
> static int
> -ecryptfs_create(struct mnt_idmap *idmap,
> +ecryptfs_create(const struct mnt_idmap *idmap,
> struct inode *directory_inode, struct dentry *ecryptfs_dentry,
> umode_t mode)
> {
> diff --git a/fs/efivarfs/inode.c b/fs/efivarfs/inode.c
> index f7dcd72e4a07..d87091b92776 100644
> --- a/fs/efivarfs/inode.c
> +++ b/fs/efivarfs/inode.c
> @@ -74,7 +74,7 @@ static bool efivarfs_valid_name(const char *str, int len)
> return uuid_is_valid(s);
> }
>
> -static int efivarfs_create(struct mnt_idmap *idmap, struct inode *dir,
> +static int efivarfs_create(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> struct inode *inode = NULL;
> diff --git a/fs/exfat/namei.c b/fs/exfat/namei.c
> index 4accf96ea7f9..5e7836af63b8 100644
> --- a/fs/exfat/namei.c
> +++ b/fs/exfat/namei.c
> @@ -552,7 +552,7 @@ static int exfat_add_entry(struct inode *inode, const char *path,
> return ret;
> }
>
> -static int exfat_create(struct mnt_idmap *idmap, struct inode *dir,
> +static int exfat_create(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> struct super_block *sb = dir->i_sb;
> diff --git a/fs/ext2/namei.c b/fs/ext2/namei.c
> index 7da42f071eab..bfb6a463a95e 100644
> --- a/fs/ext2/namei.c
> +++ b/fs/ext2/namei.c
> @@ -97,7 +97,7 @@ struct dentry *ext2_get_parent(struct dentry *child)
> * If the create succeeds, we fill in the inode information
> * with d_instantiate().
> */
> -static int ext2_create (struct mnt_idmap * idmap,
> +static int ext2_create (const struct mnt_idmap * idmap,
> struct inode * dir, struct dentry * dentry,
> umode_t mode)
> {
> diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
> index 6e493b4d205f..6e0630a49e48 100644
> --- a/fs/ext4/namei.c
> +++ b/fs/ext4/namei.c
> @@ -2812,7 +2812,7 @@ static int ext4_add_nondir(handle_t *handle,
> * If the create succeeds, we fill in the inode information
> * with d_instantiate().
> */
> -static int ext4_create(struct mnt_idmap *idmap, struct inode *dir,
> +static int ext4_create(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> handle_t *handle;
> diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
> index b2e99822d8b4..9934777eb2a9 100644
> --- a/fs/f2fs/namei.c
> +++ b/fs/f2fs/namei.c
> @@ -365,7 +365,7 @@ static struct inode *f2fs_new_inode(const struct mnt_idmap *idmap,
> return ERR_PTR(err);
> }
>
> -static int f2fs_create(struct mnt_idmap *idmap, struct inode *dir,
> +static int f2fs_create(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> struct f2fs_sb_info *sbi = F2FS_I_SB(dir);
> diff --git a/fs/fat/namei_msdos.c b/fs/fat/namei_msdos.c
> index 9ee899391f4f..dde4215616f9 100644
> --- a/fs/fat/namei_msdos.c
> +++ b/fs/fat/namei_msdos.c
> @@ -263,7 +263,7 @@ static int msdos_add_entry(struct inode *dir, const unsigned char *name,
> }
>
> /***** Create a file */
> -static int msdos_create(struct mnt_idmap *idmap, struct inode *dir,
> +static int msdos_create(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> struct super_block *sb = dir->i_sb;
> diff --git a/fs/fat/namei_vfat.c b/fs/fat/namei_vfat.c
> index a3f3320fe630..3dc063ba0a73 100644
> --- a/fs/fat/namei_vfat.c
> +++ b/fs/fat/namei_vfat.c
> @@ -753,7 +753,7 @@ static struct dentry *vfat_lookup(struct inode *dir, struct dentry *dentry,
> return ERR_PTR(err);
> }
>
> -static int vfat_create(struct mnt_idmap *idmap, struct inode *dir,
> +static int vfat_create(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> struct super_block *sb = dir->i_sb;
> diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
> index 3d8246ff061e..ff941e78918f 100644
> --- a/fs/fuse/dir.c
> +++ b/fs/fuse/dir.c
> @@ -1092,7 +1092,7 @@ static int fuse_mknod(const struct mnt_idmap *idmap, struct inode *dir,
> return create_new_nondir(idmap, fm, &args, dir, entry, mode);
> }
>
> -static int fuse_create(struct mnt_idmap *idmap, struct inode *dir,
> +static int fuse_create(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *entry, umode_t mode)
> {
> return fuse_mknod(idmap, dir, entry, mode, 0);
> diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
> index c8f2b01e8cf5..e207ab1f5c23 100644
> --- a/fs/gfs2/inode.c
> +++ b/fs/gfs2/inode.c
> @@ -967,7 +967,7 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry,
> * Returns: errno
> */
>
> -static int gfs2_create(struct mnt_idmap *idmap, struct inode *dir,
> +static int gfs2_create(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> return gfs2_create_inode(dir, dentry, NULL, S_IFREG | mode, 0, NULL, 0, 1);
> diff --git a/fs/hfs/dir.c b/fs/hfs/dir.c
> index d60399c62e99..f6b97da19788 100644
> --- a/fs/hfs/dir.c
> +++ b/fs/hfs/dir.c
> @@ -183,7 +183,7 @@ static int hfs_dir_release(struct inode *inode, struct file *file)
> * a directory and return a corresponding inode, given the inode for
> * the directory and the name (and its length) of the new file.
> */
> -static int hfs_create(struct mnt_idmap *idmap, struct inode *dir,
> +static int hfs_create(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> struct inode *inode;
> diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c
> index 1b59ddb6d1e1..b3a1193a491f 100644
> --- a/fs/hfsplus/dir.c
> +++ b/fs/hfsplus/dir.c
> @@ -561,7 +561,7 @@ static int hfsplus_mknod(const struct mnt_idmap *idmap, struct inode *dir,
> return res;
> }
>
> -static int hfsplus_create(struct mnt_idmap *idmap, struct inode *dir,
> +static int hfsplus_create(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> return hfsplus_mknod(&nop_mnt_idmap, dir, dentry, mode, 0);
> diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
> index ef03763aa074..c8ad58be047e 100644
> --- a/fs/hostfs/hostfs_kern.c
> +++ b/fs/hostfs/hostfs_kern.c
> @@ -592,7 +592,7 @@ static struct inode *hostfs_iget(struct super_block *sb, char *name)
> return inode;
> }
>
> -static int hostfs_create(struct mnt_idmap *idmap, struct inode *dir,
> +static int hostfs_create(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> struct inode *inode;
> diff --git a/fs/hpfs/namei.c b/fs/hpfs/namei.c
> index 44a7fb797633..ac9b5e3e83fa 100644
> --- a/fs/hpfs/namei.c
> +++ b/fs/hpfs/namei.c
> @@ -128,7 +128,7 @@ static struct dentry *hpfs_mkdir(const struct mnt_idmap *idmap, struct inode *di
> return ERR_PTR(err);
> }
>
> -static int hpfs_create(struct mnt_idmap *idmap, struct inode *dir,
> +static int hpfs_create(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> const unsigned char *name = dentry->d_name.name;
> diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
> index 9e937602b2ec..0b95be14d3ee 100644
> --- a/fs/hugetlbfs/inode.c
> +++ b/fs/hugetlbfs/inode.c
> @@ -977,7 +977,7 @@ static struct dentry *hugetlbfs_mkdir(const struct mnt_idmap *idmap, struct inod
> return ERR_PTR(retval);
> }
>
> -static int hugetlbfs_create(struct mnt_idmap *idmap,
> +static int hugetlbfs_create(const struct mnt_idmap *idmap,
> struct inode *dir, struct dentry *dentry,
> umode_t mode)
> {
> diff --git a/fs/jffs2/dir.c b/fs/jffs2/dir.c
> index 7d23be0bab72..23813f191281 100644
> --- a/fs/jffs2/dir.c
> +++ b/fs/jffs2/dir.c
> @@ -25,7 +25,7 @@
>
> static int jffs2_readdir (struct file *, struct dir_context *);
>
> -static int jffs2_create (struct mnt_idmap *, struct inode *,
> +static int jffs2_create (const struct mnt_idmap *, struct inode *,
> struct dentry *, umode_t);
> static struct dentry *jffs2_lookup (struct inode *,struct dentry *,
> unsigned int);
> @@ -162,7 +162,7 @@ static int jffs2_readdir(struct file *file, struct dir_context *ctx)
> /***********************************************************************/
>
>
> -static int jffs2_create(struct mnt_idmap *idmap, struct inode *dir_i,
> +static int jffs2_create(const struct mnt_idmap *idmap, struct inode *dir_i,
> struct dentry *dentry, umode_t mode)
> {
> struct jffs2_raw_inode *ri;
> diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c
> index 6009d65ab53f..8ab2e952ce16 100644
> --- a/fs/jfs/namei.c
> +++ b/fs/jfs/namei.c
> @@ -60,7 +60,7 @@ static inline void free_ea_wmap(struct inode *inode)
> * RETURN: Errors from subroutines
> *
> */
> -static int jfs_create(struct mnt_idmap *idmap, struct inode *dip,
> +static int jfs_create(const struct mnt_idmap *idmap, struct inode *dip,
> struct dentry *dentry, umode_t mode)
> {
> int rc = 0;
> diff --git a/fs/minix/namei.c b/fs/minix/namei.c
> index 11b66a25e92b..f450b11b9860 100644
> --- a/fs/minix/namei.c
> +++ b/fs/minix/namei.c
> @@ -63,7 +63,7 @@ static int minix_tmpfile(const struct mnt_idmap *idmap, struct inode *dir,
> return finish_open_simple(file, 0);
> }
>
> -static int minix_create(struct mnt_idmap *idmap, struct inode *dir,
> +static int minix_create(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> return minix_mknod(&nop_mnt_idmap, dir, dentry, mode, 0);
> diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
> index a917c008a05a..354f986e60c4 100644
> --- a/fs/nfs/dir.c
> +++ b/fs/nfs/dir.c
> @@ -2437,7 +2437,7 @@ static int nfs_do_create(struct inode *dir, struct dentry *dentry,
> return error;
> }
>
> -int nfs_create(struct mnt_idmap *idmap, struct inode *dir,
> +int nfs_create(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> return nfs_do_create(dir, dentry, mode, O_EXCL);
> diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
> index 4c966dac7f7d..cbb323c6530d 100644
> --- a/fs/nfs/internal.h
> +++ b/fs/nfs/internal.h
> @@ -396,7 +396,7 @@ extern unsigned long nfs_access_cache_scan(struct shrinker *shrink,
> struct shrink_control *sc);
> struct dentry *nfs_lookup(struct inode *, struct dentry *, unsigned int);
> void nfs_d_prune_case_insensitive_aliases(struct inode *inode);
> -int nfs_create(struct mnt_idmap *, struct inode *, struct dentry *,
> +int nfs_create(const struct mnt_idmap *, struct inode *, struct dentry *,
> umode_t);
> struct dentry *nfs_mkdir(const struct mnt_idmap *, struct inode *, struct dentry *,
> umode_t);
> diff --git a/fs/nilfs2/namei.c b/fs/nilfs2/namei.c
> index 8762fdc16c05..d0ae24f37854 100644
> --- a/fs/nilfs2/namei.c
> +++ b/fs/nilfs2/namei.c
> @@ -85,7 +85,7 @@ nilfs_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags)
> * If the create succeeds, we fill in the inode information
> * with d_instantiate().
> */
> -static int nilfs_create(struct mnt_idmap *idmap, struct inode *dir,
> +static int nilfs_create(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> struct inode *inode;
> diff --git a/fs/ntfs/namei.c b/fs/ntfs/namei.c
> index 637bc3690844..5d222edadf0c 100644
> --- a/fs/ntfs/namei.c
> +++ b/fs/ntfs/namei.c
> @@ -732,7 +732,7 @@ static struct ntfs_inode *__ntfs_create(const struct mnt_idmap *idmap, struct in
> return ERR_PTR(err);
> }
>
> -static int ntfs_create(struct mnt_idmap *idmap, struct inode *dir,
> +static int ntfs_create(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> struct ntfs_volume *vol = NTFS_SB(dir->i_sb);
> diff --git a/fs/ntfs3/namei.c b/fs/ntfs3/namei.c
> index 289796da6ba5..ae88cb66fb7e 100644
> --- a/fs/ntfs3/namei.c
> +++ b/fs/ntfs3/namei.c
> @@ -111,7 +111,7 @@ static struct dentry *ntfs_lookup(struct inode *dir, struct dentry *dentry,
> /*
> * ntfs_create - inode_operations::create
> */
> -static int ntfs_create(struct mnt_idmap *idmap, struct inode *dir,
> +static int ntfs_create(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> return ntfs_create_inode(idmap, dir, dentry, NULL, S_IFREG | mode, 0,
> diff --git a/fs/ocfs2/dlmfs/dlmfs.c b/fs/ocfs2/dlmfs/dlmfs.c
> index 5e544d8ded42..fef79b21a4a5 100644
> --- a/fs/ocfs2/dlmfs/dlmfs.c
> +++ b/fs/ocfs2/dlmfs/dlmfs.c
> @@ -450,7 +450,7 @@ static struct dentry *dlmfs_mkdir(const struct mnt_idmap * idmap,
> return ERR_PTR(status);
> }
>
> -static int dlmfs_create(struct mnt_idmap *idmap,
> +static int dlmfs_create(const struct mnt_idmap *idmap,
> struct inode *dir,
> struct dentry *dentry,
> umode_t mode)
> diff --git a/fs/ocfs2/namei.c b/fs/ocfs2/namei.c
> index dfa2cb2bcb12..4873525be3b1 100644
> --- a/fs/ocfs2/namei.c
> +++ b/fs/ocfs2/namei.c
> @@ -671,7 +671,7 @@ static struct dentry *ocfs2_mkdir(const struct mnt_idmap *idmap,
> return ERR_PTR(ret);
> }
>
> -static int ocfs2_create(struct mnt_idmap *idmap,
> +static int ocfs2_create(const struct mnt_idmap *idmap,
> struct inode *dir,
> struct dentry *dentry,
> umode_t mode)
> diff --git a/fs/omfs/dir.c b/fs/omfs/dir.c
> index a476675e8e61..18f4b4543cc8 100644
> --- a/fs/omfs/dir.c
> +++ b/fs/omfs/dir.c
> @@ -285,7 +285,7 @@ static struct dentry *omfs_mkdir(const struct mnt_idmap *idmap, struct inode *di
> return ERR_PTR(omfs_add_node(dir, dentry, mode));
> }
>
> -static int omfs_create(struct mnt_idmap *idmap, struct inode *dir,
> +static int omfs_create(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> return omfs_add_node(dir, dentry, mode | S_IFREG);
> diff --git a/fs/orangefs/namei.c b/fs/orangefs/namei.c
> index f5deb8cdbf2f..32b7769ea49c 100644
> --- a/fs/orangefs/namei.c
> +++ b/fs/orangefs/namei.c
> @@ -15,7 +15,7 @@
> /*
> * Get a newly allocated inode to go with a negative dentry.
> */
> -static int orangefs_create(struct mnt_idmap *idmap,
> +static int orangefs_create(const struct mnt_idmap *idmap,
> struct inode *dir,
> struct dentry *dentry,
> umode_t mode)
> diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c
> index f7a3fd3a25b9..1194ccf981c3 100644
> --- a/fs/overlayfs/dir.c
> +++ b/fs/overlayfs/dir.c
> @@ -730,7 +730,7 @@ static int ovl_create_object(const struct mnt_idmap *idmap, struct dentry *dentr
> return err;
> }
>
> -static int ovl_create(struct mnt_idmap *idmap, struct inode *dir,
> +static int ovl_create(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> return ovl_create_object(idmap, dentry, (mode & 07777) | S_IFREG, 0, NULL);
> diff --git a/fs/ramfs/inode.c b/fs/ramfs/inode.c
> index cc06d806b214..ef91b933d4e6 100644
> --- a/fs/ramfs/inode.c
> +++ b/fs/ramfs/inode.c
> @@ -127,7 +127,7 @@ static struct dentry *ramfs_mkdir(const struct mnt_idmap *idmap, struct inode *d
> return ERR_PTR(retval);
> }
>
> -static int ramfs_create(struct mnt_idmap *idmap, struct inode *dir,
> +static int ramfs_create(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> return ramfs_mknod(&nop_mnt_idmap, dir, dentry, mode | S_IFREG, 0);
> diff --git a/fs/smb/client/cifsfs.h b/fs/smb/client/cifsfs.h
> index 483d2b23fc23..cf09d915bedd 100644
> --- a/fs/smb/client/cifsfs.h
> +++ b/fs/smb/client/cifsfs.h
> @@ -53,7 +53,7 @@ void cifs_sb_deactive(struct super_block *sb);
> /* Functions related to inodes */
> extern const struct inode_operations cifs_dir_inode_ops;
> struct inode *cifs_root_iget(struct super_block *sb);
> -int cifs_create(struct mnt_idmap *idmap, struct inode *dir,
> +int cifs_create(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *direntry, umode_t mode);
> int cifs_atomic_open(struct inode *dir, struct dentry *direntry,
> struct file *file, unsigned int oflags, umode_t mode);
> diff --git a/fs/smb/client/dir.c b/fs/smb/client/dir.c
> index 95da43ad7c02..52d30ebe67f3 100644
> --- a/fs/smb/client/dir.c
> +++ b/fs/smb/client/dir.c
> @@ -640,7 +640,7 @@ int cifs_atomic_open(struct inode *dir, struct dentry *direntry,
> * The initial dentry state is hashed-negative. On success, dentry will become
> * hashed-positive by calling d_instantiate().
> */
> -int cifs_create(struct mnt_idmap *idmap, struct inode *dir,
> +int cifs_create(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *direntry, umode_t mode)
> {
> struct cifs_sb_info *cifs_sb = CIFS_SB(dir);
> diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
> index d784283d427f..57640b6ff72d 100644
> --- a/fs/ubifs/dir.c
> +++ b/fs/ubifs/dir.c
> @@ -302,7 +302,7 @@ static int ubifs_prepare_create(struct inode *dir, struct dentry *dentry,
> return fscrypt_setup_filename(dir, &dentry->d_name, 0, nm);
> }
>
> -static int ubifs_create(struct mnt_idmap *idmap, struct inode *dir,
> +static int ubifs_create(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> struct inode *inode;
> diff --git a/fs/udf/namei.c b/fs/udf/namei.c
> index 002e79052f92..42d000fe9d6b 100644
> --- a/fs/udf/namei.c
> +++ b/fs/udf/namei.c
> @@ -370,7 +370,7 @@ static int udf_add_nondir(struct dentry *dentry, struct inode *inode)
> return 0;
> }
>
> -static int udf_create(struct mnt_idmap *idmap, struct inode *dir,
> +static int udf_create(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> struct inode *inode = udf_new_inode(dir, mode);
> diff --git a/fs/ufs/namei.c b/fs/ufs/namei.c
> index 9231a5cda08e..d45347a25741 100644
> --- a/fs/ufs/namei.c
> +++ b/fs/ufs/namei.c
> @@ -69,7 +69,7 @@ static struct dentry *ufs_lookup(struct inode * dir, struct dentry *dentry, unsi
> * If the create succeeds, we fill in the inode information
> * with d_instantiate().
> */
> -static int ufs_create (struct mnt_idmap * idmap,
> +static int ufs_create (const struct mnt_idmap * idmap,
> struct inode * dir, struct dentry * dentry, umode_t mode)
> {
> struct inode *inode;
> diff --git a/fs/vboxsf/dir.c b/fs/vboxsf/dir.c
> index 9db16e90f670..b9c46c769c4e 100644
> --- a/fs/vboxsf/dir.c
> +++ b/fs/vboxsf/dir.c
> @@ -296,7 +296,7 @@ static int vboxsf_dir_create(struct inode *parent, struct dentry *dentry,
> return err;
> }
>
> -static int vboxsf_dir_mkfile(struct mnt_idmap *idmap,
> +static int vboxsf_dir_mkfile(const struct mnt_idmap *idmap,
> struct inode *parent, struct dentry *dentry,
> umode_t mode)
> {
> diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
> index fe388619a138..791af2db7124 100644
> --- a/fs/xfs/xfs_iops.c
> +++ b/fs/xfs/xfs_iops.c
> @@ -290,7 +290,7 @@ xfs_vn_mknod(
>
> STATIC int
> xfs_vn_create(
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct inode *dir,
> struct dentry *dentry,
> umode_t mode)
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index f2c7838644c3..2b9ae72010f0 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -1999,7 +1999,7 @@ struct inode_operations {
>
> int (*readlink) (struct dentry *, char __user *,int);
>
> - int (*create) (struct mnt_idmap *, struct inode *,struct dentry *,
> + int (*create) (const struct mnt_idmap *, struct inode *,struct dentry *,
> umode_t);
> int (*link) (struct dentry *,struct inode *,struct dentry *);
> int (*unlink) (struct inode *,struct dentry *);
> diff --git a/ipc/mqueue.c b/ipc/mqueue.c
> index d1dd36a651b0..e3a1f3b6d00f 100644
> --- a/ipc/mqueue.c
> +++ b/ipc/mqueue.c
> @@ -607,7 +607,7 @@ static int mqueue_create_attr(struct dentry *dentry, umode_t mode, void *arg)
> return error;
> }
>
> -static int mqueue_create(struct mnt_idmap *idmap, struct inode *dir,
> +static int mqueue_create(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> return mqueue_create_attr(dentry, mode, NULL);
> diff --git a/mm/shmem.c b/mm/shmem.c
> index f633af032a08..656235b2f9c5 100644
> --- a/mm/shmem.c
> +++ b/mm/shmem.c
> @@ -3897,7 +3897,7 @@ static struct dentry *shmem_mkdir(const struct mnt_idmap *idmap, struct inode *d
> return NULL;
> }
>
> -static int shmem_create(struct mnt_idmap *idmap, struct inode *dir,
> +static int shmem_create(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode)
> {
> return shmem_mknod(idmap, dir, dentry, mode | S_IFREG, 0);
>
> --
> 2.53.0
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 62+ messages in thread
* [PATCH 23/27] fs: port ->getattr() to pass const mnt_idmap
2026-09-01 12:14 [PATCH 00/27] fs: port to const struct mnt_idmap Christian Brauner
` (21 preceding siblings ...)
2026-09-01 12:14 ` [PATCH 22/27] fs: port ->create() " Christian Brauner
@ 2026-09-01 12:14 ` Christian Brauner
2026-09-02 15:58 ` Jan Kara
2026-09-01 12:14 ` [PATCH 24/27] fs: port ->setattr() " Christian Brauner
` (3 subsequent siblings)
26 siblings, 1 reply; 62+ messages in thread
From: Christian Brauner @ 2026-09-01 12:14 UTC (permalink / raw)
To: linux-fsdevel
Cc: Alexander Viro, Jan Kara, Christoph Hellwig, Seth Forshee,
Paul Moore, linux-security-module, Mimi Zohar, linux-integrity,
Ilya Dryomov, ceph-devel, Carlos Maiolino, linux-xfs,
Miklos Szeredi, Amir Goldstein, linux-unionfs, Namjae Jeon,
linux-cifs, linux-kernel, Christian Brauner (Amutable)
Convert to const struct mnt_idmap.
A mount's idmapping is immutable. The only thing that is allowed to be
modified afterwards is the reference count and that is hidden behind
mnt_idmap_get() and mnt_idmap_put(). Everything else only ever reads
from the idmapping. This is the same model that struct cred uses and the
idmapping is also rather sensitive.
So make the idmap argument const wherever we can. The conversion is done
from the bottom up so callers can continue to pass a non-const pointer
to a const parameter until the conversion is finished.
No functional changes.
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
---
Documentation/filesystems/locking.rst | 2 +-
Documentation/filesystems/vfs.rst | 2 +-
fs/9p/vfs_inode.c | 2 +-
fs/9p/vfs_inode_dotl.c | 2 +-
fs/afs/inode.c | 2 +-
fs/afs/internal.h | 2 +-
fs/anon_inodes.c | 2 +-
fs/bad_inode.c | 2 +-
fs/btrfs/inode.c | 2 +-
fs/ceph/inode.c | 4 ++--
fs/ceph/super.h | 2 +-
fs/coda/coda_linux.h | 2 +-
fs/coda/inode.c | 2 +-
fs/ecryptfs/inode.c | 4 ++--
fs/erofs/inode.c | 2 +-
fs/erofs/internal.h | 2 +-
fs/exfat/exfat_fs.h | 2 +-
fs/exfat/file.c | 2 +-
fs/ext2/ext2.h | 2 +-
fs/ext2/inode.c | 2 +-
fs/ext4/ext4.h | 4 ++--
fs/ext4/inode.c | 4 ++--
fs/ext4/symlink.c | 2 +-
fs/f2fs/f2fs.h | 2 +-
fs/f2fs/file.c | 2 +-
fs/f2fs/namei.c | 2 +-
fs/failfs.c | 2 +-
fs/fat/fat.h | 2 +-
fs/fat/file.c | 2 +-
fs/fuse/dir.c | 4 ++--
fs/gfs2/inode.c | 2 +-
fs/hfsplus/hfsplus_fs.h | 2 +-
fs/hfsplus/inode.c | 2 +-
fs/internal.h | 2 +-
fs/kernfs/inode.c | 2 +-
fs/kernfs/kernfs-internal.h | 2 +-
fs/libfs.c | 2 +-
fs/minix/inode.c | 2 +-
fs/minix/minix.h | 2 +-
fs/nfs/inode.c | 2 +-
fs/nfs/namespace.c | 2 +-
fs/ntfs/file.c | 2 +-
fs/ntfs/inode.h | 2 +-
fs/ntfs3/file.c | 2 +-
fs/ntfs3/ntfs_fs.h | 2 +-
fs/ocfs2/file.c | 2 +-
fs/ocfs2/file.h | 2 +-
fs/orangefs/inode.c | 2 +-
fs/orangefs/orangefs-kernel.h | 2 +-
fs/overlayfs/inode.c | 2 +-
fs/overlayfs/overlayfs.h | 2 +-
fs/pidfs.c | 2 +-
fs/proc/base.c | 4 ++--
fs/proc/fd.c | 2 +-
fs/proc/generic.c | 2 +-
fs/proc/internal.h | 2 +-
fs/proc/proc_net.c | 2 +-
fs/proc/proc_sysctl.c | 2 +-
fs/proc/root.c | 2 +-
fs/smb/client/cifsfs.h | 2 +-
fs/smb/client/inode.c | 2 +-
fs/stat.c | 2 +-
fs/tracefs/inode.c | 2 +-
fs/ubifs/dir.c | 2 +-
fs/ubifs/file.c | 2 +-
fs/ubifs/ubifs.h | 2 +-
fs/udf/symlink.c | 2 +-
fs/vboxsf/utils.c | 2 +-
fs/vboxsf/vfsmod.h | 2 +-
fs/xfs/xfs_iops.c | 2 +-
include/linux/fs.h | 6 +++---
include/linux/nfs_fs.h | 2 +-
mm/shmem.c | 2 +-
73 files changed, 81 insertions(+), 81 deletions(-)
diff --git a/Documentation/filesystems/locking.rst b/Documentation/filesystems/locking.rst
index 864768700eda..f11bfc2e0c13 100644
--- a/Documentation/filesystems/locking.rst
+++ b/Documentation/filesystems/locking.rst
@@ -77,7 +77,7 @@ prototypes::
int (*permission) (const struct mnt_idmap *, struct inode *, int, unsigned int);
struct posix_acl * (*get_inode_acl)(struct inode *, int, bool);
int (*setattr) (struct mnt_idmap *, struct dentry *, struct iattr *);
- int (*getattr) (struct mnt_idmap *, const struct path *, struct kstat *, u32, unsigned int);
+ int (*getattr) (const struct mnt_idmap *, const struct path *, struct kstat *, u32, unsigned int);
ssize_t (*listxattr) (struct dentry *, char *, size_t);
int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start, u64 len);
void (*update_time)(struct inode *inode, enum fs_update_time type,
diff --git a/Documentation/filesystems/vfs.rst b/Documentation/filesystems/vfs.rst
index 2ad273cfe547..98aefc5d399e 100644
--- a/Documentation/filesystems/vfs.rst
+++ b/Documentation/filesystems/vfs.rst
@@ -431,7 +431,7 @@ As of kernel 2.6.22, the following members are defined:
int (*permission) (const struct mnt_idmap *, struct inode *, int);
struct posix_acl * (*get_inode_acl)(struct inode *, int, bool);
int (*setattr) (struct mnt_idmap *, struct dentry *, struct iattr *);
- int (*getattr) (struct mnt_idmap *, const struct path *, struct kstat *, u32, unsigned int);
+ int (*getattr) (const struct mnt_idmap *, const struct path *, struct kstat *, u32, unsigned int);
ssize_t (*listxattr) (struct dentry *, char *, size_t);
void (*update_time)(struct inode *inode, enum fs_update_time type,
int flags);
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index f2d0eef68acf..0c280342f8e9 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -966,7 +966,7 @@ v9fs_vfs_rename(const struct mnt_idmap *idmap, struct inode *old_dir,
*/
static int
-v9fs_vfs_getattr(struct mnt_idmap *idmap, const struct path *path,
+v9fs_vfs_getattr(const struct mnt_idmap *idmap, const struct path *path,
struct kstat *stat, u32 request_mask, unsigned int flags)
{
struct dentry *dentry = path->dentry;
diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c
index c7176719a4f9..e37854ee6346 100644
--- a/fs/9p/vfs_inode_dotl.c
+++ b/fs/9p/vfs_inode_dotl.c
@@ -414,7 +414,7 @@ static struct dentry *v9fs_vfs_mkdir_dotl(const struct mnt_idmap *idmap,
}
static int
-v9fs_vfs_getattr_dotl(struct mnt_idmap *idmap,
+v9fs_vfs_getattr_dotl(const struct mnt_idmap *idmap,
const struct path *path, struct kstat *stat,
u32 request_mask, unsigned int flags)
{
diff --git a/fs/afs/inode.c b/fs/afs/inode.c
index 14f39a9bea6c..7b8a2adc3f59 100644
--- a/fs/afs/inode.c
+++ b/fs/afs/inode.c
@@ -596,7 +596,7 @@ struct inode *afs_root_iget(struct super_block *sb, struct key *key)
/*
* read the attributes of an inode
*/
-int afs_getattr(struct mnt_idmap *idmap, const struct path *path,
+int afs_getattr(const struct mnt_idmap *idmap, const struct path *path,
struct kstat *stat, u32 request_mask, unsigned int query_flags)
{
struct inode *inode = d_inode(path->dentry);
diff --git a/fs/afs/internal.h b/fs/afs/internal.h
index e772da2a15f2..7a8cdde9e0ad 100644
--- a/fs/afs/internal.h
+++ b/fs/afs/internal.h
@@ -1258,7 +1258,7 @@ extern int afs_fetch_status(struct afs_vnode *, struct key *, bool, afs_access_t
extern int afs_ilookup5_test_by_fid(struct inode *, void *);
extern struct inode *afs_iget(struct afs_operation *, struct afs_vnode_param *);
extern struct inode *afs_root_iget(struct super_block *, struct key *);
-extern int afs_getattr(struct mnt_idmap *idmap, const struct path *,
+extern int afs_getattr(const struct mnt_idmap *idmap, const struct path *,
struct kstat *, u32, unsigned int);
extern int afs_setattr(struct mnt_idmap *idmap, struct dentry *, struct iattr *);
extern void afs_evict_inode(struct inode *);
diff --git a/fs/anon_inodes.c b/fs/anon_inodes.c
index a7b9b948e33d..d4a7e0b67289 100644
--- a/fs/anon_inodes.c
+++ b/fs/anon_inodes.c
@@ -46,7 +46,7 @@ static struct inode *anon_inode_inode __ro_after_init;
* Rather than mess with our internal sane inode data, just fix it
* up here in getattr() by masking off the format bits.
*/
-int anon_inode_getattr(struct mnt_idmap *idmap, const struct path *path,
+int anon_inode_getattr(const struct mnt_idmap *idmap, const struct path *path,
struct kstat *stat, u32 request_mask,
unsigned int query_flags)
{
diff --git a/fs/bad_inode.c b/fs/bad_inode.c
index 8c7578ea4bd7..e740b4e658bf 100644
--- a/fs/bad_inode.c
+++ b/fs/bad_inode.c
@@ -95,7 +95,7 @@ static int bad_inode_permission(const struct mnt_idmap *idmap,
return -EIO;
}
-static int bad_inode_getattr(struct mnt_idmap *idmap,
+static int bad_inode_getattr(const struct mnt_idmap *idmap,
const struct path *path, struct kstat *stat,
u32 request_mask, unsigned int query_flags)
{
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index 61cfa03b6152..da143f9376ee 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -8224,7 +8224,7 @@ int __init btrfs_init_cachep(void)
return 0;
}
-static int btrfs_getattr(struct mnt_idmap *idmap,
+static int btrfs_getattr(const struct mnt_idmap *idmap,
const struct path *path, struct kstat *stat,
u32 request_mask, unsigned int flags)
{
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index b8527f67e3f0..185d713218e6 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -2398,7 +2398,7 @@ static const char *ceph_encrypted_get_link(struct dentry *dentry,
done);
}
-static int ceph_encrypted_symlink_getattr(struct mnt_idmap *idmap,
+static int ceph_encrypted_symlink_getattr(const struct mnt_idmap *idmap,
const struct path *path,
struct kstat *stat, u32 request_mask,
unsigned int query_flags)
@@ -3145,7 +3145,7 @@ static int statx_to_caps(u32 want, umode_t mode)
* Get all the attributes. If we have sufficient caps for the requested attrs,
* then we can avoid talking to the MDS at all.
*/
-int ceph_getattr(struct mnt_idmap *idmap, const struct path *path,
+int ceph_getattr(const struct mnt_idmap *idmap, const struct path *path,
struct kstat *stat, u32 request_mask, unsigned int flags)
{
struct inode *inode = d_inode(path->dentry);
diff --git a/fs/ceph/super.h b/fs/ceph/super.h
index fd603be209e4..0a5e3916e855 100644
--- a/fs/ceph/super.h
+++ b/fs/ceph/super.h
@@ -1177,7 +1177,7 @@ extern int __ceph_setattr(const struct mnt_idmap *idmap, struct inode *inode,
struct iattr *attr, struct ceph_iattr *cia);
extern int ceph_setattr(struct mnt_idmap *idmap,
struct dentry *dentry, struct iattr *attr);
-extern int ceph_getattr(struct mnt_idmap *idmap,
+extern int ceph_getattr(const struct mnt_idmap *idmap,
const struct path *path, struct kstat *stat,
u32 request_mask, unsigned int flags);
void ceph_inode_shutdown(struct inode *inode);
diff --git a/fs/coda/coda_linux.h b/fs/coda/coda_linux.h
index 5ee6cedd3865..5dc9e392079f 100644
--- a/fs/coda/coda_linux.h
+++ b/fs/coda/coda_linux.h
@@ -49,7 +49,7 @@ int coda_release(struct inode *i, struct file *f);
int coda_permission(const struct mnt_idmap *idmap, struct inode *inode,
int mask);
int coda_revalidate_inode(struct inode *);
-int coda_getattr(struct mnt_idmap *, const struct path *, struct kstat *,
+int coda_getattr(const struct mnt_idmap *, const struct path *, struct kstat *,
u32, unsigned int);
int coda_setattr(struct mnt_idmap *, struct dentry *, struct iattr *);
diff --git a/fs/coda/inode.c b/fs/coda/inode.c
index 40b43866e6a5..f83ebd94c6be 100644
--- a/fs/coda/inode.c
+++ b/fs/coda/inode.c
@@ -294,7 +294,7 @@ static void coda_evict_inode(struct inode *inode)
coda_cache_clear_inode(inode);
}
-int coda_getattr(struct mnt_idmap *idmap, const struct path *path,
+int coda_getattr(const struct mnt_idmap *idmap, const struct path *path,
struct kstat *stat, u32 request_mask, unsigned int flags)
{
int err = coda_revalidate_inode(d_inode(path->dentry));
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index 432f82bc5b0c..e70a8d73d137 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -939,7 +939,7 @@ static int ecryptfs_setattr(struct mnt_idmap *idmap,
return rc;
}
-static int ecryptfs_getattr_link(struct mnt_idmap *idmap,
+static int ecryptfs_getattr_link(const struct mnt_idmap *idmap,
const struct path *path, struct kstat *stat,
u32 request_mask, unsigned int flags)
{
@@ -965,7 +965,7 @@ static int ecryptfs_getattr_link(struct mnt_idmap *idmap,
return rc;
}
-static int ecryptfs_getattr(struct mnt_idmap *idmap,
+static int ecryptfs_getattr(const struct mnt_idmap *idmap,
const struct path *path, struct kstat *stat,
u32 request_mask, unsigned int flags)
{
diff --git a/fs/erofs/inode.c b/fs/erofs/inode.c
index 45afe5c50de8..26ea3790ff21 100644
--- a/fs/erofs/inode.c
+++ b/fs/erofs/inode.c
@@ -311,7 +311,7 @@ struct inode *erofs_iget(struct super_block *sb, erofs_nid_t nid)
return inode;
}
-int erofs_getattr(struct mnt_idmap *idmap, const struct path *path,
+int erofs_getattr(const struct mnt_idmap *idmap, const struct path *path,
struct kstat *stat, u32 request_mask,
unsigned int query_flags)
{
diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h
index 65974e57aebf..b4f52f5cd626 100644
--- a/fs/erofs/internal.h
+++ b/fs/erofs/internal.h
@@ -421,7 +421,7 @@ void erofs_onlinefolio_init(struct folio *folio);
void erofs_onlinefolio_split(struct folio *folio);
void erofs_onlinefolio_end(struct folio *folio, int err, bool dirty);
struct inode *erofs_iget(struct super_block *sb, erofs_nid_t nid);
-int erofs_getattr(struct mnt_idmap *idmap, const struct path *path,
+int erofs_getattr(const struct mnt_idmap *idmap, const struct path *path,
struct kstat *stat, u32 request_mask,
unsigned int query_flags);
int erofs_namei(struct inode *dir, const struct qstr *name,
diff --git a/fs/exfat/exfat_fs.h b/fs/exfat/exfat_fs.h
index a9131fe03302..5165a0df068a 100644
--- a/fs/exfat/exfat_fs.h
+++ b/fs/exfat/exfat_fs.h
@@ -557,7 +557,7 @@ extern const struct file_operations exfat_file_operations;
int __exfat_truncate(struct inode *inode);
int exfat_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *attr);
-int exfat_getattr(struct mnt_idmap *idmap, const struct path *path,
+int exfat_getattr(const struct mnt_idmap *idmap, const struct path *path,
struct kstat *stat, unsigned int request_mask,
unsigned int query_flags);
struct file_kattr;
diff --git a/fs/exfat/file.c b/fs/exfat/file.c
index 0530803f71e8..c072a0663e69 100644
--- a/fs/exfat/file.c
+++ b/fs/exfat/file.c
@@ -319,7 +319,7 @@ static void exfat_truncate(struct inode *inode)
mutex_unlock(&sbi->s_lock);
}
-int exfat_getattr(struct mnt_idmap *idmap, const struct path *path,
+int exfat_getattr(const struct mnt_idmap *idmap, const struct path *path,
struct kstat *stat, unsigned int request_mask,
unsigned int query_flags)
{
diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h
index 702cb7aa1afd..f4bb8b888052 100644
--- a/fs/ext2/ext2.h
+++ b/fs/ext2/ext2.h
@@ -740,7 +740,7 @@ extern void ext2_evict_inode(struct inode *);
void ext2_write_failed(struct address_space *mapping, loff_t to);
extern int ext2_get_block(struct inode *, sector_t, struct buffer_head *, int);
extern int ext2_setattr (struct mnt_idmap *, struct dentry *, struct iattr *);
-extern int ext2_getattr (struct mnt_idmap *, const struct path *,
+extern int ext2_getattr (const struct mnt_idmap *, const struct path *,
struct kstat *, u32, unsigned int);
extern void ext2_set_inode_flags(struct inode *inode);
extern int ext2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
index a9245f0cda4d..d4b2a2dec35e 100644
--- a/fs/ext2/inode.c
+++ b/fs/ext2/inode.c
@@ -1591,7 +1591,7 @@ int ext2_sync_inode_metadata(struct inode *inode, struct writeback_control *wbc)
return err;
}
-int ext2_getattr(struct mnt_idmap *idmap, const struct path *path,
+int ext2_getattr(const struct mnt_idmap *idmap, const struct path *path,
struct kstat *stat, u32 request_mask, unsigned int query_flags)
{
struct inode *inode = d_inode(path->dentry);
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 2c9a845ed0f8..eb7cf19f606a 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -3182,11 +3182,11 @@ extern int ext4_sync_inode_metadata(struct inode *, struct writeback_control *)
extern int ext4_setattr(struct mnt_idmap *, struct dentry *,
struct iattr *);
extern u32 ext4_dio_alignment(struct inode *inode);
-extern int ext4_getattr(struct mnt_idmap *, const struct path *,
+extern int ext4_getattr(const struct mnt_idmap *, const struct path *,
struct kstat *, u32, unsigned int);
extern void ext4_evict_inode(struct inode *);
extern void ext4_clear_inode(struct inode *);
-extern int ext4_file_getattr(struct mnt_idmap *, const struct path *,
+extern int ext4_file_getattr(const struct mnt_idmap *, const struct path *,
struct kstat *, u32, unsigned int);
extern void ext4_dirty_inode(struct inode *, int);
extern int ext4_change_inode_journal_flag(struct inode *, int);
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index bd4b778df9eb..045f5385f26e 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -6263,7 +6263,7 @@ u32 ext4_dio_alignment(struct inode *inode)
return 1; /* use the iomap defaults */
}
-int ext4_getattr(struct mnt_idmap *idmap, const struct path *path,
+int ext4_getattr(const struct mnt_idmap *idmap, const struct path *path,
struct kstat *stat, u32 request_mask, unsigned int query_flags)
{
struct inode *inode = d_inode(path->dentry);
@@ -6332,7 +6332,7 @@ int ext4_getattr(struct mnt_idmap *idmap, const struct path *path,
return 0;
}
-int ext4_file_getattr(struct mnt_idmap *idmap,
+int ext4_file_getattr(const struct mnt_idmap *idmap,
const struct path *path, struct kstat *stat,
u32 request_mask, unsigned int query_flags)
{
diff --git a/fs/ext4/symlink.c b/fs/ext4/symlink.c
index b612262719ed..e680d1e45b47 100644
--- a/fs/ext4/symlink.c
+++ b/fs/ext4/symlink.c
@@ -55,7 +55,7 @@ static const char *ext4_encrypted_get_link(struct dentry *dentry,
return paddr;
}
-static int ext4_encrypted_symlink_getattr(struct mnt_idmap *idmap,
+static int ext4_encrypted_symlink_getattr(const struct mnt_idmap *idmap,
const struct path *path,
struct kstat *stat, u32 request_mask,
unsigned int query_flags)
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 245df8563256..06538f5fd725 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -3848,7 +3848,7 @@ int f2fs_sync_file(struct file *file, loff_t start, loff_t end, int datasync);
int f2fs_do_truncate_blocks(struct inode *inode, u64 from, bool lock);
int f2fs_truncate_blocks(struct inode *inode, u64 from, bool lock);
int f2fs_truncate(struct inode *inode);
-int f2fs_getattr(struct mnt_idmap *idmap, const struct path *path,
+int f2fs_getattr(const struct mnt_idmap *idmap, const struct path *path,
struct kstat *stat, u32 request_mask, unsigned int flags);
int f2fs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *attr);
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index d0cc2ca1397a..267a3a191d54 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -1032,7 +1032,7 @@ static bool f2fs_force_buffered_io(struct inode *inode, int rw)
return false;
}
-int f2fs_getattr(struct mnt_idmap *idmap, const struct path *path,
+int f2fs_getattr(const struct mnt_idmap *idmap, const struct path *path,
struct kstat *stat, u32 request_mask, unsigned int query_flags)
{
struct inode *inode = d_inode(path->dentry);
diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
index 9934777eb2a9..233c07fec171 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -1394,7 +1394,7 @@ static const char *f2fs_encrypted_get_link(struct dentry *dentry,
return target;
}
-static int f2fs_encrypted_symlink_getattr(struct mnt_idmap *idmap,
+static int f2fs_encrypted_symlink_getattr(const struct mnt_idmap *idmap,
const struct path *path,
struct kstat *stat, u32 request_mask,
unsigned int query_flags)
diff --git a/fs/failfs.c b/fs/failfs.c
index cec6cad99eb2..437cdc981c2d 100644
--- a/fs/failfs.c
+++ b/fs/failfs.c
@@ -35,7 +35,7 @@ static struct dentry *failfs_lookup(struct inode *dir, struct dentry *dentry,
return ERR_PTR(-EOPNOTSUPP);
}
-static int failfs_getattr(struct mnt_idmap *idmap, const struct path *path,
+static int failfs_getattr(const struct mnt_idmap *idmap, const struct path *path,
struct kstat *stat, u32 request_mask,
unsigned int query_flags)
{
diff --git a/fs/fat/fat.h b/fs/fat/fat.h
index 61338413d9f3..202f209a544b 100644
--- a/fs/fat/fat.h
+++ b/fs/fat/fat.h
@@ -407,7 +407,7 @@ extern const struct inode_operations fat_file_inode_operations;
extern int fat_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *attr);
extern void fat_truncate_blocks(struct inode *inode, loff_t offset);
-extern int fat_getattr(struct mnt_idmap *idmap,
+extern int fat_getattr(const struct mnt_idmap *idmap,
const struct path *path, struct kstat *stat,
u32 request_mask, unsigned int flags);
int fat_fileattr_get(struct dentry *dentry, struct file_kattr *fa);
diff --git a/fs/fat/file.c b/fs/fat/file.c
index 0b8b493d06e4..b37bc637945f 100644
--- a/fs/fat/file.c
+++ b/fs/fat/file.c
@@ -432,7 +432,7 @@ int fat_fileattr_get(struct dentry *dentry, struct file_kattr *fa)
}
EXPORT_SYMBOL_GPL(fat_fileattr_get);
-int fat_getattr(struct mnt_idmap *idmap, const struct path *path,
+int fat_getattr(const struct mnt_idmap *idmap, const struct path *path,
struct kstat *stat, u32 request_mask, unsigned int flags)
{
struct inode *inode = d_inode(path->dentry);
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index ff941e78918f..dd267d9498bc 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -1537,7 +1537,7 @@ static int fuse_do_getattr(const struct mnt_idmap *idmap, struct inode *inode,
return err;
}
-static int fuse_update_get_attr(struct mnt_idmap *idmap, struct inode *inode,
+static int fuse_update_get_attr(const struct mnt_idmap *idmap, struct inode *inode,
struct file *file, struct kstat *stat,
u32 request_mask, unsigned int flags)
{
@@ -2387,7 +2387,7 @@ static int fuse_setattr(struct mnt_idmap *idmap, struct dentry *entry,
return ret;
}
-static int fuse_getattr(struct mnt_idmap *idmap,
+static int fuse_getattr(const struct mnt_idmap *idmap,
const struct path *path, struct kstat *stat,
u32 request_mask, unsigned int flags)
{
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index e207ab1f5c23..5ddac2f50f30 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -2156,7 +2156,7 @@ static int gfs2_setattr(struct mnt_idmap *idmap,
* Returns: errno
*/
-static int gfs2_getattr(struct mnt_idmap *idmap,
+static int gfs2_getattr(const struct mnt_idmap *idmap,
const struct path *path, struct kstat *stat,
u32 request_mask, unsigned int flags)
{
diff --git a/fs/hfsplus/hfsplus_fs.h b/fs/hfsplus/hfsplus_fs.h
index 86fc1c1cdfd6..d55cb16e3897 100644
--- a/fs/hfsplus/hfsplus_fs.h
+++ b/fs/hfsplus/hfsplus_fs.h
@@ -459,7 +459,7 @@ void hfsplus_inode_write_fork(struct inode *inode,
struct hfsplus_fork_raw *fork);
int hfsplus_cat_read_inode(struct inode *inode, struct hfs_find_data *fd);
int hfsplus_cat_write_inode(struct inode *inode);
-int hfsplus_getattr(struct mnt_idmap *idmap, const struct path *path,
+int hfsplus_getattr(const struct mnt_idmap *idmap, const struct path *path,
struct kstat *stat, u32 request_mask,
unsigned int query_flags);
int hfsplus_file_fsync(struct file *file, loff_t start, loff_t end,
diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
index 9821662bfc1d..2807b29c7028 100644
--- a/fs/hfsplus/inode.c
+++ b/fs/hfsplus/inode.c
@@ -335,7 +335,7 @@ static int hfsplus_setattr(struct mnt_idmap *idmap,
return 0;
}
-int hfsplus_getattr(struct mnt_idmap *idmap, const struct path *path,
+int hfsplus_getattr(const struct mnt_idmap *idmap, const struct path *path,
struct kstat *stat, u32 request_mask,
unsigned int query_flags)
{
diff --git a/fs/internal.h b/fs/internal.h
index 8a1c7c05c5a2..88d9296c2a48 100644
--- a/fs/internal.h
+++ b/fs/internal.h
@@ -356,7 +356,7 @@ void file_f_owner_release(struct file *file);
bool file_seek_cur_needs_f_lock(struct file *file);
int statmount_mnt_idmap(const struct mnt_idmap *idmap, struct seq_file *seq, bool uid_map);
struct dentry *find_next_child(struct dentry *parent, struct dentry *prev);
-int anon_inode_getattr(struct mnt_idmap *idmap, const struct path *path,
+int anon_inode_getattr(const struct mnt_idmap *idmap, const struct path *path,
struct kstat *stat, u32 request_mask,
unsigned int query_flags);
int anon_inode_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
diff --git a/fs/kernfs/inode.c b/fs/kernfs/inode.c
index b348d4cd150b..6a92aa789ce5 100644
--- a/fs/kernfs/inode.c
+++ b/fs/kernfs/inode.c
@@ -181,7 +181,7 @@ static void kernfs_refresh_inode(struct kernfs_node *kn, struct inode *inode)
set_nlink(inode, kn->dir.subdirs + 2);
}
-int kernfs_iop_getattr(struct mnt_idmap *idmap,
+int kernfs_iop_getattr(const struct mnt_idmap *idmap,
const struct path *path, struct kstat *stat,
u32 request_mask, unsigned int query_flags)
{
diff --git a/fs/kernfs/kernfs-internal.h b/fs/kernfs/kernfs-internal.h
index 0f6f412213f6..8af7849f2c9c 100644
--- a/fs/kernfs/kernfs-internal.h
+++ b/fs/kernfs/kernfs-internal.h
@@ -175,7 +175,7 @@ int kernfs_iop_permission(const struct mnt_idmap *idmap,
struct inode *inode, int mask);
int kernfs_iop_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *iattr);
-int kernfs_iop_getattr(struct mnt_idmap *idmap,
+int kernfs_iop_getattr(const struct mnt_idmap *idmap,
const struct path *path, struct kstat *stat,
u32 request_mask, unsigned int query_flags);
ssize_t kernfs_iop_listxattr(struct dentry *dentry, char *buf, size_t size);
diff --git a/fs/libfs.c b/fs/libfs.c
index 8b379230b64f..b70977b10a7c 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -29,7 +29,7 @@
#include "internal.h"
-int simple_getattr(struct mnt_idmap *idmap, const struct path *path,
+int simple_getattr(const struct mnt_idmap *idmap, const struct path *path,
struct kstat *stat, u32 request_mask,
unsigned int query_flags)
{
diff --git a/fs/minix/inode.c b/fs/minix/inode.c
index daf83e4ff25c..670179173645 100644
--- a/fs/minix/inode.c
+++ b/fs/minix/inode.c
@@ -724,7 +724,7 @@ static int minix_sync_inode_metadata(struct inode *inode,
return err;
}
-int minix_getattr(struct mnt_idmap *idmap, const struct path *path,
+int minix_getattr(const struct mnt_idmap *idmap, const struct path *path,
struct kstat *stat, u32 request_mask, unsigned int flags)
{
struct super_block *sb = path->dentry->d_sb;
diff --git a/fs/minix/minix.h b/fs/minix/minix.h
index 78722ce22e1e..db92cf9e0e1b 100644
--- a/fs/minix/minix.h
+++ b/fs/minix/minix.h
@@ -55,7 +55,7 @@ unsigned long minix_count_free_inodes(struct super_block *sb);
int minix_new_block(struct inode *inode);
void minix_free_block(struct inode *inode, unsigned long block);
unsigned long minix_count_free_blocks(struct super_block *sb);
-int minix_getattr(struct mnt_idmap *, const struct path *,
+int minix_getattr(const struct mnt_idmap *, const struct path *,
struct kstat *, u32, unsigned int);
int minix_prepare_chunk(struct folio *folio, loff_t pos, unsigned len);
struct mapping_metadata_bhs *minix_get_metadata_bhs(struct inode *inode);
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index 3022454f7698..b114488715fb 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -955,7 +955,7 @@ static u32 nfs_get_valid_attrmask(struct inode *inode)
return reply_mask;
}
-int nfs_getattr(struct mnt_idmap *idmap, const struct path *path,
+int nfs_getattr(const struct mnt_idmap *idmap, const struct path *path,
struct kstat *stat, u32 request_mask, unsigned int query_flags)
{
struct inode *inode = d_inode(path->dentry);
diff --git a/fs/nfs/namespace.c b/fs/nfs/namespace.c
index 6d0073c24771..17f54d79efa7 100644
--- a/fs/nfs/namespace.c
+++ b/fs/nfs/namespace.c
@@ -222,7 +222,7 @@ struct vfsmount *nfs_d_automount(struct path *path)
}
static int
-nfs_namespace_getattr(struct mnt_idmap *idmap,
+nfs_namespace_getattr(const struct mnt_idmap *idmap,
const struct path *path, struct kstat *stat,
u32 request_mask, unsigned int query_flags)
{
diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
index 88747217ba61..40e01704ea8f 100644
--- a/fs/ntfs/file.c
+++ b/fs/ntfs/file.c
@@ -364,7 +364,7 @@ int ntfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
return err;
}
-int ntfs_getattr(struct mnt_idmap *idmap, const struct path *path,
+int ntfs_getattr(const struct mnt_idmap *idmap, const struct path *path,
struct kstat *stat, unsigned int request_mask,
unsigned int query_flags)
{
diff --git a/fs/ntfs/inode.h b/fs/ntfs/inode.h
index ff61bd402df0..9cf923911825 100644
--- a/fs/ntfs/inode.h
+++ b/fs/ntfs/inode.h
@@ -332,7 +332,7 @@ int ntfs_truncate_vfs(struct inode *vi, loff_t new_size, loff_t i_size);
int ntfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *attr);
-int ntfs_getattr(struct mnt_idmap *idmap, const struct path *path,
+int ntfs_getattr(const struct mnt_idmap *idmap, const struct path *path,
struct kstat *stat, unsigned int request_mask,
unsigned int query_flags);
diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c
index f7baa202dc28..f4d08346d25d 100644
--- a/fs/ntfs3/file.c
+++ b/fs/ntfs3/file.c
@@ -261,7 +261,7 @@ long ntfs_compat_ioctl(struct file *filp, u32 cmd, unsigned long arg)
/*
* ntfs_getattr - inode_operations::getattr
*/
-int ntfs_getattr(struct mnt_idmap *idmap, const struct path *path,
+int ntfs_getattr(const struct mnt_idmap *idmap, const struct path *path,
struct kstat *stat, u32 request_mask, u32 flags)
{
struct inode *inode = d_inode(path->dentry);
diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h
index d89609a17886..262b7ff2d6e1 100644
--- a/fs/ntfs3/ntfs_fs.h
+++ b/fs/ntfs3/ntfs_fs.h
@@ -553,7 +553,7 @@ extern const struct file_operations ntfs_dir_operations;
int ntfs_fileattr_get(struct dentry *dentry, struct file_kattr *fa);
int ntfs_fileattr_set(const struct mnt_idmap *idmap, struct dentry *dentry,
struct file_kattr *fa);
-int ntfs_getattr(struct mnt_idmap *idmap, const struct path *path,
+int ntfs_getattr(const struct mnt_idmap *idmap, const struct path *path,
struct kstat *stat, u32 request_mask, u32 flags);
int ntfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *attr);
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index 24bbf607546c..befc6ebb2a06 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -1317,7 +1317,7 @@ int ocfs2_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
return status;
}
-int ocfs2_getattr(struct mnt_idmap *idmap, const struct path *path,
+int ocfs2_getattr(const struct mnt_idmap *idmap, const struct path *path,
struct kstat *stat, u32 request_mask, unsigned int flags)
{
struct inode *inode = d_inode(path->dentry);
diff --git a/fs/ocfs2/file.h b/fs/ocfs2/file.h
index 08e4d6796531..b51c8e77dad7 100644
--- a/fs/ocfs2/file.h
+++ b/fs/ocfs2/file.h
@@ -52,7 +52,7 @@ int ocfs2_zero_extend(struct inode *inode, struct buffer_head *di_bh,
loff_t zero_to);
int ocfs2_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *attr);
-int ocfs2_getattr(struct mnt_idmap *idmap, const struct path *path,
+int ocfs2_getattr(const struct mnt_idmap *idmap, const struct path *path,
struct kstat *stat, u32 request_mask, unsigned int flags);
int ocfs2_permission(const struct mnt_idmap *idmap,
struct inode *inode,
diff --git a/fs/orangefs/inode.c b/fs/orangefs/inode.c
index 536d5e842c55..100669ee5862 100644
--- a/fs/orangefs/inode.c
+++ b/fs/orangefs/inode.c
@@ -848,7 +848,7 @@ int orangefs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
/*
* Obtain attributes of an object given a dentry
*/
-int orangefs_getattr(struct mnt_idmap *idmap, const struct path *path,
+int orangefs_getattr(const struct mnt_idmap *idmap, const struct path *path,
struct kstat *stat, u32 request_mask, unsigned int flags)
{
int ret;
diff --git a/fs/orangefs/orangefs-kernel.h b/fs/orangefs/orangefs-kernel.h
index a5c9e7be4005..3bf01c0c763b 100644
--- a/fs/orangefs/orangefs-kernel.h
+++ b/fs/orangefs/orangefs-kernel.h
@@ -354,7 +354,7 @@ int __orangefs_setattr(struct inode *, struct iattr *);
int __orangefs_setattr_mode(struct dentry *dentry, struct iattr *iattr);
int orangefs_setattr(struct mnt_idmap *, struct dentry *, struct iattr *);
-int orangefs_getattr(struct mnt_idmap *idmap, const struct path *path,
+int orangefs_getattr(const struct mnt_idmap *idmap, const struct path *path,
struct kstat *stat, u32 request_mask, unsigned int flags);
int orangefs_permission(const struct mnt_idmap *idmap,
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
index 18e4cbe154cf..b765780686e6 100644
--- a/fs/overlayfs/inode.c
+++ b/fs/overlayfs/inode.c
@@ -168,7 +168,7 @@ static inline int ovl_real_getattr_nosec(struct super_block *sb,
return vfs_getattr_nosec(path, stat, request_mask, flags);
}
-int ovl_getattr(struct mnt_idmap *idmap, const struct path *path,
+int ovl_getattr(const struct mnt_idmap *idmap, const struct path *path,
struct kstat *stat, u32 request_mask, unsigned int flags)
{
struct dentry *dentry = path->dentry;
diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h
index 1759221dcad5..02a822dc8e5e 100644
--- a/fs/overlayfs/overlayfs.h
+++ b/fs/overlayfs/overlayfs.h
@@ -950,6 +950,6 @@ static inline bool ovl_force_readonly(struct ovl_fs *ofs)
const struct xattr_handler * const *ovl_xattr_handlers(struct ovl_fs *ofs);
int ovl_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *attr);
-int ovl_getattr(struct mnt_idmap *idmap, const struct path *path,
+int ovl_getattr(const struct mnt_idmap *idmap, const struct path *path,
struct kstat *stat, u32 request_mask, unsigned int flags);
ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size);
diff --git a/fs/pidfs.c b/fs/pidfs.c
index 5bc136de8660..38868ac99950 100644
--- a/fs/pidfs.c
+++ b/fs/pidfs.c
@@ -829,7 +829,7 @@ static int pidfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
return anon_inode_setattr(idmap, dentry, attr);
}
-static int pidfs_getattr(struct mnt_idmap *idmap, const struct path *path,
+static int pidfs_getattr(const struct mnt_idmap *idmap, const struct path *path,
struct kstat *stat, u32 request_mask,
unsigned int query_flags)
{
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 8dc43c846298..3278c37e5cde 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -1994,7 +1994,7 @@ static struct inode *proc_pid_make_base_inode(struct super_block *sb,
return inode;
}
-int pid_getattr(struct mnt_idmap *idmap, const struct path *path,
+int pid_getattr(const struct mnt_idmap *idmap, const struct path *path,
struct kstat *stat, u32 request_mask, unsigned int query_flags)
{
struct inode *inode = d_inode(path->dentry);
@@ -3936,7 +3936,7 @@ static int proc_task_readdir(struct file *file, struct dir_context *ctx)
return 0;
}
-static int proc_task_getattr(struct mnt_idmap *idmap,
+static int proc_task_getattr(const struct mnt_idmap *idmap,
const struct path *path, struct kstat *stat,
u32 request_mask, unsigned int query_flags)
{
diff --git a/fs/proc/fd.c b/fs/proc/fd.c
index 0653bceb730d..7214a7495380 100644
--- a/fs/proc/fd.c
+++ b/fs/proc/fd.c
@@ -342,7 +342,7 @@ int proc_fd_permission(const struct mnt_idmap *idmap,
return rv;
}
-static int proc_fd_getattr(struct mnt_idmap *idmap,
+static int proc_fd_getattr(const struct mnt_idmap *idmap,
const struct path *path, struct kstat *stat,
u32 request_mask, unsigned int query_flags)
{
diff --git a/fs/proc/generic.c b/fs/proc/generic.c
index 26086a283672..4c4f1e63f68f 100644
--- a/fs/proc/generic.c
+++ b/fs/proc/generic.c
@@ -135,7 +135,7 @@ static int proc_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
return 0;
}
-static int proc_getattr(struct mnt_idmap *idmap,
+static int proc_getattr(const struct mnt_idmap *idmap,
const struct path *path, struct kstat *stat,
u32 request_mask, unsigned int query_flags)
{
diff --git a/fs/proc/internal.h b/fs/proc/internal.h
index 04bd6c9e65a7..706fae7d30be 100644
--- a/fs/proc/internal.h
+++ b/fs/proc/internal.h
@@ -258,7 +258,7 @@ extern int proc_pid_statm(struct seq_file *, struct pid_namespace *,
* base.c
*/
extern const struct dentry_operations pid_dentry_operations;
-extern int pid_getattr(struct mnt_idmap *, const struct path *,
+extern int pid_getattr(const struct mnt_idmap *, const struct path *,
struct kstat *, u32, unsigned int);
int proc_nochmod_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *attr);
diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
index 00cc385bce21..b1f5eafb069a 100644
--- a/fs/proc/proc_net.c
+++ b/fs/proc/proc_net.c
@@ -308,7 +308,7 @@ static struct dentry *proc_tgid_net_lookup(struct inode *dir,
return de;
}
-static int proc_tgid_net_getattr(struct mnt_idmap *idmap,
+static int proc_tgid_net_getattr(const struct mnt_idmap *idmap,
const struct path *path, struct kstat *stat,
u32 request_mask, unsigned int query_flags)
{
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index 5315d891f244..bd6730000b27 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -834,7 +834,7 @@ static int proc_sys_setattr(struct mnt_idmap *idmap,
return 0;
}
-static int proc_sys_getattr(struct mnt_idmap *idmap,
+static int proc_sys_getattr(const struct mnt_idmap *idmap,
const struct path *path, struct kstat *stat,
u32 request_mask, unsigned int query_flags)
{
diff --git a/fs/proc/root.c b/fs/proc/root.c
index 99adddfeb4a4..7fbbe92bf73a 100644
--- a/fs/proc/root.c
+++ b/fs/proc/root.c
@@ -402,7 +402,7 @@ void __init proc_root_init(void)
register_filesystem(&proc_fs_type);
}
-static int proc_root_getattr(struct mnt_idmap *idmap,
+static int proc_root_getattr(const struct mnt_idmap *idmap,
const struct path *path, struct kstat *stat,
u32 request_mask, unsigned int query_flags)
{
diff --git a/fs/smb/client/cifsfs.h b/fs/smb/client/cifsfs.h
index cf09d915bedd..c0adc5219213 100644
--- a/fs/smb/client/cifsfs.h
+++ b/fs/smb/client/cifsfs.h
@@ -78,7 +78,7 @@ int cifs_revalidate_file(struct file *filp);
int cifs_revalidate_dentry(struct dentry *dentry);
int cifs_revalidate_mapping(struct inode *inode);
int cifs_zap_mapping(struct inode *inode);
-int cifs_getattr(struct mnt_idmap *idmap, const struct path *path,
+int cifs_getattr(const struct mnt_idmap *idmap, const struct path *path,
struct kstat *stat, u32 request_mask, unsigned int flags);
int cifs_setattr(struct mnt_idmap *idmap, struct dentry *direntry,
struct iattr *attrs);
diff --git a/fs/smb/client/inode.c b/fs/smb/client/inode.c
index e3610e456bd4..132f9e072b77 100644
--- a/fs/smb/client/inode.c
+++ b/fs/smb/client/inode.c
@@ -2932,7 +2932,7 @@ int cifs_revalidate_dentry(struct dentry *dentry)
return cifs_revalidate_mapping(inode);
}
-int cifs_getattr(struct mnt_idmap *idmap, const struct path *path,
+int cifs_getattr(const struct mnt_idmap *idmap, const struct path *path,
struct kstat *stat, u32 request_mask, unsigned int flags)
{
struct cifs_sb_info *cifs_sb = CIFS_SB(path->dentry);
diff --git a/fs/stat.c b/fs/stat.c
index c461c3054234..fe351818d1d6 100644
--- a/fs/stat.c
+++ b/fs/stat.c
@@ -79,7 +79,7 @@ EXPORT_SYMBOL(fill_mg_cmtime);
* uid and gid filds. On non-idmapped mounts or if permission checking is to be
* performed on the raw inode simply pass @nop_mnt_idmap.
*/
-void generic_fillattr(struct mnt_idmap *idmap, u32 request_mask,
+void generic_fillattr(const struct mnt_idmap *idmap, u32 request_mask,
struct inode *inode, struct kstat *stat)
{
vfsuid_t vfsuid = i_uid_into_vfsuid(idmap, inode);
diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c
index 995b8d0f8d33..44448f1a2bb1 100644
--- a/fs/tracefs/inode.c
+++ b/fs/tracefs/inode.c
@@ -196,7 +196,7 @@ static int tracefs_permission(const struct mnt_idmap *idmap,
return generic_permission(idmap, inode, mask);
}
-static int tracefs_getattr(struct mnt_idmap *idmap,
+static int tracefs_getattr(const struct mnt_idmap *idmap,
const struct path *path, struct kstat *stat,
u32 request_mask, unsigned int flags)
{
diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
index 57640b6ff72d..c67954f6bee0 100644
--- a/fs/ubifs/dir.c
+++ b/fs/ubifs/dir.c
@@ -1667,7 +1667,7 @@ static int ubifs_rename(const struct mnt_idmap *idmap,
return do_rename(old_dir, old_dentry, new_dir, new_dentry, flags);
}
-int ubifs_getattr(struct mnt_idmap *idmap, const struct path *path,
+int ubifs_getattr(const struct mnt_idmap *idmap, const struct path *path,
struct kstat *stat, u32 request_mask, unsigned int flags)
{
loff_t size;
diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
index e73c28b12f97..bfc1bd0203ad 100644
--- a/fs/ubifs/file.c
+++ b/fs/ubifs/file.c
@@ -1611,7 +1611,7 @@ static const char *ubifs_get_link(struct dentry *dentry,
return fscrypt_get_symlink(inode, ui->data, ui->data_len, done);
}
-static int ubifs_symlink_getattr(struct mnt_idmap *idmap,
+static int ubifs_symlink_getattr(const struct mnt_idmap *idmap,
const struct path *path, struct kstat *stat,
u32 request_mask, unsigned int query_flags)
{
diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h
index af0ef3583aeb..d455a67fe411 100644
--- a/fs/ubifs/ubifs.h
+++ b/fs/ubifs/ubifs.h
@@ -2028,7 +2028,7 @@ int ubifs_update_time(struct inode *inode, enum fs_update_time type,
/* dir.c */
struct inode *ubifs_new_inode(struct ubifs_info *c, struct inode *dir,
umode_t mode, bool is_xattr);
-int ubifs_getattr(struct mnt_idmap *idmap, const struct path *path,
+int ubifs_getattr(const struct mnt_idmap *idmap, const struct path *path,
struct kstat *stat, u32 request_mask, unsigned int flags);
int ubifs_check_dir_empty(struct inode *dir);
diff --git a/fs/udf/symlink.c b/fs/udf/symlink.c
index a05d1888a2ba..df41bf5a05b1 100644
--- a/fs/udf/symlink.c
+++ b/fs/udf/symlink.c
@@ -133,7 +133,7 @@ static int udf_symlink_filler(struct file *file, struct folio *folio)
return err;
}
-static int udf_symlink_getattr(struct mnt_idmap *idmap,
+static int udf_symlink_getattr(const struct mnt_idmap *idmap,
const struct path *path, struct kstat *stat,
u32 request_mask, unsigned int flags)
{
diff --git a/fs/vboxsf/utils.c b/fs/vboxsf/utils.c
index 298bfc93255c..6a5a47a32075 100644
--- a/fs/vboxsf/utils.c
+++ b/fs/vboxsf/utils.c
@@ -233,7 +233,7 @@ int vboxsf_inode_revalidate(struct dentry *dentry)
return 0;
}
-int vboxsf_getattr(struct mnt_idmap *idmap, const struct path *path,
+int vboxsf_getattr(const struct mnt_idmap *idmap, const struct path *path,
struct kstat *kstat, u32 request_mask, unsigned int flags)
{
int err;
diff --git a/fs/vboxsf/vfsmod.h b/fs/vboxsf/vfsmod.h
index b61afd0ce842..9c713b8e7aa2 100644
--- a/fs/vboxsf/vfsmod.h
+++ b/fs/vboxsf/vfsmod.h
@@ -98,7 +98,7 @@ int vboxsf_stat(struct vboxsf_sbi *sbi, struct shfl_string *path,
struct shfl_fsobjinfo *info);
int vboxsf_stat_dentry(struct dentry *dentry, struct shfl_fsobjinfo *info);
int vboxsf_inode_revalidate(struct dentry *dentry);
-int vboxsf_getattr(struct mnt_idmap *idmap, const struct path *path,
+int vboxsf_getattr(const struct mnt_idmap *idmap, const struct path *path,
struct kstat *kstat, u32 request_mask,
unsigned int query_flags);
int vboxsf_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index 791af2db7124..19fd83cea18b 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -679,7 +679,7 @@ xfs_report_atomic_write(
STATIC int
xfs_vn_getattr(
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
const struct path *path,
struct kstat *stat,
u32 request_mask,
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 2b9ae72010f0..c79fd3776bbf 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2013,7 +2013,7 @@ struct inode_operations {
int (*rename) (const struct mnt_idmap *, struct inode *, struct dentry *,
struct inode *, struct dentry *, unsigned int);
int (*setattr) (struct mnt_idmap *, struct dentry *, struct iattr *);
- int (*getattr) (struct mnt_idmap *, const struct path *,
+ int (*getattr) (const struct mnt_idmap *, const struct path *,
struct kstat *, u32, unsigned int);
ssize_t (*listxattr) (struct dentry *, char *, size_t);
int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start,
@@ -3204,7 +3204,7 @@ extern int page_symlink(struct inode *inode, const char *symname, int len);
extern const struct inode_operations page_symlink_inode_operations;
extern void kfree_link(void *);
void fill_mg_cmtime(struct kstat *stat, u32 request_mask, struct inode *inode);
-void generic_fillattr(struct mnt_idmap *, u32, struct inode *, struct kstat *);
+void generic_fillattr(const struct mnt_idmap *, u32, struct inode *, struct kstat *);
void generic_fill_statx_attr(struct inode *inode, struct kstat *stat);
void generic_fill_statx_atomic_writes(struct kstat *stat,
unsigned int unit_min,
@@ -3263,7 +3263,7 @@ extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
extern int dcache_readdir(struct file *, struct dir_context *);
extern int simple_setattr(struct mnt_idmap *, struct dentry *,
struct iattr *);
-extern int simple_getattr(struct mnt_idmap *, const struct path *,
+extern int simple_getattr(const struct mnt_idmap *, const struct path *,
struct kstat *, u32, unsigned int);
extern int simple_statfs(struct dentry *, struct kstatfs *);
extern int simple_open(struct inode *inode, struct file *file);
diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h
index b2828ea03abe..7b307dea7ce7 100644
--- a/include/linux/nfs_fs.h
+++ b/include/linux/nfs_fs.h
@@ -437,7 +437,7 @@ extern int nfs_refresh_inode(struct inode *, struct nfs_fattr *);
extern int nfs_post_op_update_inode(struct inode *inode, struct nfs_fattr *fattr);
extern int nfs_post_op_update_inode_force_wcc(struct inode *inode, struct nfs_fattr *fattr);
extern int nfs_post_op_update_inode_force_wcc_locked(struct inode *inode, struct nfs_fattr *fattr);
-extern int nfs_getattr(struct mnt_idmap *, const struct path *,
+extern int nfs_getattr(const struct mnt_idmap *, const struct path *,
struct kstat *, u32, unsigned int);
extern void nfs_access_add_cache(struct inode *, struct nfs_access_entry *, const struct cred *);
extern void nfs_access_set_mask(struct nfs_access_entry *, u32);
diff --git a/mm/shmem.c b/mm/shmem.c
index 656235b2f9c5..b27e5f23dc93 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -1292,7 +1292,7 @@ void shmem_truncate_range(struct inode *inode, loff_t lstart, uoff_t lend)
}
EXPORT_SYMBOL_GPL(shmem_truncate_range);
-static int shmem_getattr(struct mnt_idmap *idmap,
+static int shmem_getattr(const struct mnt_idmap *idmap,
const struct path *path, struct kstat *stat,
u32 request_mask, unsigned int query_flags)
{
--
2.53.0
^ permalink raw reply related [flat|nested] 62+ messages in thread* Re: [PATCH 23/27] fs: port ->getattr() to pass const mnt_idmap
2026-09-01 12:14 ` [PATCH 23/27] fs: port ->getattr() " Christian Brauner
@ 2026-09-02 15:58 ` Jan Kara
0 siblings, 0 replies; 62+ messages in thread
From: Jan Kara @ 2026-09-02 15:58 UTC (permalink / raw)
To: Christian Brauner
Cc: linux-fsdevel, Alexander Viro, Jan Kara, Christoph Hellwig,
Seth Forshee, Paul Moore, linux-security-module, Mimi Zohar,
linux-integrity, Ilya Dryomov, ceph-devel, Carlos Maiolino,
linux-xfs, Miklos Szeredi, Amir Goldstein, linux-unionfs,
Namjae Jeon, linux-cifs, linux-kernel
On Tue 01-09-26 14:14:48, Christian Brauner wrote:
> Convert to const struct mnt_idmap.
>
> A mount's idmapping is immutable. The only thing that is allowed to be
> modified afterwards is the reference count and that is hidden behind
> mnt_idmap_get() and mnt_idmap_put(). Everything else only ever reads
> from the idmapping. This is the same model that struct cred uses and the
> idmapping is also rather sensitive.
>
> So make the idmap argument const wherever we can. The conversion is done
> from the bottom up so callers can continue to pass a non-const pointer
> to a const parameter until the conversion is finished.
>
> No functional changes.
>
> Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> Documentation/filesystems/locking.rst | 2 +-
> Documentation/filesystems/vfs.rst | 2 +-
> fs/9p/vfs_inode.c | 2 +-
> fs/9p/vfs_inode_dotl.c | 2 +-
> fs/afs/inode.c | 2 +-
> fs/afs/internal.h | 2 +-
> fs/anon_inodes.c | 2 +-
> fs/bad_inode.c | 2 +-
> fs/btrfs/inode.c | 2 +-
> fs/ceph/inode.c | 4 ++--
> fs/ceph/super.h | 2 +-
> fs/coda/coda_linux.h | 2 +-
> fs/coda/inode.c | 2 +-
> fs/ecryptfs/inode.c | 4 ++--
> fs/erofs/inode.c | 2 +-
> fs/erofs/internal.h | 2 +-
> fs/exfat/exfat_fs.h | 2 +-
> fs/exfat/file.c | 2 +-
> fs/ext2/ext2.h | 2 +-
> fs/ext2/inode.c | 2 +-
> fs/ext4/ext4.h | 4 ++--
> fs/ext4/inode.c | 4 ++--
> fs/ext4/symlink.c | 2 +-
> fs/f2fs/f2fs.h | 2 +-
> fs/f2fs/file.c | 2 +-
> fs/f2fs/namei.c | 2 +-
> fs/failfs.c | 2 +-
> fs/fat/fat.h | 2 +-
> fs/fat/file.c | 2 +-
> fs/fuse/dir.c | 4 ++--
> fs/gfs2/inode.c | 2 +-
> fs/hfsplus/hfsplus_fs.h | 2 +-
> fs/hfsplus/inode.c | 2 +-
> fs/internal.h | 2 +-
> fs/kernfs/inode.c | 2 +-
> fs/kernfs/kernfs-internal.h | 2 +-
> fs/libfs.c | 2 +-
> fs/minix/inode.c | 2 +-
> fs/minix/minix.h | 2 +-
> fs/nfs/inode.c | 2 +-
> fs/nfs/namespace.c | 2 +-
> fs/ntfs/file.c | 2 +-
> fs/ntfs/inode.h | 2 +-
> fs/ntfs3/file.c | 2 +-
> fs/ntfs3/ntfs_fs.h | 2 +-
> fs/ocfs2/file.c | 2 +-
> fs/ocfs2/file.h | 2 +-
> fs/orangefs/inode.c | 2 +-
> fs/orangefs/orangefs-kernel.h | 2 +-
> fs/overlayfs/inode.c | 2 +-
> fs/overlayfs/overlayfs.h | 2 +-
> fs/pidfs.c | 2 +-
> fs/proc/base.c | 4 ++--
> fs/proc/fd.c | 2 +-
> fs/proc/generic.c | 2 +-
> fs/proc/internal.h | 2 +-
> fs/proc/proc_net.c | 2 +-
> fs/proc/proc_sysctl.c | 2 +-
> fs/proc/root.c | 2 +-
> fs/smb/client/cifsfs.h | 2 +-
> fs/smb/client/inode.c | 2 +-
> fs/stat.c | 2 +-
> fs/tracefs/inode.c | 2 +-
> fs/ubifs/dir.c | 2 +-
> fs/ubifs/file.c | 2 +-
> fs/ubifs/ubifs.h | 2 +-
> fs/udf/symlink.c | 2 +-
> fs/vboxsf/utils.c | 2 +-
> fs/vboxsf/vfsmod.h | 2 +-
> fs/xfs/xfs_iops.c | 2 +-
> include/linux/fs.h | 6 +++---
> include/linux/nfs_fs.h | 2 +-
> mm/shmem.c | 2 +-
> 73 files changed, 81 insertions(+), 81 deletions(-)
>
> diff --git a/Documentation/filesystems/locking.rst b/Documentation/filesystems/locking.rst
> index 864768700eda..f11bfc2e0c13 100644
> --- a/Documentation/filesystems/locking.rst
> +++ b/Documentation/filesystems/locking.rst
> @@ -77,7 +77,7 @@ prototypes::
> int (*permission) (const struct mnt_idmap *, struct inode *, int, unsigned int);
> struct posix_acl * (*get_inode_acl)(struct inode *, int, bool);
> int (*setattr) (struct mnt_idmap *, struct dentry *, struct iattr *);
> - int (*getattr) (struct mnt_idmap *, const struct path *, struct kstat *, u32, unsigned int);
> + int (*getattr) (const struct mnt_idmap *, const struct path *, struct kstat *, u32, unsigned int);
> ssize_t (*listxattr) (struct dentry *, char *, size_t);
> int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start, u64 len);
> void (*update_time)(struct inode *inode, enum fs_update_time type,
> diff --git a/Documentation/filesystems/vfs.rst b/Documentation/filesystems/vfs.rst
> index 2ad273cfe547..98aefc5d399e 100644
> --- a/Documentation/filesystems/vfs.rst
> +++ b/Documentation/filesystems/vfs.rst
> @@ -431,7 +431,7 @@ As of kernel 2.6.22, the following members are defined:
> int (*permission) (const struct mnt_idmap *, struct inode *, int);
> struct posix_acl * (*get_inode_acl)(struct inode *, int, bool);
> int (*setattr) (struct mnt_idmap *, struct dentry *, struct iattr *);
> - int (*getattr) (struct mnt_idmap *, const struct path *, struct kstat *, u32, unsigned int);
> + int (*getattr) (const struct mnt_idmap *, const struct path *, struct kstat *, u32, unsigned int);
> ssize_t (*listxattr) (struct dentry *, char *, size_t);
> void (*update_time)(struct inode *inode, enum fs_update_time type,
> int flags);
> diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
> index f2d0eef68acf..0c280342f8e9 100644
> --- a/fs/9p/vfs_inode.c
> +++ b/fs/9p/vfs_inode.c
> @@ -966,7 +966,7 @@ v9fs_vfs_rename(const struct mnt_idmap *idmap, struct inode *old_dir,
> */
>
> static int
> -v9fs_vfs_getattr(struct mnt_idmap *idmap, const struct path *path,
> +v9fs_vfs_getattr(const struct mnt_idmap *idmap, const struct path *path,
> struct kstat *stat, u32 request_mask, unsigned int flags)
> {
> struct dentry *dentry = path->dentry;
> diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c
> index c7176719a4f9..e37854ee6346 100644
> --- a/fs/9p/vfs_inode_dotl.c
> +++ b/fs/9p/vfs_inode_dotl.c
> @@ -414,7 +414,7 @@ static struct dentry *v9fs_vfs_mkdir_dotl(const struct mnt_idmap *idmap,
> }
>
> static int
> -v9fs_vfs_getattr_dotl(struct mnt_idmap *idmap,
> +v9fs_vfs_getattr_dotl(const struct mnt_idmap *idmap,
> const struct path *path, struct kstat *stat,
> u32 request_mask, unsigned int flags)
> {
> diff --git a/fs/afs/inode.c b/fs/afs/inode.c
> index 14f39a9bea6c..7b8a2adc3f59 100644
> --- a/fs/afs/inode.c
> +++ b/fs/afs/inode.c
> @@ -596,7 +596,7 @@ struct inode *afs_root_iget(struct super_block *sb, struct key *key)
> /*
> * read the attributes of an inode
> */
> -int afs_getattr(struct mnt_idmap *idmap, const struct path *path,
> +int afs_getattr(const struct mnt_idmap *idmap, const struct path *path,
> struct kstat *stat, u32 request_mask, unsigned int query_flags)
> {
> struct inode *inode = d_inode(path->dentry);
> diff --git a/fs/afs/internal.h b/fs/afs/internal.h
> index e772da2a15f2..7a8cdde9e0ad 100644
> --- a/fs/afs/internal.h
> +++ b/fs/afs/internal.h
> @@ -1258,7 +1258,7 @@ extern int afs_fetch_status(struct afs_vnode *, struct key *, bool, afs_access_t
> extern int afs_ilookup5_test_by_fid(struct inode *, void *);
> extern struct inode *afs_iget(struct afs_operation *, struct afs_vnode_param *);
> extern struct inode *afs_root_iget(struct super_block *, struct key *);
> -extern int afs_getattr(struct mnt_idmap *idmap, const struct path *,
> +extern int afs_getattr(const struct mnt_idmap *idmap, const struct path *,
> struct kstat *, u32, unsigned int);
> extern int afs_setattr(struct mnt_idmap *idmap, struct dentry *, struct iattr *);
> extern void afs_evict_inode(struct inode *);
> diff --git a/fs/anon_inodes.c b/fs/anon_inodes.c
> index a7b9b948e33d..d4a7e0b67289 100644
> --- a/fs/anon_inodes.c
> +++ b/fs/anon_inodes.c
> @@ -46,7 +46,7 @@ static struct inode *anon_inode_inode __ro_after_init;
> * Rather than mess with our internal sane inode data, just fix it
> * up here in getattr() by masking off the format bits.
> */
> -int anon_inode_getattr(struct mnt_idmap *idmap, const struct path *path,
> +int anon_inode_getattr(const struct mnt_idmap *idmap, const struct path *path,
> struct kstat *stat, u32 request_mask,
> unsigned int query_flags)
> {
> diff --git a/fs/bad_inode.c b/fs/bad_inode.c
> index 8c7578ea4bd7..e740b4e658bf 100644
> --- a/fs/bad_inode.c
> +++ b/fs/bad_inode.c
> @@ -95,7 +95,7 @@ static int bad_inode_permission(const struct mnt_idmap *idmap,
> return -EIO;
> }
>
> -static int bad_inode_getattr(struct mnt_idmap *idmap,
> +static int bad_inode_getattr(const struct mnt_idmap *idmap,
> const struct path *path, struct kstat *stat,
> u32 request_mask, unsigned int query_flags)
> {
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index 61cfa03b6152..da143f9376ee 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -8224,7 +8224,7 @@ int __init btrfs_init_cachep(void)
> return 0;
> }
>
> -static int btrfs_getattr(struct mnt_idmap *idmap,
> +static int btrfs_getattr(const struct mnt_idmap *idmap,
> const struct path *path, struct kstat *stat,
> u32 request_mask, unsigned int flags)
> {
> diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
> index b8527f67e3f0..185d713218e6 100644
> --- a/fs/ceph/inode.c
> +++ b/fs/ceph/inode.c
> @@ -2398,7 +2398,7 @@ static const char *ceph_encrypted_get_link(struct dentry *dentry,
> done);
> }
>
> -static int ceph_encrypted_symlink_getattr(struct mnt_idmap *idmap,
> +static int ceph_encrypted_symlink_getattr(const struct mnt_idmap *idmap,
> const struct path *path,
> struct kstat *stat, u32 request_mask,
> unsigned int query_flags)
> @@ -3145,7 +3145,7 @@ static int statx_to_caps(u32 want, umode_t mode)
> * Get all the attributes. If we have sufficient caps for the requested attrs,
> * then we can avoid talking to the MDS at all.
> */
> -int ceph_getattr(struct mnt_idmap *idmap, const struct path *path,
> +int ceph_getattr(const struct mnt_idmap *idmap, const struct path *path,
> struct kstat *stat, u32 request_mask, unsigned int flags)
> {
> struct inode *inode = d_inode(path->dentry);
> diff --git a/fs/ceph/super.h b/fs/ceph/super.h
> index fd603be209e4..0a5e3916e855 100644
> --- a/fs/ceph/super.h
> +++ b/fs/ceph/super.h
> @@ -1177,7 +1177,7 @@ extern int __ceph_setattr(const struct mnt_idmap *idmap, struct inode *inode,
> struct iattr *attr, struct ceph_iattr *cia);
> extern int ceph_setattr(struct mnt_idmap *idmap,
> struct dentry *dentry, struct iattr *attr);
> -extern int ceph_getattr(struct mnt_idmap *idmap,
> +extern int ceph_getattr(const struct mnt_idmap *idmap,
> const struct path *path, struct kstat *stat,
> u32 request_mask, unsigned int flags);
> void ceph_inode_shutdown(struct inode *inode);
> diff --git a/fs/coda/coda_linux.h b/fs/coda/coda_linux.h
> index 5ee6cedd3865..5dc9e392079f 100644
> --- a/fs/coda/coda_linux.h
> +++ b/fs/coda/coda_linux.h
> @@ -49,7 +49,7 @@ int coda_release(struct inode *i, struct file *f);
> int coda_permission(const struct mnt_idmap *idmap, struct inode *inode,
> int mask);
> int coda_revalidate_inode(struct inode *);
> -int coda_getattr(struct mnt_idmap *, const struct path *, struct kstat *,
> +int coda_getattr(const struct mnt_idmap *, const struct path *, struct kstat *,
> u32, unsigned int);
> int coda_setattr(struct mnt_idmap *, struct dentry *, struct iattr *);
>
> diff --git a/fs/coda/inode.c b/fs/coda/inode.c
> index 40b43866e6a5..f83ebd94c6be 100644
> --- a/fs/coda/inode.c
> +++ b/fs/coda/inode.c
> @@ -294,7 +294,7 @@ static void coda_evict_inode(struct inode *inode)
> coda_cache_clear_inode(inode);
> }
>
> -int coda_getattr(struct mnt_idmap *idmap, const struct path *path,
> +int coda_getattr(const struct mnt_idmap *idmap, const struct path *path,
> struct kstat *stat, u32 request_mask, unsigned int flags)
> {
> int err = coda_revalidate_inode(d_inode(path->dentry));
> diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
> index 432f82bc5b0c..e70a8d73d137 100644
> --- a/fs/ecryptfs/inode.c
> +++ b/fs/ecryptfs/inode.c
> @@ -939,7 +939,7 @@ static int ecryptfs_setattr(struct mnt_idmap *idmap,
> return rc;
> }
>
> -static int ecryptfs_getattr_link(struct mnt_idmap *idmap,
> +static int ecryptfs_getattr_link(const struct mnt_idmap *idmap,
> const struct path *path, struct kstat *stat,
> u32 request_mask, unsigned int flags)
> {
> @@ -965,7 +965,7 @@ static int ecryptfs_getattr_link(struct mnt_idmap *idmap,
> return rc;
> }
>
> -static int ecryptfs_getattr(struct mnt_idmap *idmap,
> +static int ecryptfs_getattr(const struct mnt_idmap *idmap,
> const struct path *path, struct kstat *stat,
> u32 request_mask, unsigned int flags)
> {
> diff --git a/fs/erofs/inode.c b/fs/erofs/inode.c
> index 45afe5c50de8..26ea3790ff21 100644
> --- a/fs/erofs/inode.c
> +++ b/fs/erofs/inode.c
> @@ -311,7 +311,7 @@ struct inode *erofs_iget(struct super_block *sb, erofs_nid_t nid)
> return inode;
> }
>
> -int erofs_getattr(struct mnt_idmap *idmap, const struct path *path,
> +int erofs_getattr(const struct mnt_idmap *idmap, const struct path *path,
> struct kstat *stat, u32 request_mask,
> unsigned int query_flags)
> {
> diff --git a/fs/erofs/internal.h b/fs/erofs/internal.h
> index 65974e57aebf..b4f52f5cd626 100644
> --- a/fs/erofs/internal.h
> +++ b/fs/erofs/internal.h
> @@ -421,7 +421,7 @@ void erofs_onlinefolio_init(struct folio *folio);
> void erofs_onlinefolio_split(struct folio *folio);
> void erofs_onlinefolio_end(struct folio *folio, int err, bool dirty);
> struct inode *erofs_iget(struct super_block *sb, erofs_nid_t nid);
> -int erofs_getattr(struct mnt_idmap *idmap, const struct path *path,
> +int erofs_getattr(const struct mnt_idmap *idmap, const struct path *path,
> struct kstat *stat, u32 request_mask,
> unsigned int query_flags);
> int erofs_namei(struct inode *dir, const struct qstr *name,
> diff --git a/fs/exfat/exfat_fs.h b/fs/exfat/exfat_fs.h
> index a9131fe03302..5165a0df068a 100644
> --- a/fs/exfat/exfat_fs.h
> +++ b/fs/exfat/exfat_fs.h
> @@ -557,7 +557,7 @@ extern const struct file_operations exfat_file_operations;
> int __exfat_truncate(struct inode *inode);
> int exfat_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *attr);
> -int exfat_getattr(struct mnt_idmap *idmap, const struct path *path,
> +int exfat_getattr(const struct mnt_idmap *idmap, const struct path *path,
> struct kstat *stat, unsigned int request_mask,
> unsigned int query_flags);
> struct file_kattr;
> diff --git a/fs/exfat/file.c b/fs/exfat/file.c
> index 0530803f71e8..c072a0663e69 100644
> --- a/fs/exfat/file.c
> +++ b/fs/exfat/file.c
> @@ -319,7 +319,7 @@ static void exfat_truncate(struct inode *inode)
> mutex_unlock(&sbi->s_lock);
> }
>
> -int exfat_getattr(struct mnt_idmap *idmap, const struct path *path,
> +int exfat_getattr(const struct mnt_idmap *idmap, const struct path *path,
> struct kstat *stat, unsigned int request_mask,
> unsigned int query_flags)
> {
> diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h
> index 702cb7aa1afd..f4bb8b888052 100644
> --- a/fs/ext2/ext2.h
> +++ b/fs/ext2/ext2.h
> @@ -740,7 +740,7 @@ extern void ext2_evict_inode(struct inode *);
> void ext2_write_failed(struct address_space *mapping, loff_t to);
> extern int ext2_get_block(struct inode *, sector_t, struct buffer_head *, int);
> extern int ext2_setattr (struct mnt_idmap *, struct dentry *, struct iattr *);
> -extern int ext2_getattr (struct mnt_idmap *, const struct path *,
> +extern int ext2_getattr (const struct mnt_idmap *, const struct path *,
> struct kstat *, u32, unsigned int);
> extern void ext2_set_inode_flags(struct inode *inode);
> extern int ext2_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
> diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
> index a9245f0cda4d..d4b2a2dec35e 100644
> --- a/fs/ext2/inode.c
> +++ b/fs/ext2/inode.c
> @@ -1591,7 +1591,7 @@ int ext2_sync_inode_metadata(struct inode *inode, struct writeback_control *wbc)
> return err;
> }
>
> -int ext2_getattr(struct mnt_idmap *idmap, const struct path *path,
> +int ext2_getattr(const struct mnt_idmap *idmap, const struct path *path,
> struct kstat *stat, u32 request_mask, unsigned int query_flags)
> {
> struct inode *inode = d_inode(path->dentry);
> diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
> index 2c9a845ed0f8..eb7cf19f606a 100644
> --- a/fs/ext4/ext4.h
> +++ b/fs/ext4/ext4.h
> @@ -3182,11 +3182,11 @@ extern int ext4_sync_inode_metadata(struct inode *, struct writeback_control *)
> extern int ext4_setattr(struct mnt_idmap *, struct dentry *,
> struct iattr *);
> extern u32 ext4_dio_alignment(struct inode *inode);
> -extern int ext4_getattr(struct mnt_idmap *, const struct path *,
> +extern int ext4_getattr(const struct mnt_idmap *, const struct path *,
> struct kstat *, u32, unsigned int);
> extern void ext4_evict_inode(struct inode *);
> extern void ext4_clear_inode(struct inode *);
> -extern int ext4_file_getattr(struct mnt_idmap *, const struct path *,
> +extern int ext4_file_getattr(const struct mnt_idmap *, const struct path *,
> struct kstat *, u32, unsigned int);
> extern void ext4_dirty_inode(struct inode *, int);
> extern int ext4_change_inode_journal_flag(struct inode *, int);
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index bd4b778df9eb..045f5385f26e 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -6263,7 +6263,7 @@ u32 ext4_dio_alignment(struct inode *inode)
> return 1; /* use the iomap defaults */
> }
>
> -int ext4_getattr(struct mnt_idmap *idmap, const struct path *path,
> +int ext4_getattr(const struct mnt_idmap *idmap, const struct path *path,
> struct kstat *stat, u32 request_mask, unsigned int query_flags)
> {
> struct inode *inode = d_inode(path->dentry);
> @@ -6332,7 +6332,7 @@ int ext4_getattr(struct mnt_idmap *idmap, const struct path *path,
> return 0;
> }
>
> -int ext4_file_getattr(struct mnt_idmap *idmap,
> +int ext4_file_getattr(const struct mnt_idmap *idmap,
> const struct path *path, struct kstat *stat,
> u32 request_mask, unsigned int query_flags)
> {
> diff --git a/fs/ext4/symlink.c b/fs/ext4/symlink.c
> index b612262719ed..e680d1e45b47 100644
> --- a/fs/ext4/symlink.c
> +++ b/fs/ext4/symlink.c
> @@ -55,7 +55,7 @@ static const char *ext4_encrypted_get_link(struct dentry *dentry,
> return paddr;
> }
>
> -static int ext4_encrypted_symlink_getattr(struct mnt_idmap *idmap,
> +static int ext4_encrypted_symlink_getattr(const struct mnt_idmap *idmap,
> const struct path *path,
> struct kstat *stat, u32 request_mask,
> unsigned int query_flags)
> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> index 245df8563256..06538f5fd725 100644
> --- a/fs/f2fs/f2fs.h
> +++ b/fs/f2fs/f2fs.h
> @@ -3848,7 +3848,7 @@ int f2fs_sync_file(struct file *file, loff_t start, loff_t end, int datasync);
> int f2fs_do_truncate_blocks(struct inode *inode, u64 from, bool lock);
> int f2fs_truncate_blocks(struct inode *inode, u64 from, bool lock);
> int f2fs_truncate(struct inode *inode);
> -int f2fs_getattr(struct mnt_idmap *idmap, const struct path *path,
> +int f2fs_getattr(const struct mnt_idmap *idmap, const struct path *path,
> struct kstat *stat, u32 request_mask, unsigned int flags);
> int f2fs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *attr);
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index d0cc2ca1397a..267a3a191d54 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -1032,7 +1032,7 @@ static bool f2fs_force_buffered_io(struct inode *inode, int rw)
> return false;
> }
>
> -int f2fs_getattr(struct mnt_idmap *idmap, const struct path *path,
> +int f2fs_getattr(const struct mnt_idmap *idmap, const struct path *path,
> struct kstat *stat, u32 request_mask, unsigned int query_flags)
> {
> struct inode *inode = d_inode(path->dentry);
> diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
> index 9934777eb2a9..233c07fec171 100644
> --- a/fs/f2fs/namei.c
> +++ b/fs/f2fs/namei.c
> @@ -1394,7 +1394,7 @@ static const char *f2fs_encrypted_get_link(struct dentry *dentry,
> return target;
> }
>
> -static int f2fs_encrypted_symlink_getattr(struct mnt_idmap *idmap,
> +static int f2fs_encrypted_symlink_getattr(const struct mnt_idmap *idmap,
> const struct path *path,
> struct kstat *stat, u32 request_mask,
> unsigned int query_flags)
> diff --git a/fs/failfs.c b/fs/failfs.c
> index cec6cad99eb2..437cdc981c2d 100644
> --- a/fs/failfs.c
> +++ b/fs/failfs.c
> @@ -35,7 +35,7 @@ static struct dentry *failfs_lookup(struct inode *dir, struct dentry *dentry,
> return ERR_PTR(-EOPNOTSUPP);
> }
>
> -static int failfs_getattr(struct mnt_idmap *idmap, const struct path *path,
> +static int failfs_getattr(const struct mnt_idmap *idmap, const struct path *path,
> struct kstat *stat, u32 request_mask,
> unsigned int query_flags)
> {
> diff --git a/fs/fat/fat.h b/fs/fat/fat.h
> index 61338413d9f3..202f209a544b 100644
> --- a/fs/fat/fat.h
> +++ b/fs/fat/fat.h
> @@ -407,7 +407,7 @@ extern const struct inode_operations fat_file_inode_operations;
> extern int fat_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *attr);
> extern void fat_truncate_blocks(struct inode *inode, loff_t offset);
> -extern int fat_getattr(struct mnt_idmap *idmap,
> +extern int fat_getattr(const struct mnt_idmap *idmap,
> const struct path *path, struct kstat *stat,
> u32 request_mask, unsigned int flags);
> int fat_fileattr_get(struct dentry *dentry, struct file_kattr *fa);
> diff --git a/fs/fat/file.c b/fs/fat/file.c
> index 0b8b493d06e4..b37bc637945f 100644
> --- a/fs/fat/file.c
> +++ b/fs/fat/file.c
> @@ -432,7 +432,7 @@ int fat_fileattr_get(struct dentry *dentry, struct file_kattr *fa)
> }
> EXPORT_SYMBOL_GPL(fat_fileattr_get);
>
> -int fat_getattr(struct mnt_idmap *idmap, const struct path *path,
> +int fat_getattr(const struct mnt_idmap *idmap, const struct path *path,
> struct kstat *stat, u32 request_mask, unsigned int flags)
> {
> struct inode *inode = d_inode(path->dentry);
> diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
> index ff941e78918f..dd267d9498bc 100644
> --- a/fs/fuse/dir.c
> +++ b/fs/fuse/dir.c
> @@ -1537,7 +1537,7 @@ static int fuse_do_getattr(const struct mnt_idmap *idmap, struct inode *inode,
> return err;
> }
>
> -static int fuse_update_get_attr(struct mnt_idmap *idmap, struct inode *inode,
> +static int fuse_update_get_attr(const struct mnt_idmap *idmap, struct inode *inode,
> struct file *file, struct kstat *stat,
> u32 request_mask, unsigned int flags)
> {
> @@ -2387,7 +2387,7 @@ static int fuse_setattr(struct mnt_idmap *idmap, struct dentry *entry,
> return ret;
> }
>
> -static int fuse_getattr(struct mnt_idmap *idmap,
> +static int fuse_getattr(const struct mnt_idmap *idmap,
> const struct path *path, struct kstat *stat,
> u32 request_mask, unsigned int flags)
> {
> diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
> index e207ab1f5c23..5ddac2f50f30 100644
> --- a/fs/gfs2/inode.c
> +++ b/fs/gfs2/inode.c
> @@ -2156,7 +2156,7 @@ static int gfs2_setattr(struct mnt_idmap *idmap,
> * Returns: errno
> */
>
> -static int gfs2_getattr(struct mnt_idmap *idmap,
> +static int gfs2_getattr(const struct mnt_idmap *idmap,
> const struct path *path, struct kstat *stat,
> u32 request_mask, unsigned int flags)
> {
> diff --git a/fs/hfsplus/hfsplus_fs.h b/fs/hfsplus/hfsplus_fs.h
> index 86fc1c1cdfd6..d55cb16e3897 100644
> --- a/fs/hfsplus/hfsplus_fs.h
> +++ b/fs/hfsplus/hfsplus_fs.h
> @@ -459,7 +459,7 @@ void hfsplus_inode_write_fork(struct inode *inode,
> struct hfsplus_fork_raw *fork);
> int hfsplus_cat_read_inode(struct inode *inode, struct hfs_find_data *fd);
> int hfsplus_cat_write_inode(struct inode *inode);
> -int hfsplus_getattr(struct mnt_idmap *idmap, const struct path *path,
> +int hfsplus_getattr(const struct mnt_idmap *idmap, const struct path *path,
> struct kstat *stat, u32 request_mask,
> unsigned int query_flags);
> int hfsplus_file_fsync(struct file *file, loff_t start, loff_t end,
> diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
> index 9821662bfc1d..2807b29c7028 100644
> --- a/fs/hfsplus/inode.c
> +++ b/fs/hfsplus/inode.c
> @@ -335,7 +335,7 @@ static int hfsplus_setattr(struct mnt_idmap *idmap,
> return 0;
> }
>
> -int hfsplus_getattr(struct mnt_idmap *idmap, const struct path *path,
> +int hfsplus_getattr(const struct mnt_idmap *idmap, const struct path *path,
> struct kstat *stat, u32 request_mask,
> unsigned int query_flags)
> {
> diff --git a/fs/internal.h b/fs/internal.h
> index 8a1c7c05c5a2..88d9296c2a48 100644
> --- a/fs/internal.h
> +++ b/fs/internal.h
> @@ -356,7 +356,7 @@ void file_f_owner_release(struct file *file);
> bool file_seek_cur_needs_f_lock(struct file *file);
> int statmount_mnt_idmap(const struct mnt_idmap *idmap, struct seq_file *seq, bool uid_map);
> struct dentry *find_next_child(struct dentry *parent, struct dentry *prev);
> -int anon_inode_getattr(struct mnt_idmap *idmap, const struct path *path,
> +int anon_inode_getattr(const struct mnt_idmap *idmap, const struct path *path,
> struct kstat *stat, u32 request_mask,
> unsigned int query_flags);
> int anon_inode_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> diff --git a/fs/kernfs/inode.c b/fs/kernfs/inode.c
> index b348d4cd150b..6a92aa789ce5 100644
> --- a/fs/kernfs/inode.c
> +++ b/fs/kernfs/inode.c
> @@ -181,7 +181,7 @@ static void kernfs_refresh_inode(struct kernfs_node *kn, struct inode *inode)
> set_nlink(inode, kn->dir.subdirs + 2);
> }
>
> -int kernfs_iop_getattr(struct mnt_idmap *idmap,
> +int kernfs_iop_getattr(const struct mnt_idmap *idmap,
> const struct path *path, struct kstat *stat,
> u32 request_mask, unsigned int query_flags)
> {
> diff --git a/fs/kernfs/kernfs-internal.h b/fs/kernfs/kernfs-internal.h
> index 0f6f412213f6..8af7849f2c9c 100644
> --- a/fs/kernfs/kernfs-internal.h
> +++ b/fs/kernfs/kernfs-internal.h
> @@ -175,7 +175,7 @@ int kernfs_iop_permission(const struct mnt_idmap *idmap,
> struct inode *inode, int mask);
> int kernfs_iop_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *iattr);
> -int kernfs_iop_getattr(struct mnt_idmap *idmap,
> +int kernfs_iop_getattr(const struct mnt_idmap *idmap,
> const struct path *path, struct kstat *stat,
> u32 request_mask, unsigned int query_flags);
> ssize_t kernfs_iop_listxattr(struct dentry *dentry, char *buf, size_t size);
> diff --git a/fs/libfs.c b/fs/libfs.c
> index 8b379230b64f..b70977b10a7c 100644
> --- a/fs/libfs.c
> +++ b/fs/libfs.c
> @@ -29,7 +29,7 @@
>
> #include "internal.h"
>
> -int simple_getattr(struct mnt_idmap *idmap, const struct path *path,
> +int simple_getattr(const struct mnt_idmap *idmap, const struct path *path,
> struct kstat *stat, u32 request_mask,
> unsigned int query_flags)
> {
> diff --git a/fs/minix/inode.c b/fs/minix/inode.c
> index daf83e4ff25c..670179173645 100644
> --- a/fs/minix/inode.c
> +++ b/fs/minix/inode.c
> @@ -724,7 +724,7 @@ static int minix_sync_inode_metadata(struct inode *inode,
> return err;
> }
>
> -int minix_getattr(struct mnt_idmap *idmap, const struct path *path,
> +int minix_getattr(const struct mnt_idmap *idmap, const struct path *path,
> struct kstat *stat, u32 request_mask, unsigned int flags)
> {
> struct super_block *sb = path->dentry->d_sb;
> diff --git a/fs/minix/minix.h b/fs/minix/minix.h
> index 78722ce22e1e..db92cf9e0e1b 100644
> --- a/fs/minix/minix.h
> +++ b/fs/minix/minix.h
> @@ -55,7 +55,7 @@ unsigned long minix_count_free_inodes(struct super_block *sb);
> int minix_new_block(struct inode *inode);
> void minix_free_block(struct inode *inode, unsigned long block);
> unsigned long minix_count_free_blocks(struct super_block *sb);
> -int minix_getattr(struct mnt_idmap *, const struct path *,
> +int minix_getattr(const struct mnt_idmap *, const struct path *,
> struct kstat *, u32, unsigned int);
> int minix_prepare_chunk(struct folio *folio, loff_t pos, unsigned len);
> struct mapping_metadata_bhs *minix_get_metadata_bhs(struct inode *inode);
> diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
> index 3022454f7698..b114488715fb 100644
> --- a/fs/nfs/inode.c
> +++ b/fs/nfs/inode.c
> @@ -955,7 +955,7 @@ static u32 nfs_get_valid_attrmask(struct inode *inode)
> return reply_mask;
> }
>
> -int nfs_getattr(struct mnt_idmap *idmap, const struct path *path,
> +int nfs_getattr(const struct mnt_idmap *idmap, const struct path *path,
> struct kstat *stat, u32 request_mask, unsigned int query_flags)
> {
> struct inode *inode = d_inode(path->dentry);
> diff --git a/fs/nfs/namespace.c b/fs/nfs/namespace.c
> index 6d0073c24771..17f54d79efa7 100644
> --- a/fs/nfs/namespace.c
> +++ b/fs/nfs/namespace.c
> @@ -222,7 +222,7 @@ struct vfsmount *nfs_d_automount(struct path *path)
> }
>
> static int
> -nfs_namespace_getattr(struct mnt_idmap *idmap,
> +nfs_namespace_getattr(const struct mnt_idmap *idmap,
> const struct path *path, struct kstat *stat,
> u32 request_mask, unsigned int query_flags)
> {
> diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
> index 88747217ba61..40e01704ea8f 100644
> --- a/fs/ntfs/file.c
> +++ b/fs/ntfs/file.c
> @@ -364,7 +364,7 @@ int ntfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> return err;
> }
>
> -int ntfs_getattr(struct mnt_idmap *idmap, const struct path *path,
> +int ntfs_getattr(const struct mnt_idmap *idmap, const struct path *path,
> struct kstat *stat, unsigned int request_mask,
> unsigned int query_flags)
> {
> diff --git a/fs/ntfs/inode.h b/fs/ntfs/inode.h
> index ff61bd402df0..9cf923911825 100644
> --- a/fs/ntfs/inode.h
> +++ b/fs/ntfs/inode.h
> @@ -332,7 +332,7 @@ int ntfs_truncate_vfs(struct inode *vi, loff_t new_size, loff_t i_size);
>
> int ntfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *attr);
> -int ntfs_getattr(struct mnt_idmap *idmap, const struct path *path,
> +int ntfs_getattr(const struct mnt_idmap *idmap, const struct path *path,
> struct kstat *stat, unsigned int request_mask,
> unsigned int query_flags);
>
> diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c
> index f7baa202dc28..f4d08346d25d 100644
> --- a/fs/ntfs3/file.c
> +++ b/fs/ntfs3/file.c
> @@ -261,7 +261,7 @@ long ntfs_compat_ioctl(struct file *filp, u32 cmd, unsigned long arg)
> /*
> * ntfs_getattr - inode_operations::getattr
> */
> -int ntfs_getattr(struct mnt_idmap *idmap, const struct path *path,
> +int ntfs_getattr(const struct mnt_idmap *idmap, const struct path *path,
> struct kstat *stat, u32 request_mask, u32 flags)
> {
> struct inode *inode = d_inode(path->dentry);
> diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h
> index d89609a17886..262b7ff2d6e1 100644
> --- a/fs/ntfs3/ntfs_fs.h
> +++ b/fs/ntfs3/ntfs_fs.h
> @@ -553,7 +553,7 @@ extern const struct file_operations ntfs_dir_operations;
> int ntfs_fileattr_get(struct dentry *dentry, struct file_kattr *fa);
> int ntfs_fileattr_set(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct file_kattr *fa);
> -int ntfs_getattr(struct mnt_idmap *idmap, const struct path *path,
> +int ntfs_getattr(const struct mnt_idmap *idmap, const struct path *path,
> struct kstat *stat, u32 request_mask, u32 flags);
> int ntfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *attr);
> diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
> index 24bbf607546c..befc6ebb2a06 100644
> --- a/fs/ocfs2/file.c
> +++ b/fs/ocfs2/file.c
> @@ -1317,7 +1317,7 @@ int ocfs2_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> return status;
> }
>
> -int ocfs2_getattr(struct mnt_idmap *idmap, const struct path *path,
> +int ocfs2_getattr(const struct mnt_idmap *idmap, const struct path *path,
> struct kstat *stat, u32 request_mask, unsigned int flags)
> {
> struct inode *inode = d_inode(path->dentry);
> diff --git a/fs/ocfs2/file.h b/fs/ocfs2/file.h
> index 08e4d6796531..b51c8e77dad7 100644
> --- a/fs/ocfs2/file.h
> +++ b/fs/ocfs2/file.h
> @@ -52,7 +52,7 @@ int ocfs2_zero_extend(struct inode *inode, struct buffer_head *di_bh,
> loff_t zero_to);
> int ocfs2_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *attr);
> -int ocfs2_getattr(struct mnt_idmap *idmap, const struct path *path,
> +int ocfs2_getattr(const struct mnt_idmap *idmap, const struct path *path,
> struct kstat *stat, u32 request_mask, unsigned int flags);
> int ocfs2_permission(const struct mnt_idmap *idmap,
> struct inode *inode,
> diff --git a/fs/orangefs/inode.c b/fs/orangefs/inode.c
> index 536d5e842c55..100669ee5862 100644
> --- a/fs/orangefs/inode.c
> +++ b/fs/orangefs/inode.c
> @@ -848,7 +848,7 @@ int orangefs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> /*
> * Obtain attributes of an object given a dentry
> */
> -int orangefs_getattr(struct mnt_idmap *idmap, const struct path *path,
> +int orangefs_getattr(const struct mnt_idmap *idmap, const struct path *path,
> struct kstat *stat, u32 request_mask, unsigned int flags)
> {
> int ret;
> diff --git a/fs/orangefs/orangefs-kernel.h b/fs/orangefs/orangefs-kernel.h
> index a5c9e7be4005..3bf01c0c763b 100644
> --- a/fs/orangefs/orangefs-kernel.h
> +++ b/fs/orangefs/orangefs-kernel.h
> @@ -354,7 +354,7 @@ int __orangefs_setattr(struct inode *, struct iattr *);
> int __orangefs_setattr_mode(struct dentry *dentry, struct iattr *iattr);
> int orangefs_setattr(struct mnt_idmap *, struct dentry *, struct iattr *);
>
> -int orangefs_getattr(struct mnt_idmap *idmap, const struct path *path,
> +int orangefs_getattr(const struct mnt_idmap *idmap, const struct path *path,
> struct kstat *stat, u32 request_mask, unsigned int flags);
>
> int orangefs_permission(const struct mnt_idmap *idmap,
> diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
> index 18e4cbe154cf..b765780686e6 100644
> --- a/fs/overlayfs/inode.c
> +++ b/fs/overlayfs/inode.c
> @@ -168,7 +168,7 @@ static inline int ovl_real_getattr_nosec(struct super_block *sb,
> return vfs_getattr_nosec(path, stat, request_mask, flags);
> }
>
> -int ovl_getattr(struct mnt_idmap *idmap, const struct path *path,
> +int ovl_getattr(const struct mnt_idmap *idmap, const struct path *path,
> struct kstat *stat, u32 request_mask, unsigned int flags)
> {
> struct dentry *dentry = path->dentry;
> diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h
> index 1759221dcad5..02a822dc8e5e 100644
> --- a/fs/overlayfs/overlayfs.h
> +++ b/fs/overlayfs/overlayfs.h
> @@ -950,6 +950,6 @@ static inline bool ovl_force_readonly(struct ovl_fs *ofs)
> const struct xattr_handler * const *ovl_xattr_handlers(struct ovl_fs *ofs);
> int ovl_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *attr);
> -int ovl_getattr(struct mnt_idmap *idmap, const struct path *path,
> +int ovl_getattr(const struct mnt_idmap *idmap, const struct path *path,
> struct kstat *stat, u32 request_mask, unsigned int flags);
> ssize_t ovl_listxattr(struct dentry *dentry, char *list, size_t size);
> diff --git a/fs/pidfs.c b/fs/pidfs.c
> index 5bc136de8660..38868ac99950 100644
> --- a/fs/pidfs.c
> +++ b/fs/pidfs.c
> @@ -829,7 +829,7 @@ static int pidfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> return anon_inode_setattr(idmap, dentry, attr);
> }
>
> -static int pidfs_getattr(struct mnt_idmap *idmap, const struct path *path,
> +static int pidfs_getattr(const struct mnt_idmap *idmap, const struct path *path,
> struct kstat *stat, u32 request_mask,
> unsigned int query_flags)
> {
> diff --git a/fs/proc/base.c b/fs/proc/base.c
> index 8dc43c846298..3278c37e5cde 100644
> --- a/fs/proc/base.c
> +++ b/fs/proc/base.c
> @@ -1994,7 +1994,7 @@ static struct inode *proc_pid_make_base_inode(struct super_block *sb,
> return inode;
> }
>
> -int pid_getattr(struct mnt_idmap *idmap, const struct path *path,
> +int pid_getattr(const struct mnt_idmap *idmap, const struct path *path,
> struct kstat *stat, u32 request_mask, unsigned int query_flags)
> {
> struct inode *inode = d_inode(path->dentry);
> @@ -3936,7 +3936,7 @@ static int proc_task_readdir(struct file *file, struct dir_context *ctx)
> return 0;
> }
>
> -static int proc_task_getattr(struct mnt_idmap *idmap,
> +static int proc_task_getattr(const struct mnt_idmap *idmap,
> const struct path *path, struct kstat *stat,
> u32 request_mask, unsigned int query_flags)
> {
> diff --git a/fs/proc/fd.c b/fs/proc/fd.c
> index 0653bceb730d..7214a7495380 100644
> --- a/fs/proc/fd.c
> +++ b/fs/proc/fd.c
> @@ -342,7 +342,7 @@ int proc_fd_permission(const struct mnt_idmap *idmap,
> return rv;
> }
>
> -static int proc_fd_getattr(struct mnt_idmap *idmap,
> +static int proc_fd_getattr(const struct mnt_idmap *idmap,
> const struct path *path, struct kstat *stat,
> u32 request_mask, unsigned int query_flags)
> {
> diff --git a/fs/proc/generic.c b/fs/proc/generic.c
> index 26086a283672..4c4f1e63f68f 100644
> --- a/fs/proc/generic.c
> +++ b/fs/proc/generic.c
> @@ -135,7 +135,7 @@ static int proc_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> return 0;
> }
>
> -static int proc_getattr(struct mnt_idmap *idmap,
> +static int proc_getattr(const struct mnt_idmap *idmap,
> const struct path *path, struct kstat *stat,
> u32 request_mask, unsigned int query_flags)
> {
> diff --git a/fs/proc/internal.h b/fs/proc/internal.h
> index 04bd6c9e65a7..706fae7d30be 100644
> --- a/fs/proc/internal.h
> +++ b/fs/proc/internal.h
> @@ -258,7 +258,7 @@ extern int proc_pid_statm(struct seq_file *, struct pid_namespace *,
> * base.c
> */
> extern const struct dentry_operations pid_dentry_operations;
> -extern int pid_getattr(struct mnt_idmap *, const struct path *,
> +extern int pid_getattr(const struct mnt_idmap *, const struct path *,
> struct kstat *, u32, unsigned int);
> int proc_nochmod_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *attr);
> diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
> index 00cc385bce21..b1f5eafb069a 100644
> --- a/fs/proc/proc_net.c
> +++ b/fs/proc/proc_net.c
> @@ -308,7 +308,7 @@ static struct dentry *proc_tgid_net_lookup(struct inode *dir,
> return de;
> }
>
> -static int proc_tgid_net_getattr(struct mnt_idmap *idmap,
> +static int proc_tgid_net_getattr(const struct mnt_idmap *idmap,
> const struct path *path, struct kstat *stat,
> u32 request_mask, unsigned int query_flags)
> {
> diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
> index 5315d891f244..bd6730000b27 100644
> --- a/fs/proc/proc_sysctl.c
> +++ b/fs/proc/proc_sysctl.c
> @@ -834,7 +834,7 @@ static int proc_sys_setattr(struct mnt_idmap *idmap,
> return 0;
> }
>
> -static int proc_sys_getattr(struct mnt_idmap *idmap,
> +static int proc_sys_getattr(const struct mnt_idmap *idmap,
> const struct path *path, struct kstat *stat,
> u32 request_mask, unsigned int query_flags)
> {
> diff --git a/fs/proc/root.c b/fs/proc/root.c
> index 99adddfeb4a4..7fbbe92bf73a 100644
> --- a/fs/proc/root.c
> +++ b/fs/proc/root.c
> @@ -402,7 +402,7 @@ void __init proc_root_init(void)
> register_filesystem(&proc_fs_type);
> }
>
> -static int proc_root_getattr(struct mnt_idmap *idmap,
> +static int proc_root_getattr(const struct mnt_idmap *idmap,
> const struct path *path, struct kstat *stat,
> u32 request_mask, unsigned int query_flags)
> {
> diff --git a/fs/smb/client/cifsfs.h b/fs/smb/client/cifsfs.h
> index cf09d915bedd..c0adc5219213 100644
> --- a/fs/smb/client/cifsfs.h
> +++ b/fs/smb/client/cifsfs.h
> @@ -78,7 +78,7 @@ int cifs_revalidate_file(struct file *filp);
> int cifs_revalidate_dentry(struct dentry *dentry);
> int cifs_revalidate_mapping(struct inode *inode);
> int cifs_zap_mapping(struct inode *inode);
> -int cifs_getattr(struct mnt_idmap *idmap, const struct path *path,
> +int cifs_getattr(const struct mnt_idmap *idmap, const struct path *path,
> struct kstat *stat, u32 request_mask, unsigned int flags);
> int cifs_setattr(struct mnt_idmap *idmap, struct dentry *direntry,
> struct iattr *attrs);
> diff --git a/fs/smb/client/inode.c b/fs/smb/client/inode.c
> index e3610e456bd4..132f9e072b77 100644
> --- a/fs/smb/client/inode.c
> +++ b/fs/smb/client/inode.c
> @@ -2932,7 +2932,7 @@ int cifs_revalidate_dentry(struct dentry *dentry)
> return cifs_revalidate_mapping(inode);
> }
>
> -int cifs_getattr(struct mnt_idmap *idmap, const struct path *path,
> +int cifs_getattr(const struct mnt_idmap *idmap, const struct path *path,
> struct kstat *stat, u32 request_mask, unsigned int flags)
> {
> struct cifs_sb_info *cifs_sb = CIFS_SB(path->dentry);
> diff --git a/fs/stat.c b/fs/stat.c
> index c461c3054234..fe351818d1d6 100644
> --- a/fs/stat.c
> +++ b/fs/stat.c
> @@ -79,7 +79,7 @@ EXPORT_SYMBOL(fill_mg_cmtime);
> * uid and gid filds. On non-idmapped mounts or if permission checking is to be
> * performed on the raw inode simply pass @nop_mnt_idmap.
> */
> -void generic_fillattr(struct mnt_idmap *idmap, u32 request_mask,
> +void generic_fillattr(const struct mnt_idmap *idmap, u32 request_mask,
> struct inode *inode, struct kstat *stat)
> {
> vfsuid_t vfsuid = i_uid_into_vfsuid(idmap, inode);
> diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c
> index 995b8d0f8d33..44448f1a2bb1 100644
> --- a/fs/tracefs/inode.c
> +++ b/fs/tracefs/inode.c
> @@ -196,7 +196,7 @@ static int tracefs_permission(const struct mnt_idmap *idmap,
> return generic_permission(idmap, inode, mask);
> }
>
> -static int tracefs_getattr(struct mnt_idmap *idmap,
> +static int tracefs_getattr(const struct mnt_idmap *idmap,
> const struct path *path, struct kstat *stat,
> u32 request_mask, unsigned int flags)
> {
> diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c
> index 57640b6ff72d..c67954f6bee0 100644
> --- a/fs/ubifs/dir.c
> +++ b/fs/ubifs/dir.c
> @@ -1667,7 +1667,7 @@ static int ubifs_rename(const struct mnt_idmap *idmap,
> return do_rename(old_dir, old_dentry, new_dir, new_dentry, flags);
> }
>
> -int ubifs_getattr(struct mnt_idmap *idmap, const struct path *path,
> +int ubifs_getattr(const struct mnt_idmap *idmap, const struct path *path,
> struct kstat *stat, u32 request_mask, unsigned int flags)
> {
> loff_t size;
> diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
> index e73c28b12f97..bfc1bd0203ad 100644
> --- a/fs/ubifs/file.c
> +++ b/fs/ubifs/file.c
> @@ -1611,7 +1611,7 @@ static const char *ubifs_get_link(struct dentry *dentry,
> return fscrypt_get_symlink(inode, ui->data, ui->data_len, done);
> }
>
> -static int ubifs_symlink_getattr(struct mnt_idmap *idmap,
> +static int ubifs_symlink_getattr(const struct mnt_idmap *idmap,
> const struct path *path, struct kstat *stat,
> u32 request_mask, unsigned int query_flags)
> {
> diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h
> index af0ef3583aeb..d455a67fe411 100644
> --- a/fs/ubifs/ubifs.h
> +++ b/fs/ubifs/ubifs.h
> @@ -2028,7 +2028,7 @@ int ubifs_update_time(struct inode *inode, enum fs_update_time type,
> /* dir.c */
> struct inode *ubifs_new_inode(struct ubifs_info *c, struct inode *dir,
> umode_t mode, bool is_xattr);
> -int ubifs_getattr(struct mnt_idmap *idmap, const struct path *path,
> +int ubifs_getattr(const struct mnt_idmap *idmap, const struct path *path,
> struct kstat *stat, u32 request_mask, unsigned int flags);
> int ubifs_check_dir_empty(struct inode *dir);
>
> diff --git a/fs/udf/symlink.c b/fs/udf/symlink.c
> index a05d1888a2ba..df41bf5a05b1 100644
> --- a/fs/udf/symlink.c
> +++ b/fs/udf/symlink.c
> @@ -133,7 +133,7 @@ static int udf_symlink_filler(struct file *file, struct folio *folio)
> return err;
> }
>
> -static int udf_symlink_getattr(struct mnt_idmap *idmap,
> +static int udf_symlink_getattr(const struct mnt_idmap *idmap,
> const struct path *path, struct kstat *stat,
> u32 request_mask, unsigned int flags)
> {
> diff --git a/fs/vboxsf/utils.c b/fs/vboxsf/utils.c
> index 298bfc93255c..6a5a47a32075 100644
> --- a/fs/vboxsf/utils.c
> +++ b/fs/vboxsf/utils.c
> @@ -233,7 +233,7 @@ int vboxsf_inode_revalidate(struct dentry *dentry)
> return 0;
> }
>
> -int vboxsf_getattr(struct mnt_idmap *idmap, const struct path *path,
> +int vboxsf_getattr(const struct mnt_idmap *idmap, const struct path *path,
> struct kstat *kstat, u32 request_mask, unsigned int flags)
> {
> int err;
> diff --git a/fs/vboxsf/vfsmod.h b/fs/vboxsf/vfsmod.h
> index b61afd0ce842..9c713b8e7aa2 100644
> --- a/fs/vboxsf/vfsmod.h
> +++ b/fs/vboxsf/vfsmod.h
> @@ -98,7 +98,7 @@ int vboxsf_stat(struct vboxsf_sbi *sbi, struct shfl_string *path,
> struct shfl_fsobjinfo *info);
> int vboxsf_stat_dentry(struct dentry *dentry, struct shfl_fsobjinfo *info);
> int vboxsf_inode_revalidate(struct dentry *dentry);
> -int vboxsf_getattr(struct mnt_idmap *idmap, const struct path *path,
> +int vboxsf_getattr(const struct mnt_idmap *idmap, const struct path *path,
> struct kstat *kstat, u32 request_mask,
> unsigned int query_flags);
> int vboxsf_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
> index 791af2db7124..19fd83cea18b 100644
> --- a/fs/xfs/xfs_iops.c
> +++ b/fs/xfs/xfs_iops.c
> @@ -679,7 +679,7 @@ xfs_report_atomic_write(
>
> STATIC int
> xfs_vn_getattr(
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> const struct path *path,
> struct kstat *stat,
> u32 request_mask,
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 2b9ae72010f0..c79fd3776bbf 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -2013,7 +2013,7 @@ struct inode_operations {
> int (*rename) (const struct mnt_idmap *, struct inode *, struct dentry *,
> struct inode *, struct dentry *, unsigned int);
> int (*setattr) (struct mnt_idmap *, struct dentry *, struct iattr *);
> - int (*getattr) (struct mnt_idmap *, const struct path *,
> + int (*getattr) (const struct mnt_idmap *, const struct path *,
> struct kstat *, u32, unsigned int);
> ssize_t (*listxattr) (struct dentry *, char *, size_t);
> int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start,
> @@ -3204,7 +3204,7 @@ extern int page_symlink(struct inode *inode, const char *symname, int len);
> extern const struct inode_operations page_symlink_inode_operations;
> extern void kfree_link(void *);
> void fill_mg_cmtime(struct kstat *stat, u32 request_mask, struct inode *inode);
> -void generic_fillattr(struct mnt_idmap *, u32, struct inode *, struct kstat *);
> +void generic_fillattr(const struct mnt_idmap *, u32, struct inode *, struct kstat *);
> void generic_fill_statx_attr(struct inode *inode, struct kstat *stat);
> void generic_fill_statx_atomic_writes(struct kstat *stat,
> unsigned int unit_min,
> @@ -3263,7 +3263,7 @@ extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
> extern int dcache_readdir(struct file *, struct dir_context *);
> extern int simple_setattr(struct mnt_idmap *, struct dentry *,
> struct iattr *);
> -extern int simple_getattr(struct mnt_idmap *, const struct path *,
> +extern int simple_getattr(const struct mnt_idmap *, const struct path *,
> struct kstat *, u32, unsigned int);
> extern int simple_statfs(struct dentry *, struct kstatfs *);
> extern int simple_open(struct inode *inode, struct file *file);
> diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h
> index b2828ea03abe..7b307dea7ce7 100644
> --- a/include/linux/nfs_fs.h
> +++ b/include/linux/nfs_fs.h
> @@ -437,7 +437,7 @@ extern int nfs_refresh_inode(struct inode *, struct nfs_fattr *);
> extern int nfs_post_op_update_inode(struct inode *inode, struct nfs_fattr *fattr);
> extern int nfs_post_op_update_inode_force_wcc(struct inode *inode, struct nfs_fattr *fattr);
> extern int nfs_post_op_update_inode_force_wcc_locked(struct inode *inode, struct nfs_fattr *fattr);
> -extern int nfs_getattr(struct mnt_idmap *, const struct path *,
> +extern int nfs_getattr(const struct mnt_idmap *, const struct path *,
> struct kstat *, u32, unsigned int);
> extern void nfs_access_add_cache(struct inode *, struct nfs_access_entry *, const struct cred *);
> extern void nfs_access_set_mask(struct nfs_access_entry *, u32);
> diff --git a/mm/shmem.c b/mm/shmem.c
> index 656235b2f9c5..b27e5f23dc93 100644
> --- a/mm/shmem.c
> +++ b/mm/shmem.c
> @@ -1292,7 +1292,7 @@ void shmem_truncate_range(struct inode *inode, loff_t lstart, uoff_t lend)
> }
> EXPORT_SYMBOL_GPL(shmem_truncate_range);
>
> -static int shmem_getattr(struct mnt_idmap *idmap,
> +static int shmem_getattr(const struct mnt_idmap *idmap,
> const struct path *path, struct kstat *stat,
> u32 request_mask, unsigned int query_flags)
> {
>
> --
> 2.53.0
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 62+ messages in thread
* [PATCH 24/27] fs: port ->setattr() to pass const mnt_idmap
2026-09-01 12:14 [PATCH 00/27] fs: port to const struct mnt_idmap Christian Brauner
` (22 preceding siblings ...)
2026-09-01 12:14 ` [PATCH 23/27] fs: port ->getattr() " Christian Brauner
@ 2026-09-01 12:14 ` Christian Brauner
2026-09-01 15:53 ` Casey Schaufler
` (2 more replies)
2026-09-01 12:14 ` [PATCH 25/27] fs: port vfs_*() helpers to " Christian Brauner
` (2 subsequent siblings)
26 siblings, 3 replies; 62+ messages in thread
From: Christian Brauner @ 2026-09-01 12:14 UTC (permalink / raw)
To: linux-fsdevel
Cc: Alexander Viro, Jan Kara, Christoph Hellwig, Seth Forshee,
Paul Moore, linux-security-module, Mimi Zohar, linux-integrity,
Ilya Dryomov, ceph-devel, Carlos Maiolino, linux-xfs,
Miklos Szeredi, Amir Goldstein, linux-unionfs, Namjae Jeon,
linux-cifs, linux-kernel, Christian Brauner (Amutable)
Convert to const struct mnt_idmap.
A mount's idmapping is immutable. The only thing that is allowed to be
modified afterwards is the reference count and that is hidden behind
mnt_idmap_get() and mnt_idmap_put(). Everything else only ever reads
from the idmapping. This is the same model that struct cred uses and the
idmapping is also rather sensitive.
So make the idmap argument const wherever we can. The conversion is done
from the bottom up so callers can continue to pass a non-const pointer
to a const parameter until the conversion is finished.
No functional changes.
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
---
Documentation/filesystems/locking.rst | 2 +-
Documentation/filesystems/vfs.rst | 2 +-
arch/powerpc/platforms/cell/spufs/inode.c | 2 +-
fs/9p/v9fs_vfs.h | 2 +-
fs/9p/vfs_inode.c | 2 +-
fs/9p/vfs_inode_dotl.c | 2 +-
fs/adfs/adfs.h | 2 +-
fs/adfs/inode.c | 2 +-
fs/affs/affs.h | 2 +-
fs/affs/inode.c | 2 +-
fs/afs/inode.c | 2 +-
fs/afs/internal.h | 2 +-
fs/anon_inodes.c | 2 +-
fs/attr.c | 2 +-
fs/bad_inode.c | 2 +-
fs/btrfs/inode.c | 2 +-
fs/ceph/inode.c | 2 +-
fs/ceph/super.h | 2 +-
fs/coda/coda_linux.h | 2 +-
fs/coda/inode.c | 2 +-
fs/configfs/configfs_internal.h | 2 +-
fs/configfs/inode.c | 2 +-
fs/debugfs/inode.c | 2 +-
fs/ecryptfs/inode.c | 2 +-
fs/efivarfs/inode.c | 2 +-
fs/exfat/exfat_fs.h | 2 +-
fs/exfat/file.c | 2 +-
fs/ext2/ext2.h | 2 +-
fs/ext2/inode.c | 2 +-
fs/ext4/ext4.h | 2 +-
fs/ext4/inode.c | 2 +-
fs/f2fs/f2fs.h | 2 +-
fs/f2fs/file.c | 2 +-
fs/fat/fat.h | 2 +-
fs/fat/file.c | 2 +-
fs/fuse/dir.c | 2 +-
fs/gfs2/inode.c | 2 +-
fs/hfs/hfs_fs.h | 2 +-
fs/hfs/inode.c | 2 +-
fs/hfsplus/inode.c | 2 +-
fs/hostfs/hostfs_kern.c | 2 +-
fs/hpfs/hpfs_fn.h | 2 +-
fs/hpfs/inode.c | 2 +-
fs/hugetlbfs/inode.c | 2 +-
fs/inode.c | 2 +-
fs/internal.h | 2 +-
fs/jffs2/fs.c | 2 +-
fs/jffs2/os-linux.h | 2 +-
fs/jfs/file.c | 2 +-
fs/jfs/jfs_inode.h | 2 +-
fs/kernfs/inode.c | 2 +-
fs/kernfs/kernfs-internal.h | 2 +-
fs/libfs.c | 4 ++--
fs/minix/file.c | 2 +-
fs/nfs/inode.c | 2 +-
fs/nfs/namespace.c | 2 +-
fs/nilfs2/inode.c | 2 +-
fs/nilfs2/nilfs.h | 2 +-
fs/ntfs/file.c | 2 +-
fs/ntfs/inode.h | 2 +-
fs/ntfs3/file.c | 2 +-
fs/ntfs3/ntfs_fs.h | 2 +-
fs/ocfs2/dlmfs/dlmfs.c | 2 +-
fs/ocfs2/file.c | 2 +-
fs/ocfs2/file.h | 2 +-
fs/omfs/file.c | 2 +-
fs/orangefs/inode.c | 2 +-
fs/orangefs/orangefs-kernel.h | 2 +-
fs/overlayfs/inode.c | 2 +-
fs/overlayfs/overlayfs.h | 2 +-
fs/pidfs.c | 2 +-
fs/proc/base.c | 2 +-
fs/proc/generic.c | 2 +-
fs/proc/internal.h | 2 +-
fs/proc/proc_sysctl.c | 2 +-
fs/ramfs/file-nommu.c | 4 ++--
fs/smb/client/cifsfs.h | 2 +-
fs/smb/client/inode.c | 2 +-
fs/tracefs/event_inode.c | 2 +-
fs/tracefs/inode.c | 2 +-
fs/ubifs/file.c | 2 +-
fs/ubifs/ubifs.h | 2 +-
fs/udf/file.c | 2 +-
fs/ufs/inode.c | 2 +-
fs/ufs/ufs.h | 2 +-
fs/vboxsf/utils.c | 2 +-
fs/vboxsf/vfsmod.h | 2 +-
fs/xfs/xfs_iops.c | 2 +-
fs/zonefs/super.c | 2 +-
include/linux/fs.h | 6 +++---
include/linux/lsm_hook_defs.h | 4 ++--
include/linux/nfs_fs.h | 2 +-
include/linux/security.h | 8 ++++----
mm/secretmem.c | 2 +-
mm/shmem.c | 2 +-
net/socket.c | 2 +-
security/integrity/evm/evm_main.c | 4 ++--
security/integrity/ima/ima_appraise.c | 2 +-
security/security.c | 4 ++--
security/selinux/hooks.c | 2 +-
security/smack/smack_lsm.c | 2 +-
virt/kvm/guest_memfd.c | 2 +-
102 files changed, 112 insertions(+), 112 deletions(-)
diff --git a/Documentation/filesystems/locking.rst b/Documentation/filesystems/locking.rst
index f11bfc2e0c13..6330653287d5 100644
--- a/Documentation/filesystems/locking.rst
+++ b/Documentation/filesystems/locking.rst
@@ -76,7 +76,7 @@ prototypes::
void (*truncate) (struct inode *);
int (*permission) (const struct mnt_idmap *, struct inode *, int, unsigned int);
struct posix_acl * (*get_inode_acl)(struct inode *, int, bool);
- int (*setattr) (struct mnt_idmap *, struct dentry *, struct iattr *);
+ int (*setattr) (const struct mnt_idmap *, struct dentry *, struct iattr *);
int (*getattr) (const struct mnt_idmap *, const struct path *, struct kstat *, u32, unsigned int);
ssize_t (*listxattr) (struct dentry *, char *, size_t);
int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start, u64 len);
diff --git a/Documentation/filesystems/vfs.rst b/Documentation/filesystems/vfs.rst
index 98aefc5d399e..7b9475b1282f 100644
--- a/Documentation/filesystems/vfs.rst
+++ b/Documentation/filesystems/vfs.rst
@@ -430,7 +430,7 @@ As of kernel 2.6.22, the following members are defined:
struct delayed_call *);
int (*permission) (const struct mnt_idmap *, struct inode *, int);
struct posix_acl * (*get_inode_acl)(struct inode *, int, bool);
- int (*setattr) (struct mnt_idmap *, struct dentry *, struct iattr *);
+ int (*setattr) (const struct mnt_idmap *, struct dentry *, struct iattr *);
int (*getattr) (const struct mnt_idmap *, const struct path *, struct kstat *, u32, unsigned int);
ssize_t (*listxattr) (struct dentry *, char *, size_t);
void (*update_time)(struct inode *inode, enum fs_update_time type,
diff --git a/arch/powerpc/platforms/cell/spufs/inode.c b/arch/powerpc/platforms/cell/spufs/inode.c
index 2b54afb31529..a7b2df936c90 100644
--- a/arch/powerpc/platforms/cell/spufs/inode.c
+++ b/arch/powerpc/platforms/cell/spufs/inode.c
@@ -92,7 +92,7 @@ spufs_new_inode(struct super_block *sb, umode_t mode)
}
static int
-spufs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+spufs_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *attr)
{
struct inode *inode = d_inode(dentry);
diff --git a/fs/9p/v9fs_vfs.h b/fs/9p/v9fs_vfs.h
index 1856d91f8703..5e7b60042498 100644
--- a/fs/9p/v9fs_vfs.h
+++ b/fs/9p/v9fs_vfs.h
@@ -74,7 +74,7 @@ int v9fs_file_open(struct inode *inode, struct file *file);
int v9fs_uflags2omode(int uflags, int extended);
void v9fs_blank_wstat(struct p9_wstat *wstat);
-int v9fs_vfs_setattr_dotl(struct mnt_idmap *idmap,
+int v9fs_vfs_setattr_dotl(const struct mnt_idmap *idmap,
struct dentry *dentry, struct iattr *iattr);
int v9fs_file_fsync_dotl(struct file *filp, loff_t start, loff_t end,
int datasync);
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
index 0c280342f8e9..c95e653344f6 100644
--- a/fs/9p/vfs_inode.c
+++ b/fs/9p/vfs_inode.c
@@ -1014,7 +1014,7 @@ v9fs_vfs_getattr(const struct mnt_idmap *idmap, const struct path *path,
*
*/
-static int v9fs_vfs_setattr(struct mnt_idmap *idmap,
+static int v9fs_vfs_setattr(const struct mnt_idmap *idmap,
struct dentry *dentry, struct iattr *iattr)
{
int retval, use_dentry = 0;
diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c
index e37854ee6346..2cd2898580a9 100644
--- a/fs/9p/vfs_inode_dotl.c
+++ b/fs/9p/vfs_inode_dotl.c
@@ -508,7 +508,7 @@ static int v9fs_mapped_iattr_valid(int iattr_valid)
*
*/
-int v9fs_vfs_setattr_dotl(struct mnt_idmap *idmap,
+int v9fs_vfs_setattr_dotl(const struct mnt_idmap *idmap,
struct dentry *dentry, struct iattr *iattr)
{
int retval, use_dentry = 0;
diff --git a/fs/adfs/adfs.h b/fs/adfs/adfs.h
index 0d32b7cd99b4..6003832277f8 100644
--- a/fs/adfs/adfs.h
+++ b/fs/adfs/adfs.h
@@ -144,7 +144,7 @@ struct adfs_discmap {
/* Inode stuff */
struct inode *adfs_iget(struct super_block *sb, struct object_info *obj);
int adfs_write_inode(struct inode *inode, struct writeback_control *wbc);
-int adfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+int adfs_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *attr);
/* map.c */
diff --git a/fs/adfs/inode.c b/fs/adfs/inode.c
index 4ac442d0a8c0..34598b499372 100644
--- a/fs/adfs/inode.c
+++ b/fs/adfs/inode.c
@@ -299,7 +299,7 @@ adfs_iget(struct super_block *sb, struct object_info *obj)
* later.
*/
int
-adfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry, struct iattr *attr)
+adfs_setattr(const struct mnt_idmap *idmap, struct dentry *dentry, struct iattr *attr)
{
struct inode *inode = d_inode(dentry);
struct super_block *sb = inode->i_sb;
diff --git a/fs/affs/affs.h b/fs/affs/affs.h
index 8d4ca16c7891..2518de96a0c8 100644
--- a/fs/affs/affs.h
+++ b/fs/affs/affs.h
@@ -184,7 +184,7 @@ extern int affs_rename2(const struct mnt_idmap *idmap,
/* inode.c */
extern struct inode *affs_new_inode(struct inode *dir);
-extern int affs_setattr(struct mnt_idmap *idmap,
+extern int affs_setattr(const struct mnt_idmap *idmap,
struct dentry *dentry, struct iattr *attr);
extern void affs_evict_inode(struct inode *inode);
extern struct inode *affs_iget(struct super_block *sb,
diff --git a/fs/affs/inode.c b/fs/affs/inode.c
index d4a3f381c4bc..2a48d7422091 100644
--- a/fs/affs/inode.c
+++ b/fs/affs/inode.c
@@ -213,7 +213,7 @@ affs_write_inode(struct inode *inode, struct writeback_control *wbc)
}
int
-affs_setattr(struct mnt_idmap *idmap, struct dentry *dentry, struct iattr *attr)
+affs_setattr(const struct mnt_idmap *idmap, struct dentry *dentry, struct iattr *attr)
{
struct inode *inode = d_inode(dentry);
int error;
diff --git a/fs/afs/inode.c b/fs/afs/inode.c
index 7b8a2adc3f59..8e6ca6b45c6b 100644
--- a/fs/afs/inode.c
+++ b/fs/afs/inode.c
@@ -759,7 +759,7 @@ static const struct afs_operation_ops afs_setattr_operation = {
/*
* set the attributes of an inode
*/
-int afs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+int afs_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *attr)
{
const unsigned int supported =
diff --git a/fs/afs/internal.h b/fs/afs/internal.h
index 7a8cdde9e0ad..0bd851f00bbe 100644
--- a/fs/afs/internal.h
+++ b/fs/afs/internal.h
@@ -1260,7 +1260,7 @@ extern struct inode *afs_iget(struct afs_operation *, struct afs_vnode_param *);
extern struct inode *afs_root_iget(struct super_block *, struct key *);
extern int afs_getattr(const struct mnt_idmap *idmap, const struct path *,
struct kstat *, u32, unsigned int);
-extern int afs_setattr(struct mnt_idmap *idmap, struct dentry *, struct iattr *);
+extern int afs_setattr(const struct mnt_idmap *idmap, struct dentry *, struct iattr *);
extern void afs_evict_inode(struct inode *);
extern int afs_drop_inode(struct inode *);
diff --git a/fs/anon_inodes.c b/fs/anon_inodes.c
index d4a7e0b67289..8f07c8d9bda0 100644
--- a/fs/anon_inodes.c
+++ b/fs/anon_inodes.c
@@ -57,7 +57,7 @@ int anon_inode_getattr(const struct mnt_idmap *idmap, const struct path *path,
return 0;
}
-int anon_inode_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+int anon_inode_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *attr)
{
return -EOPNOTSUPP;
diff --git a/fs/attr.c b/fs/attr.c
index 1845d145fe4c..9706d370f34a 100644
--- a/fs/attr.c
+++ b/fs/attr.c
@@ -424,7 +424,7 @@ EXPORT_SYMBOL(may_setattr);
* permissions. On non-idmapped mounts or if permission checking is to be
* performed on the raw inode simply pass @nop_mnt_idmap.
*/
-int notify_change(struct mnt_idmap *idmap, struct dentry *dentry,
+int notify_change(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *attr, struct delegated_inode *delegated_inode)
{
struct inode *inode = dentry->d_inode;
diff --git a/fs/bad_inode.c b/fs/bad_inode.c
index e740b4e658bf..bea9f4876ee0 100644
--- a/fs/bad_inode.c
+++ b/fs/bad_inode.c
@@ -102,7 +102,7 @@ static int bad_inode_getattr(const struct mnt_idmap *idmap,
return -EIO;
}
-static int bad_inode_setattr(struct mnt_idmap *idmap,
+static int bad_inode_setattr(const struct mnt_idmap *idmap,
struct dentry *direntry, struct iattr *attrs)
{
return -EIO;
diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
index da143f9376ee..149ec3b23063 100644
--- a/fs/btrfs/inode.c
+++ b/fs/btrfs/inode.c
@@ -5479,7 +5479,7 @@ static int btrfs_setsize(struct inode *inode, struct iattr *attr)
return ret;
}
-static int btrfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+static int btrfs_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *attr)
{
struct inode *inode = d_inode(dentry);
diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
index 185d713218e6..a695dba82554 100644
--- a/fs/ceph/inode.c
+++ b/fs/ceph/inode.c
@@ -2921,7 +2921,7 @@ int __ceph_setattr(const struct mnt_idmap *idmap, struct inode *inode,
/*
* setattr
*/
-int ceph_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+int ceph_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *attr)
{
struct inode *inode = d_inode(dentry);
diff --git a/fs/ceph/super.h b/fs/ceph/super.h
index 0a5e3916e855..a033331bb151 100644
--- a/fs/ceph/super.h
+++ b/fs/ceph/super.h
@@ -1175,7 +1175,7 @@ struct ceph_iattr {
extern int __ceph_setattr(const struct mnt_idmap *idmap, struct inode *inode,
struct iattr *attr, struct ceph_iattr *cia);
-extern int ceph_setattr(struct mnt_idmap *idmap,
+extern int ceph_setattr(const struct mnt_idmap *idmap,
struct dentry *dentry, struct iattr *attr);
extern int ceph_getattr(const struct mnt_idmap *idmap,
const struct path *path, struct kstat *stat,
diff --git a/fs/coda/coda_linux.h b/fs/coda/coda_linux.h
index 5dc9e392079f..0c0d5f81653c 100644
--- a/fs/coda/coda_linux.h
+++ b/fs/coda/coda_linux.h
@@ -51,7 +51,7 @@ int coda_permission(const struct mnt_idmap *idmap, struct inode *inode,
int coda_revalidate_inode(struct inode *);
int coda_getattr(const struct mnt_idmap *, const struct path *, struct kstat *,
u32, unsigned int);
-int coda_setattr(struct mnt_idmap *, struct dentry *, struct iattr *);
+int coda_setattr(const struct mnt_idmap *, struct dentry *, struct iattr *);
/* this file: helpers */
char *coda_f2s(struct CodaFid *f);
diff --git a/fs/coda/inode.c b/fs/coda/inode.c
index f83ebd94c6be..c449954e23c2 100644
--- a/fs/coda/inode.c
+++ b/fs/coda/inode.c
@@ -304,7 +304,7 @@ int coda_getattr(const struct mnt_idmap *idmap, const struct path *path,
return err;
}
-int coda_setattr(struct mnt_idmap *idmap, struct dentry *de,
+int coda_setattr(const struct mnt_idmap *idmap, struct dentry *de,
struct iattr *iattr)
{
struct inode *inode = d_inode(de);
diff --git a/fs/configfs/configfs_internal.h b/fs/configfs/configfs_internal.h
index 63d70dc05444..860f1b695921 100644
--- a/fs/configfs/configfs_internal.h
+++ b/fs/configfs/configfs_internal.h
@@ -76,7 +76,7 @@ extern int configfs_make_dirent(struct configfs_dirent *, struct dentry *,
extern int configfs_dirent_is_ready(struct configfs_dirent *);
extern const unsigned char * configfs_get_name(struct configfs_dirent *sd);
-extern int configfs_setattr(struct mnt_idmap *idmap,
+extern int configfs_setattr(const struct mnt_idmap *idmap,
struct dentry *dentry, struct iattr *iattr);
extern struct dentry *configfs_pin_fs(void);
diff --git a/fs/configfs/inode.c b/fs/configfs/inode.c
index 68290fe0e374..6ba125d25c66 100644
--- a/fs/configfs/inode.c
+++ b/fs/configfs/inode.c
@@ -32,7 +32,7 @@ static const struct inode_operations configfs_inode_operations ={
.setattr = configfs_setattr,
};
-int configfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+int configfs_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *iattr)
{
struct inode * inode = d_inode(dentry);
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
index e054e62919ec..287ec424ceed 100644
--- a/fs/debugfs/inode.c
+++ b/fs/debugfs/inode.c
@@ -42,7 +42,7 @@ static bool debugfs_enabled __ro_after_init = IS_ENABLED(CONFIG_DEBUG_FS_ALLOW_A
* so that we can use the file mode as part of a heuristic to determine whether
* to lock down individual files.
*/
-static int debugfs_setattr(struct mnt_idmap *idmap,
+static int debugfs_setattr(const struct mnt_idmap *idmap,
struct dentry *dentry, struct iattr *ia)
{
int ret;
diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
index e70a8d73d137..48e520960d66 100644
--- a/fs/ecryptfs/inode.c
+++ b/fs/ecryptfs/inode.c
@@ -869,7 +869,7 @@ ecryptfs_permission(const struct mnt_idmap *idmap, struct inode *inode,
* All other metadata changes will be passed right to the lower filesystem,
* and we will just update our inode to look like the lower.
*/
-static int ecryptfs_setattr(struct mnt_idmap *idmap,
+static int ecryptfs_setattr(const struct mnt_idmap *idmap,
struct dentry *dentry, struct iattr *ia)
{
struct inode *inode = d_inode(dentry);
diff --git a/fs/efivarfs/inode.c b/fs/efivarfs/inode.c
index d87091b92776..07602cd5d33c 100644
--- a/fs/efivarfs/inode.c
+++ b/fs/efivarfs/inode.c
@@ -170,7 +170,7 @@ efivarfs_fileattr_set(const struct mnt_idmap *idmap,
}
/* copy of simple_setattr except that it doesn't do i_size updates */
-static int efivarfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+static int efivarfs_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *iattr)
{
struct inode *inode = d_inode(dentry);
diff --git a/fs/exfat/exfat_fs.h b/fs/exfat/exfat_fs.h
index 5165a0df068a..5acfe7ef57d6 100644
--- a/fs/exfat/exfat_fs.h
+++ b/fs/exfat/exfat_fs.h
@@ -555,7 +555,7 @@ int exfat_trim_fs(struct inode *inode, struct fstrim_range *range);
/* file.c */
extern const struct file_operations exfat_file_operations;
int __exfat_truncate(struct inode *inode);
-int exfat_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+int exfat_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *attr);
int exfat_getattr(const struct mnt_idmap *idmap, const struct path *path,
struct kstat *stat, unsigned int request_mask,
diff --git a/fs/exfat/file.c b/fs/exfat/file.c
index c072a0663e69..3867e78c2312 100644
--- a/fs/exfat/file.c
+++ b/fs/exfat/file.c
@@ -347,7 +347,7 @@ int exfat_fileattr_get(struct dentry *dentry, struct file_kattr *fa)
return 0;
}
-int exfat_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+int exfat_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *attr)
{
struct exfat_sb_info *sbi = EXFAT_SB(dentry->d_sb);
diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h
index f4bb8b888052..cf2796e5703e 100644
--- a/fs/ext2/ext2.h
+++ b/fs/ext2/ext2.h
@@ -739,7 +739,7 @@ extern int ext2_sync_inode_metadata(struct inode *, struct writeback_control *);
extern void ext2_evict_inode(struct inode *);
void ext2_write_failed(struct address_space *mapping, loff_t to);
extern int ext2_get_block(struct inode *, sector_t, struct buffer_head *, int);
-extern int ext2_setattr (struct mnt_idmap *, struct dentry *, struct iattr *);
+extern int ext2_setattr (const struct mnt_idmap *, struct dentry *, struct iattr *);
extern int ext2_getattr (const struct mnt_idmap *, const struct path *,
struct kstat *, u32, unsigned int);
extern void ext2_set_inode_flags(struct inode *inode);
diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
index d4b2a2dec35e..b52ded333aa9 100644
--- a/fs/ext2/inode.c
+++ b/fs/ext2/inode.c
@@ -1617,7 +1617,7 @@ int ext2_getattr(const struct mnt_idmap *idmap, const struct path *path,
return 0;
}
-int ext2_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+int ext2_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *iattr)
{
struct inode *inode = d_inode(dentry);
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index eb7cf19f606a..cbc59d03ca81 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -3179,7 +3179,7 @@ extern struct inode *__ext4_iget(struct super_block *sb, unsigned long ino,
extern int ext4_write_inode(struct inode *, struct writeback_control *);
extern int ext4_sync_inode_metadata(struct inode *, struct writeback_control *);
-extern int ext4_setattr(struct mnt_idmap *, struct dentry *,
+extern int ext4_setattr(const struct mnt_idmap *, struct dentry *,
struct iattr *);
extern u32 ext4_dio_alignment(struct inode *inode);
extern int ext4_getattr(const struct mnt_idmap *, const struct path *,
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 045f5385f26e..3c39bb945821 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -6006,7 +6006,7 @@ static void ext4_wait_for_tail_page_commit(struct inode *inode)
*
* Called with inode->i_rwsem down.
*/
-int ext4_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+int ext4_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *attr)
{
struct inode *inode = d_inode(dentry);
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 06538f5fd725..128813d4f6e3 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -3850,7 +3850,7 @@ int f2fs_truncate_blocks(struct inode *inode, u64 from, bool lock);
int f2fs_truncate(struct inode *inode);
int f2fs_getattr(const struct mnt_idmap *idmap, const struct path *path,
struct kstat *stat, u32 request_mask, unsigned int flags);
-int f2fs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+int f2fs_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *attr);
int f2fs_truncate_hole(struct inode *inode, pgoff_t pg_start, pgoff_t pg_end);
void f2fs_truncate_data_blocks_range(struct dnode_of_data *dn, int count);
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index 267a3a191d54..fb8b03a9972d 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -1121,7 +1121,7 @@ static void __setattr_copy(const struct mnt_idmap *idmap,
#define __setattr_copy setattr_copy
#endif
-int f2fs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+int f2fs_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *attr)
{
struct inode *inode = d_inode(dentry);
diff --git a/fs/fat/fat.h b/fs/fat/fat.h
index 202f209a544b..dbbcfc90a9c2 100644
--- a/fs/fat/fat.h
+++ b/fs/fat/fat.h
@@ -404,7 +404,7 @@ extern long fat_generic_ioctl(struct file *filp, unsigned int cmd,
unsigned long arg);
extern const struct file_operations fat_file_operations;
extern const struct inode_operations fat_file_inode_operations;
-extern int fat_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+extern int fat_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *attr);
extern void fat_truncate_blocks(struct inode *inode, loff_t offset);
extern int fat_getattr(const struct mnt_idmap *idmap,
diff --git a/fs/fat/file.c b/fs/fat/file.c
index b37bc637945f..2c6aee9f0305 100644
--- a/fs/fat/file.c
+++ b/fs/fat/file.c
@@ -514,7 +514,7 @@ static int fat_allow_set_time(const struct mnt_idmap *idmap,
/* valid file mode bits */
#define FAT_VALID_MODE (S_IFREG | S_IFDIR | S_IRWXUGO)
-int fat_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+int fat_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *attr)
{
struct msdos_sb_info *sbi = MSDOS_SB(dentry->d_sb);
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index dd267d9498bc..6d23878cfae5 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -2324,7 +2324,7 @@ int fuse_do_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
return err;
}
-static int fuse_setattr(struct mnt_idmap *idmap, struct dentry *entry,
+static int fuse_setattr(const struct mnt_idmap *idmap, struct dentry *entry,
struct iattr *attr)
{
struct inode *inode = d_inode(entry);
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
index 5ddac2f50f30..a040da86d8ed 100644
--- a/fs/gfs2/inode.c
+++ b/fs/gfs2/inode.c
@@ -2095,7 +2095,7 @@ static int setattr_chown(struct inode *inode, struct iattr *attr)
* Returns: errno
*/
-static int gfs2_setattr(struct mnt_idmap *idmap,
+static int gfs2_setattr(const struct mnt_idmap *idmap,
struct dentry *dentry, struct iattr *attr)
{
struct inode *inode = d_inode(dentry);
diff --git a/fs/hfs/hfs_fs.h b/fs/hfs/hfs_fs.h
index e250f87a5e33..fdfa5d303d5e 100644
--- a/fs/hfs/hfs_fs.h
+++ b/fs/hfs/hfs_fs.h
@@ -212,7 +212,7 @@ extern struct inode *hfs_new_inode(struct inode *dir, const struct qstr *name,
extern void hfs_inode_write_fork(struct inode *inode, struct hfs_extent *ext,
__be32 *log_size, __be32 *phys_size);
extern int hfs_write_inode(struct inode *inode, struct writeback_control *wbc);
-extern int hfs_inode_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+extern int hfs_inode_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *attr);
extern void hfs_inode_read_fork(struct inode *inode, struct hfs_extent *ext,
__be32 __log_size, __be32 phys_size,
diff --git a/fs/hfs/inode.c b/fs/hfs/inode.c
index 2aef3c36a150..c81314f668ac 100644
--- a/fs/hfs/inode.c
+++ b/fs/hfs/inode.c
@@ -643,7 +643,7 @@ static int hfs_file_release(struct inode *inode, struct file *file)
return 0;
}
-int hfs_inode_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+int hfs_inode_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *attr)
{
struct inode *inode = d_inode(dentry);
diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
index 2807b29c7028..aed0866499b2 100644
--- a/fs/hfsplus/inode.c
+++ b/fs/hfsplus/inode.c
@@ -305,7 +305,7 @@ static int hfsplus_file_release(struct inode *inode, struct file *file)
return 0;
}
-static int hfsplus_setattr(struct mnt_idmap *idmap,
+static int hfsplus_setattr(const struct mnt_idmap *idmap,
struct dentry *dentry, struct iattr *attr)
{
struct inode *inode = d_inode(dentry);
diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
index c8ad58be047e..613146e76dec 100644
--- a/fs/hostfs/hostfs_kern.c
+++ b/fs/hostfs/hostfs_kern.c
@@ -801,7 +801,7 @@ static int hostfs_permission(const struct mnt_idmap *idmap,
return err;
}
-static int hostfs_setattr(struct mnt_idmap *idmap,
+static int hostfs_setattr(const struct mnt_idmap *idmap,
struct dentry *dentry, struct iattr *attr)
{
struct inode *inode = d_inode(dentry);
diff --git a/fs/hpfs/hpfs_fn.h b/fs/hpfs/hpfs_fn.h
index 237c1c23e855..a398dd8bdf30 100644
--- a/fs/hpfs/hpfs_fn.h
+++ b/fs/hpfs/hpfs_fn.h
@@ -280,7 +280,7 @@ void hpfs_init_inode(struct inode *);
void hpfs_read_inode(struct inode *);
void hpfs_write_inode(struct inode *);
void hpfs_write_inode_nolock(struct inode *);
-int hpfs_setattr(struct mnt_idmap *, struct dentry *, struct iattr *);
+int hpfs_setattr(const struct mnt_idmap *, struct dentry *, struct iattr *);
void hpfs_write_if_changed(struct inode *);
void hpfs_evict_inode(struct inode *);
diff --git a/fs/hpfs/inode.c b/fs/hpfs/inode.c
index 1b4fcf760aad..396773d0b669 100644
--- a/fs/hpfs/inode.c
+++ b/fs/hpfs/inode.c
@@ -257,7 +257,7 @@ void hpfs_write_inode_nolock(struct inode *i)
brelse(bh);
}
-int hpfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+int hpfs_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *attr)
{
struct inode *inode = d_inode(dentry);
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 0b95be14d3ee..6656807ce437 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -828,7 +828,7 @@ static long hugetlbfs_fallocate(struct file *file, int mode, loff_t offset,
return error;
}
-static int hugetlbfs_setattr(struct mnt_idmap *idmap,
+static int hugetlbfs_setattr(const struct mnt_idmap *idmap,
struct dentry *dentry, struct iattr *attr)
{
struct inode *inode = d_inode(dentry);
diff --git a/fs/inode.c b/fs/inode.c
index 99f1aab89eae..bd9808f07eb8 100644
--- a/fs/inode.c
+++ b/fs/inode.c
@@ -2356,7 +2356,7 @@ int dentry_needs_remove_privs(const struct mnt_idmap *idmap,
return mask;
}
-static int __remove_privs(struct mnt_idmap *idmap,
+static int __remove_privs(const struct mnt_idmap *idmap,
struct dentry *dentry, int kill)
{
struct iattr newattrs;
diff --git a/fs/internal.h b/fs/internal.h
index 88d9296c2a48..2b8cffc22fb3 100644
--- a/fs/internal.h
+++ b/fs/internal.h
@@ -359,7 +359,7 @@ struct dentry *find_next_child(struct dentry *parent, struct dentry *prev);
int anon_inode_getattr(const struct mnt_idmap *idmap, const struct path *path,
struct kstat *stat, u32 request_mask,
unsigned int query_flags);
-int anon_inode_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+int anon_inode_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *attr);
void pidfs_get_root(struct path *path);
void nsfs_get_root(struct path *path);
diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c
index 6ada8369a762..05cf860307c7 100644
--- a/fs/jffs2/fs.c
+++ b/fs/jffs2/fs.c
@@ -190,7 +190,7 @@ int jffs2_do_setattr (struct inode *inode, struct iattr *iattr)
return 0;
}
-int jffs2_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+int jffs2_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *iattr)
{
struct inode *inode = d_inode(dentry);
diff --git a/fs/jffs2/os-linux.h b/fs/jffs2/os-linux.h
index 86ab014a349c..bff2134d771d 100644
--- a/fs/jffs2/os-linux.h
+++ b/fs/jffs2/os-linux.h
@@ -164,7 +164,7 @@ long jffs2_ioctl(struct file *, unsigned int, unsigned long);
extern const struct inode_operations jffs2_symlink_inode_operations;
/* fs.c */
-int jffs2_setattr (struct mnt_idmap *, struct dentry *, struct iattr *);
+int jffs2_setattr (const struct mnt_idmap *, struct dentry *, struct iattr *);
int jffs2_do_setattr (struct inode *, struct iattr *);
struct inode *jffs2_iget(struct super_block *, unsigned long);
void jffs2_evict_inode (struct inode *);
diff --git a/fs/jfs/file.c b/fs/jfs/file.c
index 246568cb9a6e..2f5bb79c0591 100644
--- a/fs/jfs/file.c
+++ b/fs/jfs/file.c
@@ -89,7 +89,7 @@ static int jfs_release(struct inode *inode, struct file *file)
return 0;
}
-int jfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+int jfs_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *iattr)
{
struct inode *inode = d_inode(dentry);
diff --git a/fs/jfs/jfs_inode.h b/fs/jfs/jfs_inode.h
index 88cfc3886282..5a118b07fbff 100644
--- a/fs/jfs/jfs_inode.h
+++ b/fs/jfs/jfs_inode.h
@@ -28,7 +28,7 @@ extern struct dentry *jfs_fh_to_parent(struct super_block *sb, struct fid *fid,
int fh_len, int fh_type);
extern void jfs_set_inode_flags(struct inode *);
extern int jfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
-extern int jfs_setattr(struct mnt_idmap *, struct dentry *, struct iattr *);
+extern int jfs_setattr(const struct mnt_idmap *, struct dentry *, struct iattr *);
extern const struct address_space_operations jfs_aops;
extern const struct inode_operations jfs_dir_inode_operations;
diff --git a/fs/kernfs/inode.c b/fs/kernfs/inode.c
index 6a92aa789ce5..b9dbb504d226 100644
--- a/fs/kernfs/inode.c
+++ b/fs/kernfs/inode.c
@@ -107,7 +107,7 @@ int kernfs_setattr(struct kernfs_node *kn, const struct iattr *iattr)
return ret;
}
-int kernfs_iop_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+int kernfs_iop_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *iattr)
{
struct inode *inode = d_inode(dentry);
diff --git a/fs/kernfs/kernfs-internal.h b/fs/kernfs/kernfs-internal.h
index 8af7849f2c9c..d0c68ec2d236 100644
--- a/fs/kernfs/kernfs-internal.h
+++ b/fs/kernfs/kernfs-internal.h
@@ -173,7 +173,7 @@ extern const struct xattr_handler * const kernfs_xattr_handlers[];
void kernfs_evict_inode(struct inode *inode);
int kernfs_iop_permission(const struct mnt_idmap *idmap,
struct inode *inode, int mask);
-int kernfs_iop_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+int kernfs_iop_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *iattr);
int kernfs_iop_getattr(const struct mnt_idmap *idmap,
const struct path *path, struct kstat *stat,
diff --git a/fs/libfs.c b/fs/libfs.c
index b70977b10a7c..8e2cc627bc7f 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -913,7 +913,7 @@ EXPORT_SYMBOL(simple_rename);
* on simple regular filesystems. Anything that needs to change on-disk
* or wire state on size changes needs its own setattr method.
*/
-int simple_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+int simple_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *iattr)
{
struct inode *inode = d_inode(dentry);
@@ -1727,7 +1727,7 @@ static struct dentry *empty_dir_lookup(struct inode *dir, struct dentry *dentry,
return ERR_PTR(-ENOENT);
}
-static int empty_dir_setattr(struct mnt_idmap *idmap,
+static int empty_dir_setattr(const struct mnt_idmap *idmap,
struct dentry *dentry, struct iattr *attr)
{
return -EPERM;
diff --git a/fs/minix/file.c b/fs/minix/file.c
index 02aabbdb5dea..c0929fc38fbc 100644
--- a/fs/minix/file.c
+++ b/fs/minix/file.c
@@ -23,7 +23,7 @@ const struct file_operations minix_file_operations = {
.splice_read = filemap_splice_read,
};
-static int minix_setattr(struct mnt_idmap *idmap,
+static int minix_setattr(const struct mnt_idmap *idmap,
struct dentry *dentry, struct iattr *attr)
{
struct inode *inode = d_inode(dentry);
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
index b114488715fb..3c9b2ec4e244 100644
--- a/fs/nfs/inode.c
+++ b/fs/nfs/inode.c
@@ -690,7 +690,7 @@ EXPORT_SYMBOL_GPL(nfs_update_delegated_mtime);
#define NFS_VALID_ATTRS (ATTR_MODE|ATTR_UID|ATTR_GID|ATTR_SIZE|ATTR_ATIME|ATTR_ATIME_SET|ATTR_MTIME|ATTR_MTIME_SET|ATTR_FILE|ATTR_OPEN)
int
-nfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+nfs_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *attr)
{
struct inode *inode = d_inode(dentry);
diff --git a/fs/nfs/namespace.c b/fs/nfs/namespace.c
index 17f54d79efa7..c50d59c52c50 100644
--- a/fs/nfs/namespace.c
+++ b/fs/nfs/namespace.c
@@ -235,7 +235,7 @@ nfs_namespace_getattr(const struct mnt_idmap *idmap,
}
static int
-nfs_namespace_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+nfs_namespace_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *attr)
{
if (NFS_FH(d_inode(dentry))->size != 0)
diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c
index 9342f651bf9b..8953719c4950 100644
--- a/fs/nilfs2/inode.c
+++ b/fs/nilfs2/inode.c
@@ -904,7 +904,7 @@ void nilfs_evict_inode(struct inode *inode)
*/
}
-int nilfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+int nilfs_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *iattr)
{
struct nilfs_transaction_info ti;
diff --git a/fs/nilfs2/nilfs.h b/fs/nilfs2/nilfs.h
index 829df7be11fe..28d35b2fa7f7 100644
--- a/fs/nilfs2/nilfs.h
+++ b/fs/nilfs2/nilfs.h
@@ -299,7 +299,7 @@ struct inode *nilfs_iget_for_shadow(struct inode *inode);
extern void nilfs_update_inode(struct inode *, struct buffer_head *, int);
extern void nilfs_truncate(struct inode *);
extern void nilfs_evict_inode(struct inode *);
-extern int nilfs_setattr(struct mnt_idmap *, struct dentry *,
+extern int nilfs_setattr(const struct mnt_idmap *, struct dentry *,
struct iattr *);
extern void nilfs_write_failed(struct address_space *mapping, loff_t to);
int nilfs_permission(const struct mnt_idmap *idmap, struct inode *inode,
diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
index 40e01704ea8f..da85cbae2420 100644
--- a/fs/ntfs/file.c
+++ b/fs/ntfs/file.c
@@ -294,7 +294,7 @@ static int ntfs_setattr_size(struct inode *vi, struct iattr *attr)
* NOTE: Changes in inode size are not supported yet for compressed or
* encrypted files.
*/
-int ntfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+int ntfs_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *attr)
{
struct inode *vi = d_inode(dentry);
diff --git a/fs/ntfs/inode.h b/fs/ntfs/inode.h
index 9cf923911825..45a396c97846 100644
--- a/fs/ntfs/inode.h
+++ b/fs/ntfs/inode.h
@@ -330,7 +330,7 @@ int ntfs_read_inode_mount(struct inode *vi);
int ntfs_show_options(struct seq_file *sf, struct dentry *root);
int ntfs_truncate_vfs(struct inode *vi, loff_t new_size, loff_t i_size);
-int ntfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+int ntfs_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *attr);
int ntfs_getattr(const struct mnt_idmap *idmap, const struct path *path,
struct kstat *stat, unsigned int request_mask,
diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c
index f4d08346d25d..52e1cd969e06 100644
--- a/fs/ntfs3/file.c
+++ b/fs/ntfs3/file.c
@@ -703,7 +703,7 @@ static long ntfs_fallocate(struct file *file, int mode, loff_t vbo, loff_t len)
/*
* ntfs_setattr - inode_operations::setattr
*/
-int ntfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+int ntfs_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *attr)
{
struct inode *inode = d_inode(dentry);
diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h
index 262b7ff2d6e1..ea24126c70db 100644
--- a/fs/ntfs3/ntfs_fs.h
+++ b/fs/ntfs3/ntfs_fs.h
@@ -555,7 +555,7 @@ int ntfs_fileattr_set(const struct mnt_idmap *idmap, struct dentry *dentry,
struct file_kattr *fa);
int ntfs_getattr(const struct mnt_idmap *idmap, const struct path *path,
struct kstat *stat, u32 request_mask, u32 flags);
-int ntfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+int ntfs_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *attr);
int ntfs_file_open(struct inode *inode, struct file *file);
int ntfs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
diff --git a/fs/ocfs2/dlmfs/dlmfs.c b/fs/ocfs2/dlmfs/dlmfs.c
index fef79b21a4a5..d3bfcada3e3b 100644
--- a/fs/ocfs2/dlmfs/dlmfs.c
+++ b/fs/ocfs2/dlmfs/dlmfs.c
@@ -188,7 +188,7 @@ static int dlmfs_file_release(struct inode *inode,
* We do ->setattr() just to override size changes. Our size is the size
* of the LVB and nothing else.
*/
-static int dlmfs_file_setattr(struct mnt_idmap *idmap,
+static int dlmfs_file_setattr(const struct mnt_idmap *idmap,
struct dentry *dentry, struct iattr *attr)
{
int error;
diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
index befc6ebb2a06..62f45a1b5ca1 100644
--- a/fs/ocfs2/file.c
+++ b/fs/ocfs2/file.c
@@ -1117,7 +1117,7 @@ static int ocfs2_extend_file(struct inode *inode,
return ret;
}
-int ocfs2_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+int ocfs2_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *attr)
{
int status = 0, size_change;
diff --git a/fs/ocfs2/file.h b/fs/ocfs2/file.h
index b51c8e77dad7..97492ee5789e 100644
--- a/fs/ocfs2/file.h
+++ b/fs/ocfs2/file.h
@@ -50,7 +50,7 @@ int ocfs2_extend_no_holes(struct inode *inode, struct buffer_head *di_bh,
u64 new_i_size, u64 zero_to);
int ocfs2_zero_extend(struct inode *inode, struct buffer_head *di_bh,
loff_t zero_to);
-int ocfs2_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+int ocfs2_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *attr);
int ocfs2_getattr(const struct mnt_idmap *idmap, const struct path *path,
struct kstat *stat, u32 request_mask, unsigned int flags);
diff --git a/fs/omfs/file.c b/fs/omfs/file.c
index 28f3b113340e..79a413f1dc0d 100644
--- a/fs/omfs/file.c
+++ b/fs/omfs/file.c
@@ -338,7 +338,7 @@ const struct file_operations omfs_file_operations = {
.splice_read = filemap_splice_read,
};
-static int omfs_setattr(struct mnt_idmap *idmap,
+static int omfs_setattr(const struct mnt_idmap *idmap,
struct dentry *dentry, struct iattr *attr)
{
struct inode *inode = d_inode(dentry);
diff --git a/fs/orangefs/inode.c b/fs/orangefs/inode.c
index 100669ee5862..75ac1e485e35 100644
--- a/fs/orangefs/inode.c
+++ b/fs/orangefs/inode.c
@@ -828,7 +828,7 @@ int __orangefs_setattr_mode(struct dentry *dentry, struct iattr *iattr)
/*
* Change attributes of an object referenced by dentry.
*/
-int orangefs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+int orangefs_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *iattr)
{
int ret;
diff --git a/fs/orangefs/orangefs-kernel.h b/fs/orangefs/orangefs-kernel.h
index 3bf01c0c763b..348fe340c5d5 100644
--- a/fs/orangefs/orangefs-kernel.h
+++ b/fs/orangefs/orangefs-kernel.h
@@ -352,7 +352,7 @@ struct inode *orangefs_new_inode(struct super_block *sb,
int __orangefs_setattr(struct inode *, struct iattr *);
int __orangefs_setattr_mode(struct dentry *dentry, struct iattr *iattr);
-int orangefs_setattr(struct mnt_idmap *, struct dentry *, struct iattr *);
+int orangefs_setattr(const struct mnt_idmap *, struct dentry *, struct iattr *);
int orangefs_getattr(const struct mnt_idmap *idmap, const struct path *path,
struct kstat *stat, u32 request_mask, unsigned int flags);
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
index b765780686e6..622e9bb833af 100644
--- a/fs/overlayfs/inode.c
+++ b/fs/overlayfs/inode.c
@@ -18,7 +18,7 @@
#include "overlayfs.h"
-int ovl_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+int ovl_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *attr)
{
int err;
diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h
index 02a822dc8e5e..f0eac9ae1e38 100644
--- a/fs/overlayfs/overlayfs.h
+++ b/fs/overlayfs/overlayfs.h
@@ -948,7 +948,7 @@ static inline bool ovl_force_readonly(struct ovl_fs *ofs)
/* xattr.c */
const struct xattr_handler * const *ovl_xattr_handlers(struct ovl_fs *ofs);
-int ovl_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+int ovl_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *attr);
int ovl_getattr(const struct mnt_idmap *idmap, const struct path *path,
struct kstat *stat, u32 request_mask, unsigned int flags);
diff --git a/fs/pidfs.c b/fs/pidfs.c
index 38868ac99950..c37c17bcdbdc 100644
--- a/fs/pidfs.c
+++ b/fs/pidfs.c
@@ -823,7 +823,7 @@ static struct vfsmount *pidfs_mnt __ro_after_init;
* implemented. Let's reject it completely until we have a clean
* permission concept for pidfds.
*/
-static int pidfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+static int pidfs_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *attr)
{
return anon_inode_setattr(idmap, dentry, attr);
diff --git a/fs/proc/base.c b/fs/proc/base.c
index 3278c37e5cde..5a18636ba81f 100644
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -702,7 +702,7 @@ static int proc_pid_syscall(struct seq_file *m, struct pid_namespace *ns,
/* Here the fs part begins */
/************************************************************************/
-int proc_nochmod_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+int proc_nochmod_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *attr)
{
int error;
diff --git a/fs/proc/generic.c b/fs/proc/generic.c
index 4c4f1e63f68f..2b1971da4a85 100644
--- a/fs/proc/generic.c
+++ b/fs/proc/generic.c
@@ -117,7 +117,7 @@ static bool pde_subdir_insert(struct proc_dir_entry *dir,
return true;
}
-static int proc_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+static int proc_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *iattr)
{
struct inode *inode = d_inode(dentry);
diff --git a/fs/proc/internal.h b/fs/proc/internal.h
index 706fae7d30be..b9aaac41c283 100644
--- a/fs/proc/internal.h
+++ b/fs/proc/internal.h
@@ -260,7 +260,7 @@ extern int proc_pid_statm(struct seq_file *, struct pid_namespace *,
extern const struct dentry_operations pid_dentry_operations;
extern int pid_getattr(const struct mnt_idmap *, const struct path *,
struct kstat *, u32, unsigned int);
-int proc_nochmod_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+int proc_nochmod_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *attr);
extern void proc_pid_evict_inode(struct proc_inode *);
extern struct inode *proc_pid_make_inode(struct super_block *, struct task_struct *, umode_t);
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
index bd6730000b27..d1cfd2941359 100644
--- a/fs/proc/proc_sysctl.c
+++ b/fs/proc/proc_sysctl.c
@@ -817,7 +817,7 @@ static int proc_sys_permission(const struct mnt_idmap *idmap,
return error;
}
-static int proc_sys_setattr(struct mnt_idmap *idmap,
+static int proc_sys_setattr(const struct mnt_idmap *idmap,
struct dentry *dentry, struct iattr *attr)
{
struct inode *inode = d_inode(dentry);
diff --git a/fs/ramfs/file-nommu.c b/fs/ramfs/file-nommu.c
index fb471bf88ab7..7ed6fba134c6 100644
--- a/fs/ramfs/file-nommu.c
+++ b/fs/ramfs/file-nommu.c
@@ -22,7 +22,7 @@
#include <linux/uaccess.h>
#include "internal.h"
-static int ramfs_nommu_setattr(struct mnt_idmap *, struct dentry *, struct iattr *);
+static int ramfs_nommu_setattr(const struct mnt_idmap *, struct dentry *, struct iattr *);
static unsigned long ramfs_nommu_get_unmapped_area(struct file *file,
unsigned long addr,
unsigned long len,
@@ -161,7 +161,7 @@ static int ramfs_nommu_resize(struct inode *inode, loff_t newsize, loff_t size)
* handle a change of attributes
* - we're specifically interested in a change of size
*/
-static int ramfs_nommu_setattr(struct mnt_idmap *idmap,
+static int ramfs_nommu_setattr(const struct mnt_idmap *idmap,
struct dentry *dentry, struct iattr *ia)
{
struct inode *inode = d_inode(dentry);
diff --git a/fs/smb/client/cifsfs.h b/fs/smb/client/cifsfs.h
index c0adc5219213..51692e14c4dd 100644
--- a/fs/smb/client/cifsfs.h
+++ b/fs/smb/client/cifsfs.h
@@ -80,7 +80,7 @@ int cifs_revalidate_mapping(struct inode *inode);
int cifs_zap_mapping(struct inode *inode);
int cifs_getattr(const struct mnt_idmap *idmap, const struct path *path,
struct kstat *stat, u32 request_mask, unsigned int flags);
-int cifs_setattr(struct mnt_idmap *idmap, struct dentry *direntry,
+int cifs_setattr(const struct mnt_idmap *idmap, struct dentry *direntry,
struct iattr *attrs);
int cifs_fiemap(struct inode *inode, struct fiemap_extent_info *fei, u64 start,
u64 len);
diff --git a/fs/smb/client/inode.c b/fs/smb/client/inode.c
index 132f9e072b77..248b7891e687 100644
--- a/fs/smb/client/inode.c
+++ b/fs/smb/client/inode.c
@@ -3549,7 +3549,7 @@ cifs_setattr_nounix(struct dentry *direntry, struct iattr *attrs)
}
int
-cifs_setattr(struct mnt_idmap *idmap, struct dentry *direntry,
+cifs_setattr(const struct mnt_idmap *idmap, struct dentry *direntry,
struct iattr *attrs)
{
struct cifs_sb_info *cifs_sb = CIFS_SB(direntry->d_sb);
diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c
index 6e3513b13cfa..6f6daac88621 100644
--- a/fs/tracefs/event_inode.c
+++ b/fs/tracefs/event_inode.c
@@ -182,7 +182,7 @@ static void update_attr(struct eventfs_attr *attr, struct iattr *iattr)
}
}
-static int eventfs_set_attr(struct mnt_idmap *idmap, struct dentry *dentry,
+static int eventfs_set_attr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *iattr)
{
const struct eventfs_entry *entry;
diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c
index 44448f1a2bb1..5020365ca704 100644
--- a/fs/tracefs/inode.c
+++ b/fs/tracefs/inode.c
@@ -207,7 +207,7 @@ static int tracefs_getattr(const struct mnt_idmap *idmap,
return 0;
}
-static int tracefs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+static int tracefs_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *attr)
{
unsigned int ia_valid = attr->ia_valid;
diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
index bfc1bd0203ad..244b835fc82a 100644
--- a/fs/ubifs/file.c
+++ b/fs/ubifs/file.c
@@ -1251,7 +1251,7 @@ static int do_setattr(struct ubifs_info *c, struct inode *inode,
return err;
}
-int ubifs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+int ubifs_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *attr)
{
int err;
diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h
index d455a67fe411..b85b45a0564b 100644
--- a/fs/ubifs/ubifs.h
+++ b/fs/ubifs/ubifs.h
@@ -2020,7 +2020,7 @@ int ubifs_calc_dark(const struct ubifs_info *c, int spc);
/* file.c */
int ubifs_fsync(struct file *file, loff_t start, loff_t end, int datasync);
-int ubifs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+int ubifs_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *attr);
int ubifs_update_time(struct inode *inode, enum fs_update_time type,
unsigned int flags);
diff --git a/fs/udf/file.c b/fs/udf/file.c
index 57d11606a2a7..02e9314818dc 100644
--- a/fs/udf/file.c
+++ b/fs/udf/file.c
@@ -212,7 +212,7 @@ const struct file_operations udf_file_operations = {
.setlease = generic_setlease,
};
-static int udf_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+static int udf_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *attr)
{
struct inode *inode = d_inode(dentry);
diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c
index 440d014cc5ed..c9ff8673fa66 100644
--- a/fs/ufs/inode.c
+++ b/fs/ufs/inode.c
@@ -1195,7 +1195,7 @@ static int ufs_truncate(struct inode *inode, loff_t size)
return err;
}
-int ufs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+int ufs_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *attr)
{
struct inode *inode = d_inode(dentry);
diff --git a/fs/ufs/ufs.h b/fs/ufs/ufs.h
index 788e025056b2..541566f5b5fb 100644
--- a/fs/ufs/ufs.h
+++ b/fs/ufs/ufs.h
@@ -120,7 +120,7 @@ extern struct inode *ufs_iget(struct super_block *, unsigned long);
extern int ufs_write_inode (struct inode *, struct writeback_control *);
extern int ufs_sync_inode (struct inode *);
extern void ufs_evict_inode (struct inode *);
-extern int ufs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+extern int ufs_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *attr);
/* namei.c */
diff --git a/fs/vboxsf/utils.c b/fs/vboxsf/utils.c
index 6a5a47a32075..8775fbee1ce6 100644
--- a/fs/vboxsf/utils.c
+++ b/fs/vboxsf/utils.c
@@ -258,7 +258,7 @@ int vboxsf_getattr(const struct mnt_idmap *idmap, const struct path *path,
return 0;
}
-int vboxsf_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+int vboxsf_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *iattr)
{
struct vboxsf_inode *sf_i = VBOXSF_I(d_inode(dentry));
diff --git a/fs/vboxsf/vfsmod.h b/fs/vboxsf/vfsmod.h
index 9c713b8e7aa2..59a4e44c4005 100644
--- a/fs/vboxsf/vfsmod.h
+++ b/fs/vboxsf/vfsmod.h
@@ -101,7 +101,7 @@ int vboxsf_inode_revalidate(struct dentry *dentry);
int vboxsf_getattr(const struct mnt_idmap *idmap, const struct path *path,
struct kstat *kstat, u32 request_mask,
unsigned int query_flags);
-int vboxsf_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+int vboxsf_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *iattr);
struct shfl_string *vboxsf_path_from_dentry(struct vboxsf_sbi *sbi,
struct dentry *dentry);
diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
index 19fd83cea18b..535e8a9e071e 100644
--- a/fs/xfs/xfs_iops.c
+++ b/fs/xfs/xfs_iops.c
@@ -1130,7 +1130,7 @@ xfs_vn_setattr_size(
STATIC int
xfs_vn_setattr(
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct dentry *dentry,
struct iattr *iattr)
{
diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c
index ff43d6d1ea30..b97f1f2b8dda 100644
--- a/fs/zonefs/super.c
+++ b/fs/zonefs/super.c
@@ -533,7 +533,7 @@ static int zonefs_show_options(struct seq_file *seq, struct dentry *root)
return 0;
}
-static int zonefs_inode_setattr(struct mnt_idmap *idmap,
+static int zonefs_inode_setattr(const struct mnt_idmap *idmap,
struct dentry *dentry, struct iattr *iattr)
{
struct inode *inode = d_inode(dentry);
diff --git a/include/linux/fs.h b/include/linux/fs.h
index c79fd3776bbf..55d8e7e473ff 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2012,7 +2012,7 @@ struct inode_operations {
umode_t,dev_t);
int (*rename) (const struct mnt_idmap *, struct inode *, struct dentry *,
struct inode *, struct dentry *, unsigned int);
- int (*setattr) (struct mnt_idmap *, struct dentry *, struct iattr *);
+ int (*setattr) (const struct mnt_idmap *, struct dentry *, struct iattr *);
int (*getattr) (const struct mnt_idmap *, const struct path *,
struct kstat *, u32, unsigned int);
ssize_t (*listxattr) (struct dentry *, char *, size_t);
@@ -2707,7 +2707,7 @@ static inline int bmap(struct inode *inode, sector_t *block)
}
#endif
-int notify_change(struct mnt_idmap *, struct dentry *,
+int notify_change(const struct mnt_idmap *, struct dentry *,
struct iattr *, struct delegated_inode *);
int inode_permission(const struct mnt_idmap *, struct inode *, int);
int generic_permission(const struct mnt_idmap *, struct inode *, int);
@@ -3261,7 +3261,7 @@ extern int dcache_dir_open(struct inode *, struct file *);
extern int dcache_dir_close(struct inode *, struct file *);
extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
extern int dcache_readdir(struct file *, struct dir_context *);
-extern int simple_setattr(struct mnt_idmap *, struct dentry *,
+extern int simple_setattr(const struct mnt_idmap *, struct dentry *,
struct iattr *);
extern int simple_getattr(const struct mnt_idmap *, const struct path *,
struct kstat *, u32, unsigned int);
diff --git a/include/linux/lsm_hook_defs.h b/include/linux/lsm_hook_defs.h
index ad05971e6137..194084f60746 100644
--- a/include/linux/lsm_hook_defs.h
+++ b/include/linux/lsm_hook_defs.h
@@ -140,9 +140,9 @@ LSM_HOOK(int, 0, inode_readlink, struct dentry *dentry)
LSM_HOOK(int, 0, inode_follow_link, struct dentry *dentry, struct inode *inode,
bool rcu)
LSM_HOOK(int, 0, inode_permission, struct inode *inode, int mask)
-LSM_HOOK(int, 0, inode_setattr, struct mnt_idmap *idmap, struct dentry *dentry,
+LSM_HOOK(int, 0, inode_setattr, const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *attr)
-LSM_HOOK(void, LSM_RET_VOID, inode_post_setattr, struct mnt_idmap *idmap,
+LSM_HOOK(void, LSM_RET_VOID, inode_post_setattr, const struct mnt_idmap *idmap,
struct dentry *dentry, int ia_valid)
LSM_HOOK(int, 0, inode_getattr, const struct path *path)
LSM_HOOK(int, 0, inode_xattr_skipcap, const char *name)
diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h
index 7b307dea7ce7..d2c716322c6f 100644
--- a/include/linux/nfs_fs.h
+++ b/include/linux/nfs_fs.h
@@ -450,7 +450,7 @@ extern int nfs_clear_invalid_mapping(struct address_space *mapping);
extern bool nfs_mapping_need_revalidate_inode(struct inode *inode);
extern int nfs_revalidate_mapping(struct inode *inode, struct address_space *mapping);
extern int nfs_revalidate_mapping_rcu(struct inode *inode);
-extern int nfs_setattr(struct mnt_idmap *, struct dentry *, struct iattr *);
+extern int nfs_setattr(const struct mnt_idmap *, struct dentry *, struct iattr *);
extern void nfs_setattr_update_inode(struct inode *inode, struct iattr *attr, struct nfs_fattr *);
extern void nfs_setsecurity(struct inode *inode, struct nfs_fattr *fattr);
extern struct nfs_open_context *get_nfs_open_context(struct nfs_open_context *ctx);
diff --git a/include/linux/security.h b/include/linux/security.h
index d4100396da27..c7691feb8f8e 100644
--- a/include/linux/security.h
+++ b/include/linux/security.h
@@ -422,9 +422,9 @@ int security_inode_readlink(struct dentry *dentry);
int security_inode_follow_link(struct dentry *dentry, struct inode *inode,
bool rcu);
int security_inode_permission(struct inode *inode, int mask);
-int security_inode_setattr(struct mnt_idmap *idmap,
+int security_inode_setattr(const struct mnt_idmap *idmap,
struct dentry *dentry, struct iattr *attr);
-void security_inode_post_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+void security_inode_post_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
int ia_valid);
int security_inode_getattr(const struct path *path);
int security_inode_setxattr(const struct mnt_idmap *idmap,
@@ -979,7 +979,7 @@ static inline int security_inode_permission(struct inode *inode, int mask)
return 0;
}
-static inline int security_inode_setattr(struct mnt_idmap *idmap,
+static inline int security_inode_setattr(const struct mnt_idmap *idmap,
struct dentry *dentry,
struct iattr *attr)
{
@@ -987,7 +987,7 @@ static inline int security_inode_setattr(struct mnt_idmap *idmap,
}
static inline void
-security_inode_post_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+security_inode_post_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
int ia_valid)
{ }
diff --git a/mm/secretmem.c b/mm/secretmem.c
index d29865075b6e..7bb6e426ac6e 100644
--- a/mm/secretmem.c
+++ b/mm/secretmem.c
@@ -161,7 +161,7 @@ const struct address_space_operations secretmem_aops = {
.migrate_folio = secretmem_migrate_folio,
};
-static int secretmem_setattr(struct mnt_idmap *idmap,
+static int secretmem_setattr(const struct mnt_idmap *idmap,
struct dentry *dentry, struct iattr *iattr)
{
struct inode *inode = d_inode(dentry);
diff --git a/mm/shmem.c b/mm/shmem.c
index b27e5f23dc93..2c086c2b604e 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -1326,7 +1326,7 @@ static int shmem_getattr(const struct mnt_idmap *idmap,
return 0;
}
-static int shmem_setattr(struct mnt_idmap *idmap,
+static int shmem_setattr(const struct mnt_idmap *idmap,
struct dentry *dentry, struct iattr *attr)
{
struct inode *inode = d_inode(dentry);
diff --git a/net/socket.c b/net/socket.c
index 052273ad081a..c0ab6a3ad8ed 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -670,7 +670,7 @@ static ssize_t sockfs_listxattr(struct dentry *dentry, char *buffer,
return used;
}
-static int sockfs_setattr(struct mnt_idmap *idmap,
+static int sockfs_setattr(const struct mnt_idmap *idmap,
struct dentry *dentry, struct iattr *iattr)
{
int err = simple_setattr(&nop_mnt_idmap, dentry, iattr);
diff --git a/security/integrity/evm/evm_main.c b/security/integrity/evm/evm_main.c
index 10a0b39dd9b7..9bfea858df2d 100644
--- a/security/integrity/evm/evm_main.c
+++ b/security/integrity/evm/evm_main.c
@@ -956,7 +956,7 @@ static int evm_attr_change(const struct mnt_idmap *idmap,
* Permit update of file attributes when files have a valid EVM signature,
* except in the case of them having an immutable portable signature.
*/
-static int evm_inode_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+static int evm_inode_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *attr)
{
unsigned int ia_valid = attr->ia_valid;
@@ -1008,7 +1008,7 @@ static int evm_inode_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
* This function is called from notify_change(), which expects the caller
* to lock the inode's i_mutex.
*/
-static void evm_inode_post_setattr(struct mnt_idmap *idmap,
+static void evm_inode_post_setattr(const struct mnt_idmap *idmap,
struct dentry *dentry, int ia_valid)
{
if (!evm_revalidate_status(NULL))
diff --git a/security/integrity/ima/ima_appraise.c b/security/integrity/ima/ima_appraise.c
index cfc20c63a814..659b71e77ac8 100644
--- a/security/integrity/ima/ima_appraise.c
+++ b/security/integrity/ima/ima_appraise.c
@@ -634,7 +634,7 @@ void ima_update_xattr(struct ima_iint_cache *iint, struct file *file)
* This function is called from notify_change(), which expects the caller
* to lock the inode's i_mutex.
*/
-static void ima_inode_post_setattr(struct mnt_idmap *idmap,
+static void ima_inode_post_setattr(const struct mnt_idmap *idmap,
struct dentry *dentry, int ia_valid)
{
struct inode *inode = d_backing_inode(dentry);
diff --git a/security/security.c b/security/security.c
index 9a3ae6746fb3..304048f26d03 100644
--- a/security/security.c
+++ b/security/security.c
@@ -1855,7 +1855,7 @@ int security_inode_permission(struct inode *inode, int mask)
*
* Return: Returns 0 if permission is granted.
*/
-int security_inode_setattr(struct mnt_idmap *idmap,
+int security_inode_setattr(const struct mnt_idmap *idmap,
struct dentry *dentry, struct iattr *attr)
{
if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
@@ -1872,7 +1872,7 @@ EXPORT_SYMBOL_GPL(security_inode_setattr);
*
* Update inode security field after successful setting file attributes.
*/
-void security_inode_post_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+void security_inode_post_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
int ia_valid)
{
if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index b7c6eba08fdc..1e59fb67dffb 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -3297,7 +3297,7 @@ static int selinux_inode_permission(struct inode *inode, int requested)
return rc;
}
-static int selinux_inode_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+static int selinux_inode_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *iattr)
{
const struct cred *cred = current_cred();
diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
index df4fc6ff26aa..bb78569b3d5b 100644
--- a/security/smack/smack_lsm.c
+++ b/security/smack/smack_lsm.c
@@ -1270,7 +1270,7 @@ static int smack_inode_permission(struct inode *inode, int mask)
*
* Returns 0 if access is permitted, an error code otherwise
*/
-static int smack_inode_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+static int smack_inode_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *iattr)
{
struct smk_audit_info ad;
diff --git a/virt/kvm/guest_memfd.c b/virt/kvm/guest_memfd.c
index 625e62e1a031..5c084d5393a6 100644
--- a/virt/kvm/guest_memfd.c
+++ b/virt/kvm/guest_memfd.c
@@ -506,7 +506,7 @@ static const struct address_space_operations kvm_gmem_aops = {
#endif
};
-static int kvm_gmem_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
+static int kvm_gmem_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
struct iattr *attr)
{
return -EINVAL;
--
2.53.0
^ permalink raw reply related [flat|nested] 62+ messages in thread* Re: [PATCH 24/27] fs: port ->setattr() to pass const mnt_idmap
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
2 siblings, 0 replies; 62+ messages in thread
From: Casey Schaufler @ 2026-09-01 15:53 UTC (permalink / raw)
To: Christian Brauner, linux-fsdevel
Cc: Alexander Viro, Jan Kara, Christoph Hellwig, Seth Forshee,
Paul Moore, linux-security-module, Mimi Zohar, linux-integrity,
Ilya Dryomov, ceph-devel, Carlos Maiolino, linux-xfs,
Miklos Szeredi, Amir Goldstein, linux-unionfs, Namjae Jeon,
linux-cifs, linux-kernel, Casey Schaufler
On 9/1/2026 5:14 AM, Christian Brauner wrote:
> Convert to const struct mnt_idmap.
>
> A mount's idmapping is immutable. The only thing that is allowed to be
> modified afterwards is the reference count and that is hidden behind
> mnt_idmap_get() and mnt_idmap_put(). Everything else only ever reads
> from the idmapping. This is the same model that struct cred uses and the
> idmapping is also rather sensitive.
>
> So make the idmap argument const wherever we can. The conversion is done
> from the bottom up so callers can continue to pass a non-const pointer
> to a const parameter until the conversion is finished.
>
> No functional changes.
>
> Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
> ---
> Documentation/filesystems/locking.rst | 2 +-
> Documentation/filesystems/vfs.rst | 2 +-
> arch/powerpc/platforms/cell/spufs/inode.c | 2 +-
> fs/9p/v9fs_vfs.h | 2 +-
> fs/9p/vfs_inode.c | 2 +-
> fs/9p/vfs_inode_dotl.c | 2 +-
> fs/adfs/adfs.h | 2 +-
> fs/adfs/inode.c | 2 +-
> fs/affs/affs.h | 2 +-
> fs/affs/inode.c | 2 +-
> fs/afs/inode.c | 2 +-
> fs/afs/internal.h | 2 +-
> fs/anon_inodes.c | 2 +-
> fs/attr.c | 2 +-
> fs/bad_inode.c | 2 +-
> fs/btrfs/inode.c | 2 +-
> fs/ceph/inode.c | 2 +-
> fs/ceph/super.h | 2 +-
> fs/coda/coda_linux.h | 2 +-
> fs/coda/inode.c | 2 +-
> fs/configfs/configfs_internal.h | 2 +-
> fs/configfs/inode.c | 2 +-
> fs/debugfs/inode.c | 2 +-
> fs/ecryptfs/inode.c | 2 +-
> fs/efivarfs/inode.c | 2 +-
> fs/exfat/exfat_fs.h | 2 +-
> fs/exfat/file.c | 2 +-
> fs/ext2/ext2.h | 2 +-
> fs/ext2/inode.c | 2 +-
> fs/ext4/ext4.h | 2 +-
> fs/ext4/inode.c | 2 +-
> fs/f2fs/f2fs.h | 2 +-
> fs/f2fs/file.c | 2 +-
> fs/fat/fat.h | 2 +-
> fs/fat/file.c | 2 +-
> fs/fuse/dir.c | 2 +-
> fs/gfs2/inode.c | 2 +-
> fs/hfs/hfs_fs.h | 2 +-
> fs/hfs/inode.c | 2 +-
> fs/hfsplus/inode.c | 2 +-
> fs/hostfs/hostfs_kern.c | 2 +-
> fs/hpfs/hpfs_fn.h | 2 +-
> fs/hpfs/inode.c | 2 +-
> fs/hugetlbfs/inode.c | 2 +-
> fs/inode.c | 2 +-
> fs/internal.h | 2 +-
> fs/jffs2/fs.c | 2 +-
> fs/jffs2/os-linux.h | 2 +-
> fs/jfs/file.c | 2 +-
> fs/jfs/jfs_inode.h | 2 +-
> fs/kernfs/inode.c | 2 +-
> fs/kernfs/kernfs-internal.h | 2 +-
> fs/libfs.c | 4 ++--
> fs/minix/file.c | 2 +-
> fs/nfs/inode.c | 2 +-
> fs/nfs/namespace.c | 2 +-
> fs/nilfs2/inode.c | 2 +-
> fs/nilfs2/nilfs.h | 2 +-
> fs/ntfs/file.c | 2 +-
> fs/ntfs/inode.h | 2 +-
> fs/ntfs3/file.c | 2 +-
> fs/ntfs3/ntfs_fs.h | 2 +-
> fs/ocfs2/dlmfs/dlmfs.c | 2 +-
> fs/ocfs2/file.c | 2 +-
> fs/ocfs2/file.h | 2 +-
> fs/omfs/file.c | 2 +-
> fs/orangefs/inode.c | 2 +-
> fs/orangefs/orangefs-kernel.h | 2 +-
> fs/overlayfs/inode.c | 2 +-
> fs/overlayfs/overlayfs.h | 2 +-
> fs/pidfs.c | 2 +-
> fs/proc/base.c | 2 +-
> fs/proc/generic.c | 2 +-
> fs/proc/internal.h | 2 +-
> fs/proc/proc_sysctl.c | 2 +-
> fs/ramfs/file-nommu.c | 4 ++--
> fs/smb/client/cifsfs.h | 2 +-
> fs/smb/client/inode.c | 2 +-
> fs/tracefs/event_inode.c | 2 +-
> fs/tracefs/inode.c | 2 +-
> fs/ubifs/file.c | 2 +-
> fs/ubifs/ubifs.h | 2 +-
> fs/udf/file.c | 2 +-
> fs/ufs/inode.c | 2 +-
> fs/ufs/ufs.h | 2 +-
> fs/vboxsf/utils.c | 2 +-
> fs/vboxsf/vfsmod.h | 2 +-
> fs/xfs/xfs_iops.c | 2 +-
> fs/zonefs/super.c | 2 +-
> include/linux/fs.h | 6 +++---
> include/linux/lsm_hook_defs.h | 4 ++--
> include/linux/nfs_fs.h | 2 +-
> include/linux/security.h | 8 ++++----
> mm/secretmem.c | 2 +-
> mm/shmem.c | 2 +-
> net/socket.c | 2 +-
> security/integrity/evm/evm_main.c | 4 ++--
> security/integrity/ima/ima_appraise.c | 2 +-
> security/security.c | 4 ++--
> security/selinux/hooks.c | 2 +-
> security/smack/smack_lsm.c | 2 +-
> virt/kvm/guest_memfd.c | 2 +-
> 102 files changed, 112 insertions(+), 112 deletions(-)
...
> diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
> index df4fc6ff26aa..bb78569b3d5b 100644
> --- a/security/smack/smack_lsm.c
> +++ b/security/smack/smack_lsm.c
> @@ -1270,7 +1270,7 @@ static int smack_inode_permission(struct inode *inode, int mask)
> *
> * Returns 0 if access is permitted, an error code otherwise
> */
> -static int smack_inode_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +static int smack_inode_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *iattr)
Please keep to 80 columns.
+static int smack_inode_setattr(const struct mnt_idmap *idmap,
+ struct dentry *dentry, struct iattr *iattr)
Note that the above may get whitespace mangled.
> {
> struct smk_audit_info ad;
>
^ permalink raw reply [flat|nested] 62+ messages in thread* Re: [PATCH 24/27] fs: port ->setattr() to pass const mnt_idmap
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
2 siblings, 0 replies; 62+ messages in thread
From: Jan Kara @ 2026-09-02 16:01 UTC (permalink / raw)
To: Christian Brauner
Cc: linux-fsdevel, Alexander Viro, Jan Kara, Christoph Hellwig,
Seth Forshee, Paul Moore, linux-security-module, Mimi Zohar,
linux-integrity, Ilya Dryomov, ceph-devel, Carlos Maiolino,
linux-xfs, Miklos Szeredi, Amir Goldstein, linux-unionfs,
Namjae Jeon, linux-cifs, linux-kernel
On Tue 01-09-26 14:14:49, Christian Brauner wrote:
> Convert to const struct mnt_idmap.
>
> A mount's idmapping is immutable. The only thing that is allowed to be
> modified afterwards is the reference count and that is hidden behind
> mnt_idmap_get() and mnt_idmap_put(). Everything else only ever reads
> from the idmapping. This is the same model that struct cred uses and the
> idmapping is also rather sensitive.
>
> So make the idmap argument const wherever we can. The conversion is done
> from the bottom up so callers can continue to pass a non-const pointer
> to a const parameter until the conversion is finished.
>
> No functional changes.
>
> Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> Documentation/filesystems/locking.rst | 2 +-
> Documentation/filesystems/vfs.rst | 2 +-
> arch/powerpc/platforms/cell/spufs/inode.c | 2 +-
> fs/9p/v9fs_vfs.h | 2 +-
> fs/9p/vfs_inode.c | 2 +-
> fs/9p/vfs_inode_dotl.c | 2 +-
> fs/adfs/adfs.h | 2 +-
> fs/adfs/inode.c | 2 +-
> fs/affs/affs.h | 2 +-
> fs/affs/inode.c | 2 +-
> fs/afs/inode.c | 2 +-
> fs/afs/internal.h | 2 +-
> fs/anon_inodes.c | 2 +-
> fs/attr.c | 2 +-
> fs/bad_inode.c | 2 +-
> fs/btrfs/inode.c | 2 +-
> fs/ceph/inode.c | 2 +-
> fs/ceph/super.h | 2 +-
> fs/coda/coda_linux.h | 2 +-
> fs/coda/inode.c | 2 +-
> fs/configfs/configfs_internal.h | 2 +-
> fs/configfs/inode.c | 2 +-
> fs/debugfs/inode.c | 2 +-
> fs/ecryptfs/inode.c | 2 +-
> fs/efivarfs/inode.c | 2 +-
> fs/exfat/exfat_fs.h | 2 +-
> fs/exfat/file.c | 2 +-
> fs/ext2/ext2.h | 2 +-
> fs/ext2/inode.c | 2 +-
> fs/ext4/ext4.h | 2 +-
> fs/ext4/inode.c | 2 +-
> fs/f2fs/f2fs.h | 2 +-
> fs/f2fs/file.c | 2 +-
> fs/fat/fat.h | 2 +-
> fs/fat/file.c | 2 +-
> fs/fuse/dir.c | 2 +-
> fs/gfs2/inode.c | 2 +-
> fs/hfs/hfs_fs.h | 2 +-
> fs/hfs/inode.c | 2 +-
> fs/hfsplus/inode.c | 2 +-
> fs/hostfs/hostfs_kern.c | 2 +-
> fs/hpfs/hpfs_fn.h | 2 +-
> fs/hpfs/inode.c | 2 +-
> fs/hugetlbfs/inode.c | 2 +-
> fs/inode.c | 2 +-
> fs/internal.h | 2 +-
> fs/jffs2/fs.c | 2 +-
> fs/jffs2/os-linux.h | 2 +-
> fs/jfs/file.c | 2 +-
> fs/jfs/jfs_inode.h | 2 +-
> fs/kernfs/inode.c | 2 +-
> fs/kernfs/kernfs-internal.h | 2 +-
> fs/libfs.c | 4 ++--
> fs/minix/file.c | 2 +-
> fs/nfs/inode.c | 2 +-
> fs/nfs/namespace.c | 2 +-
> fs/nilfs2/inode.c | 2 +-
> fs/nilfs2/nilfs.h | 2 +-
> fs/ntfs/file.c | 2 +-
> fs/ntfs/inode.h | 2 +-
> fs/ntfs3/file.c | 2 +-
> fs/ntfs3/ntfs_fs.h | 2 +-
> fs/ocfs2/dlmfs/dlmfs.c | 2 +-
> fs/ocfs2/file.c | 2 +-
> fs/ocfs2/file.h | 2 +-
> fs/omfs/file.c | 2 +-
> fs/orangefs/inode.c | 2 +-
> fs/orangefs/orangefs-kernel.h | 2 +-
> fs/overlayfs/inode.c | 2 +-
> fs/overlayfs/overlayfs.h | 2 +-
> fs/pidfs.c | 2 +-
> fs/proc/base.c | 2 +-
> fs/proc/generic.c | 2 +-
> fs/proc/internal.h | 2 +-
> fs/proc/proc_sysctl.c | 2 +-
> fs/ramfs/file-nommu.c | 4 ++--
> fs/smb/client/cifsfs.h | 2 +-
> fs/smb/client/inode.c | 2 +-
> fs/tracefs/event_inode.c | 2 +-
> fs/tracefs/inode.c | 2 +-
> fs/ubifs/file.c | 2 +-
> fs/ubifs/ubifs.h | 2 +-
> fs/udf/file.c | 2 +-
> fs/ufs/inode.c | 2 +-
> fs/ufs/ufs.h | 2 +-
> fs/vboxsf/utils.c | 2 +-
> fs/vboxsf/vfsmod.h | 2 +-
> fs/xfs/xfs_iops.c | 2 +-
> fs/zonefs/super.c | 2 +-
> include/linux/fs.h | 6 +++---
> include/linux/lsm_hook_defs.h | 4 ++--
> include/linux/nfs_fs.h | 2 +-
> include/linux/security.h | 8 ++++----
> mm/secretmem.c | 2 +-
> mm/shmem.c | 2 +-
> net/socket.c | 2 +-
> security/integrity/evm/evm_main.c | 4 ++--
> security/integrity/ima/ima_appraise.c | 2 +-
> security/security.c | 4 ++--
> security/selinux/hooks.c | 2 +-
> security/smack/smack_lsm.c | 2 +-
> virt/kvm/guest_memfd.c | 2 +-
> 102 files changed, 112 insertions(+), 112 deletions(-)
>
> diff --git a/Documentation/filesystems/locking.rst b/Documentation/filesystems/locking.rst
> index f11bfc2e0c13..6330653287d5 100644
> --- a/Documentation/filesystems/locking.rst
> +++ b/Documentation/filesystems/locking.rst
> @@ -76,7 +76,7 @@ prototypes::
> void (*truncate) (struct inode *);
> int (*permission) (const struct mnt_idmap *, struct inode *, int, unsigned int);
> struct posix_acl * (*get_inode_acl)(struct inode *, int, bool);
> - int (*setattr) (struct mnt_idmap *, struct dentry *, struct iattr *);
> + int (*setattr) (const struct mnt_idmap *, struct dentry *, struct iattr *);
> int (*getattr) (const struct mnt_idmap *, const struct path *, struct kstat *, u32, unsigned int);
> ssize_t (*listxattr) (struct dentry *, char *, size_t);
> int (*fiemap)(struct inode *, struct fiemap_extent_info *, u64 start, u64 len);
> diff --git a/Documentation/filesystems/vfs.rst b/Documentation/filesystems/vfs.rst
> index 98aefc5d399e..7b9475b1282f 100644
> --- a/Documentation/filesystems/vfs.rst
> +++ b/Documentation/filesystems/vfs.rst
> @@ -430,7 +430,7 @@ As of kernel 2.6.22, the following members are defined:
> struct delayed_call *);
> int (*permission) (const struct mnt_idmap *, struct inode *, int);
> struct posix_acl * (*get_inode_acl)(struct inode *, int, bool);
> - int (*setattr) (struct mnt_idmap *, struct dentry *, struct iattr *);
> + int (*setattr) (const struct mnt_idmap *, struct dentry *, struct iattr *);
> int (*getattr) (const struct mnt_idmap *, const struct path *, struct kstat *, u32, unsigned int);
> ssize_t (*listxattr) (struct dentry *, char *, size_t);
> void (*update_time)(struct inode *inode, enum fs_update_time type,
> diff --git a/arch/powerpc/platforms/cell/spufs/inode.c b/arch/powerpc/platforms/cell/spufs/inode.c
> index 2b54afb31529..a7b2df936c90 100644
> --- a/arch/powerpc/platforms/cell/spufs/inode.c
> +++ b/arch/powerpc/platforms/cell/spufs/inode.c
> @@ -92,7 +92,7 @@ spufs_new_inode(struct super_block *sb, umode_t mode)
> }
>
> static int
> -spufs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +spufs_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *attr)
> {
> struct inode *inode = d_inode(dentry);
> diff --git a/fs/9p/v9fs_vfs.h b/fs/9p/v9fs_vfs.h
> index 1856d91f8703..5e7b60042498 100644
> --- a/fs/9p/v9fs_vfs.h
> +++ b/fs/9p/v9fs_vfs.h
> @@ -74,7 +74,7 @@ int v9fs_file_open(struct inode *inode, struct file *file);
> int v9fs_uflags2omode(int uflags, int extended);
>
> void v9fs_blank_wstat(struct p9_wstat *wstat);
> -int v9fs_vfs_setattr_dotl(struct mnt_idmap *idmap,
> +int v9fs_vfs_setattr_dotl(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct iattr *iattr);
> int v9fs_file_fsync_dotl(struct file *filp, loff_t start, loff_t end,
> int datasync);
> diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
> index 0c280342f8e9..c95e653344f6 100644
> --- a/fs/9p/vfs_inode.c
> +++ b/fs/9p/vfs_inode.c
> @@ -1014,7 +1014,7 @@ v9fs_vfs_getattr(const struct mnt_idmap *idmap, const struct path *path,
> *
> */
>
> -static int v9fs_vfs_setattr(struct mnt_idmap *idmap,
> +static int v9fs_vfs_setattr(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct iattr *iattr)
> {
> int retval, use_dentry = 0;
> diff --git a/fs/9p/vfs_inode_dotl.c b/fs/9p/vfs_inode_dotl.c
> index e37854ee6346..2cd2898580a9 100644
> --- a/fs/9p/vfs_inode_dotl.c
> +++ b/fs/9p/vfs_inode_dotl.c
> @@ -508,7 +508,7 @@ static int v9fs_mapped_iattr_valid(int iattr_valid)
> *
> */
>
> -int v9fs_vfs_setattr_dotl(struct mnt_idmap *idmap,
> +int v9fs_vfs_setattr_dotl(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct iattr *iattr)
> {
> int retval, use_dentry = 0;
> diff --git a/fs/adfs/adfs.h b/fs/adfs/adfs.h
> index 0d32b7cd99b4..6003832277f8 100644
> --- a/fs/adfs/adfs.h
> +++ b/fs/adfs/adfs.h
> @@ -144,7 +144,7 @@ struct adfs_discmap {
> /* Inode stuff */
> struct inode *adfs_iget(struct super_block *sb, struct object_info *obj);
> int adfs_write_inode(struct inode *inode, struct writeback_control *wbc);
> -int adfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +int adfs_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *attr);
>
> /* map.c */
> diff --git a/fs/adfs/inode.c b/fs/adfs/inode.c
> index 4ac442d0a8c0..34598b499372 100644
> --- a/fs/adfs/inode.c
> +++ b/fs/adfs/inode.c
> @@ -299,7 +299,7 @@ adfs_iget(struct super_block *sb, struct object_info *obj)
> * later.
> */
> int
> -adfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry, struct iattr *attr)
> +adfs_setattr(const struct mnt_idmap *idmap, struct dentry *dentry, struct iattr *attr)
> {
> struct inode *inode = d_inode(dentry);
> struct super_block *sb = inode->i_sb;
> diff --git a/fs/affs/affs.h b/fs/affs/affs.h
> index 8d4ca16c7891..2518de96a0c8 100644
> --- a/fs/affs/affs.h
> +++ b/fs/affs/affs.h
> @@ -184,7 +184,7 @@ extern int affs_rename2(const struct mnt_idmap *idmap,
> /* inode.c */
>
> extern struct inode *affs_new_inode(struct inode *dir);
> -extern int affs_setattr(struct mnt_idmap *idmap,
> +extern int affs_setattr(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct iattr *attr);
> extern void affs_evict_inode(struct inode *inode);
> extern struct inode *affs_iget(struct super_block *sb,
> diff --git a/fs/affs/inode.c b/fs/affs/inode.c
> index d4a3f381c4bc..2a48d7422091 100644
> --- a/fs/affs/inode.c
> +++ b/fs/affs/inode.c
> @@ -213,7 +213,7 @@ affs_write_inode(struct inode *inode, struct writeback_control *wbc)
> }
>
> int
> -affs_setattr(struct mnt_idmap *idmap, struct dentry *dentry, struct iattr *attr)
> +affs_setattr(const struct mnt_idmap *idmap, struct dentry *dentry, struct iattr *attr)
> {
> struct inode *inode = d_inode(dentry);
> int error;
> diff --git a/fs/afs/inode.c b/fs/afs/inode.c
> index 7b8a2adc3f59..8e6ca6b45c6b 100644
> --- a/fs/afs/inode.c
> +++ b/fs/afs/inode.c
> @@ -759,7 +759,7 @@ static const struct afs_operation_ops afs_setattr_operation = {
> /*
> * set the attributes of an inode
> */
> -int afs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +int afs_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *attr)
> {
> const unsigned int supported =
> diff --git a/fs/afs/internal.h b/fs/afs/internal.h
> index 7a8cdde9e0ad..0bd851f00bbe 100644
> --- a/fs/afs/internal.h
> +++ b/fs/afs/internal.h
> @@ -1260,7 +1260,7 @@ extern struct inode *afs_iget(struct afs_operation *, struct afs_vnode_param *);
> extern struct inode *afs_root_iget(struct super_block *, struct key *);
> extern int afs_getattr(const struct mnt_idmap *idmap, const struct path *,
> struct kstat *, u32, unsigned int);
> -extern int afs_setattr(struct mnt_idmap *idmap, struct dentry *, struct iattr *);
> +extern int afs_setattr(const struct mnt_idmap *idmap, struct dentry *, struct iattr *);
> extern void afs_evict_inode(struct inode *);
> extern int afs_drop_inode(struct inode *);
>
> diff --git a/fs/anon_inodes.c b/fs/anon_inodes.c
> index d4a7e0b67289..8f07c8d9bda0 100644
> --- a/fs/anon_inodes.c
> +++ b/fs/anon_inodes.c
> @@ -57,7 +57,7 @@ int anon_inode_getattr(const struct mnt_idmap *idmap, const struct path *path,
> return 0;
> }
>
> -int anon_inode_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +int anon_inode_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *attr)
> {
> return -EOPNOTSUPP;
> diff --git a/fs/attr.c b/fs/attr.c
> index 1845d145fe4c..9706d370f34a 100644
> --- a/fs/attr.c
> +++ b/fs/attr.c
> @@ -424,7 +424,7 @@ EXPORT_SYMBOL(may_setattr);
> * permissions. On non-idmapped mounts or if permission checking is to be
> * performed on the raw inode simply pass @nop_mnt_idmap.
> */
> -int notify_change(struct mnt_idmap *idmap, struct dentry *dentry,
> +int notify_change(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *attr, struct delegated_inode *delegated_inode)
> {
> struct inode *inode = dentry->d_inode;
> diff --git a/fs/bad_inode.c b/fs/bad_inode.c
> index e740b4e658bf..bea9f4876ee0 100644
> --- a/fs/bad_inode.c
> +++ b/fs/bad_inode.c
> @@ -102,7 +102,7 @@ static int bad_inode_getattr(const struct mnt_idmap *idmap,
> return -EIO;
> }
>
> -static int bad_inode_setattr(struct mnt_idmap *idmap,
> +static int bad_inode_setattr(const struct mnt_idmap *idmap,
> struct dentry *direntry, struct iattr *attrs)
> {
> return -EIO;
> diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
> index da143f9376ee..149ec3b23063 100644
> --- a/fs/btrfs/inode.c
> +++ b/fs/btrfs/inode.c
> @@ -5479,7 +5479,7 @@ static int btrfs_setsize(struct inode *inode, struct iattr *attr)
> return ret;
> }
>
> -static int btrfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +static int btrfs_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *attr)
> {
> struct inode *inode = d_inode(dentry);
> diff --git a/fs/ceph/inode.c b/fs/ceph/inode.c
> index 185d713218e6..a695dba82554 100644
> --- a/fs/ceph/inode.c
> +++ b/fs/ceph/inode.c
> @@ -2921,7 +2921,7 @@ int __ceph_setattr(const struct mnt_idmap *idmap, struct inode *inode,
> /*
> * setattr
> */
> -int ceph_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +int ceph_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *attr)
> {
> struct inode *inode = d_inode(dentry);
> diff --git a/fs/ceph/super.h b/fs/ceph/super.h
> index 0a5e3916e855..a033331bb151 100644
> --- a/fs/ceph/super.h
> +++ b/fs/ceph/super.h
> @@ -1175,7 +1175,7 @@ struct ceph_iattr {
>
> extern int __ceph_setattr(const struct mnt_idmap *idmap, struct inode *inode,
> struct iattr *attr, struct ceph_iattr *cia);
> -extern int ceph_setattr(struct mnt_idmap *idmap,
> +extern int ceph_setattr(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct iattr *attr);
> extern int ceph_getattr(const struct mnt_idmap *idmap,
> const struct path *path, struct kstat *stat,
> diff --git a/fs/coda/coda_linux.h b/fs/coda/coda_linux.h
> index 5dc9e392079f..0c0d5f81653c 100644
> --- a/fs/coda/coda_linux.h
> +++ b/fs/coda/coda_linux.h
> @@ -51,7 +51,7 @@ int coda_permission(const struct mnt_idmap *idmap, struct inode *inode,
> int coda_revalidate_inode(struct inode *);
> int coda_getattr(const struct mnt_idmap *, const struct path *, struct kstat *,
> u32, unsigned int);
> -int coda_setattr(struct mnt_idmap *, struct dentry *, struct iattr *);
> +int coda_setattr(const struct mnt_idmap *, struct dentry *, struct iattr *);
>
> /* this file: helpers */
> char *coda_f2s(struct CodaFid *f);
> diff --git a/fs/coda/inode.c b/fs/coda/inode.c
> index f83ebd94c6be..c449954e23c2 100644
> --- a/fs/coda/inode.c
> +++ b/fs/coda/inode.c
> @@ -304,7 +304,7 @@ int coda_getattr(const struct mnt_idmap *idmap, const struct path *path,
> return err;
> }
>
> -int coda_setattr(struct mnt_idmap *idmap, struct dentry *de,
> +int coda_setattr(const struct mnt_idmap *idmap, struct dentry *de,
> struct iattr *iattr)
> {
> struct inode *inode = d_inode(de);
> diff --git a/fs/configfs/configfs_internal.h b/fs/configfs/configfs_internal.h
> index 63d70dc05444..860f1b695921 100644
> --- a/fs/configfs/configfs_internal.h
> +++ b/fs/configfs/configfs_internal.h
> @@ -76,7 +76,7 @@ extern int configfs_make_dirent(struct configfs_dirent *, struct dentry *,
> extern int configfs_dirent_is_ready(struct configfs_dirent *);
>
> extern const unsigned char * configfs_get_name(struct configfs_dirent *sd);
> -extern int configfs_setattr(struct mnt_idmap *idmap,
> +extern int configfs_setattr(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct iattr *iattr);
>
> extern struct dentry *configfs_pin_fs(void);
> diff --git a/fs/configfs/inode.c b/fs/configfs/inode.c
> index 68290fe0e374..6ba125d25c66 100644
> --- a/fs/configfs/inode.c
> +++ b/fs/configfs/inode.c
> @@ -32,7 +32,7 @@ static const struct inode_operations configfs_inode_operations ={
> .setattr = configfs_setattr,
> };
>
> -int configfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +int configfs_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *iattr)
> {
> struct inode * inode = d_inode(dentry);
> diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
> index e054e62919ec..287ec424ceed 100644
> --- a/fs/debugfs/inode.c
> +++ b/fs/debugfs/inode.c
> @@ -42,7 +42,7 @@ static bool debugfs_enabled __ro_after_init = IS_ENABLED(CONFIG_DEBUG_FS_ALLOW_A
> * so that we can use the file mode as part of a heuristic to determine whether
> * to lock down individual files.
> */
> -static int debugfs_setattr(struct mnt_idmap *idmap,
> +static int debugfs_setattr(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct iattr *ia)
> {
> int ret;
> diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
> index e70a8d73d137..48e520960d66 100644
> --- a/fs/ecryptfs/inode.c
> +++ b/fs/ecryptfs/inode.c
> @@ -869,7 +869,7 @@ ecryptfs_permission(const struct mnt_idmap *idmap, struct inode *inode,
> * All other metadata changes will be passed right to the lower filesystem,
> * and we will just update our inode to look like the lower.
> */
> -static int ecryptfs_setattr(struct mnt_idmap *idmap,
> +static int ecryptfs_setattr(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct iattr *ia)
> {
> struct inode *inode = d_inode(dentry);
> diff --git a/fs/efivarfs/inode.c b/fs/efivarfs/inode.c
> index d87091b92776..07602cd5d33c 100644
> --- a/fs/efivarfs/inode.c
> +++ b/fs/efivarfs/inode.c
> @@ -170,7 +170,7 @@ efivarfs_fileattr_set(const struct mnt_idmap *idmap,
> }
>
> /* copy of simple_setattr except that it doesn't do i_size updates */
> -static int efivarfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +static int efivarfs_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *iattr)
> {
> struct inode *inode = d_inode(dentry);
> diff --git a/fs/exfat/exfat_fs.h b/fs/exfat/exfat_fs.h
> index 5165a0df068a..5acfe7ef57d6 100644
> --- a/fs/exfat/exfat_fs.h
> +++ b/fs/exfat/exfat_fs.h
> @@ -555,7 +555,7 @@ int exfat_trim_fs(struct inode *inode, struct fstrim_range *range);
> /* file.c */
> extern const struct file_operations exfat_file_operations;
> int __exfat_truncate(struct inode *inode);
> -int exfat_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +int exfat_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *attr);
> int exfat_getattr(const struct mnt_idmap *idmap, const struct path *path,
> struct kstat *stat, unsigned int request_mask,
> diff --git a/fs/exfat/file.c b/fs/exfat/file.c
> index c072a0663e69..3867e78c2312 100644
> --- a/fs/exfat/file.c
> +++ b/fs/exfat/file.c
> @@ -347,7 +347,7 @@ int exfat_fileattr_get(struct dentry *dentry, struct file_kattr *fa)
> return 0;
> }
>
> -int exfat_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +int exfat_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *attr)
> {
> struct exfat_sb_info *sbi = EXFAT_SB(dentry->d_sb);
> diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h
> index f4bb8b888052..cf2796e5703e 100644
> --- a/fs/ext2/ext2.h
> +++ b/fs/ext2/ext2.h
> @@ -739,7 +739,7 @@ extern int ext2_sync_inode_metadata(struct inode *, struct writeback_control *);
> extern void ext2_evict_inode(struct inode *);
> void ext2_write_failed(struct address_space *mapping, loff_t to);
> extern int ext2_get_block(struct inode *, sector_t, struct buffer_head *, int);
> -extern int ext2_setattr (struct mnt_idmap *, struct dentry *, struct iattr *);
> +extern int ext2_setattr (const struct mnt_idmap *, struct dentry *, struct iattr *);
> extern int ext2_getattr (const struct mnt_idmap *, const struct path *,
> struct kstat *, u32, unsigned int);
> extern void ext2_set_inode_flags(struct inode *inode);
> diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
> index d4b2a2dec35e..b52ded333aa9 100644
> --- a/fs/ext2/inode.c
> +++ b/fs/ext2/inode.c
> @@ -1617,7 +1617,7 @@ int ext2_getattr(const struct mnt_idmap *idmap, const struct path *path,
> return 0;
> }
>
> -int ext2_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +int ext2_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *iattr)
> {
> struct inode *inode = d_inode(dentry);
> diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
> index eb7cf19f606a..cbc59d03ca81 100644
> --- a/fs/ext4/ext4.h
> +++ b/fs/ext4/ext4.h
> @@ -3179,7 +3179,7 @@ extern struct inode *__ext4_iget(struct super_block *sb, unsigned long ino,
>
> extern int ext4_write_inode(struct inode *, struct writeback_control *);
> extern int ext4_sync_inode_metadata(struct inode *, struct writeback_control *);
> -extern int ext4_setattr(struct mnt_idmap *, struct dentry *,
> +extern int ext4_setattr(const struct mnt_idmap *, struct dentry *,
> struct iattr *);
> extern u32 ext4_dio_alignment(struct inode *inode);
> extern int ext4_getattr(const struct mnt_idmap *, const struct path *,
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 045f5385f26e..3c39bb945821 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -6006,7 +6006,7 @@ static void ext4_wait_for_tail_page_commit(struct inode *inode)
> *
> * Called with inode->i_rwsem down.
> */
> -int ext4_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +int ext4_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *attr)
> {
> struct inode *inode = d_inode(dentry);
> diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
> index 06538f5fd725..128813d4f6e3 100644
> --- a/fs/f2fs/f2fs.h
> +++ b/fs/f2fs/f2fs.h
> @@ -3850,7 +3850,7 @@ int f2fs_truncate_blocks(struct inode *inode, u64 from, bool lock);
> int f2fs_truncate(struct inode *inode);
> int f2fs_getattr(const struct mnt_idmap *idmap, const struct path *path,
> struct kstat *stat, u32 request_mask, unsigned int flags);
> -int f2fs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +int f2fs_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *attr);
> int f2fs_truncate_hole(struct inode *inode, pgoff_t pg_start, pgoff_t pg_end);
> void f2fs_truncate_data_blocks_range(struct dnode_of_data *dn, int count);
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index 267a3a191d54..fb8b03a9972d 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -1121,7 +1121,7 @@ static void __setattr_copy(const struct mnt_idmap *idmap,
> #define __setattr_copy setattr_copy
> #endif
>
> -int f2fs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +int f2fs_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *attr)
> {
> struct inode *inode = d_inode(dentry);
> diff --git a/fs/fat/fat.h b/fs/fat/fat.h
> index 202f209a544b..dbbcfc90a9c2 100644
> --- a/fs/fat/fat.h
> +++ b/fs/fat/fat.h
> @@ -404,7 +404,7 @@ extern long fat_generic_ioctl(struct file *filp, unsigned int cmd,
> unsigned long arg);
> extern const struct file_operations fat_file_operations;
> extern const struct inode_operations fat_file_inode_operations;
> -extern int fat_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +extern int fat_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *attr);
> extern void fat_truncate_blocks(struct inode *inode, loff_t offset);
> extern int fat_getattr(const struct mnt_idmap *idmap,
> diff --git a/fs/fat/file.c b/fs/fat/file.c
> index b37bc637945f..2c6aee9f0305 100644
> --- a/fs/fat/file.c
> +++ b/fs/fat/file.c
> @@ -514,7 +514,7 @@ static int fat_allow_set_time(const struct mnt_idmap *idmap,
> /* valid file mode bits */
> #define FAT_VALID_MODE (S_IFREG | S_IFDIR | S_IRWXUGO)
>
> -int fat_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +int fat_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *attr)
> {
> struct msdos_sb_info *sbi = MSDOS_SB(dentry->d_sb);
> diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
> index dd267d9498bc..6d23878cfae5 100644
> --- a/fs/fuse/dir.c
> +++ b/fs/fuse/dir.c
> @@ -2324,7 +2324,7 @@ int fuse_do_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> return err;
> }
>
> -static int fuse_setattr(struct mnt_idmap *idmap, struct dentry *entry,
> +static int fuse_setattr(const struct mnt_idmap *idmap, struct dentry *entry,
> struct iattr *attr)
> {
> struct inode *inode = d_inode(entry);
> diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
> index 5ddac2f50f30..a040da86d8ed 100644
> --- a/fs/gfs2/inode.c
> +++ b/fs/gfs2/inode.c
> @@ -2095,7 +2095,7 @@ static int setattr_chown(struct inode *inode, struct iattr *attr)
> * Returns: errno
> */
>
> -static int gfs2_setattr(struct mnt_idmap *idmap,
> +static int gfs2_setattr(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct iattr *attr)
> {
> struct inode *inode = d_inode(dentry);
> diff --git a/fs/hfs/hfs_fs.h b/fs/hfs/hfs_fs.h
> index e250f87a5e33..fdfa5d303d5e 100644
> --- a/fs/hfs/hfs_fs.h
> +++ b/fs/hfs/hfs_fs.h
> @@ -212,7 +212,7 @@ extern struct inode *hfs_new_inode(struct inode *dir, const struct qstr *name,
> extern void hfs_inode_write_fork(struct inode *inode, struct hfs_extent *ext,
> __be32 *log_size, __be32 *phys_size);
> extern int hfs_write_inode(struct inode *inode, struct writeback_control *wbc);
> -extern int hfs_inode_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +extern int hfs_inode_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *attr);
> extern void hfs_inode_read_fork(struct inode *inode, struct hfs_extent *ext,
> __be32 __log_size, __be32 phys_size,
> diff --git a/fs/hfs/inode.c b/fs/hfs/inode.c
> index 2aef3c36a150..c81314f668ac 100644
> --- a/fs/hfs/inode.c
> +++ b/fs/hfs/inode.c
> @@ -643,7 +643,7 @@ static int hfs_file_release(struct inode *inode, struct file *file)
> return 0;
> }
>
> -int hfs_inode_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +int hfs_inode_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *attr)
> {
> struct inode *inode = d_inode(dentry);
> diff --git a/fs/hfsplus/inode.c b/fs/hfsplus/inode.c
> index 2807b29c7028..aed0866499b2 100644
> --- a/fs/hfsplus/inode.c
> +++ b/fs/hfsplus/inode.c
> @@ -305,7 +305,7 @@ static int hfsplus_file_release(struct inode *inode, struct file *file)
> return 0;
> }
>
> -static int hfsplus_setattr(struct mnt_idmap *idmap,
> +static int hfsplus_setattr(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct iattr *attr)
> {
> struct inode *inode = d_inode(dentry);
> diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
> index c8ad58be047e..613146e76dec 100644
> --- a/fs/hostfs/hostfs_kern.c
> +++ b/fs/hostfs/hostfs_kern.c
> @@ -801,7 +801,7 @@ static int hostfs_permission(const struct mnt_idmap *idmap,
> return err;
> }
>
> -static int hostfs_setattr(struct mnt_idmap *idmap,
> +static int hostfs_setattr(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct iattr *attr)
> {
> struct inode *inode = d_inode(dentry);
> diff --git a/fs/hpfs/hpfs_fn.h b/fs/hpfs/hpfs_fn.h
> index 237c1c23e855..a398dd8bdf30 100644
> --- a/fs/hpfs/hpfs_fn.h
> +++ b/fs/hpfs/hpfs_fn.h
> @@ -280,7 +280,7 @@ void hpfs_init_inode(struct inode *);
> void hpfs_read_inode(struct inode *);
> void hpfs_write_inode(struct inode *);
> void hpfs_write_inode_nolock(struct inode *);
> -int hpfs_setattr(struct mnt_idmap *, struct dentry *, struct iattr *);
> +int hpfs_setattr(const struct mnt_idmap *, struct dentry *, struct iattr *);
> void hpfs_write_if_changed(struct inode *);
> void hpfs_evict_inode(struct inode *);
>
> diff --git a/fs/hpfs/inode.c b/fs/hpfs/inode.c
> index 1b4fcf760aad..396773d0b669 100644
> --- a/fs/hpfs/inode.c
> +++ b/fs/hpfs/inode.c
> @@ -257,7 +257,7 @@ void hpfs_write_inode_nolock(struct inode *i)
> brelse(bh);
> }
>
> -int hpfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +int hpfs_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *attr)
> {
> struct inode *inode = d_inode(dentry);
> diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
> index 0b95be14d3ee..6656807ce437 100644
> --- a/fs/hugetlbfs/inode.c
> +++ b/fs/hugetlbfs/inode.c
> @@ -828,7 +828,7 @@ static long hugetlbfs_fallocate(struct file *file, int mode, loff_t offset,
> return error;
> }
>
> -static int hugetlbfs_setattr(struct mnt_idmap *idmap,
> +static int hugetlbfs_setattr(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct iattr *attr)
> {
> struct inode *inode = d_inode(dentry);
> diff --git a/fs/inode.c b/fs/inode.c
> index 99f1aab89eae..bd9808f07eb8 100644
> --- a/fs/inode.c
> +++ b/fs/inode.c
> @@ -2356,7 +2356,7 @@ int dentry_needs_remove_privs(const struct mnt_idmap *idmap,
> return mask;
> }
>
> -static int __remove_privs(struct mnt_idmap *idmap,
> +static int __remove_privs(const struct mnt_idmap *idmap,
> struct dentry *dentry, int kill)
> {
> struct iattr newattrs;
> diff --git a/fs/internal.h b/fs/internal.h
> index 88d9296c2a48..2b8cffc22fb3 100644
> --- a/fs/internal.h
> +++ b/fs/internal.h
> @@ -359,7 +359,7 @@ struct dentry *find_next_child(struct dentry *parent, struct dentry *prev);
> int anon_inode_getattr(const struct mnt_idmap *idmap, const struct path *path,
> struct kstat *stat, u32 request_mask,
> unsigned int query_flags);
> -int anon_inode_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +int anon_inode_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *attr);
> void pidfs_get_root(struct path *path);
> void nsfs_get_root(struct path *path);
> diff --git a/fs/jffs2/fs.c b/fs/jffs2/fs.c
> index 6ada8369a762..05cf860307c7 100644
> --- a/fs/jffs2/fs.c
> +++ b/fs/jffs2/fs.c
> @@ -190,7 +190,7 @@ int jffs2_do_setattr (struct inode *inode, struct iattr *iattr)
> return 0;
> }
>
> -int jffs2_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +int jffs2_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *iattr)
> {
> struct inode *inode = d_inode(dentry);
> diff --git a/fs/jffs2/os-linux.h b/fs/jffs2/os-linux.h
> index 86ab014a349c..bff2134d771d 100644
> --- a/fs/jffs2/os-linux.h
> +++ b/fs/jffs2/os-linux.h
> @@ -164,7 +164,7 @@ long jffs2_ioctl(struct file *, unsigned int, unsigned long);
> extern const struct inode_operations jffs2_symlink_inode_operations;
>
> /* fs.c */
> -int jffs2_setattr (struct mnt_idmap *, struct dentry *, struct iattr *);
> +int jffs2_setattr (const struct mnt_idmap *, struct dentry *, struct iattr *);
> int jffs2_do_setattr (struct inode *, struct iattr *);
> struct inode *jffs2_iget(struct super_block *, unsigned long);
> void jffs2_evict_inode (struct inode *);
> diff --git a/fs/jfs/file.c b/fs/jfs/file.c
> index 246568cb9a6e..2f5bb79c0591 100644
> --- a/fs/jfs/file.c
> +++ b/fs/jfs/file.c
> @@ -89,7 +89,7 @@ static int jfs_release(struct inode *inode, struct file *file)
> return 0;
> }
>
> -int jfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +int jfs_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *iattr)
> {
> struct inode *inode = d_inode(dentry);
> diff --git a/fs/jfs/jfs_inode.h b/fs/jfs/jfs_inode.h
> index 88cfc3886282..5a118b07fbff 100644
> --- a/fs/jfs/jfs_inode.h
> +++ b/fs/jfs/jfs_inode.h
> @@ -28,7 +28,7 @@ extern struct dentry *jfs_fh_to_parent(struct super_block *sb, struct fid *fid,
> int fh_len, int fh_type);
> extern void jfs_set_inode_flags(struct inode *);
> extern int jfs_get_block(struct inode *, sector_t, struct buffer_head *, int);
> -extern int jfs_setattr(struct mnt_idmap *, struct dentry *, struct iattr *);
> +extern int jfs_setattr(const struct mnt_idmap *, struct dentry *, struct iattr *);
>
> extern const struct address_space_operations jfs_aops;
> extern const struct inode_operations jfs_dir_inode_operations;
> diff --git a/fs/kernfs/inode.c b/fs/kernfs/inode.c
> index 6a92aa789ce5..b9dbb504d226 100644
> --- a/fs/kernfs/inode.c
> +++ b/fs/kernfs/inode.c
> @@ -107,7 +107,7 @@ int kernfs_setattr(struct kernfs_node *kn, const struct iattr *iattr)
> return ret;
> }
>
> -int kernfs_iop_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +int kernfs_iop_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *iattr)
> {
> struct inode *inode = d_inode(dentry);
> diff --git a/fs/kernfs/kernfs-internal.h b/fs/kernfs/kernfs-internal.h
> index 8af7849f2c9c..d0c68ec2d236 100644
> --- a/fs/kernfs/kernfs-internal.h
> +++ b/fs/kernfs/kernfs-internal.h
> @@ -173,7 +173,7 @@ extern const struct xattr_handler * const kernfs_xattr_handlers[];
> void kernfs_evict_inode(struct inode *inode);
> int kernfs_iop_permission(const struct mnt_idmap *idmap,
> struct inode *inode, int mask);
> -int kernfs_iop_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +int kernfs_iop_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *iattr);
> int kernfs_iop_getattr(const struct mnt_idmap *idmap,
> const struct path *path, struct kstat *stat,
> diff --git a/fs/libfs.c b/fs/libfs.c
> index b70977b10a7c..8e2cc627bc7f 100644
> --- a/fs/libfs.c
> +++ b/fs/libfs.c
> @@ -913,7 +913,7 @@ EXPORT_SYMBOL(simple_rename);
> * on simple regular filesystems. Anything that needs to change on-disk
> * or wire state on size changes needs its own setattr method.
> */
> -int simple_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +int simple_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *iattr)
> {
> struct inode *inode = d_inode(dentry);
> @@ -1727,7 +1727,7 @@ static struct dentry *empty_dir_lookup(struct inode *dir, struct dentry *dentry,
> return ERR_PTR(-ENOENT);
> }
>
> -static int empty_dir_setattr(struct mnt_idmap *idmap,
> +static int empty_dir_setattr(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct iattr *attr)
> {
> return -EPERM;
> diff --git a/fs/minix/file.c b/fs/minix/file.c
> index 02aabbdb5dea..c0929fc38fbc 100644
> --- a/fs/minix/file.c
> +++ b/fs/minix/file.c
> @@ -23,7 +23,7 @@ const struct file_operations minix_file_operations = {
> .splice_read = filemap_splice_read,
> };
>
> -static int minix_setattr(struct mnt_idmap *idmap,
> +static int minix_setattr(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct iattr *attr)
> {
> struct inode *inode = d_inode(dentry);
> diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
> index b114488715fb..3c9b2ec4e244 100644
> --- a/fs/nfs/inode.c
> +++ b/fs/nfs/inode.c
> @@ -690,7 +690,7 @@ EXPORT_SYMBOL_GPL(nfs_update_delegated_mtime);
> #define NFS_VALID_ATTRS (ATTR_MODE|ATTR_UID|ATTR_GID|ATTR_SIZE|ATTR_ATIME|ATTR_ATIME_SET|ATTR_MTIME|ATTR_MTIME_SET|ATTR_FILE|ATTR_OPEN)
>
> int
> -nfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +nfs_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *attr)
> {
> struct inode *inode = d_inode(dentry);
> diff --git a/fs/nfs/namespace.c b/fs/nfs/namespace.c
> index 17f54d79efa7..c50d59c52c50 100644
> --- a/fs/nfs/namespace.c
> +++ b/fs/nfs/namespace.c
> @@ -235,7 +235,7 @@ nfs_namespace_getattr(const struct mnt_idmap *idmap,
> }
>
> static int
> -nfs_namespace_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +nfs_namespace_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *attr)
> {
> if (NFS_FH(d_inode(dentry))->size != 0)
> diff --git a/fs/nilfs2/inode.c b/fs/nilfs2/inode.c
> index 9342f651bf9b..8953719c4950 100644
> --- a/fs/nilfs2/inode.c
> +++ b/fs/nilfs2/inode.c
> @@ -904,7 +904,7 @@ void nilfs_evict_inode(struct inode *inode)
> */
> }
>
> -int nilfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +int nilfs_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *iattr)
> {
> struct nilfs_transaction_info ti;
> diff --git a/fs/nilfs2/nilfs.h b/fs/nilfs2/nilfs.h
> index 829df7be11fe..28d35b2fa7f7 100644
> --- a/fs/nilfs2/nilfs.h
> +++ b/fs/nilfs2/nilfs.h
> @@ -299,7 +299,7 @@ struct inode *nilfs_iget_for_shadow(struct inode *inode);
> extern void nilfs_update_inode(struct inode *, struct buffer_head *, int);
> extern void nilfs_truncate(struct inode *);
> extern void nilfs_evict_inode(struct inode *);
> -extern int nilfs_setattr(struct mnt_idmap *, struct dentry *,
> +extern int nilfs_setattr(const struct mnt_idmap *, struct dentry *,
> struct iattr *);
> extern void nilfs_write_failed(struct address_space *mapping, loff_t to);
> int nilfs_permission(const struct mnt_idmap *idmap, struct inode *inode,
> diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
> index 40e01704ea8f..da85cbae2420 100644
> --- a/fs/ntfs/file.c
> +++ b/fs/ntfs/file.c
> @@ -294,7 +294,7 @@ static int ntfs_setattr_size(struct inode *vi, struct iattr *attr)
> * NOTE: Changes in inode size are not supported yet for compressed or
> * encrypted files.
> */
> -int ntfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +int ntfs_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *attr)
> {
> struct inode *vi = d_inode(dentry);
> diff --git a/fs/ntfs/inode.h b/fs/ntfs/inode.h
> index 9cf923911825..45a396c97846 100644
> --- a/fs/ntfs/inode.h
> +++ b/fs/ntfs/inode.h
> @@ -330,7 +330,7 @@ int ntfs_read_inode_mount(struct inode *vi);
> int ntfs_show_options(struct seq_file *sf, struct dentry *root);
> int ntfs_truncate_vfs(struct inode *vi, loff_t new_size, loff_t i_size);
>
> -int ntfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +int ntfs_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *attr);
> int ntfs_getattr(const struct mnt_idmap *idmap, const struct path *path,
> struct kstat *stat, unsigned int request_mask,
> diff --git a/fs/ntfs3/file.c b/fs/ntfs3/file.c
> index f4d08346d25d..52e1cd969e06 100644
> --- a/fs/ntfs3/file.c
> +++ b/fs/ntfs3/file.c
> @@ -703,7 +703,7 @@ static long ntfs_fallocate(struct file *file, int mode, loff_t vbo, loff_t len)
> /*
> * ntfs_setattr - inode_operations::setattr
> */
> -int ntfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +int ntfs_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *attr)
> {
> struct inode *inode = d_inode(dentry);
> diff --git a/fs/ntfs3/ntfs_fs.h b/fs/ntfs3/ntfs_fs.h
> index 262b7ff2d6e1..ea24126c70db 100644
> --- a/fs/ntfs3/ntfs_fs.h
> +++ b/fs/ntfs3/ntfs_fs.h
> @@ -555,7 +555,7 @@ int ntfs_fileattr_set(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct file_kattr *fa);
> int ntfs_getattr(const struct mnt_idmap *idmap, const struct path *path,
> struct kstat *stat, u32 request_mask, u32 flags);
> -int ntfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +int ntfs_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *attr);
> int ntfs_file_open(struct inode *inode, struct file *file);
> int ntfs_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
> diff --git a/fs/ocfs2/dlmfs/dlmfs.c b/fs/ocfs2/dlmfs/dlmfs.c
> index fef79b21a4a5..d3bfcada3e3b 100644
> --- a/fs/ocfs2/dlmfs/dlmfs.c
> +++ b/fs/ocfs2/dlmfs/dlmfs.c
> @@ -188,7 +188,7 @@ static int dlmfs_file_release(struct inode *inode,
> * We do ->setattr() just to override size changes. Our size is the size
> * of the LVB and nothing else.
> */
> -static int dlmfs_file_setattr(struct mnt_idmap *idmap,
> +static int dlmfs_file_setattr(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct iattr *attr)
> {
> int error;
> diff --git a/fs/ocfs2/file.c b/fs/ocfs2/file.c
> index befc6ebb2a06..62f45a1b5ca1 100644
> --- a/fs/ocfs2/file.c
> +++ b/fs/ocfs2/file.c
> @@ -1117,7 +1117,7 @@ static int ocfs2_extend_file(struct inode *inode,
> return ret;
> }
>
> -int ocfs2_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +int ocfs2_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *attr)
> {
> int status = 0, size_change;
> diff --git a/fs/ocfs2/file.h b/fs/ocfs2/file.h
> index b51c8e77dad7..97492ee5789e 100644
> --- a/fs/ocfs2/file.h
> +++ b/fs/ocfs2/file.h
> @@ -50,7 +50,7 @@ int ocfs2_extend_no_holes(struct inode *inode, struct buffer_head *di_bh,
> u64 new_i_size, u64 zero_to);
> int ocfs2_zero_extend(struct inode *inode, struct buffer_head *di_bh,
> loff_t zero_to);
> -int ocfs2_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +int ocfs2_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *attr);
> int ocfs2_getattr(const struct mnt_idmap *idmap, const struct path *path,
> struct kstat *stat, u32 request_mask, unsigned int flags);
> diff --git a/fs/omfs/file.c b/fs/omfs/file.c
> index 28f3b113340e..79a413f1dc0d 100644
> --- a/fs/omfs/file.c
> +++ b/fs/omfs/file.c
> @@ -338,7 +338,7 @@ const struct file_operations omfs_file_operations = {
> .splice_read = filemap_splice_read,
> };
>
> -static int omfs_setattr(struct mnt_idmap *idmap,
> +static int omfs_setattr(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct iattr *attr)
> {
> struct inode *inode = d_inode(dentry);
> diff --git a/fs/orangefs/inode.c b/fs/orangefs/inode.c
> index 100669ee5862..75ac1e485e35 100644
> --- a/fs/orangefs/inode.c
> +++ b/fs/orangefs/inode.c
> @@ -828,7 +828,7 @@ int __orangefs_setattr_mode(struct dentry *dentry, struct iattr *iattr)
> /*
> * Change attributes of an object referenced by dentry.
> */
> -int orangefs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +int orangefs_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *iattr)
> {
> int ret;
> diff --git a/fs/orangefs/orangefs-kernel.h b/fs/orangefs/orangefs-kernel.h
> index 3bf01c0c763b..348fe340c5d5 100644
> --- a/fs/orangefs/orangefs-kernel.h
> +++ b/fs/orangefs/orangefs-kernel.h
> @@ -352,7 +352,7 @@ struct inode *orangefs_new_inode(struct super_block *sb,
>
> int __orangefs_setattr(struct inode *, struct iattr *);
> int __orangefs_setattr_mode(struct dentry *dentry, struct iattr *iattr);
> -int orangefs_setattr(struct mnt_idmap *, struct dentry *, struct iattr *);
> +int orangefs_setattr(const struct mnt_idmap *, struct dentry *, struct iattr *);
>
> int orangefs_getattr(const struct mnt_idmap *idmap, const struct path *path,
> struct kstat *stat, u32 request_mask, unsigned int flags);
> diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
> index b765780686e6..622e9bb833af 100644
> --- a/fs/overlayfs/inode.c
> +++ b/fs/overlayfs/inode.c
> @@ -18,7 +18,7 @@
> #include "overlayfs.h"
>
>
> -int ovl_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +int ovl_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *attr)
> {
> int err;
> diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h
> index 02a822dc8e5e..f0eac9ae1e38 100644
> --- a/fs/overlayfs/overlayfs.h
> +++ b/fs/overlayfs/overlayfs.h
> @@ -948,7 +948,7 @@ static inline bool ovl_force_readonly(struct ovl_fs *ofs)
> /* xattr.c */
>
> const struct xattr_handler * const *ovl_xattr_handlers(struct ovl_fs *ofs);
> -int ovl_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +int ovl_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *attr);
> int ovl_getattr(const struct mnt_idmap *idmap, const struct path *path,
> struct kstat *stat, u32 request_mask, unsigned int flags);
> diff --git a/fs/pidfs.c b/fs/pidfs.c
> index 38868ac99950..c37c17bcdbdc 100644
> --- a/fs/pidfs.c
> +++ b/fs/pidfs.c
> @@ -823,7 +823,7 @@ static struct vfsmount *pidfs_mnt __ro_after_init;
> * implemented. Let's reject it completely until we have a clean
> * permission concept for pidfds.
> */
> -static int pidfs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +static int pidfs_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *attr)
> {
> return anon_inode_setattr(idmap, dentry, attr);
> diff --git a/fs/proc/base.c b/fs/proc/base.c
> index 3278c37e5cde..5a18636ba81f 100644
> --- a/fs/proc/base.c
> +++ b/fs/proc/base.c
> @@ -702,7 +702,7 @@ static int proc_pid_syscall(struct seq_file *m, struct pid_namespace *ns,
> /* Here the fs part begins */
> /************************************************************************/
>
> -int proc_nochmod_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +int proc_nochmod_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *attr)
> {
> int error;
> diff --git a/fs/proc/generic.c b/fs/proc/generic.c
> index 4c4f1e63f68f..2b1971da4a85 100644
> --- a/fs/proc/generic.c
> +++ b/fs/proc/generic.c
> @@ -117,7 +117,7 @@ static bool pde_subdir_insert(struct proc_dir_entry *dir,
> return true;
> }
>
> -static int proc_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +static int proc_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *iattr)
> {
> struct inode *inode = d_inode(dentry);
> diff --git a/fs/proc/internal.h b/fs/proc/internal.h
> index 706fae7d30be..b9aaac41c283 100644
> --- a/fs/proc/internal.h
> +++ b/fs/proc/internal.h
> @@ -260,7 +260,7 @@ extern int proc_pid_statm(struct seq_file *, struct pid_namespace *,
> extern const struct dentry_operations pid_dentry_operations;
> extern int pid_getattr(const struct mnt_idmap *, const struct path *,
> struct kstat *, u32, unsigned int);
> -int proc_nochmod_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +int proc_nochmod_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *attr);
> extern void proc_pid_evict_inode(struct proc_inode *);
> extern struct inode *proc_pid_make_inode(struct super_block *, struct task_struct *, umode_t);
> diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
> index bd6730000b27..d1cfd2941359 100644
> --- a/fs/proc/proc_sysctl.c
> +++ b/fs/proc/proc_sysctl.c
> @@ -817,7 +817,7 @@ static int proc_sys_permission(const struct mnt_idmap *idmap,
> return error;
> }
>
> -static int proc_sys_setattr(struct mnt_idmap *idmap,
> +static int proc_sys_setattr(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct iattr *attr)
> {
> struct inode *inode = d_inode(dentry);
> diff --git a/fs/ramfs/file-nommu.c b/fs/ramfs/file-nommu.c
> index fb471bf88ab7..7ed6fba134c6 100644
> --- a/fs/ramfs/file-nommu.c
> +++ b/fs/ramfs/file-nommu.c
> @@ -22,7 +22,7 @@
> #include <linux/uaccess.h>
> #include "internal.h"
>
> -static int ramfs_nommu_setattr(struct mnt_idmap *, struct dentry *, struct iattr *);
> +static int ramfs_nommu_setattr(const struct mnt_idmap *, struct dentry *, struct iattr *);
> static unsigned long ramfs_nommu_get_unmapped_area(struct file *file,
> unsigned long addr,
> unsigned long len,
> @@ -161,7 +161,7 @@ static int ramfs_nommu_resize(struct inode *inode, loff_t newsize, loff_t size)
> * handle a change of attributes
> * - we're specifically interested in a change of size
> */
> -static int ramfs_nommu_setattr(struct mnt_idmap *idmap,
> +static int ramfs_nommu_setattr(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct iattr *ia)
> {
> struct inode *inode = d_inode(dentry);
> diff --git a/fs/smb/client/cifsfs.h b/fs/smb/client/cifsfs.h
> index c0adc5219213..51692e14c4dd 100644
> --- a/fs/smb/client/cifsfs.h
> +++ b/fs/smb/client/cifsfs.h
> @@ -80,7 +80,7 @@ int cifs_revalidate_mapping(struct inode *inode);
> int cifs_zap_mapping(struct inode *inode);
> int cifs_getattr(const struct mnt_idmap *idmap, const struct path *path,
> struct kstat *stat, u32 request_mask, unsigned int flags);
> -int cifs_setattr(struct mnt_idmap *idmap, struct dentry *direntry,
> +int cifs_setattr(const struct mnt_idmap *idmap, struct dentry *direntry,
> struct iattr *attrs);
> int cifs_fiemap(struct inode *inode, struct fiemap_extent_info *fei, u64 start,
> u64 len);
> diff --git a/fs/smb/client/inode.c b/fs/smb/client/inode.c
> index 132f9e072b77..248b7891e687 100644
> --- a/fs/smb/client/inode.c
> +++ b/fs/smb/client/inode.c
> @@ -3549,7 +3549,7 @@ cifs_setattr_nounix(struct dentry *direntry, struct iattr *attrs)
> }
>
> int
> -cifs_setattr(struct mnt_idmap *idmap, struct dentry *direntry,
> +cifs_setattr(const struct mnt_idmap *idmap, struct dentry *direntry,
> struct iattr *attrs)
> {
> struct cifs_sb_info *cifs_sb = CIFS_SB(direntry->d_sb);
> diff --git a/fs/tracefs/event_inode.c b/fs/tracefs/event_inode.c
> index 6e3513b13cfa..6f6daac88621 100644
> --- a/fs/tracefs/event_inode.c
> +++ b/fs/tracefs/event_inode.c
> @@ -182,7 +182,7 @@ static void update_attr(struct eventfs_attr *attr, struct iattr *iattr)
> }
> }
>
> -static int eventfs_set_attr(struct mnt_idmap *idmap, struct dentry *dentry,
> +static int eventfs_set_attr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *iattr)
> {
> const struct eventfs_entry *entry;
> diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c
> index 44448f1a2bb1..5020365ca704 100644
> --- a/fs/tracefs/inode.c
> +++ b/fs/tracefs/inode.c
> @@ -207,7 +207,7 @@ static int tracefs_getattr(const struct mnt_idmap *idmap,
> return 0;
> }
>
> -static int tracefs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +static int tracefs_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *attr)
> {
> unsigned int ia_valid = attr->ia_valid;
> diff --git a/fs/ubifs/file.c b/fs/ubifs/file.c
> index bfc1bd0203ad..244b835fc82a 100644
> --- a/fs/ubifs/file.c
> +++ b/fs/ubifs/file.c
> @@ -1251,7 +1251,7 @@ static int do_setattr(struct ubifs_info *c, struct inode *inode,
> return err;
> }
>
> -int ubifs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +int ubifs_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *attr)
> {
> int err;
> diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h
> index d455a67fe411..b85b45a0564b 100644
> --- a/fs/ubifs/ubifs.h
> +++ b/fs/ubifs/ubifs.h
> @@ -2020,7 +2020,7 @@ int ubifs_calc_dark(const struct ubifs_info *c, int spc);
>
> /* file.c */
> int ubifs_fsync(struct file *file, loff_t start, loff_t end, int datasync);
> -int ubifs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +int ubifs_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *attr);
> int ubifs_update_time(struct inode *inode, enum fs_update_time type,
> unsigned int flags);
> diff --git a/fs/udf/file.c b/fs/udf/file.c
> index 57d11606a2a7..02e9314818dc 100644
> --- a/fs/udf/file.c
> +++ b/fs/udf/file.c
> @@ -212,7 +212,7 @@ const struct file_operations udf_file_operations = {
> .setlease = generic_setlease,
> };
>
> -static int udf_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +static int udf_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *attr)
> {
> struct inode *inode = d_inode(dentry);
> diff --git a/fs/ufs/inode.c b/fs/ufs/inode.c
> index 440d014cc5ed..c9ff8673fa66 100644
> --- a/fs/ufs/inode.c
> +++ b/fs/ufs/inode.c
> @@ -1195,7 +1195,7 @@ static int ufs_truncate(struct inode *inode, loff_t size)
> return err;
> }
>
> -int ufs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +int ufs_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *attr)
> {
> struct inode *inode = d_inode(dentry);
> diff --git a/fs/ufs/ufs.h b/fs/ufs/ufs.h
> index 788e025056b2..541566f5b5fb 100644
> --- a/fs/ufs/ufs.h
> +++ b/fs/ufs/ufs.h
> @@ -120,7 +120,7 @@ extern struct inode *ufs_iget(struct super_block *, unsigned long);
> extern int ufs_write_inode (struct inode *, struct writeback_control *);
> extern int ufs_sync_inode (struct inode *);
> extern void ufs_evict_inode (struct inode *);
> -extern int ufs_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +extern int ufs_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *attr);
>
> /* namei.c */
> diff --git a/fs/vboxsf/utils.c b/fs/vboxsf/utils.c
> index 6a5a47a32075..8775fbee1ce6 100644
> --- a/fs/vboxsf/utils.c
> +++ b/fs/vboxsf/utils.c
> @@ -258,7 +258,7 @@ int vboxsf_getattr(const struct mnt_idmap *idmap, const struct path *path,
> return 0;
> }
>
> -int vboxsf_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +int vboxsf_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *iattr)
> {
> struct vboxsf_inode *sf_i = VBOXSF_I(d_inode(dentry));
> diff --git a/fs/vboxsf/vfsmod.h b/fs/vboxsf/vfsmod.h
> index 9c713b8e7aa2..59a4e44c4005 100644
> --- a/fs/vboxsf/vfsmod.h
> +++ b/fs/vboxsf/vfsmod.h
> @@ -101,7 +101,7 @@ int vboxsf_inode_revalidate(struct dentry *dentry);
> int vboxsf_getattr(const struct mnt_idmap *idmap, const struct path *path,
> struct kstat *kstat, u32 request_mask,
> unsigned int query_flags);
> -int vboxsf_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +int vboxsf_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *iattr);
> struct shfl_string *vboxsf_path_from_dentry(struct vboxsf_sbi *sbi,
> struct dentry *dentry);
> diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
> index 19fd83cea18b..535e8a9e071e 100644
> --- a/fs/xfs/xfs_iops.c
> +++ b/fs/xfs/xfs_iops.c
> @@ -1130,7 +1130,7 @@ xfs_vn_setattr_size(
>
> STATIC int
> xfs_vn_setattr(
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct dentry *dentry,
> struct iattr *iattr)
> {
> diff --git a/fs/zonefs/super.c b/fs/zonefs/super.c
> index ff43d6d1ea30..b97f1f2b8dda 100644
> --- a/fs/zonefs/super.c
> +++ b/fs/zonefs/super.c
> @@ -533,7 +533,7 @@ static int zonefs_show_options(struct seq_file *seq, struct dentry *root)
> return 0;
> }
>
> -static int zonefs_inode_setattr(struct mnt_idmap *idmap,
> +static int zonefs_inode_setattr(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct iattr *iattr)
> {
> struct inode *inode = d_inode(dentry);
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index c79fd3776bbf..55d8e7e473ff 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -2012,7 +2012,7 @@ struct inode_operations {
> umode_t,dev_t);
> int (*rename) (const struct mnt_idmap *, struct inode *, struct dentry *,
> struct inode *, struct dentry *, unsigned int);
> - int (*setattr) (struct mnt_idmap *, struct dentry *, struct iattr *);
> + int (*setattr) (const struct mnt_idmap *, struct dentry *, struct iattr *);
> int (*getattr) (const struct mnt_idmap *, const struct path *,
> struct kstat *, u32, unsigned int);
> ssize_t (*listxattr) (struct dentry *, char *, size_t);
> @@ -2707,7 +2707,7 @@ static inline int bmap(struct inode *inode, sector_t *block)
> }
> #endif
>
> -int notify_change(struct mnt_idmap *, struct dentry *,
> +int notify_change(const struct mnt_idmap *, struct dentry *,
> struct iattr *, struct delegated_inode *);
> int inode_permission(const struct mnt_idmap *, struct inode *, int);
> int generic_permission(const struct mnt_idmap *, struct inode *, int);
> @@ -3261,7 +3261,7 @@ extern int dcache_dir_open(struct inode *, struct file *);
> extern int dcache_dir_close(struct inode *, struct file *);
> extern loff_t dcache_dir_lseek(struct file *, loff_t, int);
> extern int dcache_readdir(struct file *, struct dir_context *);
> -extern int simple_setattr(struct mnt_idmap *, struct dentry *,
> +extern int simple_setattr(const struct mnt_idmap *, struct dentry *,
> struct iattr *);
> extern int simple_getattr(const struct mnt_idmap *, const struct path *,
> struct kstat *, u32, unsigned int);
> diff --git a/include/linux/lsm_hook_defs.h b/include/linux/lsm_hook_defs.h
> index ad05971e6137..194084f60746 100644
> --- a/include/linux/lsm_hook_defs.h
> +++ b/include/linux/lsm_hook_defs.h
> @@ -140,9 +140,9 @@ LSM_HOOK(int, 0, inode_readlink, struct dentry *dentry)
> LSM_HOOK(int, 0, inode_follow_link, struct dentry *dentry, struct inode *inode,
> bool rcu)
> LSM_HOOK(int, 0, inode_permission, struct inode *inode, int mask)
> -LSM_HOOK(int, 0, inode_setattr, struct mnt_idmap *idmap, struct dentry *dentry,
> +LSM_HOOK(int, 0, inode_setattr, const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *attr)
> -LSM_HOOK(void, LSM_RET_VOID, inode_post_setattr, struct mnt_idmap *idmap,
> +LSM_HOOK(void, LSM_RET_VOID, inode_post_setattr, const struct mnt_idmap *idmap,
> struct dentry *dentry, int ia_valid)
> LSM_HOOK(int, 0, inode_getattr, const struct path *path)
> LSM_HOOK(int, 0, inode_xattr_skipcap, const char *name)
> diff --git a/include/linux/nfs_fs.h b/include/linux/nfs_fs.h
> index 7b307dea7ce7..d2c716322c6f 100644
> --- a/include/linux/nfs_fs.h
> +++ b/include/linux/nfs_fs.h
> @@ -450,7 +450,7 @@ extern int nfs_clear_invalid_mapping(struct address_space *mapping);
> extern bool nfs_mapping_need_revalidate_inode(struct inode *inode);
> extern int nfs_revalidate_mapping(struct inode *inode, struct address_space *mapping);
> extern int nfs_revalidate_mapping_rcu(struct inode *inode);
> -extern int nfs_setattr(struct mnt_idmap *, struct dentry *, struct iattr *);
> +extern int nfs_setattr(const struct mnt_idmap *, struct dentry *, struct iattr *);
> extern void nfs_setattr_update_inode(struct inode *inode, struct iattr *attr, struct nfs_fattr *);
> extern void nfs_setsecurity(struct inode *inode, struct nfs_fattr *fattr);
> extern struct nfs_open_context *get_nfs_open_context(struct nfs_open_context *ctx);
> diff --git a/include/linux/security.h b/include/linux/security.h
> index d4100396da27..c7691feb8f8e 100644
> --- a/include/linux/security.h
> +++ b/include/linux/security.h
> @@ -422,9 +422,9 @@ int security_inode_readlink(struct dentry *dentry);
> int security_inode_follow_link(struct dentry *dentry, struct inode *inode,
> bool rcu);
> int security_inode_permission(struct inode *inode, int mask);
> -int security_inode_setattr(struct mnt_idmap *idmap,
> +int security_inode_setattr(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct iattr *attr);
> -void security_inode_post_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +void security_inode_post_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> int ia_valid);
> int security_inode_getattr(const struct path *path);
> int security_inode_setxattr(const struct mnt_idmap *idmap,
> @@ -979,7 +979,7 @@ static inline int security_inode_permission(struct inode *inode, int mask)
> return 0;
> }
>
> -static inline int security_inode_setattr(struct mnt_idmap *idmap,
> +static inline int security_inode_setattr(const struct mnt_idmap *idmap,
> struct dentry *dentry,
> struct iattr *attr)
> {
> @@ -987,7 +987,7 @@ static inline int security_inode_setattr(struct mnt_idmap *idmap,
> }
>
> static inline void
> -security_inode_post_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +security_inode_post_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> int ia_valid)
> { }
>
> diff --git a/mm/secretmem.c b/mm/secretmem.c
> index d29865075b6e..7bb6e426ac6e 100644
> --- a/mm/secretmem.c
> +++ b/mm/secretmem.c
> @@ -161,7 +161,7 @@ const struct address_space_operations secretmem_aops = {
> .migrate_folio = secretmem_migrate_folio,
> };
>
> -static int secretmem_setattr(struct mnt_idmap *idmap,
> +static int secretmem_setattr(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct iattr *iattr)
> {
> struct inode *inode = d_inode(dentry);
> diff --git a/mm/shmem.c b/mm/shmem.c
> index b27e5f23dc93..2c086c2b604e 100644
> --- a/mm/shmem.c
> +++ b/mm/shmem.c
> @@ -1326,7 +1326,7 @@ static int shmem_getattr(const struct mnt_idmap *idmap,
> return 0;
> }
>
> -static int shmem_setattr(struct mnt_idmap *idmap,
> +static int shmem_setattr(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct iattr *attr)
> {
> struct inode *inode = d_inode(dentry);
> diff --git a/net/socket.c b/net/socket.c
> index 052273ad081a..c0ab6a3ad8ed 100644
> --- a/net/socket.c
> +++ b/net/socket.c
> @@ -670,7 +670,7 @@ static ssize_t sockfs_listxattr(struct dentry *dentry, char *buffer,
> return used;
> }
>
> -static int sockfs_setattr(struct mnt_idmap *idmap,
> +static int sockfs_setattr(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct iattr *iattr)
> {
> int err = simple_setattr(&nop_mnt_idmap, dentry, iattr);
> diff --git a/security/integrity/evm/evm_main.c b/security/integrity/evm/evm_main.c
> index 10a0b39dd9b7..9bfea858df2d 100644
> --- a/security/integrity/evm/evm_main.c
> +++ b/security/integrity/evm/evm_main.c
> @@ -956,7 +956,7 @@ static int evm_attr_change(const struct mnt_idmap *idmap,
> * Permit update of file attributes when files have a valid EVM signature,
> * except in the case of them having an immutable portable signature.
> */
> -static int evm_inode_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +static int evm_inode_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *attr)
> {
> unsigned int ia_valid = attr->ia_valid;
> @@ -1008,7 +1008,7 @@ static int evm_inode_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> * This function is called from notify_change(), which expects the caller
> * to lock the inode's i_mutex.
> */
> -static void evm_inode_post_setattr(struct mnt_idmap *idmap,
> +static void evm_inode_post_setattr(const struct mnt_idmap *idmap,
> struct dentry *dentry, int ia_valid)
> {
> if (!evm_revalidate_status(NULL))
> diff --git a/security/integrity/ima/ima_appraise.c b/security/integrity/ima/ima_appraise.c
> index cfc20c63a814..659b71e77ac8 100644
> --- a/security/integrity/ima/ima_appraise.c
> +++ b/security/integrity/ima/ima_appraise.c
> @@ -634,7 +634,7 @@ void ima_update_xattr(struct ima_iint_cache *iint, struct file *file)
> * This function is called from notify_change(), which expects the caller
> * to lock the inode's i_mutex.
> */
> -static void ima_inode_post_setattr(struct mnt_idmap *idmap,
> +static void ima_inode_post_setattr(const struct mnt_idmap *idmap,
> struct dentry *dentry, int ia_valid)
> {
> struct inode *inode = d_backing_inode(dentry);
> diff --git a/security/security.c b/security/security.c
> index 9a3ae6746fb3..304048f26d03 100644
> --- a/security/security.c
> +++ b/security/security.c
> @@ -1855,7 +1855,7 @@ int security_inode_permission(struct inode *inode, int mask)
> *
> * Return: Returns 0 if permission is granted.
> */
> -int security_inode_setattr(struct mnt_idmap *idmap,
> +int security_inode_setattr(const struct mnt_idmap *idmap,
> struct dentry *dentry, struct iattr *attr)
> {
> if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
> @@ -1872,7 +1872,7 @@ EXPORT_SYMBOL_GPL(security_inode_setattr);
> *
> * Update inode security field after successful setting file attributes.
> */
> -void security_inode_post_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +void security_inode_post_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> int ia_valid)
> {
> if (unlikely(IS_PRIVATE(d_backing_inode(dentry))))
> diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
> index b7c6eba08fdc..1e59fb67dffb 100644
> --- a/security/selinux/hooks.c
> +++ b/security/selinux/hooks.c
> @@ -3297,7 +3297,7 @@ static int selinux_inode_permission(struct inode *inode, int requested)
> return rc;
> }
>
> -static int selinux_inode_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +static int selinux_inode_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *iattr)
> {
> const struct cred *cred = current_cred();
> diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
> index df4fc6ff26aa..bb78569b3d5b 100644
> --- a/security/smack/smack_lsm.c
> +++ b/security/smack/smack_lsm.c
> @@ -1270,7 +1270,7 @@ static int smack_inode_permission(struct inode *inode, int mask)
> *
> * Returns 0 if access is permitted, an error code otherwise
> */
> -static int smack_inode_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +static int smack_inode_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *iattr)
> {
> struct smk_audit_info ad;
> diff --git a/virt/kvm/guest_memfd.c b/virt/kvm/guest_memfd.c
> index 625e62e1a031..5c084d5393a6 100644
> --- a/virt/kvm/guest_memfd.c
> +++ b/virt/kvm/guest_memfd.c
> @@ -506,7 +506,7 @@ static const struct address_space_operations kvm_gmem_aops = {
> #endif
> };
>
> -static int kvm_gmem_setattr(struct mnt_idmap *idmap, struct dentry *dentry,
> +static int kvm_gmem_setattr(const struct mnt_idmap *idmap, struct dentry *dentry,
> struct iattr *attr)
> {
> return -EINVAL;
>
> --
> 2.53.0
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 62+ messages in thread* Re: [PATCH 24/27] fs: port ->setattr() to pass const mnt_idmap
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
2 siblings, 0 replies; 62+ messages in thread
From: Paul Moore @ 2026-09-02 19:34 UTC (permalink / raw)
To: Christian Brauner, linux-fsdevel
Cc: Alexander Viro, Jan Kara, Christoph Hellwig, Seth Forshee,
linux-security-module, Mimi Zohar, linux-integrity, Ilya Dryomov,
ceph-devel, Carlos Maiolino, linux-xfs, Miklos Szeredi,
Amir Goldstein, linux-unionfs, Namjae Jeon, linux-cifs,
linux-kernel, Christian Brauner (Amutable)
On Sep 1, 2026 Christian Brauner <brauner@kernel.org> wrote:
>
> Convert to const struct mnt_idmap.
>
> A mount's idmapping is immutable. The only thing that is allowed to be
> modified afterwards is the reference count and that is hidden behind
> mnt_idmap_get() and mnt_idmap_put(). Everything else only ever reads
> from the idmapping. This is the same model that struct cred uses and the
> idmapping is also rather sensitive.
>
> So make the idmap argument const wherever we can. The conversion is done
> from the bottom up so callers can continue to pass a non-const pointer
> to a const parameter until the conversion is finished.
>
> No functional changes.
>
> Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
> Reviewed-by: Jan Kara <jack@suse.cz>
> ---
> Documentation/filesystems/locking.rst | 2 +-
> Documentation/filesystems/vfs.rst | 2 +-
> arch/powerpc/platforms/cell/spufs/inode.c | 2 +-
> fs/9p/v9fs_vfs.h | 2 +-
> fs/9p/vfs_inode.c | 2 +-
> fs/9p/vfs_inode_dotl.c | 2 +-
> fs/adfs/adfs.h | 2 +-
> fs/adfs/inode.c | 2 +-
> fs/affs/affs.h | 2 +-
> fs/affs/inode.c | 2 +-
> fs/afs/inode.c | 2 +-
> fs/afs/internal.h | 2 +-
> fs/anon_inodes.c | 2 +-
> fs/attr.c | 2 +-
> fs/bad_inode.c | 2 +-
> fs/btrfs/inode.c | 2 +-
> fs/ceph/inode.c | 2 +-
> fs/ceph/super.h | 2 +-
> fs/coda/coda_linux.h | 2 +-
> fs/coda/inode.c | 2 +-
> fs/configfs/configfs_internal.h | 2 +-
> fs/configfs/inode.c | 2 +-
> fs/debugfs/inode.c | 2 +-
> fs/ecryptfs/inode.c | 2 +-
> fs/efivarfs/inode.c | 2 +-
> fs/exfat/exfat_fs.h | 2 +-
> fs/exfat/file.c | 2 +-
> fs/ext2/ext2.h | 2 +-
> fs/ext2/inode.c | 2 +-
> fs/ext4/ext4.h | 2 +-
> fs/ext4/inode.c | 2 +-
> fs/f2fs/f2fs.h | 2 +-
> fs/f2fs/file.c | 2 +-
> fs/fat/fat.h | 2 +-
> fs/fat/file.c | 2 +-
> fs/fuse/dir.c | 2 +-
> fs/gfs2/inode.c | 2 +-
> fs/hfs/hfs_fs.h | 2 +-
> fs/hfs/inode.c | 2 +-
> fs/hfsplus/inode.c | 2 +-
> fs/hostfs/hostfs_kern.c | 2 +-
> fs/hpfs/hpfs_fn.h | 2 +-
> fs/hpfs/inode.c | 2 +-
> fs/hugetlbfs/inode.c | 2 +-
> fs/inode.c | 2 +-
> fs/internal.h | 2 +-
> fs/jffs2/fs.c | 2 +-
> fs/jffs2/os-linux.h | 2 +-
> fs/jfs/file.c | 2 +-
> fs/jfs/jfs_inode.h | 2 +-
> fs/kernfs/inode.c | 2 +-
> fs/kernfs/kernfs-internal.h | 2 +-
> fs/libfs.c | 4 ++--
> fs/minix/file.c | 2 +-
> fs/nfs/inode.c | 2 +-
> fs/nfs/namespace.c | 2 +-
> fs/nilfs2/inode.c | 2 +-
> fs/nilfs2/nilfs.h | 2 +-
> fs/ntfs/file.c | 2 +-
> fs/ntfs/inode.h | 2 +-
> fs/ntfs3/file.c | 2 +-
> fs/ntfs3/ntfs_fs.h | 2 +-
> fs/ocfs2/dlmfs/dlmfs.c | 2 +-
> fs/ocfs2/file.c | 2 +-
> fs/ocfs2/file.h | 2 +-
> fs/omfs/file.c | 2 +-
> fs/orangefs/inode.c | 2 +-
> fs/orangefs/orangefs-kernel.h | 2 +-
> fs/overlayfs/inode.c | 2 +-
> fs/overlayfs/overlayfs.h | 2 +-
> fs/pidfs.c | 2 +-
> fs/proc/base.c | 2 +-
> fs/proc/generic.c | 2 +-
> fs/proc/internal.h | 2 +-
> fs/proc/proc_sysctl.c | 2 +-
> fs/ramfs/file-nommu.c | 4 ++--
> fs/smb/client/cifsfs.h | 2 +-
> fs/smb/client/inode.c | 2 +-
> fs/tracefs/event_inode.c | 2 +-
> fs/tracefs/inode.c | 2 +-
> fs/ubifs/file.c | 2 +-
> fs/ubifs/ubifs.h | 2 +-
> fs/udf/file.c | 2 +-
> fs/ufs/inode.c | 2 +-
> fs/ufs/ufs.h | 2 +-
> fs/vboxsf/utils.c | 2 +-
> fs/vboxsf/vfsmod.h | 2 +-
> fs/xfs/xfs_iops.c | 2 +-
> fs/zonefs/super.c | 2 +-
> include/linux/fs.h | 6 +++---
> include/linux/lsm_hook_defs.h | 4 ++--
> include/linux/nfs_fs.h | 2 +-
> include/linux/security.h | 8 ++++----
> mm/secretmem.c | 2 +-
> mm/shmem.c | 2 +-
> net/socket.c | 2 +-
> security/integrity/evm/evm_main.c | 4 ++--
> security/integrity/ima/ima_appraise.c | 2 +-
> security/security.c | 4 ++--
> security/selinux/hooks.c | 2 +-
> security/smack/smack_lsm.c | 2 +-
> virt/kvm/guest_memfd.c | 2 +-
> 102 files changed, 112 insertions(+), 112 deletions(-)
Acked-by: Paul Moore <paul@paul-moore.com> (LSM, SELinux)
--
paul-moore.com
^ permalink raw reply [flat|nested] 62+ messages in thread
* [PATCH 25/27] fs: port vfs_*() helpers to const mnt_idmap
2026-09-01 12:14 [PATCH 00/27] fs: port to const struct mnt_idmap Christian Brauner
` (23 preceding siblings ...)
2026-09-01 12:14 ` [PATCH 24/27] fs: port ->setattr() " Christian Brauner
@ 2026-09-01 12:14 ` 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-01 12:14 ` [PATCH 27/27] fs: make nop_mnt_idmap and invalid_mnt_idmap const Christian Brauner
26 siblings, 1 reply; 62+ messages in thread
From: Christian Brauner @ 2026-09-01 12:14 UTC (permalink / raw)
To: linux-fsdevel
Cc: Alexander Viro, Jan Kara, Christoph Hellwig, Seth Forshee,
Paul Moore, linux-security-module, Mimi Zohar, linux-integrity,
Ilya Dryomov, ceph-devel, Carlos Maiolino, linux-xfs,
Miklos Szeredi, Amir Goldstein, linux-unionfs, Namjae Jeon,
linux-cifs, linux-kernel, Christian Brauner (Amutable)
Convert to const struct mnt_idmap.
A mount's idmapping is immutable. The only thing that is allowed to be
modified afterwards is the reference count and that is hidden behind
mnt_idmap_get() and mnt_idmap_put(). Everything else only ever reads
from the idmapping. This is the same model that struct cred uses and the
idmapping is also rather sensitive.
So make the idmap argument const wherever we can. The conversion is done
from the bottom up so callers can continue to pass a non-const pointer
to a const parameter until the conversion is finished.
No functional changes.
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
---
fs/btrfs/ioctl.c | 4 ++--
fs/internal.h | 2 +-
fs/namei.c | 44 ++++++++++++++++++++++----------------------
fs/open.c | 2 +-
include/linux/fs.h | 30 +++++++++++++++---------------
include/linux/namei.h | 16 ++++++++--------
6 files changed, 49 insertions(+), 49 deletions(-)
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 94c98801800f..e20e66c0fead 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -864,7 +864,7 @@ static int create_snapshot(struct btrfs_root *root, struct inode *dir,
* inside this filesystem so it's quite a bit simpler.
*/
static noinline int btrfs_mksubvol(struct dentry *parent,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct qstr *qname, struct btrfs_root *snap_src,
bool readonly,
struct btrfs_qgroup_inherit *inherit)
@@ -911,7 +911,7 @@ static noinline int btrfs_mksubvol(struct dentry *parent,
}
static noinline int btrfs_mksnapshot(struct dentry *parent,
- struct mnt_idmap *idmap,
+ const struct mnt_idmap *idmap,
struct qstr *qname,
struct btrfs_root *root,
bool readonly,
diff --git a/fs/internal.h b/fs/internal.h
index 2b8cffc22fb3..973436f44770 100644
--- a/fs/internal.h
+++ b/fs/internal.h
@@ -63,7 +63,7 @@ int filename_mknodat(int dfd, struct filename *name, umode_t mode, unsigned int
int filename_symlinkat(struct filename *from, int newdfd, struct filename *to);
int filename_linkat(int olddfd, struct filename *old, int newdfd,
struct filename *new, int flags);
-int vfs_tmpfile(struct mnt_idmap *idmap,
+int vfs_tmpfile(const struct mnt_idmap *idmap,
const struct path *parentpath,
struct file *file, umode_t mode);
struct dentry *d_hash_and_lookup(struct dentry *, struct qstr *);
diff --git a/fs/namei.c b/fs/namei.c
index f5e00ae41ed4..14970fe08387 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -3111,7 +3111,7 @@ int lookup_noperm_common(struct qstr *qname, struct dentry *base)
return 0;
}
-static int lookup_one_common(struct mnt_idmap *idmap,
+static int lookup_one_common(const struct mnt_idmap *idmap,
struct qstr *qname, struct dentry *base)
{
int err;
@@ -3190,7 +3190,7 @@ EXPORT_SYMBOL(lookup_noperm);
*
* The caller must hold base->i_rwsem.
*/
-struct dentry *lookup_one(struct mnt_idmap *idmap, struct qstr *name,
+struct dentry *lookup_one(const struct mnt_idmap *idmap, struct qstr *name,
struct dentry *base)
{
struct dentry *dentry;
@@ -3223,7 +3223,7 @@ EXPORT_SYMBOL(lookup_one);
* - ERR_PTR(-ENOENT) if parent has been removed, or
* - ERR_PTR(-EACCES) if parent directory is not searchable.
*/
-struct dentry *lookup_one_unlocked(struct mnt_idmap *idmap, struct qstr *name,
+struct dentry *lookup_one_unlocked(const struct mnt_idmap *idmap, struct qstr *name,
struct dentry *base)
{
int err;
@@ -3263,7 +3263,7 @@ EXPORT_SYMBOL(lookup_one_unlocked);
* - same errors as lookup_one_unlocked() or
* - ERR_PTR(-EINTR) if a fatal signal is pending.
*/
-struct dentry *lookup_one_positive_killable(struct mnt_idmap *idmap,
+struct dentry *lookup_one_positive_killable(const struct mnt_idmap *idmap,
struct qstr *name,
struct dentry *base)
{
@@ -3306,7 +3306,7 @@ EXPORT_SYMBOL(lookup_one_positive_killable);
* - ERR_PTR(-ENOENT) if the name could not be found, or
* - same errors as lookup_one_unlocked().
*/
-struct dentry *lookup_one_positive_unlocked(struct mnt_idmap *idmap,
+struct dentry *lookup_one_positive_unlocked(const struct mnt_idmap *idmap,
struct qstr *name,
struct dentry *base)
{
@@ -3396,7 +3396,7 @@ EXPORT_SYMBOL(lookup_noperm_positive_unlocked);
*
* Returns: a negative or positive dentry, or an error.
*/
-struct dentry *start_creating(struct mnt_idmap *idmap, struct dentry *parent,
+struct dentry *start_creating(const struct mnt_idmap *idmap, struct dentry *parent,
struct qstr *name)
{
int err = lookup_one_common(idmap, name, parent);
@@ -3423,7 +3423,7 @@ EXPORT_SYMBOL(start_creating);
*
* Returns: a positive dentry, or an error.
*/
-struct dentry *start_removing(struct mnt_idmap *idmap, struct dentry *parent,
+struct dentry *start_removing(const struct mnt_idmap *idmap, struct dentry *parent,
struct qstr *name)
{
int err = lookup_one_common(idmap, name, parent);
@@ -3451,7 +3451,7 @@ EXPORT_SYMBOL(start_removing);
*
* Returns: a negative or positive dentry, or an error.
*/
-struct dentry *start_creating_killable(struct mnt_idmap *idmap,
+struct dentry *start_creating_killable(const struct mnt_idmap *idmap,
struct dentry *parent,
struct qstr *name)
{
@@ -3482,7 +3482,7 @@ EXPORT_SYMBOL(start_creating_killable);
*
* Returns: a positive dentry, or an error.
*/
-struct dentry *start_removing_killable(struct mnt_idmap *idmap,
+struct dentry *start_removing_killable(const struct mnt_idmap *idmap,
struct dentry *parent,
struct qstr *name)
{
@@ -3642,7 +3642,7 @@ int user_path_at(int dfd, const char __user *name, unsigned flags,
}
EXPORT_SYMBOL(user_path_at);
-int __check_sticky(struct mnt_idmap *idmap, struct inode *dir,
+int __check_sticky(const struct mnt_idmap *idmap, struct inode *dir,
struct inode *inode)
{
kuid_t fsuid = current_fsuid();
@@ -3675,7 +3675,7 @@ EXPORT_SYMBOL(__check_sticky);
* 11. We don't allow removal of NFS sillyrenamed files; it's handled by
* nfs_async_unlink().
*/
-int may_delete_dentry(struct mnt_idmap *idmap, struct inode *dir,
+int may_delete_dentry(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *victim, bool isdir)
{
struct inode *inode = d_backing_inode(victim);
@@ -3728,7 +3728,7 @@ EXPORT_SYMBOL(may_delete_dentry);
* 4. We should have write and exec permissions on dir
* 5. We can't do it if dir is immutable (done in permission())
*/
-int may_create_dentry(struct mnt_idmap *idmap,
+int may_create_dentry(const struct mnt_idmap *idmap,
struct inode *dir, struct dentry *child)
{
audit_inode_child(dir, child, AUDIT_TYPE_CHILD_CREATE);
@@ -4174,7 +4174,7 @@ static inline umode_t vfs_prepare_mode(const struct mnt_idmap *idmap,
* On non-idmapped mounts or if permission checking is to be performed on the
* raw inode simply pass @nop_mnt_idmap.
*/
-int vfs_create(struct mnt_idmap *idmap, struct dentry *dentry, umode_t mode,
+int vfs_create(const struct mnt_idmap *idmap, struct dentry *dentry, umode_t mode,
struct delegated_inode *di)
{
struct inode *dir = d_inode(dentry->d_parent);
@@ -4287,7 +4287,7 @@ static int may_open(const struct mnt_idmap *idmap, const struct path *path,
return 0;
}
-static int handle_truncate(struct mnt_idmap *idmap, struct file *filp)
+static int handle_truncate(const struct mnt_idmap *idmap, struct file *filp)
{
const struct path *path = &filp->f_path;
struct inode *inode = path->dentry->d_inode;
@@ -4863,7 +4863,7 @@ static int do_open(struct nameidata *nd,
* On non-idmapped mounts or if permission checking is to be performed on the
* raw inode simply pass @nop_mnt_idmap.
*/
-int vfs_tmpfile(struct mnt_idmap *idmap,
+int vfs_tmpfile(const struct mnt_idmap *idmap,
const struct path *parentpath,
struct file *file, umode_t mode)
{
@@ -4921,7 +4921,7 @@ int vfs_tmpfile(struct mnt_idmap *idmap,
* hence this is only for kernel internal use, and must not be installed into
* file tables or such.
*/
-struct file *kernel_tmpfile_open(struct mnt_idmap *idmap,
+struct file *kernel_tmpfile_open(const struct mnt_idmap *idmap,
const struct path *parentpath,
umode_t mode, int open_flag,
const struct cred *cred)
@@ -5236,7 +5236,7 @@ EXPORT_SYMBOL(dentry_create);
* On non-idmapped mounts or if permission checking is to be performed on the
* raw inode simply pass @nop_mnt_idmap.
*/
-int vfs_mknod(struct mnt_idmap *idmap, struct inode *dir,
+int vfs_mknod(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode, dev_t dev,
struct delegated_inode *delegated_inode)
{
@@ -5378,7 +5378,7 @@ SYSCALL_DEFINE3(mknod, const char __user *, filename, umode_t, mode, unsigned, d
*
* In case of an error the dentry is dput() and an ERR_PTR() is returned.
*/
-struct dentry *vfs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
+struct dentry *vfs_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, umode_t mode,
struct delegated_inode *delegated_inode)
{
@@ -5485,7 +5485,7 @@ SYSCALL_DEFINE2(mkdir, const char __user *, pathname, umode_t, mode)
* On non-idmapped mounts or if permission checking is to be performed on the
* raw inode simply pass @nop_mnt_idmap.
*/
-int vfs_rmdir(struct mnt_idmap *idmap, struct inode *dir,
+int vfs_rmdir(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, struct delegated_inode *delegated_inode)
{
int error = may_delete_dentry(idmap, dir, dentry, true);
@@ -5620,7 +5620,7 @@ SYSCALL_DEFINE1(rmdir, const char __user *, pathname)
* On non-idmapped mounts or if permission checking is to be performed on the
* raw inode simply pass @nop_mnt_idmap.
*/
-int vfs_unlink(struct mnt_idmap *idmap, struct inode *dir,
+int vfs_unlink(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, struct delegated_inode *delegated_inode)
{
struct inode *target = dentry->d_inode;
@@ -5770,7 +5770,7 @@ SYSCALL_DEFINE1(unlink, const char __user *, pathname)
* On non-idmapped mounts or if permission checking is to be performed on the
* raw inode simply pass @nop_mnt_idmap.
*/
-int vfs_symlink(struct mnt_idmap *idmap, struct inode *dir,
+int vfs_symlink(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *dentry, const char *oldname,
struct delegated_inode *delegated_inode)
{
@@ -5872,7 +5872,7 @@ SYSCALL_DEFINE2(symlink, const char __user *, oldname, const char __user *, newn
* On non-idmapped mounts or if permission checking is to be performed on the
* raw inode simply pass @nop_mnt_idmap.
*/
-int vfs_link(struct dentry *old_dentry, struct mnt_idmap *idmap,
+int vfs_link(struct dentry *old_dentry, const struct mnt_idmap *idmap,
struct inode *dir, struct dentry *new_dentry,
struct delegated_inode *delegated_inode)
{
diff --git a/fs/open.c b/fs/open.c
index 6b1c14e684a9..971e51008e67 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -36,7 +36,7 @@
#include "internal.h"
-int do_truncate(struct mnt_idmap *idmap, struct dentry *dentry,
+int do_truncate(const struct mnt_idmap *idmap, struct dentry *dentry,
loff_t length, unsigned int time_attrs, struct file *filp)
{
int ret;
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 55d8e7e473ff..935b0f92786f 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1761,19 +1761,19 @@ bool inode_owner_or_capable(const struct mnt_idmap *idmap,
/*
* VFS helper functions..
*/
-int vfs_create(struct mnt_idmap *, struct dentry *, umode_t,
+int vfs_create(const struct mnt_idmap *, struct dentry *, umode_t,
struct delegated_inode *);
-struct dentry *vfs_mkdir(struct mnt_idmap *, struct inode *,
+struct dentry *vfs_mkdir(const struct mnt_idmap *, struct inode *,
struct dentry *, umode_t, struct delegated_inode *);
-int vfs_mknod(struct mnt_idmap *, struct inode *, struct dentry *,
+int vfs_mknod(const struct mnt_idmap *, struct inode *, struct dentry *,
umode_t, dev_t, struct delegated_inode *);
-int vfs_symlink(struct mnt_idmap *, struct inode *,
+int vfs_symlink(const struct mnt_idmap *, struct inode *,
struct dentry *, const char *, struct delegated_inode *);
-int vfs_link(struct dentry *, struct mnt_idmap *, struct inode *,
+int vfs_link(struct dentry *, const struct mnt_idmap *, struct inode *,
struct dentry *, struct delegated_inode *);
-int vfs_rmdir(struct mnt_idmap *, struct inode *, struct dentry *,
+int vfs_rmdir(const struct mnt_idmap *, struct inode *, struct dentry *,
struct delegated_inode *);
-int vfs_unlink(struct mnt_idmap *, struct inode *, struct dentry *,
+int vfs_unlink(const struct mnt_idmap *, struct inode *, struct dentry *,
struct delegated_inode *);
/**
@@ -1787,7 +1787,7 @@ int vfs_unlink(struct mnt_idmap *, struct inode *, struct dentry *,
* @flags: rename flags
*/
struct renamedata {
- struct mnt_idmap *mnt_idmap;
+ const struct mnt_idmap *mnt_idmap;
struct dentry *old_parent;
struct dentry *old_dentry;
struct dentry *new_parent;
@@ -1798,14 +1798,14 @@ struct renamedata {
int vfs_rename(struct renamedata *);
-static inline int vfs_whiteout(struct mnt_idmap *idmap,
+static inline int vfs_whiteout(const struct mnt_idmap *idmap,
struct inode *dir, struct dentry *dentry)
{
return vfs_mknod(idmap, dir, dentry, S_IFCHR | WHITEOUT_MODE,
WHITEOUT_DEV, NULL);
}
-struct file *kernel_tmpfile_open(struct mnt_idmap *idmap,
+struct file *kernel_tmpfile_open(const struct mnt_idmap *idmap,
const struct path *parentpath,
umode_t mode, int open_flag,
const struct cred *cred);
@@ -2483,7 +2483,7 @@ static inline bool is_idmapped_mnt(const struct vfsmount *mnt)
}
int vfs_truncate(const struct path *, loff_t);
-int do_truncate(struct mnt_idmap *, struct dentry *, loff_t start,
+int do_truncate(const struct mnt_idmap *, struct dentry *, loff_t start,
unsigned int time_attrs, struct file *filp);
extern int vfs_fallocate(struct file *file, int mode, loff_t offset,
loff_t len);
@@ -2721,12 +2721,12 @@ static inline int path_permission(const struct path *path, int mask)
return inode_permission(mnt_idmap(path->mnt),
d_inode(path->dentry), mask);
}
-int __check_sticky(struct mnt_idmap *idmap, struct inode *dir,
+int __check_sticky(const struct mnt_idmap *idmap, struct inode *dir,
struct inode *inode);
-int may_delete_dentry(struct mnt_idmap *idmap, struct inode *dir,
+int may_delete_dentry(const struct mnt_idmap *idmap, struct inode *dir,
struct dentry *victim, bool isdir);
-int may_create_dentry(struct mnt_idmap *idmap,
+int may_create_dentry(const struct mnt_idmap *idmap,
struct inode *dir, struct dentry *child);
static inline bool execute_ok(struct inode *inode)
@@ -3578,7 +3578,7 @@ static inline bool is_sxid(umode_t mode)
return mode & (S_ISUID | S_ISGID);
}
-static inline int check_sticky(struct mnt_idmap *idmap,
+static inline int check_sticky(const struct mnt_idmap *idmap,
struct inode *dir, struct inode *inode)
{
if (!(dir->i_mode & S_ISVTX))
diff --git a/include/linux/namei.h b/include/linux/namei.h
index 86d657b24fc6..da5b4ccca1b5 100644
--- a/include/linux/namei.h
+++ b/include/linux/namei.h
@@ -70,24 +70,24 @@ extern struct dentry *try_lookup_noperm(struct qstr *, struct dentry *);
extern struct dentry *lookup_noperm(struct qstr *, struct dentry *);
extern struct dentry *lookup_noperm_unlocked(struct qstr *, struct dentry *);
extern struct dentry *lookup_noperm_positive_unlocked(struct qstr *, struct dentry *);
-struct dentry *lookup_one(struct mnt_idmap *, struct qstr *, struct dentry *);
-struct dentry *lookup_one_unlocked(struct mnt_idmap *idmap,
+struct dentry *lookup_one(const struct mnt_idmap *, struct qstr *, struct dentry *);
+struct dentry *lookup_one_unlocked(const struct mnt_idmap *idmap,
struct qstr *name, struct dentry *base);
-struct dentry *lookup_one_positive_unlocked(struct mnt_idmap *idmap,
+struct dentry *lookup_one_positive_unlocked(const struct mnt_idmap *idmap,
struct qstr *name,
struct dentry *base);
-struct dentry *lookup_one_positive_killable(struct mnt_idmap *idmap,
+struct dentry *lookup_one_positive_killable(const struct mnt_idmap *idmap,
struct qstr *name,
struct dentry *base);
-struct dentry *start_creating(struct mnt_idmap *idmap, struct dentry *parent,
+struct dentry *start_creating(const struct mnt_idmap *idmap, struct dentry *parent,
struct qstr *name);
-struct dentry *start_removing(struct mnt_idmap *idmap, struct dentry *parent,
+struct dentry *start_removing(const struct mnt_idmap *idmap, struct dentry *parent,
struct qstr *name);
-struct dentry *start_creating_killable(struct mnt_idmap *idmap,
+struct dentry *start_creating_killable(const struct mnt_idmap *idmap,
struct dentry *parent,
struct qstr *name);
-struct dentry *start_removing_killable(struct mnt_idmap *idmap,
+struct dentry *start_removing_killable(const struct mnt_idmap *idmap,
struct dentry *parent,
struct qstr *name);
struct dentry *start_creating_noperm(struct dentry *parent, struct qstr *name);
--
2.53.0
^ permalink raw reply related [flat|nested] 62+ messages in thread* Re: [PATCH 25/27] fs: port vfs_*() helpers to const mnt_idmap
2026-09-01 12:14 ` [PATCH 25/27] fs: port vfs_*() helpers to " Christian Brauner
@ 2026-09-02 16:02 ` Jan Kara
0 siblings, 0 replies; 62+ messages in thread
From: Jan Kara @ 2026-09-02 16:02 UTC (permalink / raw)
To: Christian Brauner
Cc: linux-fsdevel, Alexander Viro, Jan Kara, Christoph Hellwig,
Seth Forshee, Paul Moore, linux-security-module, Mimi Zohar,
linux-integrity, Ilya Dryomov, ceph-devel, Carlos Maiolino,
linux-xfs, Miklos Szeredi, Amir Goldstein, linux-unionfs,
Namjae Jeon, linux-cifs, linux-kernel
On Tue 01-09-26 14:14:50, Christian Brauner wrote:
> Convert to const struct mnt_idmap.
>
> A mount's idmapping is immutable. The only thing that is allowed to be
> modified afterwards is the reference count and that is hidden behind
> mnt_idmap_get() and mnt_idmap_put(). Everything else only ever reads
> from the idmapping. This is the same model that struct cred uses and the
> idmapping is also rather sensitive.
>
> So make the idmap argument const wherever we can. The conversion is done
> from the bottom up so callers can continue to pass a non-const pointer
> to a const parameter until the conversion is finished.
>
> No functional changes.
>
> Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> fs/btrfs/ioctl.c | 4 ++--
> fs/internal.h | 2 +-
> fs/namei.c | 44 ++++++++++++++++++++++----------------------
> fs/open.c | 2 +-
> include/linux/fs.h | 30 +++++++++++++++---------------
> include/linux/namei.h | 16 ++++++++--------
> 6 files changed, 49 insertions(+), 49 deletions(-)
>
> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
> index 94c98801800f..e20e66c0fead 100644
> --- a/fs/btrfs/ioctl.c
> +++ b/fs/btrfs/ioctl.c
> @@ -864,7 +864,7 @@ static int create_snapshot(struct btrfs_root *root, struct inode *dir,
> * inside this filesystem so it's quite a bit simpler.
> */
> static noinline int btrfs_mksubvol(struct dentry *parent,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct qstr *qname, struct btrfs_root *snap_src,
> bool readonly,
> struct btrfs_qgroup_inherit *inherit)
> @@ -911,7 +911,7 @@ static noinline int btrfs_mksubvol(struct dentry *parent,
> }
>
> static noinline int btrfs_mksnapshot(struct dentry *parent,
> - struct mnt_idmap *idmap,
> + const struct mnt_idmap *idmap,
> struct qstr *qname,
> struct btrfs_root *root,
> bool readonly,
> diff --git a/fs/internal.h b/fs/internal.h
> index 2b8cffc22fb3..973436f44770 100644
> --- a/fs/internal.h
> +++ b/fs/internal.h
> @@ -63,7 +63,7 @@ int filename_mknodat(int dfd, struct filename *name, umode_t mode, unsigned int
> int filename_symlinkat(struct filename *from, int newdfd, struct filename *to);
> int filename_linkat(int olddfd, struct filename *old, int newdfd,
> struct filename *new, int flags);
> -int vfs_tmpfile(struct mnt_idmap *idmap,
> +int vfs_tmpfile(const struct mnt_idmap *idmap,
> const struct path *parentpath,
> struct file *file, umode_t mode);
> struct dentry *d_hash_and_lookup(struct dentry *, struct qstr *);
> diff --git a/fs/namei.c b/fs/namei.c
> index f5e00ae41ed4..14970fe08387 100644
> --- a/fs/namei.c
> +++ b/fs/namei.c
> @@ -3111,7 +3111,7 @@ int lookup_noperm_common(struct qstr *qname, struct dentry *base)
> return 0;
> }
>
> -static int lookup_one_common(struct mnt_idmap *idmap,
> +static int lookup_one_common(const struct mnt_idmap *idmap,
> struct qstr *qname, struct dentry *base)
> {
> int err;
> @@ -3190,7 +3190,7 @@ EXPORT_SYMBOL(lookup_noperm);
> *
> * The caller must hold base->i_rwsem.
> */
> -struct dentry *lookup_one(struct mnt_idmap *idmap, struct qstr *name,
> +struct dentry *lookup_one(const struct mnt_idmap *idmap, struct qstr *name,
> struct dentry *base)
> {
> struct dentry *dentry;
> @@ -3223,7 +3223,7 @@ EXPORT_SYMBOL(lookup_one);
> * - ERR_PTR(-ENOENT) if parent has been removed, or
> * - ERR_PTR(-EACCES) if parent directory is not searchable.
> */
> -struct dentry *lookup_one_unlocked(struct mnt_idmap *idmap, struct qstr *name,
> +struct dentry *lookup_one_unlocked(const struct mnt_idmap *idmap, struct qstr *name,
> struct dentry *base)
> {
> int err;
> @@ -3263,7 +3263,7 @@ EXPORT_SYMBOL(lookup_one_unlocked);
> * - same errors as lookup_one_unlocked() or
> * - ERR_PTR(-EINTR) if a fatal signal is pending.
> */
> -struct dentry *lookup_one_positive_killable(struct mnt_idmap *idmap,
> +struct dentry *lookup_one_positive_killable(const struct mnt_idmap *idmap,
> struct qstr *name,
> struct dentry *base)
> {
> @@ -3306,7 +3306,7 @@ EXPORT_SYMBOL(lookup_one_positive_killable);
> * - ERR_PTR(-ENOENT) if the name could not be found, or
> * - same errors as lookup_one_unlocked().
> */
> -struct dentry *lookup_one_positive_unlocked(struct mnt_idmap *idmap,
> +struct dentry *lookup_one_positive_unlocked(const struct mnt_idmap *idmap,
> struct qstr *name,
> struct dentry *base)
> {
> @@ -3396,7 +3396,7 @@ EXPORT_SYMBOL(lookup_noperm_positive_unlocked);
> *
> * Returns: a negative or positive dentry, or an error.
> */
> -struct dentry *start_creating(struct mnt_idmap *idmap, struct dentry *parent,
> +struct dentry *start_creating(const struct mnt_idmap *idmap, struct dentry *parent,
> struct qstr *name)
> {
> int err = lookup_one_common(idmap, name, parent);
> @@ -3423,7 +3423,7 @@ EXPORT_SYMBOL(start_creating);
> *
> * Returns: a positive dentry, or an error.
> */
> -struct dentry *start_removing(struct mnt_idmap *idmap, struct dentry *parent,
> +struct dentry *start_removing(const struct mnt_idmap *idmap, struct dentry *parent,
> struct qstr *name)
> {
> int err = lookup_one_common(idmap, name, parent);
> @@ -3451,7 +3451,7 @@ EXPORT_SYMBOL(start_removing);
> *
> * Returns: a negative or positive dentry, or an error.
> */
> -struct dentry *start_creating_killable(struct mnt_idmap *idmap,
> +struct dentry *start_creating_killable(const struct mnt_idmap *idmap,
> struct dentry *parent,
> struct qstr *name)
> {
> @@ -3482,7 +3482,7 @@ EXPORT_SYMBOL(start_creating_killable);
> *
> * Returns: a positive dentry, or an error.
> */
> -struct dentry *start_removing_killable(struct mnt_idmap *idmap,
> +struct dentry *start_removing_killable(const struct mnt_idmap *idmap,
> struct dentry *parent,
> struct qstr *name)
> {
> @@ -3642,7 +3642,7 @@ int user_path_at(int dfd, const char __user *name, unsigned flags,
> }
> EXPORT_SYMBOL(user_path_at);
>
> -int __check_sticky(struct mnt_idmap *idmap, struct inode *dir,
> +int __check_sticky(const struct mnt_idmap *idmap, struct inode *dir,
> struct inode *inode)
> {
> kuid_t fsuid = current_fsuid();
> @@ -3675,7 +3675,7 @@ EXPORT_SYMBOL(__check_sticky);
> * 11. We don't allow removal of NFS sillyrenamed files; it's handled by
> * nfs_async_unlink().
> */
> -int may_delete_dentry(struct mnt_idmap *idmap, struct inode *dir,
> +int may_delete_dentry(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *victim, bool isdir)
> {
> struct inode *inode = d_backing_inode(victim);
> @@ -3728,7 +3728,7 @@ EXPORT_SYMBOL(may_delete_dentry);
> * 4. We should have write and exec permissions on dir
> * 5. We can't do it if dir is immutable (done in permission())
> */
> -int may_create_dentry(struct mnt_idmap *idmap,
> +int may_create_dentry(const struct mnt_idmap *idmap,
> struct inode *dir, struct dentry *child)
> {
> audit_inode_child(dir, child, AUDIT_TYPE_CHILD_CREATE);
> @@ -4174,7 +4174,7 @@ static inline umode_t vfs_prepare_mode(const struct mnt_idmap *idmap,
> * On non-idmapped mounts or if permission checking is to be performed on the
> * raw inode simply pass @nop_mnt_idmap.
> */
> -int vfs_create(struct mnt_idmap *idmap, struct dentry *dentry, umode_t mode,
> +int vfs_create(const struct mnt_idmap *idmap, struct dentry *dentry, umode_t mode,
> struct delegated_inode *di)
> {
> struct inode *dir = d_inode(dentry->d_parent);
> @@ -4287,7 +4287,7 @@ static int may_open(const struct mnt_idmap *idmap, const struct path *path,
> return 0;
> }
>
> -static int handle_truncate(struct mnt_idmap *idmap, struct file *filp)
> +static int handle_truncate(const struct mnt_idmap *idmap, struct file *filp)
> {
> const struct path *path = &filp->f_path;
> struct inode *inode = path->dentry->d_inode;
> @@ -4863,7 +4863,7 @@ static int do_open(struct nameidata *nd,
> * On non-idmapped mounts or if permission checking is to be performed on the
> * raw inode simply pass @nop_mnt_idmap.
> */
> -int vfs_tmpfile(struct mnt_idmap *idmap,
> +int vfs_tmpfile(const struct mnt_idmap *idmap,
> const struct path *parentpath,
> struct file *file, umode_t mode)
> {
> @@ -4921,7 +4921,7 @@ int vfs_tmpfile(struct mnt_idmap *idmap,
> * hence this is only for kernel internal use, and must not be installed into
> * file tables or such.
> */
> -struct file *kernel_tmpfile_open(struct mnt_idmap *idmap,
> +struct file *kernel_tmpfile_open(const struct mnt_idmap *idmap,
> const struct path *parentpath,
> umode_t mode, int open_flag,
> const struct cred *cred)
> @@ -5236,7 +5236,7 @@ EXPORT_SYMBOL(dentry_create);
> * On non-idmapped mounts or if permission checking is to be performed on the
> * raw inode simply pass @nop_mnt_idmap.
> */
> -int vfs_mknod(struct mnt_idmap *idmap, struct inode *dir,
> +int vfs_mknod(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode, dev_t dev,
> struct delegated_inode *delegated_inode)
> {
> @@ -5378,7 +5378,7 @@ SYSCALL_DEFINE3(mknod, const char __user *, filename, umode_t, mode, unsigned, d
> *
> * In case of an error the dentry is dput() and an ERR_PTR() is returned.
> */
> -struct dentry *vfs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
> +struct dentry *vfs_mkdir(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, umode_t mode,
> struct delegated_inode *delegated_inode)
> {
> @@ -5485,7 +5485,7 @@ SYSCALL_DEFINE2(mkdir, const char __user *, pathname, umode_t, mode)
> * On non-idmapped mounts or if permission checking is to be performed on the
> * raw inode simply pass @nop_mnt_idmap.
> */
> -int vfs_rmdir(struct mnt_idmap *idmap, struct inode *dir,
> +int vfs_rmdir(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, struct delegated_inode *delegated_inode)
> {
> int error = may_delete_dentry(idmap, dir, dentry, true);
> @@ -5620,7 +5620,7 @@ SYSCALL_DEFINE1(rmdir, const char __user *, pathname)
> * On non-idmapped mounts or if permission checking is to be performed on the
> * raw inode simply pass @nop_mnt_idmap.
> */
> -int vfs_unlink(struct mnt_idmap *idmap, struct inode *dir,
> +int vfs_unlink(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, struct delegated_inode *delegated_inode)
> {
> struct inode *target = dentry->d_inode;
> @@ -5770,7 +5770,7 @@ SYSCALL_DEFINE1(unlink, const char __user *, pathname)
> * On non-idmapped mounts or if permission checking is to be performed on the
> * raw inode simply pass @nop_mnt_idmap.
> */
> -int vfs_symlink(struct mnt_idmap *idmap, struct inode *dir,
> +int vfs_symlink(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *dentry, const char *oldname,
> struct delegated_inode *delegated_inode)
> {
> @@ -5872,7 +5872,7 @@ SYSCALL_DEFINE2(symlink, const char __user *, oldname, const char __user *, newn
> * On non-idmapped mounts or if permission checking is to be performed on the
> * raw inode simply pass @nop_mnt_idmap.
> */
> -int vfs_link(struct dentry *old_dentry, struct mnt_idmap *idmap,
> +int vfs_link(struct dentry *old_dentry, const struct mnt_idmap *idmap,
> struct inode *dir, struct dentry *new_dentry,
> struct delegated_inode *delegated_inode)
> {
> diff --git a/fs/open.c b/fs/open.c
> index 6b1c14e684a9..971e51008e67 100644
> --- a/fs/open.c
> +++ b/fs/open.c
> @@ -36,7 +36,7 @@
>
> #include "internal.h"
>
> -int do_truncate(struct mnt_idmap *idmap, struct dentry *dentry,
> +int do_truncate(const struct mnt_idmap *idmap, struct dentry *dentry,
> loff_t length, unsigned int time_attrs, struct file *filp)
> {
> int ret;
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 55d8e7e473ff..935b0f92786f 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -1761,19 +1761,19 @@ bool inode_owner_or_capable(const struct mnt_idmap *idmap,
> /*
> * VFS helper functions..
> */
> -int vfs_create(struct mnt_idmap *, struct dentry *, umode_t,
> +int vfs_create(const struct mnt_idmap *, struct dentry *, umode_t,
> struct delegated_inode *);
> -struct dentry *vfs_mkdir(struct mnt_idmap *, struct inode *,
> +struct dentry *vfs_mkdir(const struct mnt_idmap *, struct inode *,
> struct dentry *, umode_t, struct delegated_inode *);
> -int vfs_mknod(struct mnt_idmap *, struct inode *, struct dentry *,
> +int vfs_mknod(const struct mnt_idmap *, struct inode *, struct dentry *,
> umode_t, dev_t, struct delegated_inode *);
> -int vfs_symlink(struct mnt_idmap *, struct inode *,
> +int vfs_symlink(const struct mnt_idmap *, struct inode *,
> struct dentry *, const char *, struct delegated_inode *);
> -int vfs_link(struct dentry *, struct mnt_idmap *, struct inode *,
> +int vfs_link(struct dentry *, const struct mnt_idmap *, struct inode *,
> struct dentry *, struct delegated_inode *);
> -int vfs_rmdir(struct mnt_idmap *, struct inode *, struct dentry *,
> +int vfs_rmdir(const struct mnt_idmap *, struct inode *, struct dentry *,
> struct delegated_inode *);
> -int vfs_unlink(struct mnt_idmap *, struct inode *, struct dentry *,
> +int vfs_unlink(const struct mnt_idmap *, struct inode *, struct dentry *,
> struct delegated_inode *);
>
> /**
> @@ -1787,7 +1787,7 @@ int vfs_unlink(struct mnt_idmap *, struct inode *, struct dentry *,
> * @flags: rename flags
> */
> struct renamedata {
> - struct mnt_idmap *mnt_idmap;
> + const struct mnt_idmap *mnt_idmap;
> struct dentry *old_parent;
> struct dentry *old_dentry;
> struct dentry *new_parent;
> @@ -1798,14 +1798,14 @@ struct renamedata {
>
> int vfs_rename(struct renamedata *);
>
> -static inline int vfs_whiteout(struct mnt_idmap *idmap,
> +static inline int vfs_whiteout(const struct mnt_idmap *idmap,
> struct inode *dir, struct dentry *dentry)
> {
> return vfs_mknod(idmap, dir, dentry, S_IFCHR | WHITEOUT_MODE,
> WHITEOUT_DEV, NULL);
> }
>
> -struct file *kernel_tmpfile_open(struct mnt_idmap *idmap,
> +struct file *kernel_tmpfile_open(const struct mnt_idmap *idmap,
> const struct path *parentpath,
> umode_t mode, int open_flag,
> const struct cred *cred);
> @@ -2483,7 +2483,7 @@ static inline bool is_idmapped_mnt(const struct vfsmount *mnt)
> }
>
> int vfs_truncate(const struct path *, loff_t);
> -int do_truncate(struct mnt_idmap *, struct dentry *, loff_t start,
> +int do_truncate(const struct mnt_idmap *, struct dentry *, loff_t start,
> unsigned int time_attrs, struct file *filp);
> extern int vfs_fallocate(struct file *file, int mode, loff_t offset,
> loff_t len);
> @@ -2721,12 +2721,12 @@ static inline int path_permission(const struct path *path, int mask)
> return inode_permission(mnt_idmap(path->mnt),
> d_inode(path->dentry), mask);
> }
> -int __check_sticky(struct mnt_idmap *idmap, struct inode *dir,
> +int __check_sticky(const struct mnt_idmap *idmap, struct inode *dir,
> struct inode *inode);
>
> -int may_delete_dentry(struct mnt_idmap *idmap, struct inode *dir,
> +int may_delete_dentry(const struct mnt_idmap *idmap, struct inode *dir,
> struct dentry *victim, bool isdir);
> -int may_create_dentry(struct mnt_idmap *idmap,
> +int may_create_dentry(const struct mnt_idmap *idmap,
> struct inode *dir, struct dentry *child);
>
> static inline bool execute_ok(struct inode *inode)
> @@ -3578,7 +3578,7 @@ static inline bool is_sxid(umode_t mode)
> return mode & (S_ISUID | S_ISGID);
> }
>
> -static inline int check_sticky(struct mnt_idmap *idmap,
> +static inline int check_sticky(const struct mnt_idmap *idmap,
> struct inode *dir, struct inode *inode)
> {
> if (!(dir->i_mode & S_ISVTX))
> diff --git a/include/linux/namei.h b/include/linux/namei.h
> index 86d657b24fc6..da5b4ccca1b5 100644
> --- a/include/linux/namei.h
> +++ b/include/linux/namei.h
> @@ -70,24 +70,24 @@ extern struct dentry *try_lookup_noperm(struct qstr *, struct dentry *);
> extern struct dentry *lookup_noperm(struct qstr *, struct dentry *);
> extern struct dentry *lookup_noperm_unlocked(struct qstr *, struct dentry *);
> extern struct dentry *lookup_noperm_positive_unlocked(struct qstr *, struct dentry *);
> -struct dentry *lookup_one(struct mnt_idmap *, struct qstr *, struct dentry *);
> -struct dentry *lookup_one_unlocked(struct mnt_idmap *idmap,
> +struct dentry *lookup_one(const struct mnt_idmap *, struct qstr *, struct dentry *);
> +struct dentry *lookup_one_unlocked(const struct mnt_idmap *idmap,
> struct qstr *name, struct dentry *base);
> -struct dentry *lookup_one_positive_unlocked(struct mnt_idmap *idmap,
> +struct dentry *lookup_one_positive_unlocked(const struct mnt_idmap *idmap,
> struct qstr *name,
> struct dentry *base);
> -struct dentry *lookup_one_positive_killable(struct mnt_idmap *idmap,
> +struct dentry *lookup_one_positive_killable(const struct mnt_idmap *idmap,
> struct qstr *name,
> struct dentry *base);
>
> -struct dentry *start_creating(struct mnt_idmap *idmap, struct dentry *parent,
> +struct dentry *start_creating(const struct mnt_idmap *idmap, struct dentry *parent,
> struct qstr *name);
> -struct dentry *start_removing(struct mnt_idmap *idmap, struct dentry *parent,
> +struct dentry *start_removing(const struct mnt_idmap *idmap, struct dentry *parent,
> struct qstr *name);
> -struct dentry *start_creating_killable(struct mnt_idmap *idmap,
> +struct dentry *start_creating_killable(const struct mnt_idmap *idmap,
> struct dentry *parent,
> struct qstr *name);
> -struct dentry *start_removing_killable(struct mnt_idmap *idmap,
> +struct dentry *start_removing_killable(const struct mnt_idmap *idmap,
> struct dentry *parent,
> struct qstr *name);
> struct dentry *start_creating_noperm(struct dentry *parent, struct qstr *name);
>
> --
> 2.53.0
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 62+ messages in thread
* [PATCH 26/27] fs: port mnt_idmap() and file_mnt_idmap() to const mnt_idmap
2026-09-01 12:14 [PATCH 00/27] fs: port to const struct mnt_idmap Christian Brauner
` (24 preceding siblings ...)
2026-09-01 12:14 ` [PATCH 25/27] fs: port vfs_*() helpers to " Christian Brauner
@ 2026-09-01 12:14 ` 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
26 siblings, 1 reply; 62+ messages in thread
From: Christian Brauner @ 2026-09-01 12:14 UTC (permalink / raw)
To: linux-fsdevel
Cc: Alexander Viro, Jan Kara, Christoph Hellwig, Seth Forshee,
Paul Moore, linux-security-module, Mimi Zohar, linux-integrity,
Ilya Dryomov, ceph-devel, Carlos Maiolino, linux-xfs,
Miklos Szeredi, Amir Goldstein, linux-unionfs, Namjae Jeon,
linux-cifs, linux-kernel, Christian Brauner (Amutable)
Now that everything takes a mnt_idmap as const store a const pointer in
struct vfsmount, struct mount_kattr and struct kstatmount and return one
from mnt_idmap(), file_mnt_idmap() and ovl_upper_mnt_idmap(). Finally,
also make mnt_idmap_get() return a const pointer. Also convert the
remaining local variables that are initialized from the accessors.
alloc_mnt_idmap() keeps returning a non-const pointer. It is the only
place where an idmapping is actually written to.
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
---
Documentation/filesystems/porting.rst | 13 +++++++++++++
fs/backing-file.c | 2 +-
fs/btrfs/ioctl.c | 4 ++--
fs/ceph/file.c | 2 +-
fs/coredump.c | 2 +-
fs/exec.c | 4 ++--
fs/ext4/ioctl.c | 2 +-
fs/f2fs/file.c | 6 +++---
fs/fhandle.c | 2 +-
fs/file_attr.c | 4 ++--
fs/fuse/dir.c | 2 +-
fs/fuse/file.c | 2 +-
fs/internal.h | 2 +-
fs/mnt_idmapping.c | 4 ++--
fs/namei.c | 14 +++++++-------
fs/namespace.c | 8 ++++----
fs/open.c | 4 ++--
fs/overlayfs/file.c | 2 +-
fs/overlayfs/inode.c | 2 +-
fs/overlayfs/ovl_entry.h | 2 +-
fs/overlayfs/util.c | 4 ++--
fs/remap_range.c | 2 +-
fs/smb/server/oplock.c | 2 +-
fs/smb/server/smb2pdu.c | 20 ++++++++++----------
fs/smb/server/smb_common.c | 2 +-
fs/smb/server/smbacl.c | 6 +++---
fs/smb/server/vfs.c | 10 +++++-----
fs/stat.c | 2 +-
include/linux/fs.h | 2 +-
include/linux/mnt_idmapping.h | 2 +-
include/linux/mount.h | 4 ++--
net/unix/af_unix.c | 2 +-
security/apparmor/lsm.c | 4 ++--
33 files changed, 79 insertions(+), 66 deletions(-)
diff --git a/Documentation/filesystems/porting.rst b/Documentation/filesystems/porting.rst
index 60880eb0c49d..b967a129e380 100644
--- a/Documentation/filesystems/porting.rst
+++ b/Documentation/filesystems/porting.rst
@@ -1409,3 +1409,16 @@ use only if you have no alternative.
The .create inode_operation no longer receives the 'excl' arg. It must
always assume the file does not already exist. If the filesystem needs
to be involved in non-exclusive create, it should provide atomic_open.
+
+---
+
+**mandatory**
+
+All struct mnt_idmap pointers handed to filesystems are const now.
+->create(), ->mkdir(), ->mknod(), ->symlink(), ->rename(), ->setattr(),
+->getattr(), ->permission(), ->tmpfile(), ->get_acl(), ->set_acl() and
+->fileattr_set() as well as the xattr ->set() handler and the vfs_*()
+helpers take a const struct mnt_idmap *. mnt_idmap() and file_mnt_idmap()
+return one. The idmapping is immutable so nothing should have modified it
+anyway. References are taken and dropped via mnt_idmap_get() and
+mnt_idmap_put() as before, both accept a const pointer.
diff --git a/fs/backing-file.c b/fs/backing-file.c
index cc101143f921..5614cb7801e1 100644
--- a/fs/backing-file.c
+++ b/fs/backing-file.c
@@ -59,7 +59,7 @@ struct file *backing_tmpfile_open(const struct file *user_file, int flags,
const struct path *real_parentpath,
umode_t mode, const struct cred *cred)
{
- struct mnt_idmap *real_idmap = mnt_idmap(real_parentpath->mnt);
+ const struct mnt_idmap *real_idmap = mnt_idmap(real_parentpath->mnt);
const struct path *user_path = &user_file->f_path;
struct file *f;
int error;
diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index e20e66c0fead..efeb5561015c 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -1149,7 +1149,7 @@ static noinline int __btrfs_ioctl_snap_create(struct file *file,
{
int ret;
struct qstr qname = QSTR(name);
- struct mnt_idmap *idmap = file_mnt_idmap(file);
+ const struct mnt_idmap *idmap = file_mnt_idmap(file);
if (!S_ISDIR(file_inode(file)->i_mode))
return -ENOTDIR;
@@ -2226,7 +2226,7 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file,
struct btrfs_root *dest = NULL;
struct btrfs_ioctl_vol_args AUTO_KFREE(vol_args);
struct btrfs_ioctl_vol_args_v2 AUTO_KFREE(vol_args2);
- struct mnt_idmap *idmap = file_mnt_idmap(file);
+ const struct mnt_idmap *idmap = file_mnt_idmap(file);
char *subvol_name, *subvol_name_ptr = NULL;
int ret = 0;
bool destroy_parent = false;
diff --git a/fs/ceph/file.c b/fs/ceph/file.c
index bd3e3f5c269e..2c994c08ed4b 100644
--- a/fs/ceph/file.c
+++ b/fs/ceph/file.c
@@ -795,7 +795,7 @@ static int ceph_finish_async_create(struct inode *dir, struct inode *inode,
int ceph_atomic_open(struct inode *dir, struct dentry *dentry,
struct file *file, unsigned flags, umode_t mode)
{
- struct mnt_idmap *idmap = file_mnt_idmap(file);
+ const struct mnt_idmap *idmap = file_mnt_idmap(file);
struct ceph_fs_client *fsc = ceph_sb_to_fs_client(dir->i_sb);
struct ceph_client *cl = fsc->client;
struct ceph_mds_client *mdsc = fsc->mdsc;
diff --git a/fs/coredump.c b/fs/coredump.c
index ac3cd74808c6..9f75e16d3b36 100644
--- a/fs/coredump.c
+++ b/fs/coredump.c
@@ -878,7 +878,7 @@ static inline bool coredump_force_suid_safe(const struct coredump_params *cprm)
static bool coredump_file(struct core_name *cn, struct coredump_params *cprm,
const struct linux_binfmt *binfmt)
{
- struct mnt_idmap *idmap;
+ const struct mnt_idmap *idmap;
struct inode *inode;
struct file *file __free(fput) = NULL;
int open_flags = O_CREAT | O_WRONLY | O_NOFOLLOW | O_LARGEFILE | O_EXCL;
diff --git a/fs/exec.c b/fs/exec.c
index 745f6eb5279e..a7785559d0d3 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1339,7 +1339,7 @@ EXPORT_SYMBOL(begin_new_exec);
void would_dump(struct linux_binprm *bprm, struct file *file)
{
struct inode *inode = file_inode(file);
- struct mnt_idmap *idmap = file_mnt_idmap(file);
+ const struct mnt_idmap *idmap = file_mnt_idmap(file);
if (inode_permission(idmap, inode, MAY_READ) < 0) {
struct user_namespace *old, *user_ns;
bprm->interp_flags |= BINPRM_FLAGS_ENFORCE_NONDUMP;
@@ -1623,7 +1623,7 @@ static void check_unsafe_exec(struct linux_binprm *bprm)
static void bprm_fill_uid(struct linux_binprm *bprm, struct file *file)
{
/* Handle suid and sgid on files */
- struct mnt_idmap *idmap;
+ const struct mnt_idmap *idmap;
struct inode *inode = file_inode(file);
unsigned int mode;
vfsuid_t vfsuid;
diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
index 2719f20493c8..0a54b00e5be5 100644
--- a/fs/ext4/ioctl.c
+++ b/fs/ext4/ioctl.c
@@ -1539,7 +1539,7 @@ static long __ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{
struct inode *inode = file_inode(filp);
struct super_block *sb = inode->i_sb;
- struct mnt_idmap *idmap = file_mnt_idmap(filp);
+ const struct mnt_idmap *idmap = file_mnt_idmap(filp);
ext4_debug("cmd = %u, arg = %lu\n", cmd, arg);
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
index fb8b03a9972d..8596c3bc4704 100644
--- a/fs/f2fs/file.c
+++ b/fs/f2fs/file.c
@@ -2361,7 +2361,7 @@ static int f2fs_ioc_getversion(struct file *filp, unsigned long arg)
static int f2fs_ioc_start_atomic_write(struct file *filp, bool truncate)
{
struct inode *inode = file_inode(filp);
- struct mnt_idmap *idmap = file_mnt_idmap(filp);
+ const struct mnt_idmap *idmap = file_mnt_idmap(filp);
struct f2fs_inode_info *fi = F2FS_I(inode);
struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
loff_t isize;
@@ -2473,7 +2473,7 @@ static int f2fs_ioc_start_atomic_write(struct file *filp, bool truncate)
static int f2fs_ioc_commit_atomic_write(struct file *filp)
{
struct inode *inode = file_inode(filp);
- struct mnt_idmap *idmap = file_mnt_idmap(filp);
+ const struct mnt_idmap *idmap = file_mnt_idmap(filp);
int ret;
if (!(filp->f_mode & FMODE_WRITE))
@@ -2508,7 +2508,7 @@ static int f2fs_ioc_commit_atomic_write(struct file *filp)
static int f2fs_ioc_abort_atomic_write(struct file *filp)
{
struct inode *inode = file_inode(filp);
- struct mnt_idmap *idmap = file_mnt_idmap(filp);
+ const struct mnt_idmap *idmap = file_mnt_idmap(filp);
int ret;
if (!(filp->f_mode & FMODE_WRITE))
diff --git a/fs/fhandle.c b/fs/fhandle.c
index f8829231e3d7..2aa55b8a878a 100644
--- a/fs/fhandle.c
+++ b/fs/fhandle.c
@@ -201,7 +201,7 @@ static int vfs_dentry_acceptable(void *context, struct dentry *dentry)
struct handle_to_path_ctx *ctx = context;
struct user_namespace *user_ns = current_user_ns();
struct dentry *d, *root = ctx->root.dentry;
- struct mnt_idmap *idmap = mnt_idmap(ctx->root.mnt);
+ const struct mnt_idmap *idmap = mnt_idmap(ctx->root.mnt);
int retval = 0;
if (!root)
diff --git a/fs/file_attr.c b/fs/file_attr.c
index 5393c4dfa4a8..81af4364e33a 100644
--- a/fs/file_attr.c
+++ b/fs/file_attr.c
@@ -323,7 +323,7 @@ int ioctl_getflags(struct file *file, unsigned int __user *argp)
int ioctl_setflags(struct file *file, unsigned int __user *argp)
{
- struct mnt_idmap *idmap = file_mnt_idmap(file);
+ const struct mnt_idmap *idmap = file_mnt_idmap(file);
struct dentry *dentry = file->f_path.dentry;
struct file_kattr fa = {};
unsigned int flags;
@@ -355,7 +355,7 @@ int ioctl_fsgetxattr(struct file *file, void __user *argp)
int ioctl_fssetxattr(struct file *file, void __user *argp)
{
- struct mnt_idmap *idmap = file_mnt_idmap(file);
+ const struct mnt_idmap *idmap = file_mnt_idmap(file);
struct dentry *dentry = file->f_path.dentry;
struct file_kattr fa = {};
int err;
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 6d23878cfae5..1759f7fd72b0 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -941,7 +941,7 @@ static int fuse_atomic_open(struct inode *dir, struct dentry *entry,
umode_t mode)
{
int err;
- struct mnt_idmap *idmap = file_mnt_idmap(file);
+ const struct mnt_idmap *idmap = file_mnt_idmap(file);
struct fuse_conn *fc = get_fuse_conn(dir);
if (fuse_is_bad(dir))
diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index 8d6135a6108a..6ae350f8b486 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -1487,7 +1487,7 @@ static const struct iomap_write_ops fuse_iomap_write_ops = {
static ssize_t fuse_cache_write_iter(struct kiocb *iocb, struct iov_iter *from)
{
struct file *file = iocb->ki_filp;
- struct mnt_idmap *idmap = file_mnt_idmap(file);
+ const struct mnt_idmap *idmap = file_mnt_idmap(file);
struct address_space *mapping = file->f_mapping;
ssize_t written = 0;
struct inode *inode = mapping->host;
diff --git a/fs/internal.h b/fs/internal.h
index 973436f44770..3dda57fb3c7d 100644
--- a/fs/internal.h
+++ b/fs/internal.h
@@ -327,7 +327,7 @@ ssize_t __kernel_write_iter(struct file *file, struct iov_iter *from, loff_t *po
* fs/attr.c
*/
struct mnt_idmap *alloc_mnt_idmap(struct user_namespace *mnt_userns);
-struct mnt_idmap *mnt_idmap_get(const struct mnt_idmap *idmap);
+const struct mnt_idmap *mnt_idmap_get(const struct mnt_idmap *idmap);
void mnt_idmap_put(const struct mnt_idmap *idmap);
struct stashed_operations {
struct dentry *(*stash_dentry)(struct dentry **stashed,
diff --git a/fs/mnt_idmapping.c b/fs/mnt_idmapping.c
index 4d5fbf185608..26704eeb7318 100644
--- a/fs/mnt_idmapping.c
+++ b/fs/mnt_idmapping.c
@@ -312,14 +312,14 @@ struct mnt_idmap *alloc_mnt_idmap(struct user_namespace *mnt_userns)
*
* Return: @idmap with reference count bumped if @not_mnt_idmap isn't passed.
*/
-struct mnt_idmap *mnt_idmap_get(const struct mnt_idmap *idmap)
+const struct mnt_idmap *mnt_idmap_get(const struct mnt_idmap *idmap)
{
struct mnt_idmap *nonconst_idmap = (struct mnt_idmap *)idmap;
if (idmap != &nop_mnt_idmap && idmap != &invalid_mnt_idmap)
refcount_inc(&nonconst_idmap->count);
- return nonconst_idmap;
+ return idmap;
}
EXPORT_SYMBOL_GPL(mnt_idmap_get);
diff --git a/fs/namei.c b/fs/namei.c
index 14970fe08387..818444a52b88 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1273,7 +1273,7 @@ fs_initcall(init_fs_namei_sysctls);
*/
static inline int may_follow_link(struct nameidata *nd, const struct inode *inode)
{
- struct mnt_idmap *idmap;
+ const struct mnt_idmap *idmap;
vfsuid_t vfsuid;
if (!sysctl_protected_symlinks)
@@ -2596,7 +2596,7 @@ static int link_path_walk(const char *name, struct nameidata *nd)
/* At this point we know we have a real path component. */
for(;;) {
- struct mnt_idmap *idmap;
+ const struct mnt_idmap *idmap;
const char *link;
unsigned long lastword;
@@ -4432,7 +4432,7 @@ static struct dentry *lookup_open(struct nameidata *nd, struct file *file,
const struct open_flags *op)
{
struct delegated_inode delegated_inode = { };
- struct mnt_idmap *idmap;
+ const struct mnt_idmap *idmap;
struct dentry *dir = nd->path.dentry;
struct inode *dir_inode = dir->d_inode;
int open_flag;
@@ -4789,7 +4789,7 @@ static const char *open_last_lookups(struct nameidata *nd,
static int do_open(struct nameidata *nd,
struct file *file, const struct open_flags *op)
{
- struct mnt_idmap *idmap;
+ const struct mnt_idmap *idmap;
int open_flag = op->open_flag;
bool do_truncate;
int acc_mode;
@@ -5169,7 +5169,7 @@ struct file *dentry_create(struct path *path, int flags, umode_t mode,
struct dentry *orig_dentry = dentry;
struct dentry *dir = dentry->d_parent;
struct inode *dir_inode = d_inode(dir);
- struct mnt_idmap *idmap;
+ const struct mnt_idmap *idmap;
int error, create_error;
file = alloc_empty_file(flags, cred);
@@ -5294,7 +5294,7 @@ int filename_mknodat(int dfd, struct filename *name, umode_t mode,
unsigned int dev)
{
struct delegated_inode di = { };
- struct mnt_idmap *idmap;
+ const struct mnt_idmap *idmap;
struct dentry *dentry;
struct path path;
int error;
@@ -5949,7 +5949,7 @@ EXPORT_SYMBOL(vfs_link);
int filename_linkat(int olddfd, struct filename *old,
int newdfd, struct filename *new, int flags)
{
- struct mnt_idmap *idmap;
+ const struct mnt_idmap *idmap;
struct dentry *new_dentry;
struct path old_path, new_path;
struct delegated_inode delegated_inode = { };
diff --git a/fs/namespace.c b/fs/namespace.c
index 1ecd96c918b3..919c27724a59 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -109,7 +109,7 @@ struct mount_kattr {
unsigned int lookup_flags;
enum mount_kattr_flags_t kflags;
struct user_namespace *mnt_userns;
- struct mnt_idmap *mnt_idmap;
+ const struct mnt_idmap *mnt_idmap;
};
/* /sys/fs */
@@ -4898,7 +4898,7 @@ static int mount_setattr_prepare(struct mount_kattr *kattr, struct mount *mnt)
static void do_idmap_mount(const struct mount_kattr *kattr, struct mount *mnt)
{
- struct mnt_idmap *old_idmap;
+ const struct mnt_idmap *old_idmap;
if (!kattr->mnt_idmap)
return;
@@ -4941,7 +4941,7 @@ static int do_mount_setattr(const struct path *path, struct mount_kattr *kattr)
return -EINVAL;
if (kattr->mnt_userns) {
- struct mnt_idmap *mnt_idmap;
+ const struct mnt_idmap *mnt_idmap;
mnt_idmap = alloc_mnt_idmap(kattr->mnt_userns);
if (IS_ERR(mnt_idmap))
@@ -5246,7 +5246,7 @@ struct kstatmount {
struct statmount __user *buf;
size_t bufsize;
struct vfsmount *mnt;
- struct mnt_idmap *idmap;
+ const struct mnt_idmap *idmap;
u64 mask;
struct path root;
struct seq_file seq;
diff --git a/fs/open.c b/fs/open.c
index 971e51008e67..031858d77fcc 100644
--- a/fs/open.c
+++ b/fs/open.c
@@ -72,7 +72,7 @@ int do_truncate(const struct mnt_idmap *idmap, struct dentry *dentry,
int vfs_truncate(const struct path *path, loff_t length)
{
- struct mnt_idmap *idmap;
+ const struct mnt_idmap *idmap;
struct inode *inode;
int error;
@@ -787,7 +787,7 @@ static inline bool setattr_vfsgid(struct iattr *attr, kgid_t kgid)
int chown_common(const struct path *path, uid_t user, gid_t group)
{
- struct mnt_idmap *idmap;
+ const struct mnt_idmap *idmap;
struct user_namespace *fs_userns;
struct inode *inode = path->dentry->d_inode;
struct delegated_inode delegated_inode = { };
diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c
index f3d97eb146e8..7433220d4ad6 100644
--- a/fs/overlayfs/file.c
+++ b/fs/overlayfs/file.c
@@ -30,7 +30,7 @@ static struct file *ovl_open_realfile(const struct file *file,
{
struct inode *realinode = d_inode(realpath->dentry);
struct inode *inode = file_inode(file);
- struct mnt_idmap *real_idmap;
+ const struct mnt_idmap *real_idmap;
struct file *realfile;
int flags = file->f_flags | OVL_OPEN_FLAGS;
int acc_mode = ACC_MODE(flags);
diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
index 622e9bb833af..70183d516e5e 100644
--- a/fs/overlayfs/inode.c
+++ b/fs/overlayfs/inode.c
@@ -406,7 +406,7 @@ struct posix_acl *ovl_get_acl_path(const struct path *path,
const char *acl_name, bool noperm)
{
struct posix_acl *real_acl, *clone;
- struct mnt_idmap *idmap;
+ const struct mnt_idmap *idmap;
struct inode *realinode = d_inode(path->dentry);
idmap = mnt_idmap(path->mnt);
diff --git a/fs/overlayfs/ovl_entry.h b/fs/overlayfs/ovl_entry.h
index 80cad4ea96a3..ac07e8769f9b 100644
--- a/fs/overlayfs/ovl_entry.h
+++ b/fs/overlayfs/ovl_entry.h
@@ -105,7 +105,7 @@ static inline struct vfsmount *ovl_upper_mnt(struct ovl_fs *ofs)
return ofs->layers[0].mnt;
}
-static inline struct mnt_idmap *ovl_upper_mnt_idmap(struct ovl_fs *ofs)
+static inline const struct mnt_idmap *ovl_upper_mnt_idmap(struct ovl_fs *ofs)
{
return mnt_idmap(ovl_upper_mnt(ofs));
}
diff --git a/fs/overlayfs/util.c b/fs/overlayfs/util.c
index b41f4788e4f0..521717209b2e 100644
--- a/fs/overlayfs/util.c
+++ b/fs/overlayfs/util.c
@@ -657,7 +657,7 @@ bool ovl_path_is_whiteout(struct ovl_fs *ofs, const struct path *path)
struct file *ovl_path_open(const struct path *path, int flags)
{
struct inode *inode = d_inode(path->dentry);
- struct mnt_idmap *real_idmap = mnt_idmap(path->mnt);
+ const struct mnt_idmap *real_idmap = mnt_idmap(path->mnt);
int err, acc_mode;
if (flags & ~(O_ACCMODE | O_LARGEFILE))
@@ -1496,7 +1496,7 @@ void ovl_copyattr(struct inode *inode)
{
struct path realpath;
struct inode *realinode;
- struct mnt_idmap *real_idmap;
+ const struct mnt_idmap *real_idmap;
vfsuid_t vfsuid;
vfsgid_t vfsgid;
diff --git a/fs/remap_range.c b/fs/remap_range.c
index 26afbbbfb10c..6eb7d845de5d 100644
--- a/fs/remap_range.c
+++ b/fs/remap_range.c
@@ -415,7 +415,7 @@ EXPORT_SYMBOL(vfs_clone_file_range);
/* Check whether we are allowed to dedupe the destination file */
static bool may_dedupe_file(struct file *file)
{
- struct mnt_idmap *idmap = file_mnt_idmap(file);
+ const struct mnt_idmap *idmap = file_mnt_idmap(file);
struct inode *inode = file_inode(file);
if (capable(CAP_SYS_ADMIN))
diff --git a/fs/smb/server/oplock.c b/fs/smb/server/oplock.c
index 58af0fddf39f..341a812da3a8 100644
--- a/fs/smb/server/oplock.c
+++ b/fs/smb/server/oplock.c
@@ -2229,7 +2229,7 @@ void create_posix_rsp_buf(char *cc, struct ksmbd_file *fp)
{
struct create_posix_rsp *buf;
struct inode *inode = file_inode(fp->filp);
- struct mnt_idmap *idmap = file_mnt_idmap(fp->filp);
+ const struct mnt_idmap *idmap = file_mnt_idmap(fp->filp);
vfsuid_t vfsuid = i_uid_into_vfsuid(idmap, inode);
vfsgid_t vfsgid = i_gid_into_vfsgid(idmap, inode);
diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
index 0789200d602f..e2dcf8228fa4 100644
--- a/fs/smb/server/smb2pdu.c
+++ b/fs/smb/server/smb2pdu.c
@@ -3234,7 +3234,7 @@ static bool smb2_is_private_ea(const char *name, size_t name_len)
static int smb2_set_ea(struct smb2_ea_info *eabuf, unsigned int buf_len,
const struct path *path, bool get_write)
{
- struct mnt_idmap *idmap = mnt_idmap(path->mnt);
+ const struct mnt_idmap *idmap = mnt_idmap(path->mnt);
char *attr_name = NULL, *value;
int rc = 0;
unsigned int next = 0;
@@ -3335,7 +3335,7 @@ static noinline int smb2_set_stream_name_xattr(const struct path *path,
struct ksmbd_file *fp,
char *stream_name, int s_type)
{
- struct mnt_idmap *idmap = mnt_idmap(path->mnt);
+ const struct mnt_idmap *idmap = mnt_idmap(path->mnt);
size_t xattr_stream_size;
char *xattr_stream_name;
int rc;
@@ -3411,7 +3411,7 @@ static loff_t ksmbd_stream_eof(struct ksmbd_file *fp)
static int smb2_remove_smb_xattrs(const struct path *path)
{
- struct mnt_idmap *idmap = mnt_idmap(path->mnt);
+ const struct mnt_idmap *idmap = mnt_idmap(path->mnt);
char *name, *xattr_list = NULL;
ssize_t xattr_list_len;
int err = 0;
@@ -4088,7 +4088,7 @@ int smb2_open(struct ksmbd_work *work)
struct ksmbd_share_config *share = tcon->share_conf;
struct ksmbd_file *fp = NULL;
struct file *filp = NULL;
- struct mnt_idmap *idmap = NULL;
+ const struct mnt_idmap *idmap = NULL;
struct kstat stat;
struct create_context *context;
struct lease_ctx_info *lc = NULL;
@@ -5753,7 +5753,7 @@ struct smb2_query_dir_private {
static int process_query_dir_entries(struct smb2_query_dir_private *priv)
{
- struct mnt_idmap *idmap = file_mnt_idmap(priv->dir_fp->filp);
+ const struct mnt_idmap *idmap = file_mnt_idmap(priv->dir_fp->filp);
struct kstat kstat;
struct ksmbd_kstat ksmbd_kstat;
int rc;
@@ -6352,7 +6352,7 @@ static int smb2_get_ea(struct ksmbd_work *work, struct ksmbd_file *fp,
ssize_t buf_free_len, alignment_bytes, next_offset, rsp_data_cnt = 0;
struct smb2_ea_info_req *ea_req = NULL;
const struct path *path;
- struct mnt_idmap *idmap = file_mnt_idmap(fp->filp);
+ const struct mnt_idmap *idmap = file_mnt_idmap(fp->filp);
if (!(fp->daccess & FILE_READ_EA_LE)) {
pr_err("Not permitted to read ext attr : 0x%x\n",
@@ -7062,7 +7062,7 @@ static int find_file_posix_info(struct smb2_query_info_rsp *rsp,
{
struct smb311_posix_qinfo *file_info;
struct inode *inode = file_inode(fp->filp);
- struct mnt_idmap *idmap = file_mnt_idmap(fp->filp);
+ const struct mnt_idmap *idmap = file_mnt_idmap(fp->filp);
vfsuid_t vfsuid = i_uid_into_vfsuid(idmap, inode);
vfsgid_t vfsgid = i_gid_into_vfsgid(idmap, inode);
struct kstat stat;
@@ -7547,7 +7547,7 @@ static int smb2_get_info_sec(struct ksmbd_work *work,
struct smb2_query_info_rsp *rsp)
{
struct ksmbd_file *fp;
- struct mnt_idmap *idmap;
+ const struct mnt_idmap *idmap;
struct smb_ntsd *pntsd = NULL, *ppntsd = NULL;
struct smb_fattr fattr = {{0}};
struct inode *inode;
@@ -8060,7 +8060,7 @@ static int set_file_basic_info(struct ksmbd_file *fp,
struct iattr attrs;
struct file *filp;
struct inode *inode;
- struct mnt_idmap *idmap;
+ const struct mnt_idmap *idmap;
__le32 attrs_mask = FILE_ATTRIBUTE_DIRECTORY_LE |
FILE_ATTRIBUTE_COMPRESSED_LE;
int rc = 0;
@@ -10652,7 +10652,7 @@ static inline int fsctl_set_sparse(struct ksmbd_work *work, u64 id,
struct file_sparse *sparse)
{
struct ksmbd_file *fp;
- struct mnt_idmap *idmap;
+ const struct mnt_idmap *idmap;
int ret = 0;
__le32 old_fattr;
diff --git a/fs/smb/server/smb_common.c b/fs/smb/server/smb_common.c
index 4c2da65510bc..ec6ee56293ce 100644
--- a/fs/smb/server/smb_common.c
+++ b/fs/smb/server/smb_common.c
@@ -467,7 +467,7 @@ int ksmbd_populate_dot_dotdot_entries(struct ksmbd_work *work, int info_level,
{
int i, rc = 0;
struct ksmbd_conn *conn = work->conn;
- struct mnt_idmap *idmap = file_mnt_idmap(dir->filp);
+ const struct mnt_idmap *idmap = file_mnt_idmap(dir->filp);
for (i = 0; i < 2; i++) {
struct kstat kstat;
diff --git a/fs/smb/server/smbacl.c b/fs/smb/server/smbacl.c
index 915dbfab62ea..784067d14f56 100644
--- a/fs/smb/server/smbacl.c
+++ b/fs/smb/server/smbacl.c
@@ -1183,7 +1183,7 @@ int smb_inherit_dacl(struct ksmbd_conn *conn,
struct smb_ntsd *parent_pntsd = NULL;
struct smb_sid owner_sid, group_sid;
struct dentry *parent = path->dentry->d_parent;
- struct mnt_idmap *idmap = mnt_idmap(path->mnt);
+ const struct mnt_idmap *idmap = mnt_idmap(path->mnt);
int inherited_flags = 0, flags = 0, i, nt_size = 0, pdacl_size;
int rc = 0, pntsd_type, ppntsd_size, acl_len, aces_size;
unsigned int dacloffset;
@@ -1438,7 +1438,7 @@ int smb_check_perm_dacl(struct ksmbd_conn *conn, const struct path *path,
__le32 *pdaccess, __le32 raw_daccess, int uid,
bool strict)
{
- struct mnt_idmap *idmap = mnt_idmap(path->mnt);
+ const struct mnt_idmap *idmap = mnt_idmap(path->mnt);
struct smb_ntsd *pntsd = NULL;
struct smb_acl *pdacl;
struct posix_acl *posix_acls;
@@ -1660,7 +1660,7 @@ int set_info_sec(struct ksmbd_conn *conn, struct ksmbd_tree_connect *tcon,
int rc;
struct smb_fattr fattr = {{0}};
struct inode *inode = d_inode(path->dentry);
- struct mnt_idmap *idmap = mnt_idmap(path->mnt);
+ const struct mnt_idmap *idmap = mnt_idmap(path->mnt);
struct iattr newattrs;
fattr.cf_uid = INVALID_UID;
diff --git a/fs/smb/server/vfs.c b/fs/smb/server/vfs.c
index 75edff8dde31..ccfdc726d063 100644
--- a/fs/smb/server/vfs.c
+++ b/fs/smb/server/vfs.c
@@ -183,7 +183,7 @@ int ksmbd_vfs_create(struct ksmbd_work *work, const char *name, umode_t mode)
*/
int ksmbd_vfs_mkdir(struct ksmbd_work *work, const char *name, umode_t mode)
{
- struct mnt_idmap *idmap;
+ const struct mnt_idmap *idmap;
struct path path;
struct dentry *dentry, *d;
int err = 0;
@@ -386,7 +386,7 @@ static int ksmbd_vfs_stream_write(struct ksmbd_file *fp, char *buf, loff_t *pos,
{
const struct cred *saved_cred;
char *stream_buf = NULL, *wbuf;
- struct mnt_idmap *idmap = file_mnt_idmap(fp->filp);
+ const struct mnt_idmap *idmap = file_mnt_idmap(fp->filp);
size_t size;
ssize_t v_len;
int err = 0;
@@ -577,7 +577,7 @@ int ksmbd_vfs_fsync(struct ksmbd_work *work, u64 fid, u64 p_id)
*/
int ksmbd_vfs_remove_file(struct ksmbd_work *work, const struct path *path)
{
- struct mnt_idmap *idmap;
+ const struct mnt_idmap *idmap;
struct dentry *parent = path->dentry->d_parent;
int err;
@@ -1202,7 +1202,7 @@ int ksmbd_vfs_unlink(struct file *filp)
const struct cred *saved_cred;
int err = 0;
struct dentry *dir, *dentry = filp->f_path.dentry;
- struct mnt_idmap *idmap = file_mnt_idmap(filp);
+ const struct mnt_idmap *idmap = file_mnt_idmap(filp);
saved_cred = override_creds(filp->f_cred);
err = mnt_want_write(filp->f_path.mnt);
@@ -2316,7 +2316,7 @@ static int __ksmbd_vfs_set_compression(struct ksmbd_work *work,
const struct cred *saved_cred = NULL;
struct file_kattr fa;
struct dentry *dentry = fp->filp->f_path.dentry;
- struct mnt_idmap *idmap = file_mnt_idmap(fp->filp);
+ const struct mnt_idmap *idmap = file_mnt_idmap(fp->filp);
u32 flags;
__le32 old_fattr;
int rc;
diff --git a/fs/stat.c b/fs/stat.c
index fe351818d1d6..a9b7383d538d 100644
--- a/fs/stat.c
+++ b/fs/stat.c
@@ -181,7 +181,7 @@ EXPORT_SYMBOL_GPL(generic_fill_statx_atomic_writes);
int vfs_getattr_nosec(const struct path *path, struct kstat *stat,
u32 request_mask, unsigned int query_flags)
{
- struct mnt_idmap *idmap;
+ const struct mnt_idmap *idmap;
struct inode *inode = d_backing_inode(path->dentry);
memset(stat, 0, sizeof(*stat));
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 935b0f92786f..ca3e9d4797ee 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -2459,7 +2459,7 @@ struct filename {
static_assert(offsetof(struct filename, iname) % sizeof(long) == 0);
static_assert(sizeof(struct filename) % 64 == 0);
-static inline struct mnt_idmap *file_mnt_idmap(const struct file *file)
+static inline const struct mnt_idmap *file_mnt_idmap(const struct file *file)
{
return mnt_idmap(file->f_path.mnt);
}
diff --git a/include/linux/mnt_idmapping.h b/include/linux/mnt_idmapping.h
index 6656aea23be2..b445c7660040 100644
--- a/include/linux/mnt_idmapping.h
+++ b/include/linux/mnt_idmapping.h
@@ -121,7 +121,7 @@ static inline bool vfsgid_eq_kgid(vfsgid_t vfsgid, kgid_t kgid)
int vfsgid_in_group_p(vfsgid_t vfsgid);
-struct mnt_idmap *mnt_idmap_get(const struct mnt_idmap *idmap);
+const struct mnt_idmap *mnt_idmap_get(const struct mnt_idmap *idmap);
void mnt_idmap_put(const struct mnt_idmap *idmap);
vfsuid_t make_vfsuid(const struct mnt_idmap *idmap,
diff --git a/include/linux/mount.h b/include/linux/mount.h
index acfe7ef86a1b..e90ccafef281 100644
--- a/include/linux/mount.h
+++ b/include/linux/mount.h
@@ -59,10 +59,10 @@ struct vfsmount {
struct dentry *mnt_root; /* root of the mounted tree */
struct super_block *mnt_sb; /* pointer to superblock */
int mnt_flags;
- struct mnt_idmap *mnt_idmap;
+ const struct mnt_idmap *mnt_idmap;
} __randomize_layout;
-static inline struct mnt_idmap *mnt_idmap(const struct vfsmount *mnt)
+static inline const struct mnt_idmap *mnt_idmap(const struct vfsmount *mnt)
{
/* Pairs with smp_store_release() in do_idmap_mount(). */
return READ_ONCE(mnt->mnt_idmap);
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 13f9926bf205..56e1bf51ffe5 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -1361,7 +1361,7 @@ static int unix_bind_bsd(struct sock *sk, struct sockaddr_un *sunaddr,
struct unix_sock *u = unix_sk(sk);
unsigned int new_hash, old_hash;
struct net *net = sock_net(sk);
- struct mnt_idmap *idmap;
+ const struct mnt_idmap *idmap;
struct unix_address *addr;
struct dentry *dentry;
struct path parent;
diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
index d502ad0ac26f..c73681d820a0 100644
--- a/security/apparmor/lsm.c
+++ b/security/apparmor/lsm.c
@@ -397,7 +397,7 @@ static int apparmor_path_rename(const struct path *old_dir, struct dentry *old_d
label = begin_current_label_crit_section(&needput);
if (!unconfined(label)) {
- struct mnt_idmap *idmap = mnt_idmap(old_dir->mnt);
+ const struct mnt_idmap *idmap = mnt_idmap(old_dir->mnt);
vfsuid_t vfsuid;
struct path old_path = { .mnt = old_dir->mnt,
.dentry = old_dentry };
@@ -485,7 +485,7 @@ static int apparmor_file_open(struct file *file)
label = aa_get_newest_cred_label_condref(file->f_cred, &needput);
if (!unconfined(label)) {
- struct mnt_idmap *idmap = file_mnt_idmap(file);
+ const struct mnt_idmap *idmap = file_mnt_idmap(file);
struct inode *inode = file_inode(file);
vfsuid_t vfsuid;
struct path_cond cond = {
--
2.53.0
^ permalink raw reply related [flat|nested] 62+ messages in thread* Re: [PATCH 26/27] fs: port mnt_idmap() and file_mnt_idmap() to const mnt_idmap
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
0 siblings, 0 replies; 62+ messages in thread
From: Jan Kara @ 2026-09-02 16:06 UTC (permalink / raw)
To: Christian Brauner
Cc: linux-fsdevel, Alexander Viro, Jan Kara, Christoph Hellwig,
Seth Forshee, Paul Moore, linux-security-module, Mimi Zohar,
linux-integrity, Ilya Dryomov, ceph-devel, Carlos Maiolino,
linux-xfs, Miklos Szeredi, Amir Goldstein, linux-unionfs,
Namjae Jeon, linux-cifs, linux-kernel
On Tue 01-09-26 14:14:51, Christian Brauner wrote:
> Now that everything takes a mnt_idmap as const store a const pointer in
> struct vfsmount, struct mount_kattr and struct kstatmount and return one
> from mnt_idmap(), file_mnt_idmap() and ovl_upper_mnt_idmap(). Finally,
> also make mnt_idmap_get() return a const pointer. Also convert the
> remaining local variables that are initialized from the accessors.
>
> alloc_mnt_idmap() keeps returning a non-const pointer. It is the only
> place where an idmapping is actually written to.
>
> Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> Documentation/filesystems/porting.rst | 13 +++++++++++++
> fs/backing-file.c | 2 +-
> fs/btrfs/ioctl.c | 4 ++--
> fs/ceph/file.c | 2 +-
> fs/coredump.c | 2 +-
> fs/exec.c | 4 ++--
> fs/ext4/ioctl.c | 2 +-
> fs/f2fs/file.c | 6 +++---
> fs/fhandle.c | 2 +-
> fs/file_attr.c | 4 ++--
> fs/fuse/dir.c | 2 +-
> fs/fuse/file.c | 2 +-
> fs/internal.h | 2 +-
> fs/mnt_idmapping.c | 4 ++--
> fs/namei.c | 14 +++++++-------
> fs/namespace.c | 8 ++++----
> fs/open.c | 4 ++--
> fs/overlayfs/file.c | 2 +-
> fs/overlayfs/inode.c | 2 +-
> fs/overlayfs/ovl_entry.h | 2 +-
> fs/overlayfs/util.c | 4 ++--
> fs/remap_range.c | 2 +-
> fs/smb/server/oplock.c | 2 +-
> fs/smb/server/smb2pdu.c | 20 ++++++++++----------
> fs/smb/server/smb_common.c | 2 +-
> fs/smb/server/smbacl.c | 6 +++---
> fs/smb/server/vfs.c | 10 +++++-----
> fs/stat.c | 2 +-
> include/linux/fs.h | 2 +-
> include/linux/mnt_idmapping.h | 2 +-
> include/linux/mount.h | 4 ++--
> net/unix/af_unix.c | 2 +-
> security/apparmor/lsm.c | 4 ++--
> 33 files changed, 79 insertions(+), 66 deletions(-)
>
> diff --git a/Documentation/filesystems/porting.rst b/Documentation/filesystems/porting.rst
> index 60880eb0c49d..b967a129e380 100644
> --- a/Documentation/filesystems/porting.rst
> +++ b/Documentation/filesystems/porting.rst
> @@ -1409,3 +1409,16 @@ use only if you have no alternative.
> The .create inode_operation no longer receives the 'excl' arg. It must
> always assume the file does not already exist. If the filesystem needs
> to be involved in non-exclusive create, it should provide atomic_open.
> +
> +---
> +
> +**mandatory**
> +
> +All struct mnt_idmap pointers handed to filesystems are const now.
> +->create(), ->mkdir(), ->mknod(), ->symlink(), ->rename(), ->setattr(),
> +->getattr(), ->permission(), ->tmpfile(), ->get_acl(), ->set_acl() and
> +->fileattr_set() as well as the xattr ->set() handler and the vfs_*()
> +helpers take a const struct mnt_idmap *. mnt_idmap() and file_mnt_idmap()
> +return one. The idmapping is immutable so nothing should have modified it
> +anyway. References are taken and dropped via mnt_idmap_get() and
> +mnt_idmap_put() as before, both accept a const pointer.
> diff --git a/fs/backing-file.c b/fs/backing-file.c
> index cc101143f921..5614cb7801e1 100644
> --- a/fs/backing-file.c
> +++ b/fs/backing-file.c
> @@ -59,7 +59,7 @@ struct file *backing_tmpfile_open(const struct file *user_file, int flags,
> const struct path *real_parentpath,
> umode_t mode, const struct cred *cred)
> {
> - struct mnt_idmap *real_idmap = mnt_idmap(real_parentpath->mnt);
> + const struct mnt_idmap *real_idmap = mnt_idmap(real_parentpath->mnt);
> const struct path *user_path = &user_file->f_path;
> struct file *f;
> int error;
> diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
> index e20e66c0fead..efeb5561015c 100644
> --- a/fs/btrfs/ioctl.c
> +++ b/fs/btrfs/ioctl.c
> @@ -1149,7 +1149,7 @@ static noinline int __btrfs_ioctl_snap_create(struct file *file,
> {
> int ret;
> struct qstr qname = QSTR(name);
> - struct mnt_idmap *idmap = file_mnt_idmap(file);
> + const struct mnt_idmap *idmap = file_mnt_idmap(file);
>
> if (!S_ISDIR(file_inode(file)->i_mode))
> return -ENOTDIR;
> @@ -2226,7 +2226,7 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file,
> struct btrfs_root *dest = NULL;
> struct btrfs_ioctl_vol_args AUTO_KFREE(vol_args);
> struct btrfs_ioctl_vol_args_v2 AUTO_KFREE(vol_args2);
> - struct mnt_idmap *idmap = file_mnt_idmap(file);
> + const struct mnt_idmap *idmap = file_mnt_idmap(file);
> char *subvol_name, *subvol_name_ptr = NULL;
> int ret = 0;
> bool destroy_parent = false;
> diff --git a/fs/ceph/file.c b/fs/ceph/file.c
> index bd3e3f5c269e..2c994c08ed4b 100644
> --- a/fs/ceph/file.c
> +++ b/fs/ceph/file.c
> @@ -795,7 +795,7 @@ static int ceph_finish_async_create(struct inode *dir, struct inode *inode,
> int ceph_atomic_open(struct inode *dir, struct dentry *dentry,
> struct file *file, unsigned flags, umode_t mode)
> {
> - struct mnt_idmap *idmap = file_mnt_idmap(file);
> + const struct mnt_idmap *idmap = file_mnt_idmap(file);
> struct ceph_fs_client *fsc = ceph_sb_to_fs_client(dir->i_sb);
> struct ceph_client *cl = fsc->client;
> struct ceph_mds_client *mdsc = fsc->mdsc;
> diff --git a/fs/coredump.c b/fs/coredump.c
> index ac3cd74808c6..9f75e16d3b36 100644
> --- a/fs/coredump.c
> +++ b/fs/coredump.c
> @@ -878,7 +878,7 @@ static inline bool coredump_force_suid_safe(const struct coredump_params *cprm)
> static bool coredump_file(struct core_name *cn, struct coredump_params *cprm,
> const struct linux_binfmt *binfmt)
> {
> - struct mnt_idmap *idmap;
> + const struct mnt_idmap *idmap;
> struct inode *inode;
> struct file *file __free(fput) = NULL;
> int open_flags = O_CREAT | O_WRONLY | O_NOFOLLOW | O_LARGEFILE | O_EXCL;
> diff --git a/fs/exec.c b/fs/exec.c
> index 745f6eb5279e..a7785559d0d3 100644
> --- a/fs/exec.c
> +++ b/fs/exec.c
> @@ -1339,7 +1339,7 @@ EXPORT_SYMBOL(begin_new_exec);
> void would_dump(struct linux_binprm *bprm, struct file *file)
> {
> struct inode *inode = file_inode(file);
> - struct mnt_idmap *idmap = file_mnt_idmap(file);
> + const struct mnt_idmap *idmap = file_mnt_idmap(file);
> if (inode_permission(idmap, inode, MAY_READ) < 0) {
> struct user_namespace *old, *user_ns;
> bprm->interp_flags |= BINPRM_FLAGS_ENFORCE_NONDUMP;
> @@ -1623,7 +1623,7 @@ static void check_unsafe_exec(struct linux_binprm *bprm)
> static void bprm_fill_uid(struct linux_binprm *bprm, struct file *file)
> {
> /* Handle suid and sgid on files */
> - struct mnt_idmap *idmap;
> + const struct mnt_idmap *idmap;
> struct inode *inode = file_inode(file);
> unsigned int mode;
> vfsuid_t vfsuid;
> diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c
> index 2719f20493c8..0a54b00e5be5 100644
> --- a/fs/ext4/ioctl.c
> +++ b/fs/ext4/ioctl.c
> @@ -1539,7 +1539,7 @@ static long __ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
> {
> struct inode *inode = file_inode(filp);
> struct super_block *sb = inode->i_sb;
> - struct mnt_idmap *idmap = file_mnt_idmap(filp);
> + const struct mnt_idmap *idmap = file_mnt_idmap(filp);
>
> ext4_debug("cmd = %u, arg = %lu\n", cmd, arg);
>
> diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c
> index fb8b03a9972d..8596c3bc4704 100644
> --- a/fs/f2fs/file.c
> +++ b/fs/f2fs/file.c
> @@ -2361,7 +2361,7 @@ static int f2fs_ioc_getversion(struct file *filp, unsigned long arg)
> static int f2fs_ioc_start_atomic_write(struct file *filp, bool truncate)
> {
> struct inode *inode = file_inode(filp);
> - struct mnt_idmap *idmap = file_mnt_idmap(filp);
> + const struct mnt_idmap *idmap = file_mnt_idmap(filp);
> struct f2fs_inode_info *fi = F2FS_I(inode);
> struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
> loff_t isize;
> @@ -2473,7 +2473,7 @@ static int f2fs_ioc_start_atomic_write(struct file *filp, bool truncate)
> static int f2fs_ioc_commit_atomic_write(struct file *filp)
> {
> struct inode *inode = file_inode(filp);
> - struct mnt_idmap *idmap = file_mnt_idmap(filp);
> + const struct mnt_idmap *idmap = file_mnt_idmap(filp);
> int ret;
>
> if (!(filp->f_mode & FMODE_WRITE))
> @@ -2508,7 +2508,7 @@ static int f2fs_ioc_commit_atomic_write(struct file *filp)
> static int f2fs_ioc_abort_atomic_write(struct file *filp)
> {
> struct inode *inode = file_inode(filp);
> - struct mnt_idmap *idmap = file_mnt_idmap(filp);
> + const struct mnt_idmap *idmap = file_mnt_idmap(filp);
> int ret;
>
> if (!(filp->f_mode & FMODE_WRITE))
> diff --git a/fs/fhandle.c b/fs/fhandle.c
> index f8829231e3d7..2aa55b8a878a 100644
> --- a/fs/fhandle.c
> +++ b/fs/fhandle.c
> @@ -201,7 +201,7 @@ static int vfs_dentry_acceptable(void *context, struct dentry *dentry)
> struct handle_to_path_ctx *ctx = context;
> struct user_namespace *user_ns = current_user_ns();
> struct dentry *d, *root = ctx->root.dentry;
> - struct mnt_idmap *idmap = mnt_idmap(ctx->root.mnt);
> + const struct mnt_idmap *idmap = mnt_idmap(ctx->root.mnt);
> int retval = 0;
>
> if (!root)
> diff --git a/fs/file_attr.c b/fs/file_attr.c
> index 5393c4dfa4a8..81af4364e33a 100644
> --- a/fs/file_attr.c
> +++ b/fs/file_attr.c
> @@ -323,7 +323,7 @@ int ioctl_getflags(struct file *file, unsigned int __user *argp)
>
> int ioctl_setflags(struct file *file, unsigned int __user *argp)
> {
> - struct mnt_idmap *idmap = file_mnt_idmap(file);
> + const struct mnt_idmap *idmap = file_mnt_idmap(file);
> struct dentry *dentry = file->f_path.dentry;
> struct file_kattr fa = {};
> unsigned int flags;
> @@ -355,7 +355,7 @@ int ioctl_fsgetxattr(struct file *file, void __user *argp)
>
> int ioctl_fssetxattr(struct file *file, void __user *argp)
> {
> - struct mnt_idmap *idmap = file_mnt_idmap(file);
> + const struct mnt_idmap *idmap = file_mnt_idmap(file);
> struct dentry *dentry = file->f_path.dentry;
> struct file_kattr fa = {};
> int err;
> diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
> index 6d23878cfae5..1759f7fd72b0 100644
> --- a/fs/fuse/dir.c
> +++ b/fs/fuse/dir.c
> @@ -941,7 +941,7 @@ static int fuse_atomic_open(struct inode *dir, struct dentry *entry,
> umode_t mode)
> {
> int err;
> - struct mnt_idmap *idmap = file_mnt_idmap(file);
> + const struct mnt_idmap *idmap = file_mnt_idmap(file);
> struct fuse_conn *fc = get_fuse_conn(dir);
>
> if (fuse_is_bad(dir))
> diff --git a/fs/fuse/file.c b/fs/fuse/file.c
> index 8d6135a6108a..6ae350f8b486 100644
> --- a/fs/fuse/file.c
> +++ b/fs/fuse/file.c
> @@ -1487,7 +1487,7 @@ static const struct iomap_write_ops fuse_iomap_write_ops = {
> static ssize_t fuse_cache_write_iter(struct kiocb *iocb, struct iov_iter *from)
> {
> struct file *file = iocb->ki_filp;
> - struct mnt_idmap *idmap = file_mnt_idmap(file);
> + const struct mnt_idmap *idmap = file_mnt_idmap(file);
> struct address_space *mapping = file->f_mapping;
> ssize_t written = 0;
> struct inode *inode = mapping->host;
> diff --git a/fs/internal.h b/fs/internal.h
> index 973436f44770..3dda57fb3c7d 100644
> --- a/fs/internal.h
> +++ b/fs/internal.h
> @@ -327,7 +327,7 @@ ssize_t __kernel_write_iter(struct file *file, struct iov_iter *from, loff_t *po
> * fs/attr.c
> */
> struct mnt_idmap *alloc_mnt_idmap(struct user_namespace *mnt_userns);
> -struct mnt_idmap *mnt_idmap_get(const struct mnt_idmap *idmap);
> +const struct mnt_idmap *mnt_idmap_get(const struct mnt_idmap *idmap);
> void mnt_idmap_put(const struct mnt_idmap *idmap);
> struct stashed_operations {
> struct dentry *(*stash_dentry)(struct dentry **stashed,
> diff --git a/fs/mnt_idmapping.c b/fs/mnt_idmapping.c
> index 4d5fbf185608..26704eeb7318 100644
> --- a/fs/mnt_idmapping.c
> +++ b/fs/mnt_idmapping.c
> @@ -312,14 +312,14 @@ struct mnt_idmap *alloc_mnt_idmap(struct user_namespace *mnt_userns)
> *
> * Return: @idmap with reference count bumped if @not_mnt_idmap isn't passed.
> */
> -struct mnt_idmap *mnt_idmap_get(const struct mnt_idmap *idmap)
> +const struct mnt_idmap *mnt_idmap_get(const struct mnt_idmap *idmap)
> {
> struct mnt_idmap *nonconst_idmap = (struct mnt_idmap *)idmap;
>
> if (idmap != &nop_mnt_idmap && idmap != &invalid_mnt_idmap)
> refcount_inc(&nonconst_idmap->count);
>
> - return nonconst_idmap;
> + return idmap;
> }
> EXPORT_SYMBOL_GPL(mnt_idmap_get);
>
> diff --git a/fs/namei.c b/fs/namei.c
> index 14970fe08387..818444a52b88 100644
> --- a/fs/namei.c
> +++ b/fs/namei.c
> @@ -1273,7 +1273,7 @@ fs_initcall(init_fs_namei_sysctls);
> */
> static inline int may_follow_link(struct nameidata *nd, const struct inode *inode)
> {
> - struct mnt_idmap *idmap;
> + const struct mnt_idmap *idmap;
> vfsuid_t vfsuid;
>
> if (!sysctl_protected_symlinks)
> @@ -2596,7 +2596,7 @@ static int link_path_walk(const char *name, struct nameidata *nd)
>
> /* At this point we know we have a real path component. */
> for(;;) {
> - struct mnt_idmap *idmap;
> + const struct mnt_idmap *idmap;
> const char *link;
> unsigned long lastword;
>
> @@ -4432,7 +4432,7 @@ static struct dentry *lookup_open(struct nameidata *nd, struct file *file,
> const struct open_flags *op)
> {
> struct delegated_inode delegated_inode = { };
> - struct mnt_idmap *idmap;
> + const struct mnt_idmap *idmap;
> struct dentry *dir = nd->path.dentry;
> struct inode *dir_inode = dir->d_inode;
> int open_flag;
> @@ -4789,7 +4789,7 @@ static const char *open_last_lookups(struct nameidata *nd,
> static int do_open(struct nameidata *nd,
> struct file *file, const struct open_flags *op)
> {
> - struct mnt_idmap *idmap;
> + const struct mnt_idmap *idmap;
> int open_flag = op->open_flag;
> bool do_truncate;
> int acc_mode;
> @@ -5169,7 +5169,7 @@ struct file *dentry_create(struct path *path, int flags, umode_t mode,
> struct dentry *orig_dentry = dentry;
> struct dentry *dir = dentry->d_parent;
> struct inode *dir_inode = d_inode(dir);
> - struct mnt_idmap *idmap;
> + const struct mnt_idmap *idmap;
> int error, create_error;
>
> file = alloc_empty_file(flags, cred);
> @@ -5294,7 +5294,7 @@ int filename_mknodat(int dfd, struct filename *name, umode_t mode,
> unsigned int dev)
> {
> struct delegated_inode di = { };
> - struct mnt_idmap *idmap;
> + const struct mnt_idmap *idmap;
> struct dentry *dentry;
> struct path path;
> int error;
> @@ -5949,7 +5949,7 @@ EXPORT_SYMBOL(vfs_link);
> int filename_linkat(int olddfd, struct filename *old,
> int newdfd, struct filename *new, int flags)
> {
> - struct mnt_idmap *idmap;
> + const struct mnt_idmap *idmap;
> struct dentry *new_dentry;
> struct path old_path, new_path;
> struct delegated_inode delegated_inode = { };
> diff --git a/fs/namespace.c b/fs/namespace.c
> index 1ecd96c918b3..919c27724a59 100644
> --- a/fs/namespace.c
> +++ b/fs/namespace.c
> @@ -109,7 +109,7 @@ struct mount_kattr {
> unsigned int lookup_flags;
> enum mount_kattr_flags_t kflags;
> struct user_namespace *mnt_userns;
> - struct mnt_idmap *mnt_idmap;
> + const struct mnt_idmap *mnt_idmap;
> };
>
> /* /sys/fs */
> @@ -4898,7 +4898,7 @@ static int mount_setattr_prepare(struct mount_kattr *kattr, struct mount *mnt)
>
> static void do_idmap_mount(const struct mount_kattr *kattr, struct mount *mnt)
> {
> - struct mnt_idmap *old_idmap;
> + const struct mnt_idmap *old_idmap;
>
> if (!kattr->mnt_idmap)
> return;
> @@ -4941,7 +4941,7 @@ static int do_mount_setattr(const struct path *path, struct mount_kattr *kattr)
> return -EINVAL;
>
> if (kattr->mnt_userns) {
> - struct mnt_idmap *mnt_idmap;
> + const struct mnt_idmap *mnt_idmap;
>
> mnt_idmap = alloc_mnt_idmap(kattr->mnt_userns);
> if (IS_ERR(mnt_idmap))
> @@ -5246,7 +5246,7 @@ struct kstatmount {
> struct statmount __user *buf;
> size_t bufsize;
> struct vfsmount *mnt;
> - struct mnt_idmap *idmap;
> + const struct mnt_idmap *idmap;
> u64 mask;
> struct path root;
> struct seq_file seq;
> diff --git a/fs/open.c b/fs/open.c
> index 971e51008e67..031858d77fcc 100644
> --- a/fs/open.c
> +++ b/fs/open.c
> @@ -72,7 +72,7 @@ int do_truncate(const struct mnt_idmap *idmap, struct dentry *dentry,
>
> int vfs_truncate(const struct path *path, loff_t length)
> {
> - struct mnt_idmap *idmap;
> + const struct mnt_idmap *idmap;
> struct inode *inode;
> int error;
>
> @@ -787,7 +787,7 @@ static inline bool setattr_vfsgid(struct iattr *attr, kgid_t kgid)
>
> int chown_common(const struct path *path, uid_t user, gid_t group)
> {
> - struct mnt_idmap *idmap;
> + const struct mnt_idmap *idmap;
> struct user_namespace *fs_userns;
> struct inode *inode = path->dentry->d_inode;
> struct delegated_inode delegated_inode = { };
> diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c
> index f3d97eb146e8..7433220d4ad6 100644
> --- a/fs/overlayfs/file.c
> +++ b/fs/overlayfs/file.c
> @@ -30,7 +30,7 @@ static struct file *ovl_open_realfile(const struct file *file,
> {
> struct inode *realinode = d_inode(realpath->dentry);
> struct inode *inode = file_inode(file);
> - struct mnt_idmap *real_idmap;
> + const struct mnt_idmap *real_idmap;
> struct file *realfile;
> int flags = file->f_flags | OVL_OPEN_FLAGS;
> int acc_mode = ACC_MODE(flags);
> diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c
> index 622e9bb833af..70183d516e5e 100644
> --- a/fs/overlayfs/inode.c
> +++ b/fs/overlayfs/inode.c
> @@ -406,7 +406,7 @@ struct posix_acl *ovl_get_acl_path(const struct path *path,
> const char *acl_name, bool noperm)
> {
> struct posix_acl *real_acl, *clone;
> - struct mnt_idmap *idmap;
> + const struct mnt_idmap *idmap;
> struct inode *realinode = d_inode(path->dentry);
>
> idmap = mnt_idmap(path->mnt);
> diff --git a/fs/overlayfs/ovl_entry.h b/fs/overlayfs/ovl_entry.h
> index 80cad4ea96a3..ac07e8769f9b 100644
> --- a/fs/overlayfs/ovl_entry.h
> +++ b/fs/overlayfs/ovl_entry.h
> @@ -105,7 +105,7 @@ static inline struct vfsmount *ovl_upper_mnt(struct ovl_fs *ofs)
> return ofs->layers[0].mnt;
> }
>
> -static inline struct mnt_idmap *ovl_upper_mnt_idmap(struct ovl_fs *ofs)
> +static inline const struct mnt_idmap *ovl_upper_mnt_idmap(struct ovl_fs *ofs)
> {
> return mnt_idmap(ovl_upper_mnt(ofs));
> }
> diff --git a/fs/overlayfs/util.c b/fs/overlayfs/util.c
> index b41f4788e4f0..521717209b2e 100644
> --- a/fs/overlayfs/util.c
> +++ b/fs/overlayfs/util.c
> @@ -657,7 +657,7 @@ bool ovl_path_is_whiteout(struct ovl_fs *ofs, const struct path *path)
> struct file *ovl_path_open(const struct path *path, int flags)
> {
> struct inode *inode = d_inode(path->dentry);
> - struct mnt_idmap *real_idmap = mnt_idmap(path->mnt);
> + const struct mnt_idmap *real_idmap = mnt_idmap(path->mnt);
> int err, acc_mode;
>
> if (flags & ~(O_ACCMODE | O_LARGEFILE))
> @@ -1496,7 +1496,7 @@ void ovl_copyattr(struct inode *inode)
> {
> struct path realpath;
> struct inode *realinode;
> - struct mnt_idmap *real_idmap;
> + const struct mnt_idmap *real_idmap;
> vfsuid_t vfsuid;
> vfsgid_t vfsgid;
>
> diff --git a/fs/remap_range.c b/fs/remap_range.c
> index 26afbbbfb10c..6eb7d845de5d 100644
> --- a/fs/remap_range.c
> +++ b/fs/remap_range.c
> @@ -415,7 +415,7 @@ EXPORT_SYMBOL(vfs_clone_file_range);
> /* Check whether we are allowed to dedupe the destination file */
> static bool may_dedupe_file(struct file *file)
> {
> - struct mnt_idmap *idmap = file_mnt_idmap(file);
> + const struct mnt_idmap *idmap = file_mnt_idmap(file);
> struct inode *inode = file_inode(file);
>
> if (capable(CAP_SYS_ADMIN))
> diff --git a/fs/smb/server/oplock.c b/fs/smb/server/oplock.c
> index 58af0fddf39f..341a812da3a8 100644
> --- a/fs/smb/server/oplock.c
> +++ b/fs/smb/server/oplock.c
> @@ -2229,7 +2229,7 @@ void create_posix_rsp_buf(char *cc, struct ksmbd_file *fp)
> {
> struct create_posix_rsp *buf;
> struct inode *inode = file_inode(fp->filp);
> - struct mnt_idmap *idmap = file_mnt_idmap(fp->filp);
> + const struct mnt_idmap *idmap = file_mnt_idmap(fp->filp);
> vfsuid_t vfsuid = i_uid_into_vfsuid(idmap, inode);
> vfsgid_t vfsgid = i_gid_into_vfsgid(idmap, inode);
>
> diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c
> index 0789200d602f..e2dcf8228fa4 100644
> --- a/fs/smb/server/smb2pdu.c
> +++ b/fs/smb/server/smb2pdu.c
> @@ -3234,7 +3234,7 @@ static bool smb2_is_private_ea(const char *name, size_t name_len)
> static int smb2_set_ea(struct smb2_ea_info *eabuf, unsigned int buf_len,
> const struct path *path, bool get_write)
> {
> - struct mnt_idmap *idmap = mnt_idmap(path->mnt);
> + const struct mnt_idmap *idmap = mnt_idmap(path->mnt);
> char *attr_name = NULL, *value;
> int rc = 0;
> unsigned int next = 0;
> @@ -3335,7 +3335,7 @@ static noinline int smb2_set_stream_name_xattr(const struct path *path,
> struct ksmbd_file *fp,
> char *stream_name, int s_type)
> {
> - struct mnt_idmap *idmap = mnt_idmap(path->mnt);
> + const struct mnt_idmap *idmap = mnt_idmap(path->mnt);
> size_t xattr_stream_size;
> char *xattr_stream_name;
> int rc;
> @@ -3411,7 +3411,7 @@ static loff_t ksmbd_stream_eof(struct ksmbd_file *fp)
>
> static int smb2_remove_smb_xattrs(const struct path *path)
> {
> - struct mnt_idmap *idmap = mnt_idmap(path->mnt);
> + const struct mnt_idmap *idmap = mnt_idmap(path->mnt);
> char *name, *xattr_list = NULL;
> ssize_t xattr_list_len;
> int err = 0;
> @@ -4088,7 +4088,7 @@ int smb2_open(struct ksmbd_work *work)
> struct ksmbd_share_config *share = tcon->share_conf;
> struct ksmbd_file *fp = NULL;
> struct file *filp = NULL;
> - struct mnt_idmap *idmap = NULL;
> + const struct mnt_idmap *idmap = NULL;
> struct kstat stat;
> struct create_context *context;
> struct lease_ctx_info *lc = NULL;
> @@ -5753,7 +5753,7 @@ struct smb2_query_dir_private {
>
> static int process_query_dir_entries(struct smb2_query_dir_private *priv)
> {
> - struct mnt_idmap *idmap = file_mnt_idmap(priv->dir_fp->filp);
> + const struct mnt_idmap *idmap = file_mnt_idmap(priv->dir_fp->filp);
> struct kstat kstat;
> struct ksmbd_kstat ksmbd_kstat;
> int rc;
> @@ -6352,7 +6352,7 @@ static int smb2_get_ea(struct ksmbd_work *work, struct ksmbd_file *fp,
> ssize_t buf_free_len, alignment_bytes, next_offset, rsp_data_cnt = 0;
> struct smb2_ea_info_req *ea_req = NULL;
> const struct path *path;
> - struct mnt_idmap *idmap = file_mnt_idmap(fp->filp);
> + const struct mnt_idmap *idmap = file_mnt_idmap(fp->filp);
>
> if (!(fp->daccess & FILE_READ_EA_LE)) {
> pr_err("Not permitted to read ext attr : 0x%x\n",
> @@ -7062,7 +7062,7 @@ static int find_file_posix_info(struct smb2_query_info_rsp *rsp,
> {
> struct smb311_posix_qinfo *file_info;
> struct inode *inode = file_inode(fp->filp);
> - struct mnt_idmap *idmap = file_mnt_idmap(fp->filp);
> + const struct mnt_idmap *idmap = file_mnt_idmap(fp->filp);
> vfsuid_t vfsuid = i_uid_into_vfsuid(idmap, inode);
> vfsgid_t vfsgid = i_gid_into_vfsgid(idmap, inode);
> struct kstat stat;
> @@ -7547,7 +7547,7 @@ static int smb2_get_info_sec(struct ksmbd_work *work,
> struct smb2_query_info_rsp *rsp)
> {
> struct ksmbd_file *fp;
> - struct mnt_idmap *idmap;
> + const struct mnt_idmap *idmap;
> struct smb_ntsd *pntsd = NULL, *ppntsd = NULL;
> struct smb_fattr fattr = {{0}};
> struct inode *inode;
> @@ -8060,7 +8060,7 @@ static int set_file_basic_info(struct ksmbd_file *fp,
> struct iattr attrs;
> struct file *filp;
> struct inode *inode;
> - struct mnt_idmap *idmap;
> + const struct mnt_idmap *idmap;
> __le32 attrs_mask = FILE_ATTRIBUTE_DIRECTORY_LE |
> FILE_ATTRIBUTE_COMPRESSED_LE;
> int rc = 0;
> @@ -10652,7 +10652,7 @@ static inline int fsctl_set_sparse(struct ksmbd_work *work, u64 id,
> struct file_sparse *sparse)
> {
> struct ksmbd_file *fp;
> - struct mnt_idmap *idmap;
> + const struct mnt_idmap *idmap;
> int ret = 0;
> __le32 old_fattr;
>
> diff --git a/fs/smb/server/smb_common.c b/fs/smb/server/smb_common.c
> index 4c2da65510bc..ec6ee56293ce 100644
> --- a/fs/smb/server/smb_common.c
> +++ b/fs/smb/server/smb_common.c
> @@ -467,7 +467,7 @@ int ksmbd_populate_dot_dotdot_entries(struct ksmbd_work *work, int info_level,
> {
> int i, rc = 0;
> struct ksmbd_conn *conn = work->conn;
> - struct mnt_idmap *idmap = file_mnt_idmap(dir->filp);
> + const struct mnt_idmap *idmap = file_mnt_idmap(dir->filp);
>
> for (i = 0; i < 2; i++) {
> struct kstat kstat;
> diff --git a/fs/smb/server/smbacl.c b/fs/smb/server/smbacl.c
> index 915dbfab62ea..784067d14f56 100644
> --- a/fs/smb/server/smbacl.c
> +++ b/fs/smb/server/smbacl.c
> @@ -1183,7 +1183,7 @@ int smb_inherit_dacl(struct ksmbd_conn *conn,
> struct smb_ntsd *parent_pntsd = NULL;
> struct smb_sid owner_sid, group_sid;
> struct dentry *parent = path->dentry->d_parent;
> - struct mnt_idmap *idmap = mnt_idmap(path->mnt);
> + const struct mnt_idmap *idmap = mnt_idmap(path->mnt);
> int inherited_flags = 0, flags = 0, i, nt_size = 0, pdacl_size;
> int rc = 0, pntsd_type, ppntsd_size, acl_len, aces_size;
> unsigned int dacloffset;
> @@ -1438,7 +1438,7 @@ int smb_check_perm_dacl(struct ksmbd_conn *conn, const struct path *path,
> __le32 *pdaccess, __le32 raw_daccess, int uid,
> bool strict)
> {
> - struct mnt_idmap *idmap = mnt_idmap(path->mnt);
> + const struct mnt_idmap *idmap = mnt_idmap(path->mnt);
> struct smb_ntsd *pntsd = NULL;
> struct smb_acl *pdacl;
> struct posix_acl *posix_acls;
> @@ -1660,7 +1660,7 @@ int set_info_sec(struct ksmbd_conn *conn, struct ksmbd_tree_connect *tcon,
> int rc;
> struct smb_fattr fattr = {{0}};
> struct inode *inode = d_inode(path->dentry);
> - struct mnt_idmap *idmap = mnt_idmap(path->mnt);
> + const struct mnt_idmap *idmap = mnt_idmap(path->mnt);
> struct iattr newattrs;
>
> fattr.cf_uid = INVALID_UID;
> diff --git a/fs/smb/server/vfs.c b/fs/smb/server/vfs.c
> index 75edff8dde31..ccfdc726d063 100644
> --- a/fs/smb/server/vfs.c
> +++ b/fs/smb/server/vfs.c
> @@ -183,7 +183,7 @@ int ksmbd_vfs_create(struct ksmbd_work *work, const char *name, umode_t mode)
> */
> int ksmbd_vfs_mkdir(struct ksmbd_work *work, const char *name, umode_t mode)
> {
> - struct mnt_idmap *idmap;
> + const struct mnt_idmap *idmap;
> struct path path;
> struct dentry *dentry, *d;
> int err = 0;
> @@ -386,7 +386,7 @@ static int ksmbd_vfs_stream_write(struct ksmbd_file *fp, char *buf, loff_t *pos,
> {
> const struct cred *saved_cred;
> char *stream_buf = NULL, *wbuf;
> - struct mnt_idmap *idmap = file_mnt_idmap(fp->filp);
> + const struct mnt_idmap *idmap = file_mnt_idmap(fp->filp);
> size_t size;
> ssize_t v_len;
> int err = 0;
> @@ -577,7 +577,7 @@ int ksmbd_vfs_fsync(struct ksmbd_work *work, u64 fid, u64 p_id)
> */
> int ksmbd_vfs_remove_file(struct ksmbd_work *work, const struct path *path)
> {
> - struct mnt_idmap *idmap;
> + const struct mnt_idmap *idmap;
> struct dentry *parent = path->dentry->d_parent;
> int err;
>
> @@ -1202,7 +1202,7 @@ int ksmbd_vfs_unlink(struct file *filp)
> const struct cred *saved_cred;
> int err = 0;
> struct dentry *dir, *dentry = filp->f_path.dentry;
> - struct mnt_idmap *idmap = file_mnt_idmap(filp);
> + const struct mnt_idmap *idmap = file_mnt_idmap(filp);
>
> saved_cred = override_creds(filp->f_cred);
> err = mnt_want_write(filp->f_path.mnt);
> @@ -2316,7 +2316,7 @@ static int __ksmbd_vfs_set_compression(struct ksmbd_work *work,
> const struct cred *saved_cred = NULL;
> struct file_kattr fa;
> struct dentry *dentry = fp->filp->f_path.dentry;
> - struct mnt_idmap *idmap = file_mnt_idmap(fp->filp);
> + const struct mnt_idmap *idmap = file_mnt_idmap(fp->filp);
> u32 flags;
> __le32 old_fattr;
> int rc;
> diff --git a/fs/stat.c b/fs/stat.c
> index fe351818d1d6..a9b7383d538d 100644
> --- a/fs/stat.c
> +++ b/fs/stat.c
> @@ -181,7 +181,7 @@ EXPORT_SYMBOL_GPL(generic_fill_statx_atomic_writes);
> int vfs_getattr_nosec(const struct path *path, struct kstat *stat,
> u32 request_mask, unsigned int query_flags)
> {
> - struct mnt_idmap *idmap;
> + const struct mnt_idmap *idmap;
> struct inode *inode = d_backing_inode(path->dentry);
>
> memset(stat, 0, sizeof(*stat));
> diff --git a/include/linux/fs.h b/include/linux/fs.h
> index 935b0f92786f..ca3e9d4797ee 100644
> --- a/include/linux/fs.h
> +++ b/include/linux/fs.h
> @@ -2459,7 +2459,7 @@ struct filename {
> static_assert(offsetof(struct filename, iname) % sizeof(long) == 0);
> static_assert(sizeof(struct filename) % 64 == 0);
>
> -static inline struct mnt_idmap *file_mnt_idmap(const struct file *file)
> +static inline const struct mnt_idmap *file_mnt_idmap(const struct file *file)
> {
> return mnt_idmap(file->f_path.mnt);
> }
> diff --git a/include/linux/mnt_idmapping.h b/include/linux/mnt_idmapping.h
> index 6656aea23be2..b445c7660040 100644
> --- a/include/linux/mnt_idmapping.h
> +++ b/include/linux/mnt_idmapping.h
> @@ -121,7 +121,7 @@ static inline bool vfsgid_eq_kgid(vfsgid_t vfsgid, kgid_t kgid)
>
> int vfsgid_in_group_p(vfsgid_t vfsgid);
>
> -struct mnt_idmap *mnt_idmap_get(const struct mnt_idmap *idmap);
> +const struct mnt_idmap *mnt_idmap_get(const struct mnt_idmap *idmap);
> void mnt_idmap_put(const struct mnt_idmap *idmap);
>
> vfsuid_t make_vfsuid(const struct mnt_idmap *idmap,
> diff --git a/include/linux/mount.h b/include/linux/mount.h
> index acfe7ef86a1b..e90ccafef281 100644
> --- a/include/linux/mount.h
> +++ b/include/linux/mount.h
> @@ -59,10 +59,10 @@ struct vfsmount {
> struct dentry *mnt_root; /* root of the mounted tree */
> struct super_block *mnt_sb; /* pointer to superblock */
> int mnt_flags;
> - struct mnt_idmap *mnt_idmap;
> + const struct mnt_idmap *mnt_idmap;
> } __randomize_layout;
>
> -static inline struct mnt_idmap *mnt_idmap(const struct vfsmount *mnt)
> +static inline const struct mnt_idmap *mnt_idmap(const struct vfsmount *mnt)
> {
> /* Pairs with smp_store_release() in do_idmap_mount(). */
> return READ_ONCE(mnt->mnt_idmap);
> diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
> index 13f9926bf205..56e1bf51ffe5 100644
> --- a/net/unix/af_unix.c
> +++ b/net/unix/af_unix.c
> @@ -1361,7 +1361,7 @@ static int unix_bind_bsd(struct sock *sk, struct sockaddr_un *sunaddr,
> struct unix_sock *u = unix_sk(sk);
> unsigned int new_hash, old_hash;
> struct net *net = sock_net(sk);
> - struct mnt_idmap *idmap;
> + const struct mnt_idmap *idmap;
> struct unix_address *addr;
> struct dentry *dentry;
> struct path parent;
> diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
> index d502ad0ac26f..c73681d820a0 100644
> --- a/security/apparmor/lsm.c
> +++ b/security/apparmor/lsm.c
> @@ -397,7 +397,7 @@ static int apparmor_path_rename(const struct path *old_dir, struct dentry *old_d
>
> label = begin_current_label_crit_section(&needput);
> if (!unconfined(label)) {
> - struct mnt_idmap *idmap = mnt_idmap(old_dir->mnt);
> + const struct mnt_idmap *idmap = mnt_idmap(old_dir->mnt);
> vfsuid_t vfsuid;
> struct path old_path = { .mnt = old_dir->mnt,
> .dentry = old_dentry };
> @@ -485,7 +485,7 @@ static int apparmor_file_open(struct file *file)
>
> label = aa_get_newest_cred_label_condref(file->f_cred, &needput);
> if (!unconfined(label)) {
> - struct mnt_idmap *idmap = file_mnt_idmap(file);
> + const struct mnt_idmap *idmap = file_mnt_idmap(file);
> struct inode *inode = file_inode(file);
> vfsuid_t vfsuid;
> struct path_cond cond = {
>
> --
> 2.53.0
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 62+ messages in thread
* [PATCH 27/27] fs: make nop_mnt_idmap and invalid_mnt_idmap const
2026-09-01 12:14 [PATCH 00/27] fs: port to const struct mnt_idmap Christian Brauner
` (25 preceding siblings ...)
2026-09-01 12:14 ` [PATCH 26/27] fs: port mnt_idmap() and file_mnt_idmap() " Christian Brauner
@ 2026-09-01 12:14 ` Christian Brauner
2026-09-02 16:07 ` Jan Kara
26 siblings, 1 reply; 62+ messages in thread
From: Christian Brauner @ 2026-09-01 12:14 UTC (permalink / raw)
To: linux-fsdevel
Cc: Alexander Viro, Jan Kara, Christoph Hellwig, Seth Forshee,
Paul Moore, linux-security-module, Mimi Zohar, linux-integrity,
Ilya Dryomov, ceph-devel, Carlos Maiolino, linux-xfs,
Miklos Szeredi, Amir Goldstein, linux-unionfs, Namjae Jeon,
linux-cifs, linux-kernel, Christian Brauner (Amutable)
Make both static maps const so they end up in rodata. Any attempt to
modify them now faults instead of silently corrupting the initial
idmapping.
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
---
fs/mnt_idmapping.c | 4 ++--
include/linux/mnt_idmapping.h | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/fs/mnt_idmapping.c b/fs/mnt_idmapping.c
index 26704eeb7318..bed57094cef0 100644
--- a/fs/mnt_idmapping.c
+++ b/fs/mnt_idmapping.c
@@ -28,7 +28,7 @@ struct mnt_idmap {
* mapping. This means that {g,u}id 0 is mapped to {g,u}id 0, {g,u}id 1 is
* mapped to {g,u}id 1, [...], {g,u}id 1000 to {g,u}id 1000, [...].
*/
-struct mnt_idmap nop_mnt_idmap = {
+const struct mnt_idmap nop_mnt_idmap = {
.count = REFCOUNT_INIT(1),
};
EXPORT_SYMBOL_GPL(nop_mnt_idmap);
@@ -37,7 +37,7 @@ EXPORT_SYMBOL_GPL(nop_mnt_idmap);
* Carries the invalid idmapping of a full 0-4294967295 {g,u}id range.
* This means that all {g,u}ids are mapped to INVALID_VFS{G,U}ID.
*/
-struct mnt_idmap invalid_mnt_idmap = {
+const struct mnt_idmap invalid_mnt_idmap = {
.count = REFCOUNT_INIT(1),
};
EXPORT_SYMBOL_GPL(invalid_mnt_idmap);
diff --git a/include/linux/mnt_idmapping.h b/include/linux/mnt_idmapping.h
index b445c7660040..78eeef4c2996 100644
--- a/include/linux/mnt_idmapping.h
+++ b/include/linux/mnt_idmapping.h
@@ -8,8 +8,8 @@
struct mnt_idmap;
struct user_namespace;
-extern struct mnt_idmap nop_mnt_idmap;
-extern struct mnt_idmap invalid_mnt_idmap;
+extern const struct mnt_idmap nop_mnt_idmap;
+extern const struct mnt_idmap invalid_mnt_idmap;
extern struct user_namespace init_user_ns;
typedef struct {
--
2.53.0
^ permalink raw reply related [flat|nested] 62+ messages in thread* Re: [PATCH 27/27] fs: make nop_mnt_idmap and invalid_mnt_idmap const
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
0 siblings, 0 replies; 62+ messages in thread
From: Jan Kara @ 2026-09-02 16:07 UTC (permalink / raw)
To: Christian Brauner
Cc: linux-fsdevel, Alexander Viro, Jan Kara, Christoph Hellwig,
Seth Forshee, Paul Moore, linux-security-module, Mimi Zohar,
linux-integrity, Ilya Dryomov, ceph-devel, Carlos Maiolino,
linux-xfs, Miklos Szeredi, Amir Goldstein, linux-unionfs,
Namjae Jeon, linux-cifs, linux-kernel
On Tue 01-09-26 14:14:52, Christian Brauner wrote:
> Make both static maps const so they end up in rodata. Any attempt to
> modify them now faults instead of silently corrupting the initial
> idmapping.
>
> Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> fs/mnt_idmapping.c | 4 ++--
> include/linux/mnt_idmapping.h | 4 ++--
> 2 files changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/fs/mnt_idmapping.c b/fs/mnt_idmapping.c
> index 26704eeb7318..bed57094cef0 100644
> --- a/fs/mnt_idmapping.c
> +++ b/fs/mnt_idmapping.c
> @@ -28,7 +28,7 @@ struct mnt_idmap {
> * mapping. This means that {g,u}id 0 is mapped to {g,u}id 0, {g,u}id 1 is
> * mapped to {g,u}id 1, [...], {g,u}id 1000 to {g,u}id 1000, [...].
> */
> -struct mnt_idmap nop_mnt_idmap = {
> +const struct mnt_idmap nop_mnt_idmap = {
> .count = REFCOUNT_INIT(1),
> };
> EXPORT_SYMBOL_GPL(nop_mnt_idmap);
> @@ -37,7 +37,7 @@ EXPORT_SYMBOL_GPL(nop_mnt_idmap);
> * Carries the invalid idmapping of a full 0-4294967295 {g,u}id range.
> * This means that all {g,u}ids are mapped to INVALID_VFS{G,U}ID.
> */
> -struct mnt_idmap invalid_mnt_idmap = {
> +const struct mnt_idmap invalid_mnt_idmap = {
> .count = REFCOUNT_INIT(1),
> };
> EXPORT_SYMBOL_GPL(invalid_mnt_idmap);
> diff --git a/include/linux/mnt_idmapping.h b/include/linux/mnt_idmapping.h
> index b445c7660040..78eeef4c2996 100644
> --- a/include/linux/mnt_idmapping.h
> +++ b/include/linux/mnt_idmapping.h
> @@ -8,8 +8,8 @@
> struct mnt_idmap;
> struct user_namespace;
>
> -extern struct mnt_idmap nop_mnt_idmap;
> -extern struct mnt_idmap invalid_mnt_idmap;
> +extern const struct mnt_idmap nop_mnt_idmap;
> +extern const struct mnt_idmap invalid_mnt_idmap;
> extern struct user_namespace init_user_ns;
>
> typedef struct {
>
> --
> 2.53.0
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
^ permalink raw reply [flat|nested] 62+ messages in thread