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/[email protected]
Reviewed-by: Jan Kara <[email protected]>
Reviewed-by: Seth Forshee <[email protected]>
Signed-off-by: Christian Brauner (Amutable) <[email protected]>
This commit is contained in:
Christian Brauner
2026-09-23 09:19:52 +02:00
parent 025756ee7b
commit 04fcaedd25
2 changed files with 4 additions and 4 deletions
+2 -2
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);
+2 -2
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 {