summaryrefslogtreecommitdiff
path: root/rust/zerocopy
diff options
context:
space:
mode:
authorYiyang Chen <chenyy23@mails.tsinghua.edu.cn>2026-06-23 06:11:09 +0000
committerAlexei Starovoitov <ast@kernel.org>2026-06-25 17:51:20 -0700
commit931a577fc79ea6a169a33f5538f4c1433235c358 (patch)
tree4d4a34dd2ffd53a1d8287a8efe9d7dd264fdb97d /rust/zerocopy
parent66bb952b449eac53dffb341108251d632767fd2d (diff)
bpf: Reject offset refcount acquire arguments
bpf_refcount_acquire() increments the refcount at the caller-supplied pointer plus the refcount field offset, then returns the caller-supplied pointer unchanged. The verifier records the return value as a base pointer to the refcounted object. bpf_list_pop_front() and bpf_rbtree_remove() can return embedded graph-node pointers as PTR_TO_BTF_ID | MEM_ALLOC with a fixed offset equal to the node field offset. Passing such a pointer directly to bpf_refcount_acquire() currently passes the refcounted-kptr type check. That makes the runtime operation start from base + node_off while the verifier models the returned pointer as the object base. Require refcount-acquire arguments to have zero fixed offset by carrying the requirement through check_func_arg_reg_off() to __check_ptr_off_reg(). Programs can still acquire a refcount from a graph-node-derived pointer after normalizing it with container_of(). Fixes: 7c50b1cb76aca ("bpf: Add bpf_refcount_acquire kfunc") Signed-off-by: Yiyang Chen <chenyy23@mails.tsinghua.edu.cn> Acked-by: Eduard Zingerman <eddyz87@gmail.com> Acked-by: Yonghong Song <yonghong.song@linux.dev> Link: https://lore.kernel.org/r/2f894647f56f71838fdddeb97a3e057ed35ea92e.1782192383.git.chenyy23@mails.tsinghua.edu.cn Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'rust/zerocopy')
0 files changed, 0 insertions, 0 deletions