diff options
| author | Song Liu <songliubraving@fb.com> | 2018-03-14 13:23:22 -0400 |
|---|---|---|
| committer | Daniel Borkmann <daniel@iogearbox.net> | 2018-03-14 20:10:02 -0400 |
| commit | 81f77fd0deeb866d65ccc79733df8d2af5217c82 (patch) | |
| tree | bebe74af6f86ad63719e1d50442482a51a6beedf /tools/include/uapi/linux | |
| parent | 615755a77b2461ed78dfafb8a6649456201949c7 (diff) | |
bpf: add selftest for stackmap with BPF_F_STACK_BUILD_ID
test_stacktrace_build_id() is added. It accesses tracepoint urandom_read
with "dd" and "urandom_read" and gathers stack traces. Then it reads the
stack traces from the stackmap.
urandom_read is a statically link binary that reads from /dev/urandom.
test_stacktrace_build_id() calls readelf to read build ID of urandom_read
and compares it with build ID from the stackmap.
Signed-off-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'tools/include/uapi/linux')
| -rw-r--r-- | tools/include/uapi/linux/bpf.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h index db6bdc375126..1944d0aee7e8 100644 --- a/tools/include/uapi/linux/bpf.h +++ b/tools/include/uapi/linux/bpf.h | |||
| @@ -231,6 +231,28 @@ enum bpf_attach_type { | |||
| 231 | #define BPF_F_RDONLY (1U << 3) | 231 | #define BPF_F_RDONLY (1U << 3) |
| 232 | #define BPF_F_WRONLY (1U << 4) | 232 | #define BPF_F_WRONLY (1U << 4) |
| 233 | 233 | ||
| 234 | /* Flag for stack_map, store build_id+offset instead of pointer */ | ||
| 235 | #define BPF_F_STACK_BUILD_ID (1U << 5) | ||
| 236 | |||
| 237 | enum bpf_stack_build_id_status { | ||
| 238 | /* user space need an empty entry to identify end of a trace */ | ||
| 239 | BPF_STACK_BUILD_ID_EMPTY = 0, | ||
| 240 | /* with valid build_id and offset */ | ||
| 241 | BPF_STACK_BUILD_ID_VALID = 1, | ||
| 242 | /* couldn't get build_id, fallback to ip */ | ||
| 243 | BPF_STACK_BUILD_ID_IP = 2, | ||
| 244 | }; | ||
| 245 | |||
| 246 | #define BPF_BUILD_ID_SIZE 20 | ||
| 247 | struct bpf_stack_build_id { | ||
| 248 | __s32 status; | ||
| 249 | unsigned char build_id[BPF_BUILD_ID_SIZE]; | ||
| 250 | union { | ||
| 251 | __u64 offset; | ||
| 252 | __u64 ip; | ||
| 253 | }; | ||
| 254 | }; | ||
| 255 | |||
| 234 | union bpf_attr { | 256 | union bpf_attr { |
| 235 | struct { /* anonymous struct used by BPF_MAP_CREATE command */ | 257 | struct { /* anonymous struct used by BPF_MAP_CREATE command */ |
| 236 | __u32 map_type; /* one of enum bpf_map_type */ | 258 | __u32 map_type; /* one of enum bpf_map_type */ |
