Skip to content

Commit 17a9399

Browse files
thejhVlastimil Babka (SUSE)
authored andcommitted
slab,rcu: disable KVFREE_RCU_BATCHED for strict grace period
Disable CONFIG_KVFREE_RCU_BATCHED in CONFIG_RCU_STRICT_GRACE_PERIOD builds so that kernel fuzzers have an easier time finding use-after-free involving kfree_rcu(). The intent behind CONFIG_RCU_STRICT_GRACE_PERIOD is that RCU should invoke callbacks and free objects as soon as possible (at a large performance cost) so that kernel fuzzers and such have an easier time detecting use-after-free bugs in objects with RCU lifetime. CONFIG_KVFREE_RCU_BATCHED is a performance optimization that queues RCU-freed objects in ways that CONFIG_RCU_STRICT_GRACE_PERIOD can't expedite; for example, the following testcase doesn't trigger a KASAN splat when CONFIG_KVFREE_RCU_BATCHED is enabled: ``` struct foo_struct { struct rcu_head rcu; int a; }; struct foo_struct *foo = kmalloc(sizeof(*foo), GFP_KERNEL | __GFP_NOFAIL | __GFP_ZERO); pr_info("%s: calling kfree_rcu()\n", __func__); kfree_rcu(foo, rcu); msleep(10); pr_info("%s: start UAF access\n", __func__); READ_ONCE(foo->a); pr_info("%s: end UAF access\n", __func__); ``` Signed-off-by: Jann Horn <[email protected]> Acked-by: David Rientjes <[email protected]> Reviewed-by: Joel Fernandes <[email protected]> Acked-by: Harry Yoo (Oracle) <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Vlastimil Babka (SUSE) <[email protected]>
1 parent 9042e77 commit 17a9399

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

mm/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ config SLUB
172172
config KVFREE_RCU_BATCHED
173173
def_bool y
174174
depends on !SLUB_TINY && !TINY_RCU
175+
depends on !RCU_STRICT_GRACE_PERIOD
175176

176177
config SLUB_TINY
177178
bool "Configure for minimal memory footprint"

0 commit comments

Comments
 (0)