mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] pid_namespace: Add stub for to_pid_ns() when CONFIG_PID_NS is disabled
@ 2026-03-02  8:50 Pengpeng Hou
  2026-03-02 18:20 ` Eric W. Biederman
  0 siblings, 1 reply; 2+ messages in thread
From: Pengpeng Hou @ 2026-03-02  8:50 UTC (permalink / raw)
  To: Eric W . Biederman; +Cc: linux-kernel, 18291782795, Pengpeng Hou

Currently, to_pid_ns() is only defined when CONFIG_PID_NS is enabled. This
leads to compilation errors in subsystems that attempt to retrieve a PID
namespace from an ns_common structure in a non-namespace-aware kernel
configuration.

This patch adds a static inline stub for to_pid_ns() in the #else block,
returning the address of the global init_pid_ns. This ensures consistent
API availability and fixes potential build failures.

Signed-off-by: Pengpeng Hou <pengpeng.hou@isrc.iscas.ac.cn>
---
 include/linux/pid_namespace.h | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/include/linux/pid_namespace.h b/include/linux/pid_namespace.h
index b20baaa7e..ca6032db8 100644
--- a/include/linux/pid_namespace.h
+++ b/include/linux/pid_namespace.h
@@ -103,7 +103,10 @@ static inline int pidns_memfd_noexec_scope(struct pid_namespace *ns)
 {
 	return 0;
 }
-
+static inline struct pid_namespace *to_pid_ns(struct ns_common *ns)
+{
+	return &init_pid_ns;
+}
 static inline struct pid_namespace *copy_pid_ns(u64 flags,
 	struct user_namespace *user_ns, struct pid_namespace *ns)
 {
-- 
2.25.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-03-02 19:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-03-02  8:50 [PATCH] pid_namespace: Add stub for to_pid_ns() when CONFIG_PID_NS is disabled Pengpeng Hou
2026-03-02 18:20 ` Eric W. Biederman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®