Received: by 10.223.185.111 with SMTP id b44csp903356wrg; Fri, 9 Mar 2018 16:27:16 -0800 (PST) X-Google-Smtp-Source: AG47ELterlFanwHxcODbmdyVAJqDYp9o6fUsqLDyFPPA9rLXDzGnk1MnUSl8OZlwa/NHyfU4wB7A X-Received: by 2002:a17:902:59d3:: with SMTP id d19-v6mr334575plj.356.1520641635973; Fri, 09 Mar 2018 16:27:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520641635; cv=none; d=google.com; s=arc-20160816; b=XdJO/Q7aerY69On9KL+LVh5kfmp6aEp7Q4lF1Nl3kvshmOytyHMiBEny17M4qUZ+79 9lg639HEreuqo/SLZBu5HFLgqsYkNY2tEEExZz6GCZYzR79mKh9v1E7gJzyIpZi76QIQ wYR3wNnKOqhnrYf8w1LyGXDTSCbllV6a788DE1arBMDhZnsMZ1hT3R4BMse+b/f5sEVr f9Sauukrr5B+HtLAgfdGK7nzy0ONN+ZzmxpU89IOeGb53hr4DAHJBTpOaPj8g8tMEzB3 K7pWbeZByOGlxcNgAWgwX7mQVDpugoUafYhdBCsvK5PwLJq6AO+iU+WmTWvmvurJZ/VZ d9wQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=Nrci6v5ReBGvdenDdJCff4b3inj0/GlTIaToTDnSKKI=; b=wV56ExuOgBSGkdu2cBHw8KRmxp0ncWtvfJhZi/RumL49xoW7SXQlzJ/wBeP7t+f0tN baub0z8jibH4ux1MyuTPahOaldqDJryIZ1CYPphTry0JeHWOewWs0U3KcZxc6NaPQ8XS sjnpLi9Icr7PPtLsrgSGNGalcVDOKUdRZLkkC29/aOssXRr6PsNrqvaSUEbT0yjRcbY7 je0SfKzDEZWB0HOfC+YeZ/+lmd6QM3EDUPJDnEqcRc8uNpnqtzAtHhcIWLtUyOz6RddZ eQCGsre8aEDB3BOgw+2Jbo5PtEi2N/lGqQvEHBii4sg+ewHMBCjNUuRicuSzgz6zVH8t XGwg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 37-v6si1743254plq.451.2018.03.09.16.27.01; Fri, 09 Mar 2018 16:27:15 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934185AbeCJAZh (ORCPT + 99 others); Fri, 9 Mar 2018 19:25:37 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:41150 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933885AbeCJAXo (ORCPT ); Fri, 9 Mar 2018 19:23:44 -0500 Received: from localhost (unknown [185.236.200.248]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id A0A4BD7E; Sat, 10 Mar 2018 00:23:43 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, "ast@kernel.org, daniel@iogearbox.net, stable@vger.kernel.org, Yonghong Song" , Eric Dumazet , "David S. Miller" , Daniel Borkmann , Yonghong Song Subject: [PATCH 4.15 03/11] bpf: fix rcu lockdep warning for lpm_trie map_free callback Date: Fri, 9 Mar 2018 16:19:17 -0800 Message-Id: <20180310001834.715003968@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180310001834.560857664@linuxfoundation.org> References: <20180310001834.560857664@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Yonghong Song [ upstream commit 6c5f61023c5b0edb0c8a64c902fe97c6453b1852 ] Commit 9a3efb6b661f ("bpf: fix memory leak in lpm_trie map_free callback function") fixed a memory leak and removed unnecessary locks in map_free callback function. Unfortrunately, it introduced a lockdep warning. When lockdep checking is turned on, running tools/testing/selftests/bpf/test_lpm_map will have: [ 98.294321] ============================= [ 98.294807] WARNING: suspicious RCU usage [ 98.295359] 4.16.0-rc2+ #193 Not tainted [ 98.295907] ----------------------------- [ 98.296486] /home/yhs/work/bpf/kernel/bpf/lpm_trie.c:572 suspicious rcu_dereference_check() usage! [ 98.297657] [ 98.297657] other info that might help us debug this: [ 98.297657] [ 98.298663] [ 98.298663] rcu_scheduler_active = 2, debug_locks = 1 [ 98.299536] 2 locks held by kworker/2:1/54: [ 98.300152] #0: ((wq_completion)"events"){+.+.}, at: [<00000000196bc1f0>] process_one_work+0x157/0x5c0 [ 98.301381] #1: ((work_completion)(&map->work)){+.+.}, at: [<00000000196bc1f0>] process_one_work+0x157/0x5c0 Since actual trie tree removal happens only after no other accesses to the tree are possible, replacing rcu_dereference_protected(*slot, lockdep_is_held(&trie->lock)) with rcu_dereference_protected(*slot, 1) fixed the issue. Fixes: 9a3efb6b661f ("bpf: fix memory leak in lpm_trie map_free callback function") Reported-by: Eric Dumazet Suggested-by: Eric Dumazet Signed-off-by: Yonghong Song Reviewed-by: Eric Dumazet Acked-by: David S. Miller Signed-off-by: Daniel Borkmann Signed-off-by: Greg Kroah-Hartman --- kernel/bpf/lpm_trie.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/kernel/bpf/lpm_trie.c +++ b/kernel/bpf/lpm_trie.c @@ -574,8 +574,7 @@ static void trie_free(struct bpf_map *ma slot = &trie->root; for (;;) { - node = rcu_dereference_protected(*slot, - lockdep_is_held(&trie->lock)); + node = rcu_dereference_protected(*slot, 1); if (!node) goto out;