From nobody Thu Apr 16 06:52:11 2026 Received: from cstnet.cn (smtp21.cstnet.cn [159.226.251.21]) (using TLSv1.2 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5EC5432572D for ; Mon, 2 Mar 2026 08:51:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=159.226.251.21 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772441467; cv=none; b=KUPG3rm/lTlyWjPvW+tWCpLX0Ms9RROorTdrKydO0mEopGoC+8u9ADrgj9UthoP/2rFWBBPPLC+ALJ+EKlECvW+5gHIVf3vYrp9J3yBpMp608Pu2z/12GEoyi0syJ4rzGITCOwtCf6NUkT4mk/jAe13Qu8eTuR2yeUqZJOmCOSg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772441467; c=relaxed/simple; bh=vRe/EXB3Mw/LYUqiLlPrX3mh/pGm9UkaYuI/Rsl/1tY=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=ixrBn6pkF8QmO7rcxQMULsBI9FL2Qo6BH4vw61wLiwxhFx2Hw/p63K2C0KRDScfovke7sW/9kG8c+mXLz+JM/b8cutxqVbj0LMSnagd3oB3S5uPl6Npq3iPPqcLaENudxYUnMqMKUkjxq8yqO492MbyjRK9G/5ZmcD3ob/Ymz4E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=isrc.iscas.ac.cn; spf=pass smtp.mailfrom=isrc.iscas.ac.cn; arc=none smtp.client-ip=159.226.251.21 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=isrc.iscas.ac.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=isrc.iscas.ac.cn Received: from localhost.localdomain (unknown [210.73.43.101]) by APP-01 (Coremail) with SMTP id qwCowABXAGxtT6VpOOYXCQ--.466S2; Mon, 02 Mar 2026 16:50:54 +0800 (CST) From: Pengpeng Hou To: "Eric W . Biederman" Cc: linux-kernel@vger.kernel.org, 18291782795@163.com, Pengpeng Hou Subject: [PATCH] pid_namespace: Add stub for to_pid_ns() when CONFIG_PID_NS is disabled Date: Mon, 2 Mar 2026 08:50:51 +0000 Message-Id: <20260302085051.4128542-1-pengpeng.hou@isrc.iscas.ac.cn> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: qwCowABXAGxtT6VpOOYXCQ--.466S2 X-Coremail-Antispam: 1UD129KBjvdXoWrtFyrCF4rCw4kArykKFWfZrb_yoWkZFg_Za 9rtay2kF15Zrs29w13W34aqF93trWkAF1UXr4ftFZrZFn3XFsrJ3srtFy7AFWUWFs7Ww13 ur1kW3yxJr13XjkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUb2xFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8w A2z4x0Y4vE2Ix0cI8IcVAFwI0_Jr0_JF4l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Jr0_ Gr1l84ACjcxK6I8E87Iv67AKxVWUJVW8JwA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Jr0_Gr 1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0 cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r4j6F4UMcvjeVCFs4IE7xkEbVWUJVW8Jw ACjcxG0xvY0x0EwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1lc2xSY4AK67AK6r43MxAI w28IcxkI7VAKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr 4lx2IqxVCjr7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUAVWUtwCIc40Y0x0EwIxG rwCI42IY6xIIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVWUJVW8Jw CI42IY6xAIw20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2 z280aVCY1x0267AKxVWUJVW8JbIYCTnIWIevJa73UjIFyTuYvjfUb6wCDUUUU X-CM-SenderInfo: pshqw1hhqjhx1rx6x21ufox2xfdvhtffof0/ Content-Type: text/plain; charset="utf-8" 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 --- 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) { --=20 2.25.1