bpf: fix semantics issues with helpers receiving NULL arguments
Get series with b4
b4 am [email protected]Versions newest first
- v1 Latest4 patches 1 replyIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/4 | bpf: introduce ARG_PTR_TO_MEM_OR_NULLinclude/ kernel/ net/ +1 more | +112 | 0 replies | |
| 2/4 | bpf: remove explicit handling of 0 for arg2 in bpf_probe_readkernel/ | +1 | 0 replies | |
| 3/4 | bpf: change bpf_probe_read_str arg2 type to ARG_CONST_SIZE_OR_ZEROkernel/ | +1 | 0 replies | |
| 4/4 | bpf: change bpf_perf_event_output arg5 type to ARG_CONST_SIZE_OR_ZEROkernel/ | +2 | 0 replies |
Reviews trailers per patch
All 4 patches have a Reviewed-by or Acked-by.
| Patch | Alexei Starovoitov | Daniel Borkmann | Yonghong Song |
|---|---|---|---|
| 1/4 | A-b | A-b | |
| 2/4 | A-b | A-b | A-b |
| 3/4 | A-b | A-b | |
| 4/4 | A-b | A-b |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.
Cover letter [PATCH net 0/4] bpf: fix semantics issues with helpers receiving NULL arguments
This set includes some fixes in semantics and usability issues that emerged recently, and would be good to have them in net before the next release.
In particular, ARG_CONST_SIZE_OR_ZERO semantics was recently changed in commit 9fd29c08e520 ("bpf: improve verifier ARG_CONST_SIZE_OR_ZERO semantics") with the goal of letting the compiler generate simpler code that the verifier can more easily accept.
To handle this change in semantics, a few checks in some helpers were added, like in commit 9c019e2bc4b2 ("bpf: change helper bpf_probe_read arg2 type to ARG_CONST_SIZE_OR_ZERO"), and those checks are less than ideal because once they make it into a released kernel bpf programs can start relying on them, preventing the possibility of being removed later on.
This patch tries to fix the issue by introducing a new argument type ARG_PTR_TO_MEM_OR_NULL that can be used for helpers that can receive a <NULL, 0> tuple. By doing so, we can fix the semantics of the other helpers that don't need <NULL, 0> and can just handle <!NULL, 0>, allowing the code to get rid of those checks.
Gianluca Borello (4):
bpf: introduce ARG_PTR_TO_MEM_OR_NULL
bpf: remove explicit handling of 0 for arg2 in bpf_probe_read
bpf: change bpf_probe_read_str arg2 type to ARG_CONST_SIZE_OR_ZERO
bpf: change bpf_perf_event_output arg5 type to ARG_CONST_SIZE_OR_ZERO
include/linux/bpf.h | 1 + kernel/bpf/verifier.c | 4 +- kernel/trace/bpf_trace.c | 12 +-- net/core/filter.c | 4 +- tools/testing/selftests/bpf/test_verifier.c | 113 ++++++++++++++++++++++++++-- 5 files changed, 116 insertions(+), 18 deletions(-)