]> git.baikalelectronics.ru Git - kernel.git/commit
selftests/bpf: Extend verifier and bpf_sock tests for dst_port loads
authorJakub Sitnicki <jakub@cloudflare.com>
Mon, 1 Aug 2022 14:48:50 +0000 (17:48 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 11 Aug 2022 11:07:50 +0000 (13:07 +0200)
commita4799b7bed6c7e06b4659bd490863e9ca8c54417
treed39e5fc2996646541ce26e4b3ebfd6ccb7e03b63
parentfa2b54f1d100acd6e606e3b1732a6e14f2afb79b
selftests/bpf: Extend verifier and bpf_sock tests for dst_port loads

commit eea83c039b64c15bd473799a34ed89aaf26eb2de upstream.

Add coverage to the verifier tests and tests for reading bpf_sock fields to
ensure that 32-bit, 16-bit, and 8-bit loads from dst_port field are allowed
only at intended offsets and produce expected values.

While 16-bit and 8-bit access to dst_port field is straight-forward, 32-bit
wide loads need be allowed and produce a zero-padded 16-bit value for
backward compatibility.

Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com>
Link: https://lore.kernel.org/r/20220130115518.213259-3-jakub@cloudflare.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Ovidiu Panait <ovidiu.panait@windriver.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
tools/include/uapi/linux/bpf.h
tools/testing/selftests/bpf/prog_tests/sock_fields.c
tools/testing/selftests/bpf/progs/test_sock_fields.c
tools/testing/selftests/bpf/verifier/sock.c