Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp2075617ybb; Sun, 29 Mar 2020 21:53:59 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuCvxIugaBesuHa4U0bKUIfMBeEGBmUw0kZiwYhpcHiwxUqxa9HBed6AxrPhHUnmgukdgNk X-Received: by 2002:aca:a98a:: with SMTP id s132mr6675872oie.75.1585544039750; Sun, 29 Mar 2020 21:53:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585544039; cv=none; d=google.com; s=arc-20160816; b=n0Hs8X38caWC1quKRltWZUuMEVKvRzzx1NY0njRiea0jzPD09ne86tLSP5cdCBW3Ct mXdVM+4eCjBTSG2tZ49fg8tfb+dok5Srppu32+rjZ/saoOnZiL7514otKpmA3UIEv+pK X32QD/jiHwmv2OsiJ2drZxKUiTHHSluLdhey3i1Vvg7ehLJ4H3xKEjQ99+lQVipW9JOQ WfdLXFm4rtNnC14/63SJVjuvvTEsMT/8J/P1k647t7oWauvE5Lt6QR7qCZHTN0rE+ho4 wi5GNKmwkMZ9nHOLKUfJMHkIyUAXUPotap4BPbW6Qxwj52yePgwY1tEwb7mQ7RkPXw5I nNbg== 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=t1wirRAMm3a9CnlONW8b5K7vtiDjOENqn7fWImISQDI=; b=VBucFsMlPgnAXteCtiz3YVdwi5ZuUObM1yMpjXORFIjFs2uli+QYzBKw096ENgGciY dcTq8vdqH64+5+6J8NZYU8xXIPtaqD0SiG3mUdDb1WDdCEPkx7/7iJ9UR1AUfdqiXO2p 5QJXF0RznB7lry67N3xGLnH3CD7P6frgXi/VGTWkRYdW0VQCzkZvFBuDiHH0EQ5B9AI9 i+F7DAiTp69gD6XPXnsWopPF3GxsufioFh9MyAN90TILiVKp42bbeSkj05DXqC2obzYH XdBU0kg5+yZpg6oyJh0VbNo1F0/abrXJ8o4vhl5xnlIs52UyF2S9mJKWTYp/BRLfUpD5 63BQ== 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 q137si5235252oic.139.2020.03.29.21.53.46; Sun, 29 Mar 2020 21:53:59 -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 S1728159AbgC3EwZ (ORCPT + 99 others); Mon, 30 Mar 2020 00:52:25 -0400 Received: from shards.monkeyblade.net ([23.128.96.9]:33118 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726085AbgC3EwZ (ORCPT ); Mon, 30 Mar 2020 00:52:25 -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 3867415C54872; Sun, 29 Mar 2020 21:52:24 -0700 (PDT) Date: Sun, 29 Mar 2020 21:52:23 -0700 (PDT) Message-Id: <20200329.215223.1631308723332593306.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]); Sun, 29 Mar 2020 21:52:24 -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 Applied and queued up for -stable, thanks.