public inbox for systemtap@sourceware.org
 help / color / mirror / Atom feed
From: "agentzh at gmail dot com" <sourceware-bugzilla@sourceware.org>
To: systemtap@sourceware.org
Subject: [Bug runtime/30408] Always fail to read userland memory (read faults) inside perf event probes with 6.2/6.1 kernels
Date: Sat, 13 May 2023 05:33:26 +0000	[thread overview]
Message-ID: <bug-30408-6586-WpfbhMFL21@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-30408-6586@http.sourceware.org/bugzilla/>

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.

  parent reply	other threads:[~2023-05-13  5:33 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-30  6:28 [Bug runtime/30408] New: Always fail to read userland memory (read faults) inside perf event probes with 6.2 kernels agentzh at gmail dot com
2023-05-02 22:31 ` [Bug runtime/30408] " agentzh at gmail dot com
2023-05-02 22:32 ` [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
2023-05-09 19:59 ` agentzh at gmail dot com
2023-05-09 20:04 ` agentzh at gmail dot com
2023-05-13  5:33 ` agentzh at gmail dot com [this message]
2023-05-13  6:28 ` agentzh at gmail dot com
2023-05-16 19:28 ` agentzh at gmail dot com
2023-05-16 19:51 ` agentzh at gmail dot com

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=bug-30408-6586-WpfbhMFL21@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=systemtap@sourceware.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).