mbox series

[bpf,v2,0/3] Explicit raw_tp NULL arguments

Message ID 20241213175127.2084759-1-memxor@gmail.com (mailing list archive)
Headers show
Series Explicit raw_tp NULL arguments | expand

Message

Kumar Kartikeya Dwivedi Dec. 13, 2024, 5:51 p.m. UTC
This set reverts the raw_tp masking changes introduced in commit
cb4158ce8ec8 ("bpf: Mark raw_tp arguments with PTR_MAYBE_NULL") and
replaces it wwith an explicit list of tracepoints and their arguments
which need to be annotated as PTR_MAYBE_NULL. More context on the
fallout caused by the masking fix and subsequent discussions can be
found in [0].

To remedy this, we implement a solution of explicitly defined tracepoint
and define which args need to be marked NULL or scalar (for IS_ERR
case). The commit logs describes the details of this approach in detail.

We will follow up this solution an approach Eduard is working on to
perform automated analysis of NULL-ness of tracepoint arguments. The
current PoC is available here:

- LLVM branch with the analysis:
  https://github.com/eddyz87/llvm-project/tree/nullness-for-tracepoint-params
- Python script for merging of analysis results:
  https://gist.github.com/eddyz87/e47c164466a60e8d49e6911cff146f47

The idea is to infer a tri-state verdict for each tracepoint parameter:
definitely not null, can be null, unknown (in which case no assumptions
should be made).

Using this information, the verifier in most cases will be able to
precisely determine the state of the tracepoint parameter without any
human effort. At that point, the table maintained manually in this set
can be dropped and replace with this automated analysis tool's result.
This will be kept up to date with each kernel release.

  [0]: https://lore.kernel.org/bpf/20241206161053.809580-1-memxor@gmail.com

Changelog:
----------
v1 -> v2:
v1: https://lore.kernel.org/bpf/20241211020156.18966-1-memxor@gmail.com

 * Address comments from Jiri
   * Mark module tracepoints args NULL by default
   * Add more sunrpc tracepoints
   * Unify scalar or null handling
 * Address comments from Alexei
   * Use bitmask approach suggested in review
   * Unify scalar or null handling
   * Drop most tests that rely on CONFIG options
   * Drop scripts to generate tests

Kumar Kartikeya Dwivedi (3):
  bpf: Revert "bpf: Mark raw_tp arguments with PTR_MAYBE_NULL"
  bpf: Augment raw_tp arguments with PTR_MAYBE_NULL
  selftests/bpf: Add tests for raw_tp NULL args

 include/linux/bpf.h                           |   6 -
 kernel/bpf/btf.c                              | 141 +++++++++++++++++-
 kernel/bpf/verifier.c                         |  79 +---------
 .../selftests/bpf/prog_tests/raw_tp_null.c    |   3 +
 .../testing/selftests/bpf/progs/raw_tp_null.c |  19 ++-
 .../selftests/bpf/progs/raw_tp_null_fail.c    |  24 +++
 .../bpf/progs/test_tp_btf_nullable.c          |   6 +-
 7 files changed, 181 insertions(+), 97 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/progs/raw_tp_null_fail.c


base-commit: e4c80f69758e5088e8aae48f3d6abb41c6da7812