]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
selftests/bpf: Extend verifier and bpf_sock tests for dst_port loads
authorJakub Sitnicki <jakub@cloudflare.com>
Wed, 3 Aug 2022 14:50:02 +0000 (17:50 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 11 Aug 2022 10:57:51 +0000 (12:57 +0200)
commit751f05bc6f955ae3f9aa0385cf2a9a01d21117e6
tree23f396f59bb76dc0d4a02c72f9e7b5c8c3f07b33
parent7c1134c7da997523e2834dd516e2ddc51920699a
selftests/bpf: Extend verifier and bpf_sock tests for dst_port loads

commit 8f50f16ff39dd4e2d43d1548ca66925652f8aff7 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>
[OP: backport to 5.4: cherry-pick verifier changes only]
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/verifier/sock.c