Skip to content

Explicit raw_tp NULL arguments

Kumar Kartikeya Dwivedi bpf 3 versions – Applied

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

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest3 patches 0 repliesApplied 3/3
  2. v23 patches 2 repliesSuperseded
  3. v14 patches 4 repliesSuperseded

Changes in v3 from the cover letter

v2: https://lore.kernel.org/bpf/[email protected]

* Address Eduard's nits, add Reviewed-by

Patches in v3 All 3 applied

#Subject and filesSizeRepliesApplied
1/3bpf: Revert "bpf: Mark raw_tp arguments with PTR_MAYBE_NULL"include/linux/bpf.h kernel/bpf/btf.c kernel/bpf/verifier.c +1 more+9 -870 repliesApplied
2/3bpf: Augment raw_tp arguments with PTR_MAYBE_NULLkernel/bpf/btf.c tools/testing/selftests/bpf/progs/raw_tp_null.c+147 -100 repliesApplied
3/3selftests/bpf: Add tests for raw_tp NULL argstools/testing/selftests/bpf/prog_tests/raw_tp_null.c tools/testing/selftests/bpf/progs/raw_tp_null_fail.c+27 -00 repliesApplied

Reviews trailers per patch

1 of 3 patches has a Reviewed-by or Acked-by.

PatchEduard Zingerman
1/3
2/3R-b
3/3

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

Read the v3 thread

Cover letter [PATCH bpf v3 0/3] Explicit raw_tp NULL arguments

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/[email protected]

Changelog:
----------
v2 -> v3:
v2: https://lore.kernel.org/bpf/[email protected]

* Address Eduard's nits, add Reviewed-by

v1 -> v2:
v1: https://lore.kernel.org/bpf/[email protected]

* 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                              | 143 +++++++++++++++++-
 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, 183 insertions(+), 97 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/progs/raw_tp_null_fail.c

base-commit: e4c80f69758e5088e8aae48f3d6abb41c6da7812

Signature · 1 line
2.43.5