Skip to content

bpf: reject direct access to nullable PTR_TO_BUF pointers

Qi Tang bpf 4 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest2 patches 4 repliesIn review 1 of 2 applied
  2. v32 patches 2 repliesSuperseded
  3. v21 patch 1 replySuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v11 patch2 repliesSuperseded

Changes in v4 from the cover letter

- Add test runner in prog_tests/ so the test is actually invoked by test_progs (Kumar)

Patches in v4 1 of 2 applied

#Subject and filesSizeRepliesApplied
1/2bpf: reject direct access to nullable PTR_TO_BUF pointerskernel/bpf/verifier.c+2 -11 replyApplied
2/2selftests/bpf: add test for nullable PTR_TO_BUF accesstools/testing/selftests/bpf/prog_tests/iter_buf_null_fail.c tools/testing/selftests/bpf/progs/iter_buf_null_fail.c+60 -03 replies

Reviews trailers per patch

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

PatchKumar Kartikeya DwivediAmery Hung
1/2A-b R-b
2/2R-b

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

Read the v4 thread

Cover letter [PATCH bpf v4 0/2] bpf: reject direct access to nullable PTR_TO_BUF pointers

check_mem_access() allows direct dereference of PTR_TO_BUF | PTR_MAYBE_NULL without a null check, causing kernel NULL dereference on map iterator stop callbacks.

Patch 1 adds the missing type_may_be_null() guard. Patch 2 adds a selftest with a test runner.

Changes in v4:
- Add test runner in prog_tests/ so the test is actually invoked by test_progs (Kumar)

Changes in v3:
- Drop stack trace from commit log
- Split kernel fix and selftest into separate patches
- Use [PATCH bpf] prefix

Changes in v2:
- Add selftest

Qi Tang (2):
bpf: reject direct access to nullable PTR_TO_BUF pointers selftests/bpf: add test for nullable PTR_TO_BUF access

 kernel/bpf/verifier.c                                       |  3 ++-
 tools/testing/selftests/bpf/prog_tests/iter_buf_null_fail.c  |  9 +++++++++
 tools/testing/selftests/bpf/progs/iter_buf_null_fail.c       | 51 ++++++++++++
 3 files changed, 62 insertions(+), 1 deletion(-)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/iter_buf_null_fail.c
 create mode 100644 tools/testing/selftests/bpf/progs/iter_buf_null_fail.c