mirror of
git://git.yoctoproject.org/linux-yocto.git
synced 2025-08-21 16:31:14 +02:00

This patch adds test cases for zero offset (implicit cast) or non-zero offset pointer as KF_ACQUIRE kfuncs argument. Currently KF_ACQUIRE kfuncs should support passing in pointers like &sk->sk_write_queue (non-zero offset) or &sk->__sk_common (zero offset) and not be rejected by the verifier. Signed-off-by: Juntong Deng <juntong.deng@outlook.com> Link: https://lore.kernel.org/r/AM6PR03MB5848CB6F0D4D9068669A905B99952@AM6PR03MB5848.eurprd03.prod.outlook.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
34 lines
746 B
C
34 lines
746 B
C
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
#include <vmlinux.h>
|
|
#include <bpf/bpf_tracing.h>
|
|
#include <bpf/bpf_helpers.h>
|
|
#include "bpf_misc.h"
|
|
#include "../bpf_testmod/bpf_testmod_kfunc.h"
|
|
|
|
char _license[] SEC("license") = "GPL";
|
|
|
|
SEC("tp_btf/tcp_probe")
|
|
__success
|
|
int BPF_PROG(test_nested_acquire_nonzero, struct sock *sk, struct sk_buff *skb)
|
|
{
|
|
struct sk_buff *ptr;
|
|
|
|
ptr = bpf_kfunc_nested_acquire_nonzero_offset_test(&sk->sk_write_queue);
|
|
|
|
bpf_kfunc_nested_release_test(ptr);
|
|
return 0;
|
|
}
|
|
|
|
SEC("tp_btf/tcp_probe")
|
|
__success
|
|
int BPF_PROG(test_nested_acquire_zero, struct sock *sk, struct sk_buff *skb)
|
|
{
|
|
struct sk_buff *ptr;
|
|
|
|
ptr = bpf_kfunc_nested_acquire_zero_offset_test(&sk->__sk_common);
|
|
|
|
bpf_kfunc_nested_release_test(ptr);
|
|
return 0;
|
|
}
|