Skip to content

bpf: Fixes for kprobe multi on kernel modules

Jiri Olsa bpf 3 versions – Applied

Status from this message: This series was applied to bpf/bpf-next.git (master)

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest8 patches 0 repliesApplied 8/8
  2. v28 patches 5 repliesSuperseded
  3. v18 patches 15 repliesSuperseded

Changes in v3 from the cover letter

- reorder fields in struct bpf_kprobe_multi_link [Andrii]
- added ack [Andrii]

Patches in v3 All 8 applied

#Subject and filesSizeRepliesApplied
1/8kallsyms: Make module_kallsyms_on_each_symbol generally availableinclude/linux/module.h kernel/module/kallsyms.c+9 -20 repliesApplied
2/8ftrace: Add support to resolve module symbols in ftrace_lookup_symbolskernel/trace/ftrace.c+11 -50 repliesApplied
3/8bpf: Rename __bpf_kprobe_multi_cookie_cmp to bpf_kprobe_multi_addrs_cmpkernel/trace/bpf_trace.c+3 -30 repliesApplied
4/8bpf: Take module reference on kprobe_multi linkkernel/trace/bpf_trace.c+92 -00 repliesApplied
5/8selftests/bpf: Add load_kallsyms_refresh functiontools/testing/selftests/bpf/trace_helpers.c tools/testing/selftests/bpf/trace_helpers.h+15 -70 repliesApplied
6/8selftests/bpf: Add bpf_testmod_fentry_* functionstools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c+24 -00 repliesApplied
7/8selftests/bpf: Add kprobe_multi check to module attach testtools/testing/selftests/bpf/prog_tests/module_attach.c tools/testing/selftests/bpf/progs/test_module_attach.c+13 -00 repliesApplied
8/8selftests/bpf: Add kprobe_multi kmod attach api teststools/testing/selftests/bpf/prog_tests/kprobe_multi_testmod_test.c tools/testing/selftests/bpf/progs/kprobe_multi.c+139 -00 repliesApplied

Reviews trailers per patch

All 8 patches have a Reviewed-by or Acked-by.

PatchSong LiuAndrii Nakryiko
1/8A-b
2/8A-b
3/8A-b
4/8A-b
5/8A-b
6/8A-b
7/8A-b
8/8A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v3 thread

Cover letter [PATCHv3 bpf-next 0/8] bpf: Fixes for kprobe multi on kernel modules

hi,
Martynas reported kprobe _multi link does not resolve symbols from kernel modules, which attach by address works.

In addition while fixing that I realized we do not take module reference if the module has kprobe_multi link on top of it and can be removed.

There's mo crash related to this, it will silently disappear from ftrace tables, while kprobe_multi link stays up with no data.

This patchset has fixes for both issues.

v3 changes:
- reorder fields in struct bpf_kprobe_multi_link [Andrii]
- added ack [Andrii]

v2 changes:
- added acks (Song)
- added comment to kallsyms_callback (Song)
- change module_callback realloc logic (Andrii)
- get rid of macros in tests (Andrii)

thanks,
jirka

---
Jiri Olsa (8):
kallsyms: Make module_kallsyms_on_each_symbol generally available
ftrace: Add support to resolve module symbols in ftrace_lookup_symbols
bpf: Rename __bpf_kprobe_multi_cookie_cmp to bpf_kprobe_multi_addrs_cmp
bpf: Take module reference on kprobe_multi link selftests/bpf: Add load_kallsyms_refresh function selftests/bpf: Add bpf_testmod_fentry_* functions selftests/bpf: Add kprobe_multi check to module attach test selftests/bpf: Add kprobe_multi kmod attach api tests

 include/linux/module.h                                             |  9 +++++++++
 kernel/module/kallsyms.c                                           |  2 --
 kernel/trace/bpf_trace.c                                           | 98 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
 kernel/trace/ftrace.c                                              | 16 +++++++++++-----
 tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c              | 24 ++++++++++++++++++++++++
 tools/testing/selftests/bpf/prog_tests/kprobe_multi_testmod_test.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 tools/testing/selftests/bpf/prog_tests/module_attach.c             |  7 +++++++
 tools/testing/selftests/bpf/progs/kprobe_multi.c                   | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tools/testing/selftests/bpf/progs/test_module_attach.c             |  6 ++++++
 tools/testing/selftests/bpf/trace_helpers.c                        | 20 +++++++++++++-------
 tools/testing/selftests/bpf/trace_helpers.h                        |  2 ++
 11 files changed, 306 insertions(+), 17 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/kprobe_multi_testmod_test.c