Commit Graph

1 Commits

Author SHA1 Message Date
Artem Savkov c66e4faa8a selftests/bpf: Add exception handling selftests for tp_bpf program
Bugzilla: https://bugzilla.redhat.com/2069046

Upstream Status: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git

commit c23551c9c36ae394f9c53a5adf1944a943c65e0b
Author: Alan Maguire <alan.maguire@oracle.com>
Date:   Fri Nov 5 16:50:46 2021 +0000

    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

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2022-08-24 12:53:34 +02:00