mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-08-05 16:54:27 +00:00

Previously, the verifier was treating all PTR_TO_STACK registers passed to a helper call as potentially written to by the helper. However, all calls to check_stack_range_initialized() already have precise access type information available. Rather than treat ACCESS_HELPER as a proxy for BPF_WRITE, pass enum bpf_access_type to check_stack_range_initialized() to more precisely track helper arguments. One benefit from this precision is that registers tracked as valid spills and passed as a read-only helper argument remain tracked after the call. Rather than being marked STACK_MISC afterwards. An additional benefit is the verifier logs are also more precise. For this particular error, users will enjoy a slightly clearer message. See included selftest updates for examples. Acked-by: Eduard Zingerman <eddyz87@gmail.com> Signed-off-by: Daniel Xu <dxu@dxuuu.xyz> Link: https://lore.kernel.org/r/ff885c0e5859e0cd12077c3148ff0754cad4f7ed.1736886479.git.dxu@dxuuu.xyz Signed-off-by: Alexei Starovoitov <ast@kernel.org>
20 lines
428 B
C
20 lines
428 B
C
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
#include "vmlinux.h"
|
|
#include <bpf/bpf_helpers.h>
|
|
#include "bpf_misc.h"
|
|
|
|
SEC("tc/ingress")
|
|
__description("uninit/mtu: write rejected")
|
|
__success
|
|
__caps_unpriv(CAP_BPF|CAP_NET_ADMIN)
|
|
__failure_unpriv __msg_unpriv("invalid read from stack")
|
|
int tc_uninit_mtu(struct __sk_buff *ctx)
|
|
{
|
|
__u32 mtu;
|
|
|
|
bpf_check_mtu(ctx, 0, &mtu, 0, 0);
|
|
return TCX_PASS;
|
|
}
|
|
|
|
char LICENSE[] SEC("license") = "GPL";
|