[Bug runtime/30408] Always fail to read userland memory (read faults) inside perf event probes with 6.2/6.1 kernels
agentzh at gmail dot com
sourceware-bugzilla@sourceware.org
Sat May 13 05:33:26 GMT 2023
https://sourceware.org/bugzilla/show_bug.cgi?id=30408
--- Comment #4 from agentzh <agentzh at gmail dot com> ---
OK, I tracked it down to be the user_addr_max() macro missing since 5.18, which
is in the stap runtime's lookup_bad_addr_user() function. In perf event probe
handlers, the in_task() macro always returns 0 (false). in_task() is a macro
defined as
```
#define in_task() (!(in_nmi() | in_hardirq() | in_serving_softirq()))
```
And the kernels use hardirq contexts for perf events like
`perf.type(1).config(0).sample(100000)`, and thus in_hardirq() returning 1.
For comparison, the kernel's own bpf_probe_read_user() function does not check
in_task(), in_hardirq(), or user_addr_max() (though it has another deadlock
regression since 5.19 on the code path copy_from_user_nofault ->
check_object_size -> find_vmap_area() around the vmap_area_lock lock, but that
is another story).
The following patch seems to fix this for me:
https://gist.github.com/agentzh/948f77381c1f1e2cb7474c22c2c17c0e
So this regression really appeared since 5.18.
--
You are receiving this mail because:
You are the assignee for the bug.
More information about the Systemtap
mailing list