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

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

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/bpf/progs/linked_list_fail.c
Extension
.c
Size
13139 bytes
Lines
612
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 test1 {
		struct test2 {
			struct test2 *next;
		} *ptr;
	} *p;

	p = bpf_obj_new(typeof(*p));
	if (!p)
		return 0;
	bpf_this_cpu_ptr(p->ptr);
	return 0;
}

SEC("?tc")
int direct_read_lock(void *ctx)
{
	struct foo *f;

	f = bpf_obj_new(typeof(*f));
	if (!f)
		return 0;
	return *(int *)&f->lock;
}

SEC("?tc")
int direct_write_lock(void *ctx)
{
	struct foo *f;

	f = bpf_obj_new(typeof(*f));
	if (!f)
		return 0;
	*(int *)&f->lock = 0;
	return 0;
}

SEC("?tc")
int direct_read_head(void *ctx)
{
	struct foo *f;

	f = bpf_obj_new(typeof(*f));
	if (!f)
		return 0;
	return *(int *)&f->head;
}

SEC("?tc")
int direct_write_head(void *ctx)
{
	struct foo *f;

	f = bpf_obj_new(typeof(*f));
	if (!f)
		return 0;
	*(int *)&f->head = 0;
	return 0;
}

SEC("?tc")
int direct_read_node(void *ctx)
{
	struct foo *f;

	f = bpf_obj_new(typeof(*f));
	if (!f)
		return 0;
	return *(int *)&f->node2;
}

SEC("?tc")
int direct_write_node(void *ctx)
{
	struct foo *f;

	f = bpf_obj_new(typeof(*f));
	if (!f)
		return 0;
	*(int *)&f->node2 = 0;
	return 0;
}

static __always_inline
int use_after_unlock(bool push_front)
{
	struct foo *f;

	f = bpf_obj_new(typeof(*f));
	if (!f)
		return 0;

Annotation

Implementation Notes