History

selftests/bpf: Extend verifier and bpf_sock tests for dst_port loads

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.

Jakub Sitnicki committed 4 years ago

Commit 8f50f161 parent 4421a584 files · +162 −21Browse files

Showing the changes to tools/include/uapi (1 of 4 files). Show all

Unified · Split

tools/include/uapi/linux/bpf.h+2−1
@@ -5574,7 +5574,8 @@ struct bpf_sock { · 5573 unmodified lines
5574 __u32 src_ip4;5574 __u32 src_ip4;
5575 __u32 src_ip6[4];5575 __u32 src_ip6[4];
5576 __u32 src_port; /* host byte order */5576 __u32 src_port; /* host byte order */
5577 __u32 dst_port; /* network byte order */5577 __be16 dst_port; /* network byte order */
5578 __u16 :16; /* zero padding */
5578 __u32 dst_ip4;5579 __u32 dst_ip4;
5579 __u32 dst_ip6[4];5580 __u32 dst_ip6[4];
5580 __u32 state;5581 __u32 state;