selftests/bpf: Add tests for ldsx of pkt data/data_end/data_meta accesses
authorYonghong Song <yonghong.song@linux.dev>
Tue, 23 Jul 2024 15:34:44 +0000 (08:34 -0700)
committerAndrii Nakryiko <andrii@kernel.org>
Mon, 29 Jul 2024 22:05:05 +0000 (15:05 -0700)
commit63a9936b45859b24780c86c32a32fc7b087c304e
tree7e670ff4c6ded6ccbb8f081a43511b57ec1a1b6b
parent92de36080c93296ef9005690705cba260b9bd68a
selftests/bpf: Add tests for ldsx of pkt data/data_end/data_meta accesses

The following tests are added to verifier_ldsx.c:
  - sign extension of data/data_end/data_meta for tcx programs.
    The actual checking is in bpf_skb_is_valid_access() which
    is called by sk_filter, cg_skb, lwt, tc(tcx) and sk_skb.
  - sign extension of data/data_end/data_meta for xdp programs.
  - sign extension of data/data_end for flow_dissector programs.

All newly-added tests have verification failure with message
"invalid bpf_context access". Without previous patch, all these
tests succeeded verification.

Acked-by: Eduard Zingerman <eddyz87@gmail.com>
Signed-off-by: Yonghong Song <yonghong.song@linux.dev>
Link: https://lore.kernel.org/r/20240723153444.2430365-1-yonghong.song@linux.dev
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
tools/testing/selftests/bpf/progs/verifier_ldsx.c