]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/commitdiff
idr test suite: Take RCU read lock in idr_find_test_1
authorMatthew Wilcox (Oracle) <willy@infradead.org>
Thu, 1 Apr 2021 11:44:48 +0000 (07:44 -0400)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 7 May 2021 07:53:50 +0000 (09:53 +0200)
BugLink: https://bugs.launchpad.net/bugs/1926993
[ 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>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
tools/testing/radix-tree/idr-test.c

index 44ceff95a9b3063fd604aaf41d6370a4107cd540..4a9b451b7ba031b2dab8ec7cd985f3fdb52144eb 100644 (file)
@@ -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);