From: Christian Brauner <christian.brauner@ubuntu.com>
To: syzbot <syzbot+492a4acccd8fc75ddfd0@syzkaller.appspotmail.com>,
oleg@redhat.com
Cc: akpm@linux-foundation.org, arnd@arndb.de, christian@brauner.io,
deepa.kernel@gmail.com, ebiederm@xmission.com, elver@google.com,
guro@fb.com, linux-kernel@vger.kernel.org,
syzkaller-bugs@googlegroups.com, will@kernel.org
Subject: Re: KCSAN: data-race in exit_signals / prepare_signal
Date: Mon, 21 Oct 2019 13:19:21 +0200 [thread overview]
Message-ID: <20191021111920.frmc3njkha4c3a72@wittgenstein> (raw)
In-Reply-To: <0000000000003b1e8005956939f1@google.com>
[+Cc Will]
On Mon, Oct 21, 2019 at 03:34:07AM -0700, syzbot wrote:
> Hello,
>
> syzbot found the following crash on:
>
> HEAD commit: d724f94f x86, kcsan: Enable KCSAN for x86
> git tree: https://github.com/google/ktsan.git kcsan
> console output: https://syzkaller.appspot.com/x/log.txt?x=13eab79f600000
> kernel config: https://syzkaller.appspot.com/x/.config?x=c0906aa620713d80
> dashboard link: https://syzkaller.appspot.com/bug?extid=492a4acccd8fc75ddfd0
> compiler: gcc (GCC) 9.0.0 20181231 (experimental)
>
> Unfortunately, I don't have any reproducer for this crash yet.
>
> IMPORTANT: if you fix the bug, please add the following tag to the commit:
> Reported-by: syzbot+492a4acccd8fc75ddfd0@syzkaller.appspotmail.com
>
> ==================================================================
> BUG: KCSAN: data-race in exit_signals / prepare_signal
This traces back to Oleg fixing a race between a group stop and a thread
exiting before it notices that it has a pending signal or is in the middle of
do_exit() already, causing group stop to get wacky.
The original commit to fix this race is
commit d12619b5ff56 ("fix group stop with exit race") which took sighand
lock before setting PF_EXITING on the thread.
Later on in
commit 5dee1707dfbf ("move the related code from exit_notify() to exit_signals()")
an improvement was made for the single-threaded case and the
case where the group stop is already in progress. This removed the
sighand lock around the PF_EXITING assignment.
If the race really matters and given how tsk->flags is currently accessed
everywhere the simple fix for now might be:
diff --git a/kernel/signal.c b/kernel/signal.c
index c4da1ef56fdf..cf61e044c4cc 100644
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -2819,7 +2819,9 @@ void exit_signals(struct task_struct *tsk)
cgroup_threadgroup_change_begin(tsk);
if (thread_group_empty(tsk) || signal_group_exit(tsk->signal)) {
+ spin_lock_irq(&tsk->sighand->siglock);
tsk->flags |= PF_EXITING;
+ spin_unlock_irq(&tsk->sighand->siglock);
cgroup_threadgroup_change_end(tsk);
return;
}
Christian
next prev parent reply other threads:[~2019-10-21 11:19 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-21 10:34 syzbot
2019-10-21 11:19 ` Christian Brauner [this message]
2019-10-21 12:00 ` Oleg Nesterov
2019-10-21 12:15 ` Marco Elver
2019-10-21 13:47 ` Oleg Nesterov
2019-10-21 12:51 ` Christian Brauner
2019-10-21 14:21 ` cgroup_enable_task_cg_lists && PF_EXITING (Was: KCSAN: data-race in exit_signals / prepare_signal) Oleg Nesterov
2019-10-24 17:54 ` Tejun Heo
2019-10-24 19:03 ` [PATCH cgroup/for-5.5] cgroup: remove cgroup_enable_task_cg_lists() optimization Tejun Heo
2019-10-25 12:56 ` Tejun Heo
2019-10-25 13:33 ` Christian Brauner
2019-10-25 14:13 ` Oleg Nesterov
2019-10-25 14:32 ` Christian Brauner
2019-10-25 15:52 ` Oleg Nesterov
2019-10-25 17:05 ` Christian Brauner
2019-10-28 16:48 ` Oleg Nesterov
2019-10-28 17:30 ` Christian Brauner
2019-10-28 17:46 ` Marco Elver
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=20191021111920.frmc3njkha4c3a72@wittgenstein \
--to=christian.brauner@ubuntu.com \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=christian@brauner.io \
--cc=deepa.kernel@gmail.com \
--cc=ebiederm@xmission.com \
--cc=elver@google.com \
--cc=guro@fb.com \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@redhat.com \
--cc=syzbot+492a4acccd8fc75ddfd0@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
--cc=will@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 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®