mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Eric W. Biederman" <ebiederm@xmission.com>
To: Pengpeng Hou <pengpeng.hou@isrc.iscas.ac.cn>
Cc: linux-kernel@vger.kernel.org,  18291782795@163.com
Cc: Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] pid_namespace: Add stub for to_pid_ns() when CONFIG_PID_NS is disabled
Date: Mon, 02 Mar 2026 12:20:54 -0600	[thread overview]
Message-ID: <874imyozy1.fsf@email.froward.int.ebiederm.org> (raw)
In-Reply-To: <20260302085051.4128542-1-pengpeng.hou@isrc.iscas.ac.cn> (Pengpeng Hou's message of "Mon, 2 Mar 2026 08:50:51 +0000")

Pengpeng Hou <pengpeng.hou@isrc.iscas.ac.cn> writes:

> 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.

What code in the kernel tree has this problem?

Most places in the kernel (notably drivers) it is an error (of the
abstraction violation kind) to be playing with pids or namespaces.

What code in the kernel tree needs this fix?

This change also removes whitespace between functions in the header,
and it is desirable to have that whitespace.

Eric


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

      reply	other threads:[~2026-03-02 19:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-02  8:50 Pengpeng Hou
2026-03-02 18:20 ` Eric W. Biederman [this message]

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=874imyozy1.fsf@email.froward.int.ebiederm.org \
    --to=ebiederm@xmission.com \
    --cc=18291782795@163.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pengpeng.hou@isrc.iscas.ac.cn \
    /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

Powered by JetHome