From: Jiri Olsa <olsajiri@gmail.com>
To: Jiri Olsa <olsajiri@gmail.com>,
Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: Victor Laforet <victor.laforet@ip-paris.fr>, bpf@vger.kernel.org
Subject: Re: bpf_probe_read_user EFAULT
Date: Thu, 5 Jan 2023 10:47:40 +0100 [thread overview]
Message-ID: <Y7acvJqbBJt4V21+@krava> (raw)
In-Reply-To: <Y7X3qEOXeimw1JmF@krava>
On Wed, Jan 04, 2023 at 11:08:23PM +0100, Jiri Olsa wrote:
> On Wed, Jan 04, 2023 at 10:42:02PM +0100, Jiri Olsa wrote:
> > On Wed, Jan 04, 2023 at 04:24:27PM +0100, Victor Laforet wrote:
> > > Ok thanks. As I understand, tp_btf/+ probes (specifically tp_btf/sched_switch that I need) cannot be sleepable? It is then not possible to read user space memory from the bpf code?
> >
> > yes, only fentry/fexit/fmod_ret, lsm, and kprobe/uprobe programs can be sleepable
we actually allow to create tp_btf program with BPF_F_SLEEPABLE flag,
because it's TRACING prog type, but still bpf program can't sleep when
executed in tracepoint context.. so I wonder we should not allow to
load it, Alexei?
jirka
---
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 98a8051ce316..390621d79fbb 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -16755,10 +16755,14 @@ static int check_attach_btf_id(struct bpf_verifier_env *env)
return -EINVAL;
}
- if (prog->aux->sleepable && prog->type != BPF_PROG_TYPE_TRACING &&
- prog->type != BPF_PROG_TYPE_LSM && prog->type != BPF_PROG_TYPE_KPROBE) {
- verbose(env, "Only fentry/fexit/fmod_ret, lsm, and kprobe/uprobe programs can be sleepable\n");
- return -EINVAL;
+ if (prog->aux->sleepable) {
+ if ((prog->type == BPF_PROG_TYPE_TRACING &&
+ prog->expected_attach_type == BPF_TRACE_RAW_TP) ||
+ (prog->type != BPF_PROG_TYPE_TRACING &&
+ prog->type != BPF_PROG_TYPE_LSM && prog->type != BPF_PROG_TYPE_KPROBE)) {
+ verbose(env, "Only fentry/fexit/fmod_ret, lsm, and kprobe/uprobe programs can be sleepable\n");
+ return -EINVAL;
+ }
}
if (prog->type == BPF_PROG_TYPE_STRUCT_OPS)
next prev parent reply other threads:[~2023-01-05 9:47 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-27 14:56 bpf_probe_read_user EFAULT Victor Laforet
2022-12-27 16:00 ` Jiri Olsa
2022-12-28 14:00 ` Victor Laforet
2022-12-28 19:41 ` Yonghong Song
2023-01-02 22:10 ` Victor Laforet
[not found] ` <5692f180-5b78-48e0-b974-b60bd58c0839@Spark>
2023-01-03 8:03 ` Jiri Olsa
2023-01-04 15:24 ` Victor Laforet
2023-01-04 21:41 ` Jiri Olsa
2023-01-04 22:08 ` Jiri Olsa
2023-01-05 9:47 ` Jiri Olsa [this message]
2023-01-06 3:26 ` Alexei Starovoitov
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=Y7acvJqbBJt4V21+@krava \
--to=olsajiri@gmail.com \
--cc=alexei.starovoitov@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=victor.laforet@ip-paris.fr \
/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