bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC 0/3] bpf: Add d_path helper
@ 2020-04-01 11:09 Jiri Olsa
  2020-04-01 11:09 ` [PATCH 1/3] bpf: Add support to check if BTF object is nested in another object Jiri Olsa
                   ` (4 more replies)
  0 siblings, 5 replies; 20+ messages in thread
From: Jiri Olsa @ 2020-04-01 11:09 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann
  Cc: netdev, bpf, Yonghong Song, Martin KaFai Lau, David Miller,
	John Fastabend, Jesper Dangaard Brouer, Wenbo Zhang, KP Singh,
	Andrii Nakryiko, bgregg, Al Viro

hi,
adding d_path helper to return full path for 'path' object.

I originally added and used 'file_path' helper, which did the same,
but used 'struct file' object. Then realized that file_path is just
a wrapper for d_path, so we'd cover more calling sites if we add
d_path helper and allowed resolving BTF object within another object,
so we could call d_path also with file pointer, like:

  bpf_d_path(&file->f_path, buf, size);

This feature is mainly to be able to add dpath (filepath originally)
function to bpftrace, which seems to work nicely now, like:

  # bpftrace -e 'kretfunc:fget { printf("%s\n", dpath(args->ret->f_path));  }' 

I'm not completely sure this is all safe and bullet proof and there's
no other way to do this, hence RFC post.

I'd be happy also with file_path function, but I thought it'd be
a shame not to try to add d_path with the verifier change.
I'm open to any suggestions ;-)

thanks,
jirka


---
Jiri Olsa (3):
      bpf: Add support to check if BTF object is nested in another object
      bpf: Add d_path helper
      selftests/bpf: Add test for d_path helper

 include/linux/bpf.h                             |   3 ++
 include/uapi/linux/bpf.h                        |  14 ++++++-
 kernel/bpf/btf.c                                |  69 +++++++++++++++++++++++++++++++++
 kernel/bpf/verifier.c                           |  18 ++++++++-
 kernel/trace/bpf_trace.c                        |  31 +++++++++++++++
 scripts/bpf_helpers_doc.py                      |   2 +
 tools/include/uapi/linux/bpf.h                  |  14 ++++++-
 tools/testing/selftests/bpf/prog_tests/d_path.c | 196 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 tools/testing/selftests/bpf/progs/test_d_path.c |  71 ++++++++++++++++++++++++++++++++++
 9 files changed, 414 insertions(+), 4 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/d_path.c
 create mode 100644 tools/testing/selftests/bpf/progs/test_d_path.c


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

end of thread, other threads:[~2020-04-07  9:46 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-01 11:09 [RFC 0/3] bpf: Add d_path helper Jiri Olsa
2020-04-01 11:09 ` [PATCH 1/3] bpf: Add support to check if BTF object is nested in another object Jiri Olsa
2020-04-07  1:16   ` Alexei Starovoitov
2020-04-07  9:37     ` Jiri Olsa
2020-04-01 11:09 ` [PATCH 2/3] bpf: Add d_path helper Jiri Olsa
2020-04-02 14:02   ` Florent Revest
2020-04-03  9:01     ` Jiri Olsa
2020-04-06  2:49       ` Andrii Nakryiko
2020-04-01 11:09 ` [PATCH 3/3] selftests/bpf: Add test for " Jiri Olsa
2020-04-02 14:03 ` [RFC 0/3] bpf: Add " Florent Revest
2020-04-03  8:55   ` Jiri Olsa
2020-04-02 14:21 ` Al Viro
2020-04-03  9:08   ` Jiri Olsa
2020-04-06  3:16     ` Al Viro
2020-04-06  9:09       ` Jiri Olsa
2020-04-06 12:47         ` Al Viro
2020-04-07  1:10         ` Alexei Starovoitov
2020-04-07  8:53           ` Jiri Olsa
2020-04-07  9:27           ` KP Singh
2020-04-07  9:45             ` Jiri Olsa

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