mbox series

[v10,bpf-next,00/14] bpf: Add d_path helper

Message ID 20200807094559.571260-1-jolsa@kernel.org
Headers show
Series bpf: Add d_path helper | expand

Message

Jiri Olsa Aug. 7, 2020, 9:45 a.m. UTC
hi,
adding d_path helper function that returns full path for
given 'struct path' object, which needs to be the kernel
BTF 'path' object. The path is returned in buffer provided
'buf' of size 'sz' and is zero terminated.

  long bpf_d_path(struct path *path, char *buf, u32 sz);

The helper calls directly d_path function, so there's only
limited set of function it can be called from.

The patchset also adds support to add set of BTF IDs for
a helper to define functions that the helper is allowed
to be called from.

Also available at:
  https://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
  bpf/d_path

v10 changes:
  - added few acks
  - returned long instead of int in bpf_d_path helper [Alexei]
  - used local cnt variable in d_path test [Andrii]
  - fixed tyo in d_path comment [Andrii]
  - get rid of reg->off condition in check_func_arg [Andrii]

thanks,
jirka


---
Jiri Olsa (14):
      tools resolve_btfids: Add size check to get_id function
      tools resolve_btfids: Add support for set symbols
      bpf: Move btf_resolve_size into __btf_resolve_size
      bpf: Add elem_id pointer as argument to __btf_resolve_size
      bpf: Add type_id pointer as argument to __btf_resolve_size
      bpf: Remove recursion call in btf_struct_access
      bpf: Factor btf_struct_access function
      bpf: Add btf_struct_ids_match function
      bpf: Add BTF_SET_START/END macros
      bpf: Add d_path helper
      bpf: Update .BTF_ids section in btf.rst with sets info
      selftests/bpf: Add verifier test for d_path helper
      selftests/bpf: Add test for d_path helper
      selftests/bpf: Add set test to resolve_btfids

 Documentation/bpf/btf.rst                               |  25 +++++++++++++++
 include/linux/bpf.h                                     |   6 ++++
 include/linux/btf.h                                     |   3 +-
 include/linux/btf_ids.h                                 |  51 +++++++++++++++++++++++++++++-
 include/uapi/linux/bpf.h                                |  13 ++++++++
 kernel/bpf/bpf_struct_ops.c                             |   6 ++--
 kernel/bpf/btf.c                                        | 163 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------
 kernel/bpf/verifier.c                                   |  23 ++++++++++----
 kernel/trace/bpf_trace.c                                |  48 ++++++++++++++++++++++++++++
 scripts/bpf_helpers_doc.py                              |   2 ++
 tools/bpf/resolve_btfids/main.c                         |  29 +++++++++++++++--
 tools/include/linux/btf_ids.h                           |  51 +++++++++++++++++++++++++++++-
 tools/include/uapi/linux/bpf.h                          |  13 ++++++++
 tools/testing/selftests/bpf/prog_tests/d_path.c         | 147 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 tools/testing/selftests/bpf/prog_tests/resolve_btfids.c |  39 ++++++++++++++++++++++-
 tools/testing/selftests/bpf/progs/test_d_path.c         |  58 ++++++++++++++++++++++++++++++++++
 tools/testing/selftests/bpf/test_verifier.c             |  19 ++++++++++-
 tools/testing/selftests/bpf/verifier/d_path.c           |  37 ++++++++++++++++++++++
 18 files changed, 691 insertions(+), 42 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
 create mode 100644 tools/testing/selftests/bpf/verifier/d_path.c

Comments

Alexei Starovoitov Aug. 7, 2020, 4:35 p.m. UTC | #1
On Fri, Aug 07, 2020 at 11:45:45AM +0200, Jiri Olsa wrote:
> hi,
> adding d_path helper function that returns full path for
> given 'struct path' object, which needs to be the kernel
> BTF 'path' object. The path is returned in buffer provided
> 'buf' of size 'sz' and is zero terminated.
> 
>   long bpf_d_path(struct path *path, char *buf, u32 sz);
> 
> The helper calls directly d_path function, so there's only
> limited set of function it can be called from.
> 
> The patchset also adds support to add set of BTF IDs for
> a helper to define functions that the helper is allowed
> to be called from.
> 
> Also available at:
>   https://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
>   bpf/d_path
> 
> v10 changes:
>   - added few acks
>   - returned long instead of int in bpf_d_path helper [Alexei]
>   - used local cnt variable in d_path test [Andrii]
>   - fixed tyo in d_path comment [Andrii]
>   - get rid of reg->off condition in check_func_arg [Andrii]

bpf-next is closed.
I still encourage developers to submit new features for review, but please tag
them as RFC, so the purpose is clear to both maintainers and authors.
Jiri Olsa Aug. 7, 2020, 5:25 p.m. UTC | #2
On Fri, Aug 07, 2020 at 09:35:03AM -0700, Alexei Starovoitov wrote:
> On Fri, Aug 07, 2020 at 11:45:45AM +0200, Jiri Olsa wrote:
> > hi,
> > adding d_path helper function that returns full path for
> > given 'struct path' object, which needs to be the kernel
> > BTF 'path' object. The path is returned in buffer provided
> > 'buf' of size 'sz' and is zero terminated.
> > 
> >   long bpf_d_path(struct path *path, char *buf, u32 sz);
> > 
> > The helper calls directly d_path function, so there's only
> > limited set of function it can be called from.
> > 
> > The patchset also adds support to add set of BTF IDs for
> > a helper to define functions that the helper is allowed
> > to be called from.
> > 
> > Also available at:
> >   https://git.kernel.org/pub/scm/linux/kernel/git/jolsa/perf.git
> >   bpf/d_path
> > 
> > v10 changes:
> >   - added few acks
> >   - returned long instead of int in bpf_d_path helper [Alexei]
> >   - used local cnt variable in d_path test [Andrii]
> >   - fixed tyo in d_path comment [Andrii]
> >   - get rid of reg->off condition in check_func_arg [Andrii]
> 
> bpf-next is closed.
> I still encourage developers to submit new features for review, but please tag
> them as RFC, so the purpose is clear to both maintainers and authors.

sry, did not know this was the rule

jirka