Skip to content

bpf: verifier: use target program's type for access verifications

Udip Pant bpf lkml netdev 1 version Applied

Status from this message: Applied. Thanks

Get series with b4
b4 am [email protected]

Versions newest first

  1. v3 Latest4 patches 5 repliesApplied

Changes in v3 from the cover letter

* more comprehensive resolution of the program type in the verifier based on the target program (and not just for the packet access)
* selftests for checking return code and map access
* Also moved this patch to 'bpf-next' from 'bpf' tree

Patches in v3 Applied

#Subject and filesSizeRepliesApplied
1/4bpf: verifier: use target program's type for access verificationskernel/bpf/verifier.c+21 -110 replies
2/4selftests/bpf: add test for freplace program with write accesstools/testing/selftests/bpf/prog_tests/fexit_bpf2bpf.c tools/testing/selftests/bpf/progs/fexit_bpf2bpf.c tools/testing/selftests/bpf/progs/test_pkt_access.c+48 -02 replies
3/4selftests/bpf: test for checking return code for the extended progtools/testing/selftests/bpf/prog_tests/fexit_bpf2bpf.c tools/testing/selftests/bpf/progs/freplace_connect_v4_prog.c+59 -00 replies
4/4selftests/bpf: test for map update access from within EXT programstools/testing/selftests/bpf/prog_tests/fexit_bpf2bpf.c tools/testing/selftests/bpf/progs/freplace_attach_probe.c tools/testing/selftests/bpf/progs/freplace_cls_redirect.c+104 -30 replies

Reviews trailers per patch

None of the 4 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchYonghong SongToke Høiland-Jørgensen
SeriesA-b A-b
1/4
2/4
3/4
4/4

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-next v3 0/4] bpf: verifier: use target program's type for access verifications

This patch series adds changes in verifier to make decisions such as granting of read / write access or enforcement of return code status based on the program type of the target program while using dynamic program extension (of type BPF_PROG_TYPE_EXT).

The BPF_PROG_TYPE_EXT type can be used to extend types such as XDP, SKB and others. Since the BPF_PROG_TYPE_EXT program type on itself is just a placeholder for those, we need this extended check for those extended programs to actually work with proper access, while using this option.

Patch #1 includes changes in the verifier.
Patch #2 adds selftests to verify write access on a packet for a valid extension program type
Patch #3 adds selftests to verify proper check for the return code Patch #4 adds selftests to ensure access permissions and restrictions for some map types such sockmap.

Changelogs:
v2 -> v3:
* more comprehensive resolution of the program type in the verifier based on the target program (and not just for the packet access)
* selftests for checking return code and map access
* Also moved this patch to 'bpf-next' from 'bpf' tree
v1 -> v2:
* extraction of the logic to resolve prog type into a separate method
* selftests to check for packet access for a valid freplace prog

Udip Pant (4):
bpf: verifier: use target program's type for access verifications selftests/bpf: add test for freplace program with write access selftests/bpf: test for checking return code for the extended prog selftests/bpf: test for map update access from within EXT programs

 kernel/bpf/verifier.c                         | 32 ++++++---
 .../selftests/bpf/prog_tests/fexit_bpf2bpf.c  | 68 +++++++++++++++++++
 .../selftests/bpf/progs/fexit_bpf2bpf.c       | 27 ++++++++
 .../bpf/progs/freplace_attach_probe.c         | 40 +++++++++++
 .../bpf/progs/freplace_cls_redirect.c         | 34 ++++++++++
 .../bpf/progs/freplace_connect_v4_prog.c      | 19 ++++++
 .../selftests/bpf/progs/test_pkt_access.c     | 20 ++++++
 7 files changed, 229 insertions(+), 11 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/progs/freplace_attach_probe.c
 create mode 100644 tools/testing/selftests/bpf/progs/freplace_cls_redirect.c
 create mode 100644 tools/testing/selftests/bpf/progs/freplace_connect_v4_prog.c
Signature · 1 line
2.24.1