Skip to content

bpf: Reject flexible-array allocation types

Yiyang Chen bpf linux-kselftest lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 2 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2bpf: Reject flexible-array allocation typeskernel/bpf/verifier.c+28 -01 reply
2/2selftests/bpf: Cover flexible-array allocation rejectiontools/testing/selftests/bpf/prog_tests/linked_list.c tools/testing/selftests/bpf/progs/linked_list_fail.c+25 -01 reply

Reviews trailers per patch

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

PatchEduard Zingerman
1/2
2/2A-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 bpf-next 0/2] bpf: Reject flexible-array allocation types

bpf_obj_new() and bpf_percpu_obj_new() allocate only the static BTF size for the selected program-BTF type.

A program-BTF struct can nevertheless end with a zero-length flexible array. Generic BTF struct walks have special handling for such trailing arrays, and can validate field accesses beyond the allocated static object size.

Patch 1 rejects allocation kfunc types with trailing flexible arrays. Patch 2 adds a linked_list negative loader case for the rejection.

Yiyang Chen (2):
bpf: Reject flexible-array allocation types selftests/bpf: Cover flexible-array allocation rejection

 kernel/bpf/verifier.c                         | 28 +++++++++++++++++++
 .../selftests/bpf/prog_tests/linked_list.c    |  2 ++
 .../selftests/bpf/progs/linked_list_fail.c    | 23 +++++++++++++++
 3 files changed, 53 insertions(+)

base-commit: a975094bf98ca97be9146f9d3b5681a6f9cf5ce3

Signature · 1 line
2.34.1