selftests/bpf: Prevent misaligned memory access in get_stack_raw_tp test
authorAndrii Nakryiko <andrii@kernel.org>
Wed, 24 Nov 2021 00:23:21 +0000 (16:23 -0800)
committerDaniel Borkmann <daniel@iogearbox.net>
Thu, 25 Nov 2021 23:15:03 +0000 (00:15 +0100)
commit6c4dedb7550aafd094f7d803668fd039545f4e57
tree2a5f9f8563653a395493c79da90286b50a129917
parent3bd0233f388e061c44d36a1ac614a3bb4a851b7e
selftests/bpf: Prevent misaligned memory access in get_stack_raw_tp test

Perfbuf doesn't guarantee 8-byte alignment of the data like BPF ringbuf
does, so struct get_stack_trace_t can arrive not properly aligned for
subsequent u64 accesses. Easiest fix is to just copy data locally.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20211124002325.1737739-10-andrii@kernel.org
tools/testing/selftests/bpf/prog_tests/get_stack_raw_tp.c