Commit Graph

7 Commits

Author SHA1 Message Date
Viktor Malik 89d90bf3ea
selftests/bpf: Test racing between bpf_timer_cancel_and_free and bpf_timer_cancel
JIRA: https://issues.redhat.com/browse/RHEL-23644

commit 3f00e4a9c96f4488a924aff4e35b77c8eced897e
Author: Martin KaFai Lau <martin.lau@kernel.org>
Date:   Thu Feb 15 13:12:18 2024 -0800

    selftests/bpf: Test racing between bpf_timer_cancel_and_free and bpf_timer_cancel
    
    This selftest is based on a Alexei's test adopted from an internal
    user to troubleshoot another bug. During this exercise, a separate
    racing bug was discovered between bpf_timer_cancel_and_free
    and bpf_timer_cancel. The details can be found in the previous
    patch.
    
    This patch is to add a selftest that can trigger the bug.
    I can trigger the UAF everytime in my qemu setup with KASAN. The idea
    is to have multiple user space threads running in a tight loop to exercise
    both bpf_map_update_elem (which calls into bpf_timer_cancel_and_free)
    and bpf_timer_cancel.
    
    Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
    Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
    Acked-by: Hou Tao <houtao1@huawei.com>
    Link: https://lore.kernel.org/bpf/20240215211218.990808-2-martin.lau@linux.dev

Signed-off-by: Viktor Malik <vmalik@redhat.com>
2024-06-25 11:07:44 +02:00
Artem Savkov 7dcccea7ae selftests/bpf: Test pinning bpf timer to a core
JIRA: https://issues.redhat.com/browse/RHEL-23643

commit 0d7ae06860753bb30b3731302b994da071120d00
Author: David Vernet <void@manifault.com>
Date:   Wed Oct 4 11:23:39 2023 -0500

    selftests/bpf: Test pinning bpf timer to a core
    
    Now that we support pinning a BPF timer to the current core, we should
    test it with some selftests. This patch adds two new testcases to the
    timer suite, which verifies that a BPF timer both with and without
    BPF_F_TIMER_ABS, can be pinned to the calling core with BPF_F_TIMER_CPU_PIN.
    
    Signed-off-by: David Vernet <void@manifault.com>
    Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
    Acked-by: Song Liu <song@kernel.org>
    Acked-by: Hou Tao <houtao1@huawei.com>
    Link: https://lore.kernel.org/bpf/20231004162339.200702-3-void@manifault.com

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2024-03-27 10:27:52 +01:00
Jerome Marchand 6482bbf100 selftests/bpf: Add testcase for async callback return value failure
JIRA: https://issues.redhat.com/browse/RHEL-10691

commit 57ddeb86b311ff41925e0fac7b983c097336f1f3
Author: David Vernet <void@manifault.com>
Date:   Mon Oct 9 11:14:14 2023 -0500

    selftests/bpf: Add testcase for async callback return value failure

    A previous commit updated the verifier to print an accurate failure
    message for when someone specifies a nonzero return value from an async
    callback. This adds a testcase for validating that the verifier emits
    the correct message in such a case.

    Signed-off-by: David Vernet <void@manifault.com>
    Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
    Link: https://lore.kernel.org/bpf/20231009161414.235829-2-void@manifault.com

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
2023-12-15 09:29:05 +01:00
Artem Savkov 861a21cd56 selftests/bpf: Add absolute timer test
Bugzilla: https://bugzilla.redhat.com/2221599

commit 944459e88b4f5c71683b56710f96e39756afae31
Author: Tero Kristo <tero.kristo@linux.intel.com>
Date:   Thu Mar 2 13:46:14 2023 +0200

    selftests/bpf: Add absolute timer test
    
    Add test for the absolute BPF timer under the existing timer tests. This
    will run the timer two times with 1us expiration time, and then re-arm
    the timer at ~35s in the future. At the end, it is verified that the
    absolute timer expired exactly two times.
    
    Signed-off-by: Tero Kristo <tero.kristo@linux.intel.com>
    Link: https://lore.kernel.org/r/20230302114614.2985072-3-tero.kristo@linux.intel.com
    Signed-off-by: Alexei Starovoitov <ast@kernel.org>

Signed-off-by: Artem Savkov <asavkov@redhat.com>
2023-09-22 09:12:10 +02:00
Jerome Marchand c96f9d6785 selftests/bpf: Migrate from bpf_prog_test_run
Bugzilla: https://bugzilla.redhat.com/2120966

commit 04fcb5f9a104f24278ad849c642cbdf0c8f48453
Author: Delyan Kratunov <delyank@fb.com>
Date:   Wed Feb 2 15:54:20 2022 -0800

    selftests/bpf: Migrate from bpf_prog_test_run

    bpf_prog_test_run is being deprecated in favor of the OPTS-based
    bpf_prog_test_run_opts.
    We end up unable to use CHECK in most cases, so replace usages with
    ASSERT_* calls.

    Signed-off-by: Delyan Kratunov <delyank@fb.com>
    Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
    Link: https://lore.kernel.org/bpf/20220202235423.1097270-2-delyank@fb.com

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
2022-10-25 14:57:55 +02:00
Yauheni Kaliuta 5db2ed5228 selfetest/bpf: Make some tests serial
Bugzilla: http://bugzilla.redhat.com/2069045

commit d3f7b1664d3ebd69751327f45f5cd4adfb29f620
Author: Yucong Sun <sunyucong@gmail.com>
Date:   Wed Oct 6 11:56:19 2021 -0700

    selfetest/bpf: Make some tests serial
    
    Change tests that often fails in parallel execution mode to serial.
    
    Signed-off-by: Yucong Sun <sunyucong@gmail.com>
    Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
    Link: https://lore.kernel.org/bpf/20211006185619.364369-15-fallentree@fb.com

Signed-off-by: Yauheni Kaliuta <ykaliuta@redhat.com>
2022-06-03 17:23:41 +03:00
Jerome Marchand d51941f3fe selftests/bpf: Add bpf_timer test.
Bugzilla: http://bugzilla.redhat.com/2041365

commit 3540f7c6b96a62b581da5aa3d4c5af9408927bef
Author: Alexei Starovoitov <ast@kernel.org>
Date:   Wed Jul 14 17:54:16 2021 -0700

    selftests/bpf: Add bpf_timer test.

    Add bpf_timer test that creates timers in preallocated and
    non-preallocated hash, in array and in lru maps.
    Let array timer expire once and then re-arm it for 35 seconds.
    Arm lru timer into the same callback.
    Then arm and re-arm hash timers 10 times each.
    At the last invocation of prealloc hash timer cancel the array timer.
    Force timer free via LRU eviction and direct bpf_map_delete_elem.

    Signed-off-by: Alexei Starovoitov <ast@kernel.org>
    Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
    Acked-by: Andrii Nakryiko <andrii@kernel.org>
    Acked-by: Toke Høiland-Jørgensen <toke@redhat.com>
    Link: https://lore.kernel.org/bpf/20210715005417.78572-11-alexei.starovoitov@gmail.com

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
2022-04-29 18:14:32 +02:00