mirror of
https://github.com/torvalds/linux.git
synced 2026-09-26 18:12:03 +02:00
Extend the snprintf_btf test with type_ids from the vmlinux BTF that used to NULL-deref in the BTF show path: a "const void", checked to render the "<unsupported kind:0>" placeholder, and a BTF_KIND_VAR, checked to resolve and render without error. The program renders from its own buffer and the test picks a VAR whose resolved type fits it, so the render stays in bounds. Signed-off-by: Jiayuan Chen <jiayuan.chen@linux.dev> Link: https://lore.kernel.org/r/20260901104924.346187-6-jiayuan.chen@linux.dev Signed-off-by: Alexei Starovoitov <ast@kernel.org>
25 lines
463 B
C
25 lines
463 B
C
// SPDX-License-Identifier: GPL-2.0
|
|
#include "btf_ptr.h"
|
|
#include <bpf/bpf_helpers.h>
|
|
|
|
__u32 type_id;
|
|
/* A buffer we own to render the selected type from, kept in bounds. */
|
|
char obj[256];
|
|
char out[64];
|
|
long ret;
|
|
|
|
SEC("raw_tp/sys_enter")
|
|
int dump_type(void *ctx)
|
|
{
|
|
struct btf_ptr ptr = {
|
|
.ptr = obj,
|
|
.type_id = type_id,
|
|
.flags = 0,
|
|
};
|
|
|
|
ret = bpf_snprintf_btf(out, sizeof(out), &ptr, sizeof(ptr), 0);
|
|
return 0;
|
|
}
|
|
|
|
char _license[] SEC("license") = "GPL";
|