]> git.baikalelectronics.ru Git - kernel.git/commit
selftests/bpf: Add exception handling selftests for tp_bpf program
authorAlan Maguire <alan.maguire@oracle.com>
Fri, 5 Nov 2021 16:50:46 +0000 (16:50 +0000)
committerDaniel Borkmann <daniel@iogearbox.net>
Mon, 8 Nov 2021 21:17:55 +0000 (22:17 +0100)
commit71a5e2c43cfdb4a26c42ea5679f457770aa330fe
tree471a3ccfe813414650448557d08ac6380db24eca
parentc69267533a0acc3bb3fee4366c0b2a8e2dfdc311
selftests/bpf: Add exception handling selftests for tp_bpf program

Exception handling is triggered in BPF tracing programs when a NULL pointer
is dereferenced; the exception handler zeroes the target register and
execution of the BPF program progresses.

To test exception handling then, we need to trigger a NULL pointer dereference
for a field which should never be zero; if it is, the only explanation is the
exception handler ran. task->task_works is the NULL pointer chosen (for a new
task from fork() no work is associated), and the task_works->func field should
not be zero if task_works is non-NULL. The test verifies that task_works and
task_works->func are 0.

Signed-off-by: Alan Maguire <alan.maguire@oracle.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/1636131046-5982-3-git-send-email-alan.maguire@oracle.com
tools/testing/selftests/bpf/prog_tests/exhandler.c [new file with mode: 0644]
tools/testing/selftests/bpf/progs/exhandler_kern.c [new file with mode: 0644]