perf: Fix sample vs do_exit()
Linux
Affected versions
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
Linux
| Product | Affected | Fixed in |
|---|---|---|
| Linux Linux |
|
≥ c5ebcedb566ef17bda7b02686e0d658a7bb42ee7 · < 456019adaa2f5366b89c868dea9b483179bece54| No fix yet |
| Linux Linux |
|
|
In the Linux kernel, the following vulnerability has been resolved:
perf: Fix sample vs do_exit()
Baisheng Gao reported an ARM64 crash, which Mark decoded as being a synchronous external abort -- most likely due to trying to access MMIO in bad ways.
The crash further shows perf trying to do a user stack sample while in exit_mmap()'s tlb_finish_mmu() -- i.e. while tearing down the address space it is trying to access.
It turns out that we stop perf after we tear down the userspace mm; a receipie for disaster, since perf likes to access userspace for various reasons.
Flip this order by moving up where we stop perf in do_exit().
Additionally, harden PERF_SAMPLE_CALLCHAIN and PERF_SAMPLE_STACK_USER to abort when the current task does not have an mm (exit_mm() makes sure to set current->mm = NULL; before commencing with the actual teardown). Such that CPU wide events don't trip on this same problem.
From the CVE record · Linux
The Linux kernel's perf subsystem can try to sample a user stack while the process's address space is being torn down, causing an ARM64 crash. This occurs during process exit; the input does not specify whether an attacker can trigger it, whether authentication is needed, or whether user interaction is required.
Engineers running the Linux kernel should check their versions against the vendor advisory; affected versions are not specified.