bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bpf: Use tracing helpers for lsm programs
@ 2020-05-31 15:42 Jiri Olsa
  2020-06-01 19:00 ` Song Liu
  0 siblings, 1 reply; 6+ messages in thread
From: Jiri Olsa @ 2020-05-31 15:42 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann
  Cc: KP Singh, netdev, bpf, Yonghong Song, Martin KaFai Lau,
	Jakub Kicinski, David Miller, John Fastabend,
	Jesper Dangaard Brouer, Andrii Nakryiko, KP Singh

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

Cc: KP Singh <kpsingh@google.com>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 include/linux/bpf.h      | 3 +++
 kernel/bpf/bpf_lsm.c     | 2 +-
 kernel/trace/bpf_trace.c | 2 +-
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index e5884f7f801c..caa26ab471e8 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -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);
diff --git a/kernel/bpf/bpf_lsm.c b/kernel/bpf/bpf_lsm.c
index 19636703b24e..fb278144e9fd 100644
--- a/kernel/bpf/bpf_lsm.c
+++ b/kernel/bpf/bpf_lsm.c
@@ -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,
 };
diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
index 3767d34114c0..794d665bebdd 100644
--- a/kernel/trace/bpf_trace.c
+++ b/kernel/trace/bpf_trace.c
@@ -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) {
-- 
2.25.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] bpf: Use tracing helpers for lsm programs
  2020-05-31 15:42 [PATCH] bpf: Use tracing helpers for lsm programs Jiri Olsa
@ 2020-06-01 19:00 ` Song Liu
  2020-06-01 22:12   ` Alexei Starovoitov
  0 siblings, 1 reply; 6+ messages in thread
From: Song Liu @ 2020-06-01 19:00 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Alexei Starovoitov, Daniel Borkmann, KP Singh, Networking, bpf,
	Yonghong Song, Martin KaFai Lau, Jakub Kicinski, David Miller,
	John Fastabend, Jesper Dangaard Brouer, Andrii Nakryiko,
	KP Singh

On Sun, May 31, 2020 at 8:45 AM Jiri Olsa <jolsa@kernel.org> wrote:
>
> 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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] bpf: Use tracing helpers for lsm programs
  2020-06-01 19:00 ` Song Liu
@ 2020-06-01 22:12   ` Alexei Starovoitov
  2020-06-01 22:52     ` Song Liu
  2020-06-02  8:13     ` Jiri Olsa
  0 siblings, 2 replies; 6+ messages in thread
From: Alexei Starovoitov @ 2020-06-01 22:12 UTC (permalink / raw)
  To: Song Liu
  Cc: Jiri Olsa, Alexei Starovoitov, Daniel Borkmann, KP Singh,
	Networking, bpf, Yonghong Song, Martin KaFai Lau, Jakub Kicinski,
	David Miller, John Fastabend, Jesper Dangaard Brouer,
	Andrii Nakryiko, KP Singh

On Mon, Jun 1, 2020 at 12:00 PM Song Liu <song@kernel.org> wrote:
>
> On Sun, May 31, 2020 at 8:45 AM Jiri Olsa <jolsa@kernel.org> wrote:
> >
> > 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.

> 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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] bpf: Use tracing helpers for lsm programs
  2020-06-01 22:12   ` Alexei Starovoitov
@ 2020-06-01 22:52     ` Song Liu
  2020-06-02  8:13     ` Jiri Olsa
  1 sibling, 0 replies; 6+ messages in thread
From: Song Liu @ 2020-06-01 22:52 UTC (permalink / raw)
  To: Alexei Starovoitov
  Cc: Jiri Olsa, Alexei Starovoitov, Daniel Borkmann, KP Singh,
	Networking, bpf, Yonghong Song, Martin KaFai Lau, Jakub Kicinski,
	David Miller, John Fastabend, Jesper Dangaard Brouer,
	Andrii Nakryiko, KP Singh

On Mon, Jun 1, 2020 at 3:12 PM Alexei Starovoitov
<alexei.starovoitov@gmail.com> wrote:
>
> On Mon, Jun 1, 2020 at 12:00 PM Song Liu <song@kernel.org> wrote:
> >
> > On Sun, May 31, 2020 at 8:45 AM Jiri Olsa <jolsa@kernel.org> wrote:
> > >
> > > 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.

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] bpf: Use tracing helpers for lsm programs
  2020-06-01 22:12   ` Alexei Starovoitov
  2020-06-01 22:52     ` Song Liu
@ 2020-06-02  8:13     ` Jiri Olsa
  2020-06-02  9:06       ` KP Singh
  1 sibling, 1 reply; 6+ messages in thread
From: Jiri Olsa @ 2020-06-02  8:13 UTC (permalink / raw)
  To: Alexei Starovoitov
  Cc: Song Liu, Jiri Olsa, Alexei Starovoitov, Daniel Borkmann,
	KP Singh, Networking, bpf, Yonghong Song, Martin KaFai Lau,
	Jakub Kicinski, David Miller, John Fastabend,
	Jesper Dangaard Brouer, Andrii Nakryiko, KP Singh

On Mon, Jun 01, 2020 at 03:12:13PM -0700, Alexei Starovoitov wrote:
> On Mon, Jun 1, 2020 at 12:00 PM Song Liu <song@kernel.org> wrote:
> >
> > On Sun, May 31, 2020 at 8:45 AM Jiri Olsa <jolsa@kernel.org> wrote:
> > >
> > > 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.

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

> 
> > 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

> 
> +1.
> Jiri,
> pls tag the subject properly.

will do, sry

thanks,
jirka


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] bpf: Use tracing helpers for lsm programs
  2020-06-02  8:13     ` Jiri Olsa
@ 2020-06-02  9:06       ` KP Singh
  0 siblings, 0 replies; 6+ messages in thread
From: KP Singh @ 2020-06-02  9:06 UTC (permalink / raw)
  To: Jiri Olsa
  Cc: Alexei Starovoitov, Song Liu, Jiri Olsa, Alexei Starovoitov,
	Daniel Borkmann, KP Singh, Networking, bpf, Yonghong Song,
	Martin KaFai Lau, Jakub Kicinski, David Miller, John Fastabend,
	Jesper Dangaard Brouer, Andrii Nakryiko

On Tue, Jun 2, 2020 at 10:13 AM Jiri Olsa <jolsa@redhat.com> wrote:
>
> On Mon, Jun 01, 2020 at 03:12:13PM -0700, Alexei Starovoitov wrote:
> > On Mon, Jun 1, 2020 at 12:00 PM Song Liu <song@kernel.org> wrote:
> > >
> > > On Sun, May 31, 2020 at 8:45 AM Jiri Olsa <jolsa@kernel.org> wrote:
> > > >
> > > > 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.
>
> right, it's also where d_path will be as well
>
> >
> > > 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

>
> >
> > +1.
> > Jiri,
> > pls tag the subject properly.
>
> will do, sry
>
> thanks,
> jirka
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-06-02  9:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-31 15:42 [PATCH] bpf: Use tracing helpers for lsm programs Jiri Olsa
2020-06-01 19:00 ` Song Liu
2020-06-01 22:12   ` Alexei Starovoitov
2020-06-01 22:52     ` Song Liu
2020-06-02  8:13     ` Jiri Olsa
2020-06-02  9:06       ` KP Singh

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 NNTP newsgroup(s).