tools/testing/selftests/bpf/progs/verifier_private_stack.c

Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/progs/verifier_private_stack.c

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/bpf/progs/verifier_private_stack.c
Extension
.c
Size
8396 bytes
Lines
380
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: implementation source
Status
source implementation candidate

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

struct elem {
	struct bpf_timer t;
	char pad[256];
};

struct {
	__uint(type, BPF_MAP_TYPE_ARRAY);
	__uint(max_entries, 1);
	__type(key, int);
	__type(value, struct elem);
} array SEC(".maps");

SEC("kprobe")
__description("Private stack, single prog")
__success
__arch_x86_64
__jited("	movabsq	$0x{{.*}}, %r9")
__jited("	addq	%gs:{{.*}}, %r9")
__jited("	movl	$0x2a, %edi")
__jited("	movq	%rdi, -0x100(%r9)")
__arch_arm64
__jited("	stp	x25, x27, [sp, {{.*}}]!")
__jited("	mov	x27, {{.*}}")
__jited("	movk	x27, {{.*}}, lsl #16")
__jited("	movk	x27, {{.*}}")
__jited("	mrs	x10, TPIDR_EL{{[0-1]}}")
__jited("	add	x27, x27, x10")
__jited("	add	x25, x27, {{.*}}")
__jited("	mov	x0, #0x2a")
__jited("	str	x0, [x27]")
__jited("...")
__jited("	ldp	x25, x27, [sp], {{.*}}")
__naked void private_stack_single_prog(void)
{
	asm volatile ("			\
	r1 = 42;			\
	*(u64 *)(r10 - 256) = r1;	\
	r0 = 0;				\
	exit;				\
"	::: __clobber_all);
}

SEC("raw_tp")
__description("No private stack")
__success
__arch_x86_64
__jited("	subq	$0x8, %rsp")
__arch_arm64
__jited("	mov	x25, sp")
__jited("	sub	sp, sp, #0x10")
__naked void no_private_stack_nested(void)
{
	asm volatile ("			\
	r1 = 42;			\
	*(u64 *)(r10 - 8) = r1;		\
	r0 = 0;				\
	exit;				\
"	::: __clobber_all);
}

__used
__naked static void cumulative_stack_depth_subprog(void)
{
	asm volatile ("				\
	r1 = 41;				\
	*(u64 *)(r10 - 32) = r1;		\
	call %[bpf_get_smp_processor_id];	\
	exit;					\
"	:
	: __imm(bpf_get_smp_processor_id)
	: __clobber_all);
}

SEC("kprobe")
__description("Private stack, subtree > MAX_BPF_STACK")
__success
__log_level(4) __msg("stack depth 512+32 max 512")
__arch_x86_64
/* private stack fp for the main prog */
__jited("	movabsq	$0x{{.*}}, %r9")
__jited("	addq	%gs:{{.*}}, %r9")
__jited("	movl	$0x2a, %edi")
__jited("	movq	%rdi, -0x200(%r9)")
__jited("	pushq	%r9")
__jited("...")
__jited("	callq	0x{{.*}}")
__jited("	popq	%r9")
__jited("	xorl	%eax, %eax")
__arch_arm64
__jited("	stp	x25, x27, [sp, {{.*}}]!")

Annotation

Implementation Notes