From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795910342; b=k1ZkwryVpHNsNn+Gp1OA6JiF5RnL8WhHPibohUXG/Vsrhce5GWSlQZS9eJS83rco/EXb WkFxDSqmnrxtmZDf+owvUMjrdVPf2VO1Ay2ZqtKnIAS96bRy3TSCxWhCupSEwlfoK0eyD 2dKLXY6Pwm3r1slKW0t6s/OPBoiG3AMJVh6OCBfBLw+QukFKo1z3VuxKGuBX3hlEDlTP5 PS1uViEkiEIGm3CrpjsrPzAqPn6hKC9+1SsoTEsSirODLuKraJtUHtYIcfKgI4lZPuM7v 3kMVPLIBTI0xf2g/PbtyUWjd3znT0HUsn0HwvjvxGIX6N+tQoVeJn3cXyGnR6KKnuNg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795910342; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=ujYt3pxK39YV6xgrJ9ycAzI8XphJxsY1pHf5v0/Q8cY=; b=DTqMRQaN9EYV6X1PE0N+u0n2kU8cS8CJyckX+OoLuTe9UBXqi778zNpmVrME3tLecfg6 wrk+HCrPBN1ZYLRELXSLdGXEH+WBrP2kq9FT+osDXemb3YVuxqkUJLZ5mswWtgpcL4L9a 27lq7414Krdc5cKeuDqIQP6Ez+hTSENWqjMZLBDCEluAnYwkvZunprQ2fPdPdpFAKsqjw +b6Y8oc7gaRfr8GJUNUKEDx16bw7lh8Qgby4KJi09GoaZrgeQK5Wws7zE1AMKy8VeWbrx I6bkeY5dU28Hh+l9q3/9Rz9gTYYtYfzGvI6mZeXGyGarHTu4YTns+T1YbqpDD8lOEPw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=TOn8BcT+; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with UTF8SMTPS id 44280606A31C; Sat, 28 Nov 2026 23:59:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=TOn8BcT+ Received: by smtp.kernel.org (Postfix) with UTF8SMTPSA id 614031F00899; Sat, 28 Nov 2026 23:59:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795910342; bh=ujYt3pxK39YV6xgrJ9ycAzI8XphJxsY1pHf5v0/Q8cY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=TOn8BcT+ijwtTD/vKJ5qB+6u3OcXPW6sBsz9EggqQP5s1mVCHVPU9wbnmdcU055R8 TPKEVmiOSnlcWtg8xoHgSDrE47IsosNtKmmqopkiOw9X61fVXduLeSqNGdiG5n/aq/ GFpzvd/38Va9xdQaSKP0k205fcK8qBVmF68AZb5CuJqCv2rmWzAOIOjHDQbj+H6dVv XqUxLoZX0qRm7y9vb3Xhsd85dBh2yOYhunHWP7AK914GHEDyHn4Zf5g3MLNk0FC1kc 7rtE/bSG1rdtAkA44oCqzawM9E477ikXjChQb5SAeNxW5xHZezK1ndQ6ThavLfc0G8 izVZKh9seOxLw== From: Jarkko Sakkinen To: fsdevel@vger.kernel.org Cc: Jarkko Sakkinen , bpf@vger.kernel.org, containers@lists.linux.dev, linux-api@vger.kernel.org, linux-arch@vger.kernel.org, linux-doc@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org, linux-security-module@vger.kernel.org, Aleksa Sarai , Alexander Mikhalitsyn , Alexander Viro , Andy Lutomirski , Arnd Bergmann , Christian Brauner , David Howells , Eric Biggers , Georgia Garcia , Giuseppe Scrivano , Hugh Dickins , James Morris , Jan Kara , Jeff Layton , John Johansen , Jonathan Corbet , Josef Bacik , Kees Cook , KP Singh , Lennart Poettering , Matt Bobrowski , =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= , Neal Gompa , Oleg Nesterov , Paul Moore , Pavel Tikhomirov , Serge Hallyn , Shuah Khan , Stephen Smalley , Zygmunt Krynicki Subject: [RFC PATCH v8 11/29] nsproxy: Expose create_new_namespaces() Date: Sun, 29 Nov 2026 01:57:50 +0200 Message-ID: <20261128235808.2369970-12-jarkko@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261128235808.2369970-1-jarkko@kernel.org> References: <20261128235808.2369970-1-jarkko@kernel.org> X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit create_new_namespaces() is currently static to kernel/nsproxy.c, preventing callers outside kernel/nsproxy.c from constructing a child nsproxy without mutating a task. Expose create_new_namespaces() in so userland_open() can allocate a detached namespace set from current. Co-developed-by: David Howells Signed-off-by: David Howells Signed-off-by: Jarkko Sakkinen --- include/linux/nsproxy.h | 4 ++++ kernel/nsproxy.c | 6 +++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/include/linux/nsproxy.h b/include/linux/nsproxy.h index dc2447f5f092..d611c40cb4ce 100644 --- a/include/linux/nsproxy.h +++ b/include/linux/nsproxy.h @@ -12,6 +12,7 @@ struct ipc_namespace; struct pid_namespace; struct cgroup_namespace; struct fs_struct; +struct user_namespace; /* * A structure to contain pointers to all per-process @@ -92,6 +93,9 @@ static inline struct cred *nsset_cred(struct nsset *set) * */ +struct nsproxy *create_new_namespaces(u64 flags, struct task_struct *tsk, + struct user_namespace *user_ns, + struct fs_struct *new_fs); int copy_namespaces(u64 flags, struct task_struct *tsk); void switch_cred_namespaces(const struct cred *old, const struct cred *new); void exit_nsproxy_namespaces(struct task_struct *tsk); diff --git a/kernel/nsproxy.c b/kernel/nsproxy.c index 2dcf105e8ee2..3c4161515c3c 100644 --- a/kernel/nsproxy.c +++ b/kernel/nsproxy.c @@ -85,9 +85,9 @@ void deactivate_nsproxy(struct nsproxy *ns) * Return the newly created nsproxy. Do not attach this to the task, * leave it to the caller to do proper locking and attach it to task. */ -static struct nsproxy *create_new_namespaces(u64 flags, - struct task_struct *tsk, struct user_namespace *user_ns, - struct fs_struct *new_fs) +struct nsproxy *create_new_namespaces(u64 flags, struct task_struct *tsk, + struct user_namespace *user_ns, + struct fs_struct *new_fs) { struct nsproxy *new_nsp; int err; -- 2.47.3