fs: make nop_mnt_idmap and invalid_mnt_idmap const

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.

Link: https://patch.msgid.link/20260901-work-idmap-const-v1-27-54ccd48e100b@kernel.org
Reviewed-by: Jan Kara <jack@suse.cz>
Reviewed-by: Seth Forshee <sforshee@kernel.org>
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
This commit is contained in:
Christian Brauner 2026-09-01 14:14:52 +02:00
parent 025756ee7b
commit 04fcaedd25
No known key found for this signature in database
GPG Key ID: 91C61BC06578DCA2
2 changed files with 4 additions and 4 deletions

View File

@ -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);

View File

@ -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 {