Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp727606imm; Thu, 13 Sep 2018 06:55:20 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbHyjgnjTKRjRJRhi/jqUUJ5wQRsPqdOGRDPR4utnRboL2USa4PreiwUR9dI4Old+Dvwpzu X-Received: by 2002:a17:902:9a01:: with SMTP id v1-v6mr7469179plp.20.1536846920154; Thu, 13 Sep 2018 06:55:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536846920; cv=none; d=google.com; s=arc-20160816; b=kESEOmWtgJjkDsUQ4AJzIO4pxAV4psLWgYffCehwpRPvwLkgsK9R6NqJfeLC1Xzcn5 oI3Dxhtla6Zhe4Mu+d+WZAVGEvr/qUOkrj2vNdwoW/dLvAE076Phgn9DoXr66eCbluOH bzBEBuVHgWrTH+cHcW//DFqpkZXRf1jNZRBQSAIeOcb8hskMlXvcRYvS9P6X4jKgsyyk aX+EkbVInrVPU4TYL73bvL+cm5/IUzhm/mhEck2b66vwhVztiYXPJZ75tCS3cRTZw8cA GjtbialVK1nTItdf8JFSKcYLQZtsfbCgmDZZflOsLV3+/+u0PIOORTas7qf3L0Sa2r2l 7LrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=zOv8QNuxe7Hl5xBMQsDLOUiBy88Z9DVDUkddiOmIL2A=; b=OzUaDPlVMeDyTJdz1c+v8ROP7jBbj4czSRvChgqnlOiUp/ayTrbHvImfC6gCbN2J2f cd3TS+Ic7rluaPolqz6/LerdjeOAyvKHoL9wB1VSNbau0GRry1c+C9WD87hrHKTP9xqF Y75eaMOwDtOLYHM4XES37V2+2YnHXxNqz/djeUrfzOfW2MB6n+D17jV6pEmuor7WBtXN mVvYsz/IF9yV9GtQaSpTi2IqBY1pk/f/LOezy33kzCECvHb+1pFnsWfvBPYfekOJhGYY H/Zj22NpxTR+DdRZ4HH6UVDcXKbOjDLYxf8J6ksBV7wv3Vd+/4uyqltNu/KFQ+0zNY20 2EWQ== 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 t23-v6si3486055pgk.26.2018.09.13.06.55.03; Thu, 13 Sep 2018 06:55:20 -0700 (PDT) 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 S1731218AbeIMTEa (ORCPT + 99 others); Thu, 13 Sep 2018 15:04:30 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:33912 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728699AbeIMTEa (ORCPT ); Thu, 13 Sep 2018 15:04:30 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 711C6D1A; Thu, 13 Sep 2018 13:54:53 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tariq Toukan , Daniel Borkmann , Jesper Dangaard Brouer , Sasha Levin Subject: [PATCH 4.18 066/197] net/xdp: Fix suspicious RCU usage warning Date: Thu, 13 Sep 2018 15:30:15 +0200 Message-Id: <20180913131844.162508679@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180913131841.568116777@linuxfoundation.org> References: <20180913131841.568116777@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Tariq Toukan [ Upstream commit 21b172ee11b6ec260bd7e6a27b11a8a8d392fce5 ] Fix the warning below by calling rhashtable_lookup_fast. Also, make some code movements for better quality and human readability. [ 342.450870] WARNING: suspicious RCU usage [ 342.455856] 4.18.0-rc2+ #17 Tainted: G O [ 342.462210] ----------------------------- [ 342.467202] ./include/linux/rhashtable.h:481 suspicious rcu_dereference_check() usage! [ 342.476568] [ 342.476568] other info that might help us debug this: [ 342.476568] [ 342.486978] [ 342.486978] rcu_scheduler_active = 2, debug_locks = 1 [ 342.495211] 4 locks held by modprobe/3934: [ 342.500265] #0: 00000000e23116b2 (mlx5_intf_mutex){+.+.}, at: mlx5_unregister_interface+0x18/0x90 [mlx5_core] [ 342.511953] #1: 00000000ca16db96 (rtnl_mutex){+.+.}, at: unregister_netdev+0xe/0x20 [ 342.521109] #2: 00000000a46e2c4b (&priv->state_lock){+.+.}, at: mlx5e_close+0x29/0x60 [mlx5_core] [ 342.531642] #3: 0000000060c5bde3 (mem_id_lock){+.+.}, at: xdp_rxq_info_unreg+0x93/0x6b0 [ 342.541206] [ 342.541206] stack backtrace: [ 342.547075] CPU: 12 PID: 3934 Comm: modprobe Tainted: G O 4.18.0-rc2+ #17 [ 342.556621] Hardware name: Dell Inc. PowerEdge R730/0H21J3, BIOS 1.5.4 10/002/2015 [ 342.565606] Call Trace: [ 342.568861] dump_stack+0x78/0xb3 [ 342.573086] xdp_rxq_info_unreg+0x3f5/0x6b0 [ 342.578285] ? __call_rcu+0x220/0x300 [ 342.582911] mlx5e_free_rq+0x38/0xc0 [mlx5_core] [ 342.588602] mlx5e_close_channel+0x20/0x120 [mlx5_core] [ 342.594976] mlx5e_close_channels+0x26/0x40 [mlx5_core] [ 342.601345] mlx5e_close_locked+0x44/0x50 [mlx5_core] [ 342.607519] mlx5e_close+0x42/0x60 [mlx5_core] [ 342.613005] __dev_close_many+0xb1/0x120 [ 342.617911] dev_close_many+0xa2/0x170 [ 342.622622] rollback_registered_many+0x148/0x460 [ 342.628401] ? __lock_acquire+0x48d/0x11b0 [ 342.633498] ? unregister_netdev+0xe/0x20 [ 342.638495] rollback_registered+0x56/0x90 [ 342.643588] unregister_netdevice_queue+0x7e/0x100 [ 342.649461] unregister_netdev+0x18/0x20 [ 342.654362] mlx5e_remove+0x2a/0x50 [mlx5_core] [ 342.659944] mlx5_remove_device+0xe5/0x110 [mlx5_core] [ 342.666208] mlx5_unregister_interface+0x39/0x90 [mlx5_core] [ 342.673038] cleanup+0x5/0xbfc [mlx5_core] [ 342.678094] __x64_sys_delete_module+0x16b/0x240 [ 342.683725] ? do_syscall_64+0x1c/0x210 [ 342.688476] do_syscall_64+0x5a/0x210 [ 342.693025] entry_SYSCALL_64_after_hwframe+0x49/0xbe Fixes: 8d5d88527587 ("xdp: rhashtable with allocator ID to pointer mapping") Signed-off-by: Tariq Toukan Suggested-by: Daniel Borkmann Cc: Jesper Dangaard Brouer Acked-by: Jesper Dangaard Brouer Signed-off-by: Daniel Borkmann Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- net/core/xdp.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) --- a/net/core/xdp.c +++ b/net/core/xdp.c @@ -95,23 +95,15 @@ static void __xdp_rxq_info_unreg_mem_mod { struct xdp_mem_allocator *xa; int id = xdp_rxq->mem.id; - int err; if (id == 0) return; mutex_lock(&mem_id_lock); - xa = rhashtable_lookup(mem_id_ht, &id, mem_id_rht_params); - if (!xa) { - mutex_unlock(&mem_id_lock); - return; - } - - err = rhashtable_remove_fast(mem_id_ht, &xa->node, mem_id_rht_params); - WARN_ON(err); - - call_rcu(&xa->rcu, __xdp_mem_allocator_rcu_free); + xa = rhashtable_lookup_fast(mem_id_ht, &id, mem_id_rht_params); + if (xa && !rhashtable_remove_fast(mem_id_ht, &xa->node, mem_id_rht_params)) + call_rcu(&xa->rcu, __xdp_mem_allocator_rcu_free); mutex_unlock(&mem_id_lock); }