summaryrefslogtreecommitdiff
path: root/include/linux/timerqueue.h
diff options
context:
space:
mode:
authorAlexei Starovoitov <ast@kernel.org>2026-10-24 03:48:43 +0000
committerAlexei Starovoitov <ast@kernel.org>2026-10-24 03:48:43 +0000
commit605e6a0e5aff50a6bcc7a6c8731e5d767b897e3b (patch)
treeb18719b78fc5f3683a975dc44ab268a681e32e40 /include/linux/timerqueue.h
parent17bb0e2f6c8043f70a693a5f3797471cbed354c8 (diff)
parentac3df711a428a9ff4277100ee26c6765e8f80a3b (diff)
Merge branch 'bpf-fix-a-struct_ops-use-after-free-behind-a-flaky-assoc_in_timer-test'
Qiliang Yuan says: ==================== bpf: Fix a struct_ops use-after-free behind a flaky assoc_in_timer test st_ops_assoc_in_timer_no_uref drops every reference to a struct_ops map and expects a timer callback of its prog, 500ms later, to find no struct_ops associated anymore. It fails now and then while test_progs runs other tests in parallel. Since commit 5db69b0fbdc8 ("bpf: Make struct_ops tasks_rcu grace period optional"), a struct_ops map clears the association only after the RCU grace period of bpf_map_put(), so nothing waits for a prog that reads the association in between. A timer callback can then return into a freed trampoline, and the kernel hits an int3 Oops. Patch 1 lets the association be cleared in any context, and patch 2 clears it in map_free_pre_rcu(), so that the grace period bpf_map_put() already waits for follows it. Patch 3 adds a test that catches a map freed under a running .test_1. Patch 4 has the timer callback of st_ops_assoc_in_timer_no_uref retry until the association is gone. Signed-off-by: Qiliang Yuan <odys.yuan@gmail.com> Reviewed-by: Amery Hung <ameryhung@gmail.com> --- V5 -> V6: - Rebase onto current bpf-next V4 -> V5: - Drop the free_after_rcu_gp of struct_ops maps, which is dead now, and update the comment of free_after_mult_rcu_gp in struct bpf_struct_ops (Alexei) - Also stop the tests when associating syscall_prog fails (Sashiko) V3 -> V4: - Clear the association in map_free_pre_rcu() instead of deferring the free of the map (Amery Hung) - Add patch 1, replacing st_ops_assoc_mutex with a spinlock, since map_free_pre_rcu() may run in softirq - Stop st_ops_assoc_in_timer_free and _no_uref when running syscall_prog fails, instead of waiting for the timer forever (Sashiko) - Point Fixes of patch 4 at 0e841d19263ab, which added the test, as the delay left after patch 2 comes from freeing syscall_prog V2 -> V3: - Wait for an RCU tasks trace grace period in patch 1 for every map, so that progs reading the association under RCU tasks trace, e.g. from a bpf_wq callback, are waited for too (CI bot) V1 -> V2: - Add patch 1, fixing the use-after-free behind the flaky test (CI bot) - Add patch 2, a test for the use-after-free - Point Fixes of patch 3 at 5db69b0fbdc8 (CI bot) - Move the restarting of the timer into patch 2, which needs it too, so patch 3 only turns it on for st_ops_assoc_in_timer_no_uref - Rebase onto current bpf-next v5: https://lore.kernel.org/r/20261019-selftests-bpf-struct-ops-assoc-timer-v5-0-77b2e181e5cc@gmail.com v4: https://lore.kernel.org/r/20261016-selftests-bpf-struct-ops-assoc-timer-v4-0-9ad31c21220c@gmail.com v3: https://lore.kernel.org/r/20261015-selftests-bpf-struct-ops-assoc-timer-v3-0-efe643d4b2a3@gmail.com v2: https://lore.kernel.org/r/20261010-selftests-bpf-struct-ops-assoc-timer-v2-0-d7a43896dbf1@gmail.com v1: https://lore.kernel.org/r/20261009-selftests-bpf-struct-ops-assoc-timer-v1-1-9a97a9b3d1db@gmail.com --- ==================== Link: https://patch.msgid.link/20261022-selftests-bpf-struct-ops-assoc-timer-v6-0-2c0f18e82582@gmail.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'include/linux/timerqueue.h')
0 files changed, 0 insertions, 0 deletions