LinuxKPI: Run irq_work callbacks under RCU protection - #2385
Open
JustAnotherHumanBeing wants to merge 1 commit into
Open
LinuxKPI: Run irq_work callbacks under RCU protection#2385JustAnotherHumanBeing wants to merge 1 commit into
JustAnotherHumanBeing wants to merge 1 commit into
Conversation
|
Thank you for taking the time to contribute to FreeBSD! All issues resolved. |
Linux executes irq_work callbacks from an interrupt context that provides implicit RCU read-side protection. LinuxKPI dispatches these callbacks through a taskqueue, so provide equivalent protection explicitly. This prevents an RCU grace period from completing while an irq_work callback is still using an RCU-protected object. Suggested by: wulf Tested by: JustAnotherHumanBeing Signed-off-by: JustAnotherHumanBeing <oleglelchuk@gmail.com>
JustAnotherHumanBeing
force-pushed
the
agent/linuxkpi-irq-work-rcu
branch
from
August 23, 2026 13:45
3d21b11 to
a55f162
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Linux
irq_workcallbacks execute in interrupt context, which providesimplicit RCU read-side protection on non-PREEMPT_RT kernels. LinuxKPI
dispatches these callbacks through a taskqueue without equivalent RCU
protection. A grace period can therefore complete while a callback is still
using an RCU-protected object. This produced the i915/GuC use-after-free
reported in freebsd/drm-kmod#489.
Change
Wrap
irqw->func(irqw)inrcu_read_lock()andrcu_read_unlock(). Thecurrent taskqueue selection is unchanged.
The LinuxKPI-level approach was proposed by @wulf7 in
freebsd/drm-kmod#489 (comment). He
subsequently confirmed that the RCU correction is independent of the
taskqueue-selection change discussed there:
freebsd/drm-kmod#489 (comment).
Testing
irq_work/RCU test failed deterministically on theunpatched kernel:
synchronize_rcu()returned while the callback remainedactive.
GENERICkernel and module build from currentmaincompletedsuccessfully with
-Werror.drm/i915: Extend RCU protection in signal_irq_work() [FreeBSD] drm-kmod#491. Thirty controlled i915 recovery cycles were requested
while a Mesa workload was active. No panic, use-after-free, or relevant
INVARIANTS/WITNESS diagnostic occurred, and normal rendering succeeded
afterward.
Related: freebsd/drm-kmod#489
Base-system alternative to: freebsd/drm-kmod#491