From: Oleg Nesterov <oleg@redhat.com>
To: Jiayuan Chen <jiayuan.chen@linux.dev>
Cc: linux-kernel@vger.kernel.org, mrpre@163.com, mkoutny@suse.com,
syzbot+adcaa842b762a1762e7d@syzkaller.appspotmail.com,
syzbot+fab52e3459fa2f95df57@syzkaller.appspotmail.com,
syzbot+0718f65353d72efaac1e@syzkaller.appspotmail.com,
Andrew Morton <akpm@linux-foundation.org>,
Christian Brauner <brauner@kernel.org>,
Lorenzo Stoakes <lorenzo.stoakes@oracle.com>,
"Liam R. Howlett" <Liam.Howlett@Oracle.com>,
Suren Baghdasaryan <surenb@google.com>,
Wei Yang <richard.weiyang@gmail.com>,
David Hildenbrand <david@redhat.com>,
Al Viro <viro@zeniv.linux.org.uk>,
Mateusz Guzik <mjguzik@gmail.com>,
Joel Granados <joel.granados@kernel.org>,
Jens Axboe <axboe@kernel.dk>, Wei Liu <wei.liu@kernel.org>,
Frederic Weisbecker <frederic@kernel.org>
Subject: Re: [PATCH v1] pid: annotate data-races around pid_ns->pid_allocated
Date: Wed, 23 Apr 2025 15:51:02 +0200 [thread overview]
Message-ID: <20250423135101.GA28646@redhat.com> (raw)
In-Reply-To: <20250423115542.7081-1-jiayuan.chen@linux.dev>
On 04/23, Jiayuan Chen wrote:
>
> Suppress syzbot reports by annotating these accesses using
> READ_ONCE() / WRITE_ONCE().
...
> --- a/kernel/pid.c
> +++ b/kernel/pid.c
> @@ -122,7 +122,8 @@ void free_pid(struct pid *pid)
> for (i = 0; i <= pid->level; i++) {
> struct upid *upid = pid->numbers + i;
> struct pid_namespace *ns = upid->ns;
> - switch (--ns->pid_allocated) {
> + WRITE_ONCE(ns->pid_allocated, READ_ONCE(ns->pid_allocated) - 1);
> + switch (READ_ONCE(ns->pid_allocated)) {
I keep forgetting how kcsan works, but we don't need
READ_ONCE(ns->pid_allocated) under pidmap_lock?
Same for other functions which read/modify ->pid_allocated with
this lock held.
Oleg.
next prev parent reply other threads:[~2025-04-23 13:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-23 11:55 [PATCH v1] pid: annotate data-races around pid_ns->pid_allocated Jiayuan Chen
2025-04-23 13:51 ` Oleg Nesterov [this message]
2025-04-23 14:33 ` Jiayuan Chen
2025-04-23 16:24 ` Michal Koutný
2025-04-23 16:38 ` Oleg Nesterov
2025-04-24 9:38 ` Christian Brauner
2025-04-25 5:37 ` Jiayuan Chen
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=20250423135101.GA28646@redhat.com \
--to=oleg@redhat.com \
--cc=Liam.Howlett@Oracle.com \
--cc=akpm@linux-foundation.org \
--cc=axboe@kernel.dk \
--cc=brauner@kernel.org \
--cc=david@redhat.com \
--cc=frederic@kernel.org \
--cc=jiayuan.chen@linux.dev \
--cc=joel.granados@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lorenzo.stoakes@oracle.com \
--cc=mjguzik@gmail.com \
--cc=mkoutny@suse.com \
--cc=mrpre@163.com \
--cc=richard.weiyang@gmail.com \
--cc=surenb@google.com \
--cc=syzbot+0718f65353d72efaac1e@syzkaller.appspotmail.com \
--cc=syzbot+adcaa842b762a1762e7d@syzkaller.appspotmail.com \
--cc=syzbot+fab52e3459fa2f95df57@syzkaller.appspotmail.com \
--cc=viro@zeniv.linux.org.uk \
--cc=wei.liu@kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.