linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Christian Brauner <brauner@kernel.org>
To: Linus Torvalds <torvalds@linux-foundation.org>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>
Cc: Christian Brauner <brauner@kernel.org>,
	Mateusz Guzik <mjguzik@gmail.com>,
	Al Viro <viro@zeniv.linux.org.uk>, Jan Kara <jack@suse.cz>,
	Jeff Layton <jlayton@kernel.org>,
	Josef Bacik <josef@toxicpanda.com>
Subject: [PATCH RFC 2/3] mnt_idmapping: add struct mnt_idmap to header
Date: Wed, 16 Apr 2025 15:17:23 +0200	[thread overview]
Message-ID: <20250416-work-mnt_idmap-s_user_ns-v1-2-273bef3a61ec@kernel.org> (raw)
In-Reply-To: <20250416-work-mnt_idmap-s_user_ns-v1-0-273bef3a61ec@kernel.org>

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(-)

diff --git a/fs/mnt_idmapping.c b/fs/mnt_idmapping.c
index 8f7ae908ea16..5c7e1db8fef8 100644
--- a/fs/mnt_idmapping.c
+++ b/fs/mnt_idmapping.c
@@ -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
diff --git a/include/linux/mnt_idmapping.h b/include/linux/mnt_idmapping.h
index 85553b3a7904..4410672c2828 100644
--- a/include/linux/mnt_idmapping.h
+++ b/include/linux/mnt_idmapping.h
@@ -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;
diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
index 2dc767e08f54..5696c870fd0b 100644
--- a/include/linux/uidgid.h
+++ b/include/linux/uidgid.h
@@ -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 }
diff --git a/include/linux/user_namespace.h b/include/linux/user_namespace.h
index a0bb6d012137..6feae94c3661 100644
--- a/include/linux/user_namespace.h
+++ b/include/linux/user_namespace.h
@@ -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
 

-- 
2.47.2


  parent reply	other threads:[~2025-04-16 13:17 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-31  4:16 generic_permission() optimization Linus Torvalds
2024-10-31  6:05 ` Al Viro
2024-10-31  6:42   ` Linus Torvalds
2024-10-31 18:14     ` Linus Torvalds
2024-10-31 22:28       ` Al Viro
2024-10-31 22:34         ` Linus Torvalds
2024-11-01  1:17           ` Linus Torvalds
2024-11-01  1:27             ` Al Viro
2024-11-01 13:15             ` Christian Brauner
2024-10-31 13:02 ` Christian Brauner
2024-10-31 19:04   ` Linus Torvalds
2024-10-31 22:02     ` Linus Torvalds
2024-10-31 22:31       ` Linus Torvalds
2024-11-07 19:54         ` Linus Torvalds
2024-11-07 22:22           ` Mateusz Guzik
2024-11-07 22:49             ` Linus Torvalds
2025-04-12 16:26               ` Mateusz Guzik
2025-04-12 20:22                 ` Linus Torvalds
2025-04-14 10:21                   ` Christian Brauner
2025-04-16 13:17                     ` [PATCH RFC 0/3] mnt_idmapping: avoid pointer chase & inline low-level helpers Christian Brauner
2025-04-16 13:17                       ` [PATCH RFC 1/3] inode: add fastpath for filesystem user namespace retrieval Christian Brauner
2025-04-16 13:49                         ` Mateusz Guzik
2025-04-16 14:14                           ` Christian Brauner
2025-04-22 10:37                         ` Jan Kara
2025-04-22 13:33                           ` Mateusz Guzik
2025-04-22 14:05                             ` Christian Brauner
2025-04-16 13:17                       ` Christian Brauner [this message]
2025-04-16 13:17                       ` [PATCH RFC 3/3] mnt_idmapping: inline all low-level helpers Christian Brauner
2025-04-16 15:04                         ` Linus Torvalds
2025-04-22  9:28                           ` Christian Brauner
2025-04-12 21:52                 ` generic_permission() optimization Theodore Ts'o
2025-04-12 22:36                   ` Linus Torvalds
2025-04-12 23:12                     ` Linus Torvalds
2025-04-12 23:55                     ` Theodore Ts'o
2025-04-13  9:41                       ` Mateusz Guzik
2025-04-13 12:40                         ` Theodore Ts'o
2025-04-13 12:52                           ` Mateusz Guzik
2025-04-13 17:29                             ` Theodore Ts'o
2025-11-05 11:50                           ` Mateusz Guzik
2025-11-05 11:51                             ` Mateusz Guzik
2025-11-05 13:37                               ` Jan Kara
2025-11-17 11:42                                 ` Mateusz Guzik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250416-work-mnt_idmap-s_user_ns-v1-2-273bef3a61ec@kernel.org \
    --to=brauner@kernel.org \
    --cc=jack@suse.cz \
    --cc=jlayton@kernel.org \
    --cc=josef@toxicpanda.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=mjguzik@gmail.com \
    --cc=torvalds@linux-foundation.org \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).