memfd: Use radix_tree_deref_slot_protected to avoid the warning.
authorzhong jiang <zhongjiang@huawei.com>
Mon, 18 Nov 2019 03:26:07 +0000 (11:26 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 20 Nov 2019 17:00:53 +0000 (18:00 +0100)
The commit 391d4ee568b5 ("memfd: Fix locking when tagging pins")
introduces the following warning messages.

*WARNING: suspicious RCU usage in memfd_wait_for_pins*

It is because we still use radix_tree_deref_slot without read_rcu_lock.
We should use radix_tree_deref_slot_protected instead in the case.

Cc: stable@vger.kernel.org
Fixes: 391d4ee568b5 ("memfd: Fix locking when tagging pins")
Signed-off-by: zhong jiang <zhongjiang@huawei.com>
Reviewed-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
mm/shmem.c

index 5b2cc9f9b1f1de420d344a31b0228b26ed0af8c5..e55aa460a2c0bbdbaa9d6065bb0357a30883b1a4 100644 (file)
@@ -2664,7 +2664,7 @@ static void shmem_tag_pins(struct address_space *mapping)
 
        spin_lock_irq(&mapping->tree_lock);
        radix_tree_for_each_slot(slot, &mapping->page_tree, &iter, start) {
-               page = radix_tree_deref_slot(slot);
+               page = radix_tree_deref_slot_protected(slot, &mapping->tree_lock);
                if (!page || radix_tree_exception(page)) {
                        if (radix_tree_deref_retry(page)) {
                                slot = radix_tree_iter_retry(&iter);