@@ -17,12 +17,6 @@
#define VFSUIDT_INIT_RAW(val) (vfsuid_t){ val }
#define VFSGIDT_INIT_RAW(val) (vfsgid_t){ val }
-struct mnt_idmap {
- struct uid_gid_map uid_map;
- struct uid_gid_map gid_map;
- refcount_t count;
-};
-
/*
* Carries the initial idmapping of 0:0:4294967295 which is an identity
* mapping. This means that {g,u}id 0 is mapped to {g,u}id 0, {g,u}id 1 is
@@ -8,6 +8,13 @@
struct mnt_idmap;
struct user_namespace;
+/* Don't touch directly! All fields private. */
+struct mnt_idmap {
+ struct uid_gid_map uid_map;
+ struct uid_gid_map gid_map;
+ refcount_t count;
+};
+
extern struct mnt_idmap nop_mnt_idmap;
extern struct mnt_idmap invalid_mnt_idmap;
extern struct user_namespace init_user_ns;
@@ -17,7 +17,28 @@
struct user_namespace;
extern struct user_namespace init_user_ns;
-struct uid_gid_map;
+
+#define UID_GID_MAP_MAX_BASE_EXTENTS 5
+#define UID_GID_MAP_MAX_EXTENTS 340
+
+struct uid_gid_extent {
+ u32 first;
+ u32 lower_first;
+ u32 count;
+};
+
+struct uid_gid_map { /* 64 bytes -- 1 cache line */
+ union {
+ struct {
+ struct uid_gid_extent extent[UID_GID_MAP_MAX_BASE_EXTENTS];
+ u32 nr_extents;
+ };
+ struct {
+ struct uid_gid_extent *forward;
+ struct uid_gid_extent *reverse;
+ };
+ };
+};
#define KUIDT_INIT(value) (kuid_t){ value }
#define KGIDT_INIT(value) (kgid_t){ value }
@@ -12,28 +12,7 @@
#include <linux/rwsem.h>
#include <linux/sysctl.h>
#include <linux/err.h>
-
-#define UID_GID_MAP_MAX_BASE_EXTENTS 5
-#define UID_GID_MAP_MAX_EXTENTS 340
-
-struct uid_gid_extent {
- u32 first;
- u32 lower_first;
- u32 count;
-};
-
-struct uid_gid_map { /* 64 bytes -- 1 cache line */
- union {
- struct {
- struct uid_gid_extent extent[UID_GID_MAP_MAX_BASE_EXTENTS];
- u32 nr_extents;
- };
- struct {
- struct uid_gid_extent *forward;
- struct uid_gid_extent *reverse;
- };
- };
-};
+#include <linux/uidgid.h>
#define USERNS_SETGROUPS_ALLOWED 1UL
The next patch will inline all current helpers for that we need access to struct mnt_idmap internals from the header. Not my favorite but whatever. Signed-off-by: Christian Brauner <brauner@kernel.org> --- fs/mnt_idmapping.c | 6 ------ include/linux/mnt_idmapping.h | 7 +++++++ include/linux/uidgid.h | 23 ++++++++++++++++++++++- include/linux/user_namespace.h | 23 +---------------------- 4 files changed, 30 insertions(+), 29 deletions(-)