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=1796441249; b=UtaudtyVjxIfC/be0TTT8hw3+G7PBsPtPkZ1l5PNILp4MgGF5YeaS9U15qs/q/ReVU8t 8Vr+0ZQuW7KiEbXKpT5gaN8ccegOsENcZYCNJgxm+XjqkvGgvvW9znhVd/L/cwIJv7WGS r7Ld5+qsvahEjLwMyBSIsWnH4Ff8Sp80qMHuOeNk5nDJnDF1HrTJDfMl5aS98tvXeIY2u d/x6ZgR2/1VguSv11mxENp8zLz5E2dDEOVg/akHzzD34liaCiTR45cnNJ5FiNSNGP529h wDANPXDvRR+V4uoT34tC5dYWRYCxervYJsOVhRZw/IghfstbN62jX5jw01AhusNQGdg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796441249; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=+ss1/DWbAJodKqfeeF1N8miwHGXM5BQntqHpWL4pIlo=; b=2o7FHB5/bK809EN8NsT/hvZ04YJfRzwstwdNtyNzdy9cWbEQ8W4JwpD+i0BOahrpyt4v gJkkU3L7Gtr1Rimfl+G+6qtBwvYvf1irLG3vr23JbNb7yHJs64LYJkexh85BMIhklUMGg d3Q+6IoB7WtmFS3CWiwoRqWlWY022jZXbDOte77YsTFcEJmfmT3/euGEuYsr82ybbaG+F zQ4fqnT3WnAniOzQbLKc0zF0DcnVY22E+IYvM2nIZOAJHr6PvWAbs2roSepOSf6FOkiG4 vRvL3MV7ZdHrVZNvLNcj3EEBLEHHYRZW3Wd6unxZiVevVNqaxkeBhrJRWfBvcS6WiLA== 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=ogrMWO48; 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 388EA606A335; Sat, 5 Dec 2026 03:27:29 +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=ogrMWO48 Received: by smtp.kernel.org (Postfix) with UTF8SMTPSA id 28BF21F00A21; Sat, 5 Dec 2026 03:27:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796441248; bh=+ss1/DWbAJodKqfeeF1N8miwHGXM5BQntqHpWL4pIlo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ogrMWO4829+sh1BNIEGLYUQ3NNaufUNpq42W7JM3JvzNkeecSvjT8pUqgb7Hhi0Ui 3NyZR5eNH/iByrrcf3d+oFb13q5hqNK0t30d4Lq/X8jS31txj7vcS6AydfCWqNwW82 sPS4k8YvRuM7KxAaPMKZHegPbZgeNsgyZPskhW1owzfp+7uOWoMPHzmGcfW1hN7SEg ga72cMG3YaxiqWpilAJr2Pq3yq01CjvgjwJjWKaQFevxv0Q/Y1jHauDWVuYUskmnZR mRwlIExW3oLMiiXn/lvZKmyUkt4Syp5z+5zliK13684y/PQ5kJCy7k9J6cPdhsZ6DZ LkUWXeDlwCzJg== 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-integrity@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 , Alexei Starovoitov , Andrew Morton , Andrii Nakryiko , Andy Lutomirski , Arnd Bergmann , Baolin Wang , Ben Segall , Christian Brauner , Daniel Borkmann , David Hildenbrand , David Howells , David Woodhouse , Davidlohr Bueso , Dietmar Eggemann , Eduard Zingerman , Emil Tsalapatis , Eric Biggers , Georgia Garcia , Giuseppe Scrivano , =?UTF-8?q?G=C3=BCnther=20Noack?= , Hugh Dickins , Ihor Solodrai , Ingo Molnar , James Morris , Jan Kara , Jason Gunthorpe , Jeff Layton , Jiri Olsa , John Johansen , Jonathan Corbet , Josef Bacik , Juri Lelli , Kees Cook , K Prateek Nayak , KP Singh , Kumar Kartikeya Dwivedi , Lennart Poettering , "Liam R. Howlett" , Manfred Spraul , Martin KaFai Lau , Matt Bobrowski , Mel Gorman , Michal Hocko , =?UTF-8?q?Micka=C3=ABl=20Sala=C3=BCn?= , Mike Rapoport , Neal Gompa , Oleg Nesterov , Paul Moore , Pavel Tikhomirov , Peter Zijlstra , Randy Dunlap , "Serge E. Hallyn" , Serge Hallyn , Shuah Khan , Song Liu , Stephen Smalley , Steven Rostedt , Valentin Schneider , Vincent Guittot , Yonghong Song , Zygmunt Krynicki Subject: [RFC PATCH v10 10/28] nsproxy: Expose create_new_namespaces() Date: Sat, 5 Dec 2026 05:26:15 +0200 Message-ID: <20261205032633.1702772-11-jarkko@kernel.org> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20261205032633.1702772-1-jarkko@kernel.org> References: <20261205032633.1702772-1-jarkko@kernel.org> X-Mailing-List: bpf@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 runfd() 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