Skip to content

Commit 3da6bb4

Browse files
Tetsuo HandaPeter Zijlstra
authored andcommitted
perf/core: Fix WARN in perf_sigtrap()
Since exit_task_work() runs after perf_event_exit_task_context() updated ctx->task to TASK_TOMBSTONE, perf_sigtrap() from perf_pending_task() might observe event->ctx->task == TASK_TOMBSTONE. Swap the early exit tests in order not to hit WARN_ON_ONCE(). Closes: https://syzkaller.appspot.com/bug?extid=2fe61cb2a86066be6985 Reported-by: syzbot <[email protected]> Signed-off-by: Tetsuo Handa <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent d7b8f8e commit 3da6bb4

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

kernel/events/core.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7204,18 +7204,18 @@ void perf_event_wakeup(struct perf_event *event)
72047204
static void perf_sigtrap(struct perf_event *event)
72057205
{
72067206
/*
7207-
* We'd expect this to only occur if the irq_work is delayed and either
7208-
* ctx->task or current has changed in the meantime. This can be the
7209-
* case on architectures that do not implement arch_irq_work_raise().
7207+
* Both perf_pending_task() and perf_pending_irq() can race with the
7208+
* task exiting.
72107209
*/
7211-
if (WARN_ON_ONCE(event->ctx->task != current))
7210+
if (current->flags & PF_EXITING)
72127211
return;
72137212

72147213
/*
7215-
* Both perf_pending_task() and perf_pending_irq() can race with the
7216-
* task exiting.
7214+
* We'd expect this to only occur if the irq_work is delayed and either
7215+
* ctx->task or current has changed in the meantime. This can be the
7216+
* case on architectures that do not implement arch_irq_work_raise().
72177217
*/
7218-
if (current->flags & PF_EXITING)
7218+
if (WARN_ON_ONCE(event->ctx->task != current))
72197219
return;
72207220

72217221
send_sig_perf((void __user *)event->pending_addr,

0 commit comments

Comments
 (0)