From: Johannes Berg <johannes@sipsolutions.net>
To: Dawei Li <set_pte_at@outlook.com>,
richard@nod.at, anton.ivanov@cambridgegreys.com
Cc: linux-um@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] um: protect find_task_by_pid_ns() with rcu lock
Date: Sun, 16 Oct 2022 19:52:48 +0200 [thread overview]
Message-ID: <f0b1f33108fec467689b52568b5ad7c906eb5435.camel@sipsolutions.net> (raw)
In-Reply-To: <TYCP286MB2323CA02DF3A741B5F58B297CA269@TYCP286MB2323.JPNP286.PROD.OUTLOOK.COM>
On Sun, 2022-10-16 at 23:10 +0800, Dawei Li wrote:
> find_task_by_pid_ns() is safe if and only if it's under protection
> from rcu read lock, implements the protection.
>
> base-commit: 193cb8372424184dde28088a4230a5fed0afb0ad
>
> Signed-off-by: Dawei Li <set_pte_at@outlook.com>
> ---
> arch/um/drivers/mconsole_kern.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/arch/um/drivers/mconsole_kern.c b/arch/um/drivers/mconsole_kern.c
> index 5026e7b9adfe..6b80e766ae80 100644
> --- a/arch/um/drivers/mconsole_kern.c
> +++ b/arch/um/drivers/mconsole_kern.c
> @@ -683,7 +683,10 @@ void mconsole_stack(struct mc_request *req)
> return;
> }
>
> + rcu_read_lock();
> to = find_task_by_pid_ns(pid_requested, &init_pid_ns);
> + rcu_read_unlock();
> +
> if ((to == NULL) || (pid_requested == 0)) {
> mconsole_reply(req, "Couldn't find that pid", 1, 0);
> return;
This can't be right - the 'to' pointer is used later in the code (not in
the existing context), so the protection, if needed, would have to
include the later "with_console()" call?
johannes
prev parent reply other threads:[~2022-10-16 17:53 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-16 15:10 Dawei Li
2022-10-16 17:52 ` Johannes Berg [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=f0b1f33108fec467689b52568b5ad7c906eb5435.camel@sipsolutions.net \
--to=johannes@sipsolutions.net \
--cc=anton.ivanov@cambridgegreys.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-um@lists.infradead.org \
--cc=richard@nod.at \
--cc=set_pte_at@outlook.com \
/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®