From nobody Thu Oct 2 04:44:07 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7FA34238C07; Mon, 22 Sep 2025 12:42:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758544972; cv=none; b=eAVQj2i+3Z39fgpitrwEGzct8dogKlTXvWxC9lJs/38jHGOjxL4Qt13ynN6LvH/9Tvh30TF01th0x33cI2vm37mmmOxGHGEyK6w+5ybe4oPwBIiaUubpew5jIqkSJaV5esqJlOToZNUGt+oE0fQfUJt3pfbWc9QMl6lCr8Ol+nc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758544972; c=relaxed/simple; bh=6j1YGAAdB33ZNWVzjRjTKedVTDWodDiSmGf3HmSt51U=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=IHDkREamGD0gLeoCD1aBa/zUn/tJ+f9WVXHqs0QD5Btf8WhmcsVjctGHkgDaKaj9O8WWxM5cXqt0pqBfzxSUUxHHBVkdG4goBQ8KRrdxrw5Pf6MOMsVLs55wx5PiSM3uTM0dTU/SMvxvyX1j6zIOO1FEEYbNk2BhiELkmvzwigQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SovP/9kD; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="SovP/9kD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2B0A5C4CEF0; Mon, 22 Sep 2025 12:42:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758544972; bh=6j1YGAAdB33ZNWVzjRjTKedVTDWodDiSmGf3HmSt51U=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=SovP/9kDca9qx8CXw2wyAIAEY+Zkuj5oULyEI7/nbZnpp+lsn2RIOmqR+k2owX1qa zoSYkOSqzo6OkmER5+uiRoJQsdXSzZ4MGWCOk/0vUo2z6CKENuJtm1wA1/jvbHXyZL hRIF/T88mNb/TXISnLNRs2WyDzohbQfFj55eqbQnGhSqTCQcJCD1axZS+5+AFnHUGn WBe34lf/Vja228QE1H0RV4jBep6hAjhmP+M/oG8qpquq+1LTPZxRZU/i7H6YMDQ9QJ SqYcdJv7y6zZblX9z9UXz0ECgplZFMrb8Vr7W/dmUVaNChFFJcyGh0sZ755/Pb6nVe KxmY6A4huxwFA== From: Christian Brauner Date: Mon, 22 Sep 2025 14:42:35 +0200 Subject: [PATCH 1/3] cgroup: add missing ns_common include Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250922-work-namespace-ns_common-fixes-v1-1-3c26aeb30831@kernel.org> References: <20250922-work-namespace-ns_common-fixes-v1-0-3c26aeb30831@kernel.org> In-Reply-To: <20250922-work-namespace-ns_common-fixes-v1-0-3c26aeb30831@kernel.org> To: linux-fsdevel@vger.kernel.org Cc: Amir Goldstein , Josef Bacik , Jeff Layton , Mike Yuan , =?utf-8?q?Zbigniew_J=C4=99drzejewski-Szmek?= , Lennart Poettering , Aleksa Sarai , Alexander Viro , Jan Kara , Tejun Heo , Johannes Weiner , =?utf-8?q?Michal_Koutn=C3=BD?= , Jakub Kicinski , Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner , cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Christian Brauner X-Mailer: b4 0.15-dev-56183 X-Developer-Signature: v=1; a=openpgp-sha256; l=621; i=brauner@kernel.org; h=from:subject:message-id; bh=6j1YGAAdB33ZNWVzjRjTKedVTDWodDiSmGf3HmSt51U=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMWRcdHEO+bTy2CrPC7Ud7AvPRQW3VzPs9OPefbB5igprh 7yOqO27jlIWBjEuBlkxRRaHdpNwueU8FZuNMjVg5rAygQxh4OIUgInw5TMy3D35MM2o3sTiIpNR uRjTrdU7K18sCPbe1CIVufyI897QSYwMT0p3tmzJrPLynZToFLpnyp3+V/+fm1eaZTxS2hkp8uk ODwA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Add the missing include of the ns_common header. Signed-off-by: Christian Brauner Acked-by: Tejun Heo Reviewed-by: Jan Kara --- include/linux/cgroup_namespace.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/cgroup_namespace.h b/include/linux/cgroup_namesp= ace.h index b7dbf4d623d2..81ccbdee425b 100644 --- a/include/linux/cgroup_namespace.h +++ b/include/linux/cgroup_namespace.h @@ -2,6 +2,8 @@ #ifndef _LINUX_CGROUP_NAMESPACE_H #define _LINUX_CGROUP_NAMESPACE_H =20 +#include + struct cgroup_namespace { struct ns_common ns; struct user_namespace *user_ns; --=20 2.47.3 From nobody Thu Oct 2 04:44:07 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5000C306B24; Mon, 22 Sep 2025 12:42:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758544977; cv=none; b=ZZGsGTJMttC/9SyEopFnNqPA7tMzxolIxob4THGzMv3xyurMJmpYUYBJU4PZtoKzTPyy0+5cquPbgL0Oa0She4iPWigjk8CW0f7fl7i/FUgFmD1aZ7hXn+4n48C0N+tWZCu+FgC9yE2P1MS6EiyDTKVv6ymUXwBYhKn5BRPpiQU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758544977; c=relaxed/simple; bh=Vk3NS+k0XxRhYp+lepoAJRH3NoVQr4il7ukecn/Ropc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Z3HeL5j/OFemPSWTZC1oBZI0cil8f15c4Tw5+BXSr9er2YR7Pn6HscXLqn7Akxd7Qcqe3OrLRDufdi28zcWjMT7HtUaJT9icC5ZWfkD7ea801Xyn1dnDddGLPwExwBxWFKabI/vAQuk/3+f0bKmDi7xhCO8qh1cLQhkiUofeOV0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Y6M05OIb; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Y6M05OIb" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E21EAC4CEF0; Mon, 22 Sep 2025 12:42:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758544976; bh=Vk3NS+k0XxRhYp+lepoAJRH3NoVQr4il7ukecn/Ropc=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=Y6M05OIbHb1z9HyM78GPmPcHrTeZfTyavzUKzD4s42wdbSiGNv9rmrK+CeTszTErc aoOcHlVjmUkmtRbZvjGD6pOje1YN5sX8E63xEJ3Xv1X2X/AiQ8alG7vIrACenzERDk nfTLb+IqBF9I3DCJMkkT0XDodqOt1esfkpElIxXlSHf6tVASCCAdRM9nsh6U1SXX9X 0vLzEwdXssvW+2FtNTAXZ28Wxxjc3g6U79X8ORSghGd0OdW3GYmMpUo1Ve7VNbib3x gO2I7P7boJ+Dj8gLqxsrv9nR2xpOlmLx6Qpi4faYGLtx9hoeXuS4iYVOFaFlDZFotF 2LLHr6CXzsgtQ== From: Christian Brauner Date: Mon, 22 Sep 2025 14:42:36 +0200 Subject: [PATCH 2/3] ns: simplify ns_common_init() further Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250922-work-namespace-ns_common-fixes-v1-2-3c26aeb30831@kernel.org> References: <20250922-work-namespace-ns_common-fixes-v1-0-3c26aeb30831@kernel.org> In-Reply-To: <20250922-work-namespace-ns_common-fixes-v1-0-3c26aeb30831@kernel.org> To: linux-fsdevel@vger.kernel.org Cc: Amir Goldstein , Josef Bacik , Jeff Layton , Mike Yuan , =?utf-8?q?Zbigniew_J=C4=99drzejewski-Szmek?= , Lennart Poettering , Aleksa Sarai , Alexander Viro , Jan Kara , Tejun Heo , Johannes Weiner , =?utf-8?q?Michal_Koutn=C3=BD?= , Jakub Kicinski , Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner , cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Christian Brauner X-Mailer: b4 0.15-dev-56183 X-Developer-Signature: v=1; a=openpgp-sha256; l=7072; i=brauner@kernel.org; h=from:subject:message-id; bh=Vk3NS+k0XxRhYp+lepoAJRH3NoVQr4il7ukecn/Ropc=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMWRcdHFWeniH55HMCmvPl+mMF1n3Hft0mPHjqi0PeFmnd iUvkt9zvKOUhUGMi0FWTJHFod0kXG45T8Vmo0wNmDmsTCBDGLg4BWAidSUM/yw4TDmdG2IEjjye E3b+R97NxK1pP8/MdXjwNqhQzCWtZjnD/+qvPfEbz108e3RL28tdDz4INh1h/3PQOOHYtS22AY0 TS1kA X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Simply derive the ns operations from the namespace type. Signed-off-by: Christian Brauner Acked-by: Thomas Gleixner Reviewed-by: Jan Kara --- fs/namespace.c | 4 ++-- include/linux/ns_common.h | 30 ++++++++++++++++++++++++++---- ipc/namespace.c | 2 +- kernel/cgroup/namespace.c | 2 +- kernel/pid_namespace.c | 2 +- kernel/time/namespace.c | 2 +- kernel/user_namespace.c | 2 +- kernel/utsname.c | 2 +- net/core/net_namespace.c | 9 +-------- 9 files changed, 35 insertions(+), 20 deletions(-) diff --git a/fs/namespace.c b/fs/namespace.c index 271cd6294c8a..d65917ec5544 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -4104,9 +4104,9 @@ static struct mnt_namespace *alloc_mnt_ns(struct user= _namespace *user_ns, bool a } =20 if (anon) - ret =3D ns_common_init_inum(new_ns, &mntns_operations, MNT_NS_ANON_INO); + ret =3D ns_common_init_inum(new_ns, MNT_NS_ANON_INO); else - ret =3D ns_common_init(new_ns, &mntns_operations); + ret =3D ns_common_init(new_ns); if (ret) { kfree(new_ns); dec_mnt_namespaces(ucounts); diff --git a/include/linux/ns_common.h b/include/linux/ns_common.h index aea8528d799a..56492cd9ff8d 100644 --- a/include/linux/ns_common.h +++ b/include/linux/ns_common.h @@ -25,6 +25,17 @@ extern struct time_namespace init_time_ns; extern struct user_namespace init_user_ns; extern struct uts_namespace init_uts_ns; =20 +extern const struct proc_ns_operations netns_operations; +extern const struct proc_ns_operations utsns_operations; +extern const struct proc_ns_operations ipcns_operations; +extern const struct proc_ns_operations pidns_operations; +extern const struct proc_ns_operations pidns_for_children_operations; +extern const struct proc_ns_operations userns_operations; +extern const struct proc_ns_operations mntns_operations; +extern const struct proc_ns_operations cgroupns_operations; +extern const struct proc_ns_operations timens_operations; +extern const struct proc_ns_operations timens_for_children_operations; + struct ns_common { struct dentry *stashed; const struct proc_ns_operations *ops; @@ -84,10 +95,21 @@ void __ns_common_free(struct ns_common *ns); struct user_namespace *: &init_user_ns, \ struct uts_namespace *: &init_uts_ns) =20 -#define ns_common_init(__ns, __ops) \ - __ns_common_init(to_ns_common(__ns), __ops, (((__ns) =3D=3D ns_init_ns(__= ns)) ? ns_init_inum(__ns) : 0)) - -#define ns_common_init_inum(__ns, __ops, __inum) __ns_common_init(to_ns_co= mmon(__ns), __ops, __inum) +#define to_ns_operations(__ns) = \ + _Generic((__ns), = \ + struct cgroup_namespace *: (IS_ENABLED(CONFIG_CGROUPS) ? &cgroupns_opera= tions : NULL), \ + struct ipc_namespace *: (IS_ENABLED(CONFIG_IPC_NS) ? &ipcns_operatio= ns : NULL), \ + struct mnt_namespace *: &mntns_operations, = \ + struct net *: (IS_ENABLED(CONFIG_NET_NS) ? &netns_operatio= ns : NULL), \ + struct pid_namespace *: (IS_ENABLED(CONFIG_PID_NS) ? &pidns_operatio= ns : NULL), \ + struct time_namespace *: (IS_ENABLED(CONFIG_TIME_NS) ? &timens_operati= ons : NULL), \ + struct user_namespace *: (IS_ENABLED(CONFIG_USER_NS) ? &userns_operati= ons : NULL), \ + struct uts_namespace *: (IS_ENABLED(CONFIG_UTS_NS) ? &utsns_operatio= ns : NULL)) + +#define ns_common_init(__ns) \ + __ns_common_init(to_ns_common(__ns), to_ns_operations(__ns), (((__ns) =3D= =3D ns_init_ns(__ns)) ? ns_init_inum(__ns) : 0)) + +#define ns_common_init_inum(__ns, __inum) __ns_common_init(to_ns_common(__= ns), to_ns_operations(__ns), __inum) =20 #define ns_common_free(__ns) __ns_common_free(to_ns_common((__ns))) =20 diff --git a/ipc/namespace.c b/ipc/namespace.c index bd85d1c9d2c2..d89dfd718d2b 100644 --- a/ipc/namespace.c +++ b/ipc/namespace.c @@ -62,7 +62,7 @@ static struct ipc_namespace *create_ipc_ns(struct user_na= mespace *user_ns, if (ns =3D=3D NULL) goto fail_dec; =20 - err =3D ns_common_init(ns, &ipcns_operations); + err =3D ns_common_init(ns); if (err) goto fail_free; =20 diff --git a/kernel/cgroup/namespace.c b/kernel/cgroup/namespace.c index 16ead7508371..04c98338ac08 100644 --- a/kernel/cgroup/namespace.c +++ b/kernel/cgroup/namespace.c @@ -27,7 +27,7 @@ static struct cgroup_namespace *alloc_cgroup_ns(void) new_ns =3D kzalloc(sizeof(struct cgroup_namespace), GFP_KERNEL_ACCOUNT); if (!new_ns) return ERR_PTR(-ENOMEM); - ret =3D ns_common_init(new_ns, &cgroupns_operations); + ret =3D ns_common_init(new_ns); if (ret) return ERR_PTR(ret); ns_tree_add(new_ns); diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c index 162f5fb63d75..a262a3f19443 100644 --- a/kernel/pid_namespace.c +++ b/kernel/pid_namespace.c @@ -103,7 +103,7 @@ static struct pid_namespace *create_pid_namespace(struc= t user_namespace *user_ns if (ns->pid_cachep =3D=3D NULL) goto out_free_idr; =20 - err =3D ns_common_init(ns, &pidns_operations); + err =3D ns_common_init(ns); if (err) goto out_free_idr; =20 diff --git a/kernel/time/namespace.c b/kernel/time/namespace.c index 7aa4d6fedd49..9f26e61be044 100644 --- a/kernel/time/namespace.c +++ b/kernel/time/namespace.c @@ -97,7 +97,7 @@ static struct time_namespace *clone_time_ns(struct user_n= amespace *user_ns, if (!ns->vvar_page) goto fail_free; =20 - err =3D ns_common_init(ns, &timens_operations); + err =3D ns_common_init(ns); if (err) goto fail_free_page; =20 diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c index f9df45c46235..e1559e8a8a02 100644 --- a/kernel/user_namespace.c +++ b/kernel/user_namespace.c @@ -126,7 +126,7 @@ int create_user_ns(struct cred *new) =20 ns->parent_could_setfcap =3D cap_raised(new->cap_effective, CAP_SETFCAP); =20 - ret =3D ns_common_init(ns, &userns_operations); + ret =3D ns_common_init(ns); if (ret) goto fail_free; =20 diff --git a/kernel/utsname.c b/kernel/utsname.c index 95d733eb2c98..00001592ad13 100644 --- a/kernel/utsname.c +++ b/kernel/utsname.c @@ -50,7 +50,7 @@ static struct uts_namespace *clone_uts_ns(struct user_nam= espace *user_ns, if (!ns) goto fail_dec; =20 - err =3D ns_common_init(ns, &utsns_operations); + err =3D ns_common_init(ns); if (err) goto fail_free; =20 diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c index d5e3fd819163..bdea7d5fac56 100644 --- a/net/core/net_namespace.c +++ b/net/core/net_namespace.c @@ -400,16 +400,9 @@ static __net_init void preinit_net_sysctl(struct net *= net) /* init code that must occur even if setup_net() is not called. */ static __net_init int preinit_net(struct net *net, struct user_namespace *= user_ns) { - const struct proc_ns_operations *ns_ops; int ret; =20 -#ifdef CONFIG_NET_NS - ns_ops =3D &netns_operations; -#else - ns_ops =3D NULL; -#endif - - ret =3D ns_common_init(net, ns_ops); + ret =3D ns_common_init(net); if (ret) return ret; =20 --=20 2.47.3 From nobody Thu Oct 2 04:44:07 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 982BD308F38; Mon, 22 Sep 2025 12:43:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758544982; cv=none; b=eYFUNQbe46eedhUWe3ZdKmWDjeHv/3gjgnKsoXcn8Aw1wzXGtow/nLmInxiBvXV2AEaxTd+3p7uuNkJeTRtJX/TpPQ4VPteVjp3PvM4+jErepB42TZkIjgdCYfL9fJo8EM4scu3dx0Fobra29vyjlxjIo8YAZZ17PKvGB2hstoA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758544982; c=relaxed/simple; bh=eXegoR9+/J66AI1dQB6rfx5+3Y1FvmBpnCRJJsJbBZU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=FuZZDUtTVOhzLHwc6j/gvzAcTjTiBaJ1Rh9vg/CF6ZI5aw4SHLLtpJUkJ7yl238Y+oXf0lSmUQYW4Lk00SqqpCw2q+JtLrMBuEHPuIrKv33MxkaHXAMN2JmAr/5BQUZEiMEWr0xY9DN5sNZLSBH662wXa2g1OIbJyROC0MNeHu0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pvGOWEvv; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="pvGOWEvv" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 47C15C4CEF7; Mon, 22 Sep 2025 12:42:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1758544981; bh=eXegoR9+/J66AI1dQB6rfx5+3Y1FvmBpnCRJJsJbBZU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=pvGOWEvvz9AYqq4lFnEth96LOGzcnJfCvhzo3JO+7VDH3zywlRPE4G561r4ydtIRg 2cBYkO3Gs4Zk56Wk6UMJ35mPXPkQ/p9d5Fos+dNfJ+AKDPzvTWbNp2nXxTxIWMwh4Y TCl3GP96z3RGcIzv33KlcYc+1ahL3Gpni2UgtWP4NLkf+OyWiphO30UPTyUX+cs+ms EASnO9rl303Mdrv21Oqe4TnhJVioMpXzF+FKe4/duPOuuHibokFL7vZMBqBeLaIMM8 Bs+cvH94gQrzHZ+oNDQ5Bl0n+zkZGFRrR6+AdVkoHL1WvDv3ihQCTGvQObjdRn0CiW Jkemgng632A4g== From: Christian Brauner Date: Mon, 22 Sep 2025 14:42:37 +0200 Subject: [PATCH 3/3] ns: add ns_debug() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20250922-work-namespace-ns_common-fixes-v1-3-3c26aeb30831@kernel.org> References: <20250922-work-namespace-ns_common-fixes-v1-0-3c26aeb30831@kernel.org> In-Reply-To: <20250922-work-namespace-ns_common-fixes-v1-0-3c26aeb30831@kernel.org> To: linux-fsdevel@vger.kernel.org Cc: Amir Goldstein , Josef Bacik , Jeff Layton , Mike Yuan , =?utf-8?q?Zbigniew_J=C4=99drzejewski-Szmek?= , Lennart Poettering , Aleksa Sarai , Alexander Viro , Jan Kara , Tejun Heo , Johannes Weiner , =?utf-8?q?Michal_Koutn=C3=BD?= , Jakub Kicinski , Anna-Maria Behnsen , Frederic Weisbecker , Thomas Gleixner , cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Christian Brauner X-Mailer: b4 0.15-dev-56183 X-Developer-Signature: v=1; a=openpgp-sha256; l=2013; i=brauner@kernel.org; h=from:subject:message-id; bh=eXegoR9+/J66AI1dQB6rfx5+3Y1FvmBpnCRJJsJbBZU=; b=owGbwMvMwCU28Zj0gdSKO4sYT6slMWRcdHGufLdqp3vlk4Q1Dk/fn3ohZJy/jeVH4POoLO7nA tcESutyOkpZGMS4GGTFFFkc2k3C5ZbzVGw2ytSAmcPKBDKEgYtTACYi38vwP7dtrWyCt61CzoL3 X1Mq/MoZhadP8lScKVY6/aeGl/y+EIb/LgILxT4EsL3ecm/N0gQHx44va5Q9L5owT5GfJucvfdm QBwA= X-Developer-Key: i=brauner@kernel.org; a=openpgp; fpr=4880B8C9BD0E5106FC070F4F7B3C391EFEA93624 Add ns_debug() that asserts that the correct operations are used for the namespace type. Signed-off-by: Christian Brauner Reviewed-by: Jan Kara --- kernel/nscommon.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++= ++ 1 file changed, 53 insertions(+) diff --git a/kernel/nscommon.c b/kernel/nscommon.c index 7aa2be6a0c32..3cef89ddef41 100644 --- a/kernel/nscommon.c +++ b/kernel/nscommon.c @@ -2,6 +2,55 @@ =20 #include #include +#include + +#ifdef CONFIG_DEBUG_VFS +static void ns_debug(struct ns_common *ns, const struct proc_ns_operations= *ops) +{ + switch (ns->ops->type) { +#ifdef CONFIG_CGROUPS + case CLONE_NEWCGROUP: + VFS_WARN_ON_ONCE(ops !=3D &cgroupns_operations); + break; +#endif +#ifdef CONFIG_IPC_NS + case CLONE_NEWIPC: + VFS_WARN_ON_ONCE(ops !=3D &ipcns_operations); + break; +#endif + case CLONE_NEWNS: + VFS_WARN_ON_ONCE(ops !=3D &mntns_operations); + break; +#ifdef CONFIG_NET_NS + case CLONE_NEWNET: + VFS_WARN_ON_ONCE(ops !=3D &netns_operations); + break; +#endif +#ifdef CONFIG_PID_NS + case CLONE_NEWPID: + VFS_WARN_ON_ONCE(ops !=3D &pidns_operations); + break; +#endif +#ifdef CONFIG_TIME_NS + case CLONE_NEWTIME: + VFS_WARN_ON_ONCE(ops !=3D &timens_operations); + break; +#endif +#ifdef CONFIG_USER_NS + case CLONE_NEWUSER: + VFS_WARN_ON_ONCE(ops !=3D &userns_operations); + break; +#endif +#ifdef CONFIG_UTS_NS + case CLONE_NEWUTS: + VFS_WARN_ON_ONCE(ops !=3D &utsns_operations); + break; +#endif + default: + VFS_WARN_ON_ONCE(true); + } +} +#endif =20 int __ns_common_init(struct ns_common *ns, const struct proc_ns_operations= *ops, int inum) { @@ -12,6 +61,10 @@ int __ns_common_init(struct ns_common *ns, const struct = proc_ns_operations *ops, RB_CLEAR_NODE(&ns->ns_tree_node); INIT_LIST_HEAD(&ns->ns_list_node); =20 +#ifdef CONFIG_DEBUG_VFS + ns_debug(ns, ops); +#endif + if (inum) { ns->inum =3D inum; return 0; --=20 2.47.3