mirror of
https://github.com/torvalds/linux.git
synced 2026-11-27 17:02:17 +00:00
Add trivial end-to-end tests to validate that KF_IMPLICIT_ARGS flag is properly handled by both resolve_btfids and the verifier. Declare kfuncs in bpf_testmod. Check that bpf_prog_aux pointer is set in the kfunc implementation. Verify that calls with implicit args and a legacy case all work. Acked-by: Eduard Zingerman <[email protected]> Signed-off-by: Ihor Solodrai <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
42 lines
1.1 KiB
C
42 lines
1.1 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/* Copyright (c) 2026 Meta Platforms, Inc. and affiliates. */
|
|
|
|
#include <vmlinux.h>
|
|
#include <bpf/bpf_helpers.h>
|
|
#include "bpf_misc.h"
|
|
|
|
extern int bpf_kfunc_implicit_arg(int a) __weak __ksym;
|
|
extern int bpf_kfunc_implicit_arg_impl(int a, struct bpf_prog_aux *aux) __weak __ksym; /* illegal */
|
|
extern int bpf_kfunc_implicit_arg_legacy(int a, int b) __weak __ksym;
|
|
extern int bpf_kfunc_implicit_arg_legacy_impl(int a, int b, struct bpf_prog_aux *aux) __weak __ksym;
|
|
|
|
char _license[] SEC("license") = "GPL";
|
|
|
|
SEC("syscall")
|
|
__retval(5)
|
|
int test_kfunc_implicit_arg(void *ctx)
|
|
{
|
|
return bpf_kfunc_implicit_arg(5);
|
|
}
|
|
|
|
SEC("syscall")
|
|
__failure __msg("cannot find address for kernel function bpf_kfunc_implicit_arg_impl")
|
|
int test_kfunc_implicit_arg_impl_illegal(void *ctx)
|
|
{
|
|
return bpf_kfunc_implicit_arg_impl(5, NULL);
|
|
}
|
|
|
|
SEC("syscall")
|
|
__retval(7)
|
|
int test_kfunc_implicit_arg_legacy(void *ctx)
|
|
{
|
|
return bpf_kfunc_implicit_arg_legacy(3, 4);
|
|
}
|
|
|
|
SEC("syscall")
|
|
__retval(11)
|
|
int test_kfunc_implicit_arg_legacy_impl(void *ctx)
|
|
{
|
|
return bpf_kfunc_implicit_arg_legacy_impl(5, 6, NULL);
|
|
}
|