mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2026-08-09 06:14:34 +02:00
This change prepares verifier log reporting for upcoming kfunc stack argument support. Currently verifier log code mostly assumes that an argument can be described directly by a register number. That works for arguments passed in `R1` to `R5`, but it does not work once kfunc arguments can also be passed on the stack. Introduce an opaque `argno_t` type that encodes both register-based and arg-based references. Four helpers form the interface: - argno_from_reg(regno): create from a register number - argno_from_arg(arg): create from a 1-based arg number - reg_from_argno(a): extract register number, or -1 - arg_from_argno(a): extract arg number, or -1 reg_arg_name() converts an argno_t to a human-readable string for verifier logs: "R%d" for register arguments, or "*(R11-off)" for stack arguments beyond R5. Update selftests accordingly. Signed-off-by: Yonghong Song <yonghong.song@linux.dev> Link: https://lore.kernel.org/r/20260423033501.2539667-1-yonghong.song@linux.dev Signed-off-by: Alexei Starovoitov <ast@kernel.org>
34 lines
776 B
C
34 lines
776 B
C
// SPDX-License-Identifier: GPL-2.0
|
|
/* Copyright (c) 2025 Meta Platforms, Inc. and affiliates. */
|
|
#include <vmlinux.h>
|
|
#include <bpf/bpf_tracing.h>
|
|
#include <bpf/bpf_helpers.h>
|
|
#include <bpf/bpf_core_read.h>
|
|
#include "bpf_misc.h"
|
|
|
|
SEC("syscall")
|
|
__failure __msg("Possibly NULL pointer passed")
|
|
int stream_vprintk_null_arg(void *ctx)
|
|
{
|
|
bpf_stream_vprintk(BPF_STDOUT, "", NULL, 0);
|
|
return 0;
|
|
}
|
|
|
|
SEC("syscall")
|
|
__failure __msg("R3 type=scalar expected=")
|
|
int stream_vprintk_scalar_arg(void *ctx)
|
|
{
|
|
bpf_stream_vprintk(BPF_STDOUT, "", (void *)46, 0);
|
|
return 0;
|
|
}
|
|
|
|
SEC("syscall")
|
|
__failure __msg("R2 doesn't point to a const string")
|
|
int stream_vprintk_string_arg(void *ctx)
|
|
{
|
|
bpf_stream_vprintk(BPF_STDOUT, ctx, NULL, 0);
|
|
return 0;
|
|
}
|
|
|
|
char _license[] SEC("license") = "GPL";
|