// SPDX-License-Identifier: GPL-2.0 /* raw_tp chain caller->mid->target reads 96 bytes from an 8-byte test_run ctx. */ #include #include #include #include #include int main(int argc, char **argv) { const char *path = argc > 1 ? argv[1] : "rawtp_chain_leak.bpf.o"; unsigned char ctx[8] = { 1, 2, 3, 4, 5, 6, 7, 8 }; struct bpf_object *obj; int map_fd, cfd, tfd, k; obj = bpf_object__open_file(path, NULL); if (libbpf_get_error(obj) || bpf_object__load(obj)) return perror("load"), 1; map_fd = bpf_map__fd(bpf_object__find_map_by_name(obj, "jmp_table")); cfd = bpf_program__fd(bpf_object__find_program_by_name(obj, "caller")); k = 0; tfd = bpf_program__fd(bpf_object__find_program_by_name(obj, "mid")); bpf_map_update_elem(map_fd, &k, &tfd, BPF_ANY); k = 1; tfd = bpf_program__fd(bpf_object__find_program_by_name(obj, "target")); bpf_map_update_elem(map_fd, &k, &tfd, BPF_ANY); LIBBPF_OPTS(bpf_test_run_opts, o, .ctx_in = ctx, .ctx_size_in = sizeof(ctx)); printf("target direct: %s\n", bpf_prog_test_run_opts(tfd, &o) ? strerror(errno) : "accepted"); printf("via chain: %s\n", bpf_prog_test_run_opts(cfd, &o) ? strerror(errno) : "accepted"); return 0; }