diff options
author | Matthew Wilcox (Oracle) <willy@infradead.org> | 2021-04-01 07:44:48 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-04-16 11:43:21 +0200 |
commit | 9a7552daa93bf38f6975cb47f6f726d3e2b81a60 (patch) | |
tree | 03e407b74f3e8d8ba57d4b97ca6f2c9afe1595c9 /tools | |
parent | edd822b6924154c84383c3a9a513a7c9b7c98fd8 (diff) | |
download | linux-stable-9a7552daa93bf38f6975cb47f6f726d3e2b81a60.tar.gz linux-stable-9a7552daa93bf38f6975cb47f6f726d3e2b81a60.tar.bz2 linux-stable-9a7552daa93bf38f6975cb47f6f726d3e2b81a60.zip |
idr test suite: Take RCU read lock in idr_find_test_1
[ Upstream commit 703586410da69eb40062e64d413ca33bd735917a ]
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 <crecklin@redhat.com>
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/testing/radix-tree/idr-test.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/tools/testing/radix-tree/idr-test.c b/tools/testing/radix-tree/idr-test.c index 44ceff95a9b3..4a9b451b7ba0 100644 --- a/tools/testing/radix-tree/idr-test.c +++ b/tools/testing/radix-tree/idr-test.c @@ -306,11 +306,15 @@ void idr_find_test_1(int anchor_id, int throbber_id) BUG_ON(idr_alloc(&find_idr, xa_mk_value(anchor_id), anchor_id, anchor_id + 1, GFP_KERNEL) != anchor_id); + rcu_read_lock(); do { int id = 0; void *entry = idr_get_next(&find_idr, &id); + rcu_read_unlock(); BUG_ON(entry != xa_mk_value(id)); + rcu_read_lock(); } while (time(NULL) < start + 11); + rcu_read_unlock(); pthread_join(throbber, NULL); |