Skip to content

Fix bpf mem read/write vulnerability.

Hao Luo stable 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest9 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/9bpf: Introduce composable reg, ret and arg types.include/linux/bpf.h include/linux/bpf_verifier.h+55 -00 replies
2/9bpf: Replace ARG_XXX_OR_NULL with ARG_XXX | PTR_MAYBE_NULLinclude/linux/bpf.h kernel/bpf/verifier.c+23 -310 replies
3/9bpf: Replace RET_XXX_OR_NULL with RET_XXX | PTR_MAYBE_NULLinclude/linux/bpf.h kernel/bpf/helpers.c kernel/bpf/verifier.c+39 -340 replies
4/9bpf: Replace PTR_TO_XXX_OR_NULL with PTR_TO_XXX | PTR_MAYBE_NULLinclude/linux/bpf.h include/linux/bpf_verifier.h kernel/bpf/btf.c +4 more+148 -1860 replies
5/9bpf: Introduce MEM_RDONLY flaginclude/linux/bpf.h kernel/bpf/btf.c kernel/bpf/map_iter.c +3 more+60 -430 replies
6/9bpf: Convert PTR_TO_MEM_OR_NULL to composable types.include/linux/bpf.h kernel/bpf/btf.c kernel/bpf/verifier.c+2 -30 replies
7/9bpf: Make per_cpu_ptr return rdonly PTR_TO_MEM.kernel/bpf/helpers.c kernel/bpf/verifier.c+28 -60 replies
8/9bpf: Add MEM_RDONLY for helper args that are pointers to rdonly mem.include/linux/bpf.h kernel/bpf/btf.c kernel/bpf/cgroup.c +6 more+73 -570 replies
9/9bpf/selftests: Test PTR_TO_RDONLY_MEMtools/testing/selftests/bpf/prog_tests/ksyms_btf.c tools/testing/selftests/bpf/progs/test_ksyms_btf_write_check.c+43 -00 replies

Reviews trailers per patch

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

PatchAndrii Nakryiko
1/9
2/9
3/9
4/9
5/9
6/9
7/9
8/9
9/9A-b

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

Read the v1 thread

Cover letter [PATCH stable linux-5.16.y 0/9] Fix bpf mem read/write vulnerability.

Hi Greg,

Please consider cherry-pick this patch series into 5.16.x stable. It includes a fix to a bug in 5.16 stable which allows a user with cap_bpf privileges to get root privileges. The patch that fixes the bug is

patch 7/9: bpf: Make per_cpu_ptr return rdonly

The rest are the depedences required by the fix patch. This patchset has been merged in mainline v5.17. The patches were not planned to backport because of its complex dependences.

Tested by compile, build and run through a subset of bpf test_progs.

Hao Luo (9):
bpf: Introduce composable reg, ret and arg types.
bpf: Replace ARG_XXX_OR_NULL with ARG_XXX | PTR_MAYBE_NULL
bpf: Replace RET_XXX_OR_NULL with RET_XXX | PTR_MAYBE_NULL
bpf: Replace PTR_TO_XXX_OR_NULL with PTR_TO_XXX | PTR_MAYBE_NULL
bpf: Introduce MEM_RDONLY flag
bpf: Convert PTR_TO_MEM_OR_NULL to composable types.
bpf: Make per_cpu_ptr return rdonly PTR_TO_MEM.
bpf: Add MEM_RDONLY for helper args that are pointers to rdonly mem. bpf/selftests: Test PTR_TO_RDONLY_MEM

 include/linux/bpf.h                           | 101 +++-
 include/linux/bpf_verifier.h                  |  17 +
 kernel/bpf/btf.c                              |  12 +-
 kernel/bpf/cgroup.c                           |   2 +-
 kernel/bpf/helpers.c                          |  12 +-
 kernel/bpf/map_iter.c                         |   4 +-
 kernel/bpf/ringbuf.c                          |   2 +-
 kernel/bpf/syscall.c                          |   2 +-
 kernel/bpf/verifier.c                         | 488 +++++++++---------
 kernel/trace/bpf_trace.c                      |  26 +-
 net/core/bpf_sk_storage.c                     |   2 +-
 net/core/filter.c                             |  64 +--
 net/core/sock_map.c                           |   2 +-
 .../selftests/bpf/prog_tests/ksyms_btf.c      |  14 +
 .../bpf/progs/test_ksyms_btf_write_check.c    |  29 ++
 15 files changed, 444 insertions(+), 333 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/progs/test_ksyms_btf_write_check.c
Signature · 1 line
2.35.1.265.g69c8d7142f-goog