From patchwork Mon Nov 18 03:26:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zhong jiang X-Patchwork-Id: 11248823 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B9BC114DB for ; Mon, 18 Nov 2019 03:27:56 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9E3AD206D3 for ; Mon, 18 Nov 2019 03:27:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9E3AD206D3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=huawei.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id CC6A06B0007; Sun, 17 Nov 2019 22:27:55 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id C76C66B0008; Sun, 17 Nov 2019 22:27:55 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BB4A96B000A; Sun, 17 Nov 2019 22:27:55 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0108.hostedemail.com [216.40.44.108]) by kanga.kvack.org (Postfix) with ESMTP id A389E6B0007 for ; Sun, 17 Nov 2019 22:27:55 -0500 (EST) Received: from smtpin04.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with SMTP id 3927152D4 for ; Mon, 18 Nov 2019 03:27:55 +0000 (UTC) X-FDA: 76167964110.04.bed84_6233c2134234e X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,zhongjiang@huawei.com,:sashal@kernel.org:gregkh@linuxfoundation.org:stable@vger.kernel.org:willy@infradead.org::yangyingliang@huawei.com,RULES_HIT:30054,0,RBL:45.249.212.191:@huawei.com:.lbl8.mailshell.net-62.18.2.100 64.95.201.95,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:25,LUA_SUMMARY:none X-HE-Tag: bed84_6233c2134234e X-Filterd-Recvd-Size: 2325 Received: from huawei.com (szxga05-in.huawei.com [45.249.212.191]) by imf36.hostedemail.com (Postfix) with ESMTP for ; Mon, 18 Nov 2019 03:27:54 +0000 (UTC) Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id C0A5536BBF0E1CE91910; Mon, 18 Nov 2019 11:27:45 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.439.0; Mon, 18 Nov 2019 11:27:38 +0800 From: zhong jiang To: , , , CC: , Subject: [PATCH 4.19] memfd: Use radix_tree_deref_slot_protected to avoid the warning. Date: Mon, 18 Nov 2019 11:26:08 +0800 Message-ID: <20191118032610.182862-2-zhongjiang@huawei.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191118032610.182862-1-zhongjiang@huawei.com> References: <20191118032610.182862-1-zhongjiang@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.113.25] X-CFilter-Loop: Reflected X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: The commit 99b45e7a1ba1 ("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: 99b45e7a1ba1 ("memfd: Fix locking when tagging pins") Signed-off-by: zhong jiang Reviewed-by: Matthew Wilcox (Oracle) --- mm/memfd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/memfd.c b/mm/memfd.c index 5859705dafe1..9e68a4320a0e 100644 --- a/mm/memfd.c +++ b/mm/memfd.c @@ -41,7 +41,7 @@ static void memfd_tag_pins(struct address_space *mapping) xa_lock_irq(&mapping->i_pages); radix_tree_for_each_slot(slot, &mapping->i_pages, &iter, start) { - page = radix_tree_deref_slot(slot); + page = radix_tree_deref_slot_protected(slot, &mapping->i_pages.xa_lock); if (!page || radix_tree_exception(page)) { if (radix_tree_deref_retry(page)) { slot = radix_tree_iter_retry(&iter);