mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@redhat.com>
To: Bradley Morgan <include@grrlz.net>
Cc: "Cen Zhang (Microsoft)" <blbllhy@gmail.com>,
	brauner@kernel.org, akpm@linux-foundation.org, jack@suse.cz,
	avagin@gmail.com, ptikhomirov@virtuozzo.com, mjguzik@gmail.com,
	linux-kernel@vger.kernel.org,
	AutonomousCodeSecurity@microsoft.com,
	tgopinath@linux.microsoft.com, kys@microsoft.com,
	stable@vger.kernel.org
Subject: Re: [PATCH v2 2/2] pid: fix cad_pid use-after-free race
Date: Sat, 18 Jul 2026 16:13:37 +0200	[thread overview]
Message-ID: <aluKEZtkhbC0yUcT@redhat.com> (raw)
In-Reply-To: <FF14144B-5235-4805-8E78-5C1AFBCC631A@grrlz.net>

On 07/18, Bradley Morgan wrote:
>
> On July 18, 2026 2:19:57 PM GMT+01:00, Oleg Nesterov <oleg@redhat.com>
>
> > Hmm. Why do we need get/put_pid() ? I think that
> >
> > 	rcu_read_lock();
> > 	ret = kill_pid(rcu_dereference(cad_pid), sig, priv);
> > 	rcu_read_unlock();
> >
> > 	return ret;
> >
> > should work just fine?
>
> youre right that the get/put is redundant. kill_pid() doesnt sleep, it just
> grabs tasklist_lock,

(no it doesn't take tasklist)

> but i dont think either form is actually safe, and thats the bit id like
> Cen to address. rcu_read_lock() only protects the pid if the freeing side
> defers to a grace period. on the cad_pid path it doesnt:
>
> proc_do_cad_pid():
> 	put_pid(xchg(&cad_pid, new_pid));

I must have missed something.

But this patch adds synchronize_rcu() before the final put_pid() ?

And. If kill_pid(rcu_dereference(cad_pid)) was not safe under rcu_read_lock(),
then get_pid(rcu_dereference(cad_pid)) would be equally unsafe?

Oleg.


  reply	other threads:[~2026-07-18 14:13 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-18  3:19 [PATCH v2 1/2] pid: deinline kill_cad_pid Cen Zhang (Microsoft)
2026-07-18  3:20 ` [PATCH v2 2/2] pid: fix cad_pid use-after-free race Cen Zhang (Microsoft)
2026-07-18 11:54   ` Bradley Morgan
2026-07-18 13:19   ` Oleg Nesterov
2026-07-18 13:59     ` Bradley Morgan
2026-07-18 14:13       ` Oleg Nesterov [this message]
2026-07-18 14:28         ` Bradley Morgan
2026-07-18 15:37     ` Mateusz Guzik
2026-07-18 15:58       ` Oleg Nesterov
2026-07-18 10:24 ` [PATCH v2 1/2] pid: deinline kill_cad_pid Bradley Morgan

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=aluKEZtkhbC0yUcT@redhat.com \
    --to=oleg@redhat.com \
    --cc=AutonomousCodeSecurity@microsoft.com \
    --cc=akpm@linux-foundation.org \
    --cc=avagin@gmail.com \
    --cc=blbllhy@gmail.com \
    --cc=brauner@kernel.org \
    --cc=include@grrlz.net \
    --cc=jack@suse.cz \
    --cc=kys@microsoft.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mjguzik@gmail.com \
    --cc=ptikhomirov@virtuozzo.com \
    --cc=stable@vger.kernel.org \
    --cc=tgopinath@linux.microsoft.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

Powered by JetHome