Skip to content

Commit 7035864

Browse files
author
Matthew Wilcox (Oracle)
committed
idr test suite: Take RCU read lock in idr_find_test_1
When run on a single CPU, this test would frequently access already-freed memory. Due to timing, this bug never showed up on multi-CPU tests. Reported-by: Chris von Recklinghausen <[email protected]> Signed-off-by: Matthew Wilcox (Oracle) <[email protected]>
1 parent 1bb4bd2 commit 7035864

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

tools/testing/radix-tree/idr-test.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,11 +306,15 @@ void idr_find_test_1(int anchor_id, int throbber_id)
306306
BUG_ON(idr_alloc(&find_idr, xa_mk_value(anchor_id), anchor_id,
307307
anchor_id + 1, GFP_KERNEL) != anchor_id);
308308

309+
rcu_read_lock();
309310
do {
310311
int id = 0;
311312
void *entry = idr_get_next(&find_idr, &id);
313+
rcu_read_unlock();
312314
BUG_ON(entry != xa_mk_value(id));
315+
rcu_read_lock();
313316
} while (time(NULL) < start + 11);
317+
rcu_read_unlock();
314318

315319
pthread_join(throbber, NULL);
316320

0 commit comments

Comments
 (0)