Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2045919ybb; Thu, 26 Mar 2020 20:27:52 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvYcwlNpom5h+w5+osBUhdq5xnR9knQRG4exmLcRh0MieysHW8gmH7Fg4gsgaDlSj5kmJvj X-Received: by 2002:aca:5210:: with SMTP id g16mr2763158oib.174.1585279672214; Thu, 26 Mar 2020 20:27:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585279672; cv=none; d=google.com; s=arc-20160816; b=SBQSCNWeC0p9hFKj0h/ldEgKenCdm/hhW7XtmjuUcxI9X/gHvaTWLtvnXvvWJ2QJK8 Lbz0QoVBc+HtuadUi/7Ap7RyqNEE4ALoB2X4LMRiZohBYS+FwsNB0CTMBclPj5jTv5wr Xsx2X2eTLowaWNI30IyYnPUJMuYQlYUrv9fw1/6+UKfM4P7KXE8HGTXcj4PJ0cXjkvvM 9KTjNi8ywhS1VTIA3/RdkThz7wddVw1tL3OK+Z23wG8dmLeFYst7rM/N/24QcuYcW84S KZLWDUXbEPDrbTF72fBd7sAYQtaJAYBilxnLU3/C7eZo6MU+TqmLurqXRW5O3BCCitNp GqHA== 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 :references:in-reply-to:from:subject:cc:to:message-id:date; bh=2uAesikrqILvgqGUL4UkUdGRU+1OET3Id0TQl0TeXEw=; b=wgeNfWA67nxlsOv8PSDCaijKICICxz6dxfnglbJ7hBF9X9eN0fngehLg63CQkRq5xw IpuM087YdSSxhQOrokb/p1Ylewp+vmYYnnhjoH5hwEd5w6SPuvoaSH2iFIFgDQxbBxTK nyx3cSAakbWiqEV/2Bn4Bm4Comi9APSU/KqeK9ohRdgfYpkkCbDOgvXolAu3WO/G1Dyj 4Si7+A9exCdUkEw2cxvqUb2NGvPNy5UWCBc96dfHa0MnsYDNYHJ5f8NikoWauoaHN68x zba5+/+8FD63C3qS5LXI0WTRfHXzEFMxy2wL8Ih7N0NDMohmn39gf/vONLxtdl/rzldC rllQ== 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 g129si1917973oob.1.2020.03.26.20.27.39; Thu, 26 Mar 2020 20:27:52 -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 S1727717AbgC0D1Q (ORCPT + 99 others); Thu, 26 Mar 2020 23:27:16 -0400 Received: from shards.monkeyblade.net ([23.128.96.9]:58054 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726363AbgC0D1Q (ORCPT ); Thu, 26 Mar 2020 23:27:16 -0400 Received: from localhost (unknown [IPv6:2601:601:9f00:477::3d5]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) (Authenticated sender: davem-davemloft) by shards.monkeyblade.net (Postfix) with ESMTPSA id 0591D15CE962A; Thu, 26 Mar 2020 20:27:14 -0700 (PDT) Date: Thu, 26 Mar 2020 20:27:14 -0700 (PDT) Message-Id: <20200326.202714.1221436401038064762.davem@davemloft.net> To: cai@lca.pw Cc: kuznet@ms2.inr.ac.ru, yoshfuji@linux-ipv6.org, kuba@kernel.org, eric.dumazet@gmail.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] ipv4: fix a RCU-list lock in fib_triestat_seq_show From: David Miller In-Reply-To: <20200325220100.7863-1-cai@lca.pw> References: <20200325220100.7863-1-cai@lca.pw> X-Mailer: Mew version 6.8 on Emacs 26.1 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Thu, 26 Mar 2020 20:27:15 -0700 (PDT) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Qian Cai Date: Wed, 25 Mar 2020 18:01:00 -0400 > fib_triestat_seq_show() calls hlist_for_each_entry_rcu(tb, head, > tb_hlist) without rcu_read_lock() will trigger a warning, > > net/ipv4/fib_trie.c:2579 RCU-list traversed in non-reader section!! > > other info that might help us debug this: > > rcu_scheduler_active = 2, debug_locks = 1 > 1 lock held by proc01/115277: > #0: c0000014507acf00 (&p->lock){+.+.}-{3:3}, at: seq_read+0x58/0x670 > > Call Trace: > dump_stack+0xf4/0x164 (unreliable) > lockdep_rcu_suspicious+0x140/0x164 > fib_triestat_seq_show+0x750/0x880 > seq_read+0x1a0/0x670 > proc_reg_read+0x10c/0x1b0 > __vfs_read+0x3c/0x70 > vfs_read+0xac/0x170 > ksys_read+0x7c/0x140 > system_call+0x5c/0x68 > > Fix it by adding a pair of rcu_read_lock/unlock() and use > cond_resched_rcu() to avoid the situation where walking of a large > number of items may prevent scheduling for a long time. > > Signed-off-by: Qian Cai Eric, please review.