В ядре Linux была устранена следующая уязвимость: fprobe: Use guard(rcu_sched_notrace) и проверка rcu_is_watching() unregister_fprobe() и unregister_fprobe_async() (используемые BPF kprobe-multi) полагаются на стандартные льготные периоды RCU (synchronize_rcu() и call_rcu() для ожидания завершения обработчиков fprobe в полете, прежде чем освободить fprobe. Однако, если обработчик fprobe выполняется в то время, когда RCU не смотрит (например, в цикле ожидания или расширенном состоянии покоя nohz_full), стандартный RCU не отслеживает секции с упреждающим отключением. Следовательно, synchronize_rcu() не ждет этих казней, что может привести к use-after-free, если fprobe будет освобожден сразу после отмены регистрации.
Убедитесь, что обработчики выходят рано, когда !rcu_is_watching(). Кроме того, fprobe_fgraph_entry() и fprobe_ftrace_entry() ранее использовали guard(rcu)() и rcu_read_lock(), которые вызывают lockdep при каждом попадании под CONFIG_PROVE_LOCKING. Это добавляет накладные расходы и может вызвать рекурсию lockdep, если зондируемые функции взаимодействуют с lockdep.
Поскольку rhltable_lookup() и rhl_for_each_entry_rcu() используют rcu_dereference_all_check() (который проверяет rcu_read_lock_any_held()), удержание preemption disable через rcu_read_lock_sched_notrace() является полностью действительным и достаточным, пока rcu_is_watching() является истинным. Определите и используйте guard(rcu_sched_notrace) () в fprobe_ftrace_entry (), fprobe_fgraph_entry () и fprobe_return (). Это устраняет быстрый путь rcu_read_lock () и блокирует накладные расходы, гарантируя безопасную синхронизацию льготного периода.
Показать оригинальное описание (EN)
In the Linux kernel, the following vulnerability has been resolved: fprobe: Use guard(rcu_sched_notrace) and check rcu_is_watching() unregister_fprobe() and unregister_fprobe_async() (used by BPF kprobe-multi) rely on standard RCU grace periods (synchronize_rcu() and call_rcu()) to wait until in-flight fprobe handlers complete before freeing the fprobe. However, if an fprobe handler executes while RCU is not watching (such as in the idle loop or nohz_full extended quiescent states), standard RCU does not track preemption-disabled sections. Consequently, synchronize_rcu() does not wait for those executions, which can lead to a use-after-free if the fprobe is freed immediately after unregistration. Ensure handlers exit early when !rcu_is_watching(). Furthermore, fprobe_fgraph_entry() and fprobe_ftrace_entry() previously used guard(rcu)() and rcu_read_lock(), which invoke lockdep on every hit under CONFIG_PROVE_LOCKING. This adds overhead and can cause lockdep recursion if probed functions interact with lockdep. Since rhltable_lookup() and rhl_for_each_entry_rcu() use rcu_dereference_all_check() (which checks rcu_read_lock_any_held()), holding preemption disabled via rcu_read_lock_sched_notrace() is fully valid and sufficient so long as rcu_is_watching() is true. Define and use guard(rcu_sched_notrace)() across fprobe_ftrace_entry(), fprobe_fgraph_entry(), and fprobe_return(). This eliminates fast-path rcu_read_lock() and lockdep overhead while guaranteeing safe grace period synchronization.