Skip to contentSkip to conversation

bpf: Use tracing helpers for lsm programs

PATCH In review Jiri Olsa 5 participants 6 messages May 31, 2020 – Jun 2, 2020

Subsystems (7)
lore
Share & tools
lore

Jiri Olsa

author reviewer
#0 lore raw

PATCH 1/1 bpf: Use tracing helpers for lsm programs

Currenty lsm uses bpf_tracing_func_proto helpers which do not include stack trace or perf event output. It's useful to have those for bpftrace lsm support [1].

Using tracing_prog_func_proto helpers for lsm programs.

[1] https://github.com/iovisor/bpftrace/pull/1347

---
 include/linux/bpf.h      | 3 +++
 kernel/bpf/bpf_lsm.c     | 2 +-
 kernel/trace/bpf_trace.c | 2 +-
 3 files changed, 5 insertions(+), 2 deletions(-)
include/linux/bpf.h +3 -0
index e5884f7f801c..caa26ab471e8 100644
@@ -1628,6 +1628,9 @@ extern const struct bpf_func_proto bpf_ringbuf_query_proto;
 const struct bpf_func_proto *bpf_tracing_func_proto(
 	enum bpf_func_id func_id, const struct bpf_prog *prog);
 
+const struct bpf_func_proto *tracing_prog_func_proto(
+  enum bpf_func_id func_id, const struct bpf_prog *prog);
+
 /* Shared helpers among cBPF and eBPF. */
 void bpf_user_rnd_init_once(void);
 u64 bpf_user_rnd_u32(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5);
kernel/bpf/bpf_lsm.c +1 -1
index 19636703b24e..fb278144e9fd 100644
@@ -49,6 +49,6 @@ const struct bpf_prog_ops lsm_prog_ops = {
 };
 
 const struct bpf_verifier_ops lsm_verifier_ops = {
-	.get_func_proto = bpf_tracing_func_proto,
+	.get_func_proto = tracing_prog_func_proto,
 	.is_valid_access = btf_ctx_access,
 };
kernel/trace/bpf_trace.c +1 -1
index 3767d34114c0..794d665bebdd 100644
@@ -1467,7 +1467,7 @@ raw_tp_prog_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
 	}
 }
 
-static const struct bpf_func_proto *
+const struct bpf_func_proto *
 tracing_prog_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
 {
 	switch (func_id) {
Signature · 1 line
2.25.4
maintainer
#1 lore raw
Quoted 6 lines · Jiri Olsa

Currenty lsm uses bpf_tracing_func_proto helpers which do not include stack trace or perf event output. It's useful to have those for bpftrace lsm support [1].

Using tracing_prog_func_proto helpers for lsm programs.

How about using raw_tp_prog_func_proto?

Thanks,
Song

PS: Please tag the patch with subject prefix "PATCH bpf" for "PATCH bpf-next". I think this one belongs to bpf-next, which means we should wait after the merge window.

#2 lore raw
Quoted 10 lines · Song Liu
Quoted 6 lines · Jiri Olsa

Currenty lsm uses bpf_tracing_func_proto helpers which do not include stack trace or perf event output. It's useful to have those for bpftrace lsm support [1].

Using tracing_prog_func_proto helpers for lsm programs.

How about using raw_tp_prog_func_proto?

why?
I think skb/xdp_output is useful for lsm progs too. So I've applied the patch.

Quoted 3 lines

PS: Please tag the patch with subject prefix "PATCH bpf" for "PATCH bpf-next". I think this one belongs to bpf-next, which means we should wait after the merge window.

+1.
Jiri,
pls tag the subject properly.

maintainer
#3 lore raw
Quoted 9 lines · Alexei Starovoitov
Quoted 7 lines · Song Liu
Quoted 5 lines · Jiri Olsa

Currenty lsm uses bpf_tracing_func_proto helpers which do not include stack trace or perf event output. It's useful to have those for bpftrace lsm support [1].

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Using tracing_prog_func_proto helpers for lsm programs.

How about using raw_tp_prog_func_proto?

why?
I think skb/xdp_output is useful for lsm progs too. So I've applied the patch.

The only reason I asked was that the commit log only said stack trace and perf event output. No objections allowing other helpers for lsm.

Thanks,
Song

#4 lore raw
In reply to Alexei Starovoitov
Quoted 8 lines · Alexei Starovoitov
Quoted 7 lines · Song Liu
Quoted 5 lines · Jiri Olsa

Currenty lsm uses bpf_tracing_func_proto helpers which do not include stack trace or perf event output. It's useful to have those for bpftrace lsm support [1].

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Using tracing_prog_func_proto helpers for lsm programs.

How about using raw_tp_prog_func_proto?

why?
I think skb/xdp_output is useful for lsm progs too. So I've applied the patch.

right, it's also where d_path will be as well

Quoted 4 lines
Quoted 4 lines

PS: Please tag the patch with subject prefix "PATCH bpf" for "PATCH bpf-next". I think this one belongs to bpf-next, which means we should wait after the merge window.

I must have missed info about that,
thanks for info

Quoted 4 lines

+1.
Jiri,
pls tag the subject properly.

will do, sry

thanks,
jirka

#5 lore raw
Quoted 21 lines · Jiri Olsa
Quoted 8 lines · Alexei Starovoitov
Quoted 7 lines · Song Liu
Quoted 5 lines · Jiri Olsa

Currenty lsm uses bpf_tracing_func_proto helpers which do not include stack trace or perf event output. It's useful to have those for bpftrace lsm support [1].

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Using tracing_prog_func_proto helpers for lsm programs.

How about using raw_tp_prog_func_proto?

why?
I think skb/xdp_output is useful for lsm progs too. So I've applied the patch.

right, it's also where d_path will be as well

Quoted 1 line
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines

PS: Please tag the patch with subject prefix "PATCH bpf" for "PATCH bpf-next". I think this one belongs to bpf-next, which means we should wait after the merge window.

I must have missed info about that,
thanks for info

Thanks for adding this! LGTM as well.

- KP

Quoted 11 lines
Quoted 5 lines

+1.
Jiri,
pls tag the subject properly.

will do, sry

thanks,
jirka