Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

bpf: tcp: Mark bpf_load_hdr_opt() arg2 as read-write

MEM_WRITE attribute is defined as: "Non-presence of MEM_WRITE means that
MEM is only being read". bpf_load_hdr_opt() both reads and writes from
its arg2 - void *search_res.

This matters a lot for the next commit where we more precisely track
stack accesses. Without this annotation, the verifier will make false
assumptions about the contents of memory written to by helpers and
possibly prune valid branches.

Fixes: 6fad274f06f0 ("bpf: Add MEM_WRITE attribute")
Acked-by: Martin KaFai Lau <martin.lau@kernel.org>
Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
Link: https://lore.kernel.org/r/730e45f8c39be2a5f3d8c4406cceca9d574cbf14.1736886479.git.dxu@dxuuu.xyz
Signed-off-by: Alexei Starovoitov <ast@kernel.org>

authored by

Daniel Xu and committed by
Alexei Starovoitov
8ac412a3 b8a81b5d

+1 -1
+1 -1
net/core/filter.c
··· 7643 7643 .gpl_only = false, 7644 7644 .ret_type = RET_INTEGER, 7645 7645 .arg1_type = ARG_PTR_TO_CTX, 7646 - .arg2_type = ARG_PTR_TO_MEM, 7646 + .arg2_type = ARG_PTR_TO_MEM | MEM_WRITE, 7647 7647 .arg3_type = ARG_CONST_SIZE, 7648 7648 .arg4_type = ARG_ANYTHING, 7649 7649 };