From: Xuewen Yan <xuewen.yan@unisoc.com>
To: <brauner@kernel.org>, <jack@suse.cz>, <keescook@chromium.org>,
<peterz@infradead.org>, <vincent.guittot@linaro.org>
Cc: <linux-kernel@vger.kernel.org>, <xuewen.yan@unisoc.com>,
<di.shen@unisoc.com>
Subject: [PATCH] pid: Add the judgment of whether ns is NULL in the find_pid_ns
Date: Thu, 13 Jul 2023 15:17:13 +0800 [thread overview]
Message-ID: <20230713071713.5762-1-xuewen.yan@unisoc.com> (raw)
There is no the judgment of whether namspace is NULL in find_pid_ns.
But there is a corner case when ns is null, for example: if user
call find_get_pid when current is in exiting, the following stack would
set thread_id be null:
release_task
__exit_signal(p);
__unhash_process(tsk, group_dead);
detach_pid(p, PIDTYPE_PID);
__change_pid(task, type, NULL);
If user call find_get_pid at now, in find_vpid function, the
task_active_pid_ns would return NULL. As a result, it would be
error when access the ns in find_pid_ns.
So add the judgment of whether ns is NULL in the find_pid_ns to
prevent this case happen.
Signed-off-by: Xuewen Yan <xuewen.yan@unisoc.com>
---
kernel/pid.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/kernel/pid.c b/kernel/pid.c
index 6a1d23a11026..d4a9cb6f3eb9 100644
--- a/kernel/pid.c
+++ b/kernel/pid.c
@@ -308,6 +308,9 @@ void disable_pid_allocation(struct pid_namespace *ns)
struct pid *find_pid_ns(int nr, struct pid_namespace *ns)
{
+ if (!ns)
+ return NULL;
+
return idr_find(&ns->idr, nr);
}
EXPORT_SYMBOL_GPL(find_pid_ns);
--
2.25.1
next reply other threads:[~2023-07-13 7:18 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-13 7:17 Xuewen Yan [this message]
2023-07-19 11:46 ` Xuewen Yan
2023-07-25 8:26 ` Christian Brauner
2023-07-25 12:24 ` Xuewen Yan
2023-07-25 12:47 ` Christian Brauner
2023-07-26 1:23 ` Xuewen Yan
2023-07-26 9:25 ` Christian Brauner
2023-07-27 1:21 ` Xuewen Yan
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=20230713071713.5762-1-xuewen.yan@unisoc.com \
--to=xuewen.yan@unisoc.com \
--cc=brauner@kernel.org \
--cc=di.shen@unisoc.com \
--cc=jack@suse.cz \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=vincent.guittot@linaro.org \
/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
all inboxes | Powered by JetHome®