[PATCHv4 bpf-next 0/4] bpf: Add bpf_vma_build_id_parse kfunc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



hi,
first version of this patchset added helper for this functionality,
but based Alexei's feedback [1], changing it to kfunc.

With the current build_id_parse function as kfunc we can't effectively
check buffer size provided by user. Therefore adding new function as
bpf kfunc:

  int bpf_vma_build_id_parse(struct vm_area_struct *vma,
                             unsigned char *build_id,
                             size_t build_id__sz);

that triggers kfunc's verifier check for build_id/build_id__sz buffer
size and calls build_id_parse.

v4 changes:
  - vma object is now passed as trusted pointer argument [Alexei]
    - marked bpf_vma_build_id_parse with KF_TRUSTED_ARGS flag
      so it can be called only with PTR_TRUSTED args
    - marked vma objects from task_vma iter and find_vma callback
      as PTR_TRUSTED
  - added test for task_vma iterator

v3 changes:
  - restrict bpf_vma_build_id_parse to bpf_find_vma callback
  - move bpf_vma_build_id_parse to kernel/trace/bpf_trace.c
    and add new tracing_kfunc_set

thanks,
jirka


[1] https://lore.kernel.org/bpf/CAADnVQKyT4Mm4EdTCYK8c070E-BwPZS_FOkWKLJC80riSGmLTg@xxxxxxxxxxxxxx/
---
Jiri Olsa (4):
      bpf: Mark vma objects as trusted for task_vma iter and find_vma callback
      bpf: Add bpf_vma_build_id_parse function and kfunc
      selftests/bpf: Add bpf_vma_build_id_parse find_vma callback test
      selftests/bpf: Add bpf_vma_build_id_parse task vma iterator test

 include/linux/bpf.h                                             |  4 ++++
 kernel/bpf/task_iter.c                                          |  2 +-
 kernel/bpf/verifier.c                                           |  2 +-
 kernel/trace/bpf_trace.c                                        | 31 +++++++++++++++++++++++++++++++
 tools/testing/selftests/bpf/prog_tests/bpf_iter.c               | 44 ++++++++++++++++++++++++++++++++++++++++++++
 tools/testing/selftests/bpf/prog_tests/bpf_vma_build_id_parse.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 tools/testing/selftests/bpf/progs/bpf_iter_build_id.c           | 41 +++++++++++++++++++++++++++++++++++++++++
 tools/testing/selftests/bpf/progs/bpf_vma_build_id_parse.c      | 40 ++++++++++++++++++++++++++++++++++++++++
 tools/testing/selftests/bpf/trace_helpers.c                     | 40 ++++++++++++++++++++++++++++++++++++++++
 tools/testing/selftests/bpf/trace_helpers.h                     |  1 +
 10 files changed, 258 insertions(+), 2 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/bpf_vma_build_id_parse.c
 create mode 100644 tools/testing/selftests/bpf/progs/bpf_iter_build_id.c
 create mode 100644 tools/testing/selftests/bpf/progs/bpf_vma_build_id_parse.c



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux