Commit 517e6a3
Peter Zijlstra
perf: Fix perf_pending_task() UaF
Per syzbot it is possible for perf_pending_task() to run after the
event is free()'d. There are two related but distinct cases:
- the task_work was already queued before destroying the event;
- destroying the event itself queues the task_work.
The first cannot be solved using task_work_cancel() since
perf_release() itself might be called from a task_work (____fput),
which means the current->task_works list is already empty and
task_work_cancel() won't be able to find the perf_pending_task()
entry.
The simplest alternative is extending the perf_event lifetime to cover
the task_work.
The second is just silly, queueing a task_work while you know the
event is going away makes no sense and is easily avoided by
re-arranging how the event is marked STATE_DEAD and ensuring it goes
through STATE_OFF on the way down.
Reported-by: [email protected]
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Tested-by: Marco Elver <[email protected]>1 parent 030a976 commit 517e6a3
1 file changed
+13
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2291 | 2291 | | |
2292 | 2292 | | |
2293 | 2293 | | |
| 2294 | + | |
2294 | 2295 | | |
2295 | 2296 | | |
2296 | 2297 | | |
| |||
2336 | 2337 | | |
2337 | 2338 | | |
2338 | 2339 | | |
| 2340 | + | |
2339 | 2341 | | |
2340 | 2342 | | |
2341 | 2343 | | |
| |||
2356 | 2358 | | |
2357 | 2359 | | |
2358 | 2360 | | |
| 2361 | + | |
| 2362 | + | |
| 2363 | + | |
| 2364 | + | |
| 2365 | + | |
| 2366 | + | |
2359 | 2367 | | |
2360 | 2368 | | |
2361 | 2369 | | |
2362 | 2370 | | |
2363 | 2371 | | |
2364 | 2372 | | |
| 2373 | + | |
| 2374 | + | |
2365 | 2375 | | |
2366 | 2376 | | |
2367 | 2377 | | |
| |||
5121 | 5131 | | |
5122 | 5132 | | |
5123 | 5133 | | |
5124 | | - | |
5125 | 5134 | | |
5126 | | - | |
5127 | 5135 | | |
5128 | 5136 | | |
5129 | 5137 | | |
| |||
5135 | 5143 | | |
5136 | 5144 | | |
5137 | 5145 | | |
5138 | | - | |
5139 | | - | |
| 5146 | + | |
5140 | 5147 | | |
5141 | 5148 | | |
5142 | 5149 | | |
| |||
6577 | 6584 | | |
6578 | 6585 | | |
6579 | 6586 | | |
| 6587 | + | |
| 6588 | + | |
6580 | 6589 | | |
6581 | 6590 | | |
6582 | 6591 | | |
| |||
0 commit comments