Bug 208299 - Add fuzzing-optimized RCU mode that invokes RCU callbacks ASAP
Summary: Add fuzzing-optimized RCU mode that invokes RCU callbacks ASAP
Status: RESOLVED CODE_FIX
Alias: None
Product: Memory Management
Classification: Unclassified
Component: Sanitizers (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: MM/Sanitizers virtual assignee
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-06-23 16:28 UTC by Jann Horn (Google)
Modified: 2020-12-01 07:54 UTC (History)
3 users (show)

See Also:
Kernel Version: 5.7
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description Jann Horn (Google) 2020-06-23 16:28:00 UTC
At the moment, use-after-free issues in RCU allocations are hard to discover with KASAN at runtime because the RCU subsystem heavily optimizes for throughput and doesn't care much about the latency between e.g. kfree_rcu() and the actual freeing; therefore, KASAN is only informed that the object is no longer accessible long after the RCU grace period has already ended.

It would be helpful to have an RCU mode where the kernel essentially maintains an ordered list of active grace periods, allowing it to synchronously discover items with expired grace period on kfree_rcu()/call_rcu() (if no grace periods are active) or rcu_read_unlock() (when the last relevant grace period ended).

This will necessarily cause cache contention linear in either the number of RCU read-side critical sections (if a global sequence number model is used) or the number of kfree_rcu()/call_rcu() calls (if global timestamps or a set of local sequence numbers are used for figuring out the ordering of grace periods). Since RCU read-side critical sections are much more common than kfree_rcu()/call_rcu(), it may be worth thinking about how to implement this on top of instructions like RDTSCP, so that cacheline-bouncing global synchronization only happens on kfree_rcu()/call_rcu() and when grace periods exit while kfree_rcu()/call_rcu() work items are waiting to be executed.

Development of this should probably be coordinated with Paul McKenney.
Comment 1 Dmitry Vyukov 2020-08-06 13:26:27 UTC
This now exists as rcupdate.rcu_expedited=1 and was enabled on syzbot:
https://github.com/google/syzkaller/pull/2021

...which was added in 2012...
https://github.com/torvalds/linux/commit/3705b88db0d7cc4
Paul?
Comment 2 Dmitry Vyukov 2020-12-01 07:54:46 UTC
Jann, if you see anything else actionable here, please reopen. Otherwise it seems to be resolved.

Note You need to log in before you can comment on or make changes to this bug.