tools/testing/selftests/bpf/prog_tests/arena_direct_value.c

Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/prog_tests/arena_direct_value.c

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/bpf/prog_tests/arena_direct_value.c
Extension
.c
Size
1745 bytes
Lines
74
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

if (errno == EOPNOTSUPP) {
			test__skip();
			return;
		}
		ASSERT_GE(map_fd, 0, "bpf_map_create");
		return;
	}

	arena = mmap(NULL, arena_sz, PROT_READ | PROT_WRITE, MAP_SHARED, map_fd, 0);
	if (!ASSERT_NEQ(arena, MAP_FAILED, "arena_mmap"))
		goto cleanup;

	insns[0].imm = map_fd;
	insns[1].imm = arena_sz;

	prog_fd = bpf_prog_load(BPF_PROG_TYPE_RAW_TRACEPOINT,
				"arena_direct_value", "GPL", insns,
				ARRAY_SIZE(insns), &prog_opts);
	if (!ASSERT_LT(prog_fd, 0, "prog_load")) {
		close(prog_fd);
		goto cleanup;
	}

	snprintf(expected, sizeof(expected),
		 "invalid access to map value pointer, value_size=0 off=%u",
		 arena_sz);
	ASSERT_HAS_SUBSTR(log_buf, expected, "verifier_log");

cleanup:
	if (arena != MAP_FAILED)
		munmap(arena, arena_sz);
	close(map_fd);
}

void test_arena_direct_value(void)
{
	if (test__start_subtest("one_past_end"))
		test_arena_direct_value_one_past_end();
}

Annotation

Implementation Notes