Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp211762ybv; Wed, 19 Feb 2020 19:47:28 -0800 (PST) X-Google-Smtp-Source: APXvYqylSBP1JuWBL/J5tf+irwz5HlVy39U8B5lJnu+yoCkjY5iwHvRvFJFrT9sAUBdP42XCTH6Z X-Received: by 2002:a05:6830:1f0c:: with SMTP id u12mr21683698otg.253.1582170447972; Wed, 19 Feb 2020 19:47:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582170447; cv=none; d=google.com; s=arc-20160816; b=u+36GQjwLw2J1HeMhLeOsn12iv/cHyxLgQQCxsm4rtcJsdbqB599+8XJYq8cvYM7db BvQtXCIgSmh5qLkAzuFmW6oAXpKNr/DAnvn6vp5QIZmlGis4mWQmY3TMA7H2ASViam06 /KwTvOgrgEtqpyuilYrO5qRdjnJTW17wujYWZvddUg4bhupcaDQzrNaYjZDMrs9DRXkc 3VNdzrEzQ8TboDilHUavspQw2trZTzhfjp9N/0HDNU3AWRfoNCaH8bSLFiJUvq8F4WUw Xh3t7F5klkFPO8ZQqM2ZoXVdYMn3EX/sjJbFz7IB51WApVfdOCJ8w3kUJ9JyD1bq6XjR xE/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=4aa14Qa/BJ5gvTUkltBz2vTcHHykju1Xj4YvXyFnul4=; b=KwV7IVgU6FGGAZ24Z4awZPOSI+pwPvnISOAGQSoP7QbV8ayHoOzX497ZpKxV4S+iVW 1JJ3TScCaZXg26265laVm+mzkF5oSPJRsvbmGrrV5TxeVeU+gBxyQzCJVMCM/APdwvVc pSNFJZbMFzojQLRd5WBVZ/QvlXVxv5K0pd5AYFE6d+0cdV3dzXVYQP5yTKcXORyiyKL3 xvP54OZ03APp8qlAAes+x8iwo6kumJaRkha5A5D+PfQdz1M4BWDVixYBgbAfmEFhJ4wh HYPYhGwp2BOY5zEaEGN19t3oKdnN3MoB7TDROaFgU6k4eMprFmcH2Gu95wyljDfhe+5k pn1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=CltrD+f2; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m4si984024otn.281.2020.02.19.19.47.15; Wed, 19 Feb 2020 19:47:27 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=CltrD+f2; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727932AbgBTDrL (ORCPT + 99 others); Wed, 19 Feb 2020 22:47:11 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:43754 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727476AbgBTDrK (ORCPT ); Wed, 19 Feb 2020 22:47:10 -0500 Received: by mail-pl1-f193.google.com with SMTP id p11so980491plq.10; Wed, 19 Feb 2020 19:47:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=4aa14Qa/BJ5gvTUkltBz2vTcHHykju1Xj4YvXyFnul4=; b=CltrD+f29h4W+dpxHPNv1JveX0Lnoy95RgKNGY+7Zfo42vMKUAl3DpBhUFtpbKAmo+ QfpevgV35ksKPP2cMOjxPBJDtzA+6EXmzzPFR2GcqcmVNmp5e166xRJzoymejEvelyR/ fPPNNfBs1MH6q+PVxSV6pB5HX8rk1Bv5c8QgpYrSqtgPqO8x+oROOZDOazO8zj+S78Wh DAtjtQ5KUMhzVWSa2lEpHychqhfRQOPT2dFb4IiGc1r+w1dqS32b9rrb4lOBJWHUouDJ CYRUTYxUYmv2miBH7fb+ahq0k67y4Y5LlQxzuOSdBrXbmZzuvcGoIo8eSS/u2MaI6Bz6 bI9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=4aa14Qa/BJ5gvTUkltBz2vTcHHykju1Xj4YvXyFnul4=; b=iEw5A1bWoHTgKzL/nmw5CCM81D8Sy8GR9L2PFxmdFMWOcb04HHCuK4pTKan+3+P2UM tQp25DDHwjdnzJyeQ0OwQy+bnDntej2XVHfjJj1lsabdQhpSptX2n8ttntQjRTCZX1Ii vQETOhEAFJOFS63E/n6RsusKGeZ1EELfbGvAlb9oOEXEhCC10qph1r2RO1Gjf69/M6VW to6dTz9VSXSaZXhuTNasVbNrsBvPkVqMQvXJLYBTonQO4+eyJvncX/52+ITI3Zo9fNY2 n43cZe1myhJfTsEQpxjRQ8wKfbh5JEVadCA98BwmnZf7+bn6s8qscdnqwClNNGfRk63D 9IZw== X-Gm-Message-State: APjAAAUz3hzJMlDhluAcU9ll1L+RgaEbXVGMapyi09QcUhnaqigaD4DN 3+4Aw/hmquWvQMg/S95Li8M= X-Received: by 2002:a17:90a:868b:: with SMTP id p11mr1219499pjn.60.1582170429686; Wed, 19 Feb 2020 19:47:09 -0800 (PST) Received: from workstation-portable ([146.196.37.60]) by smtp.gmail.com with ESMTPSA id v25sm1099083pfe.147.2020.02.19.19.47.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Feb 2020 19:47:09 -0800 (PST) Date: Thu, 20 Feb 2020 09:17:02 +0530 From: Amol Grover To: Eric Dumazet Cc: Eric Dumazet , "David S . Miller" , Alexey Kuznetsov , Hideaki YOSHIFUJI , Jakub Kicinski , linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org, Joel Fernandes , Madhuparna Bhowmik , "Paul E . McKenney" , netdev@vger.kernel.org Subject: Re: [PATCH] tcp: Pass lockdep expression to RCU lists Message-ID: <20200220034702.GA2349@workstation-portable> References: <20200219100545.27397-1-frextrite@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 19, 2020 at 11:35:21AM -0800, Eric Dumazet wrote: > > > On 2/19/20 2:05 AM, Amol Grover wrote: > > tcp_cong_list is traversed using list_for_each_entry_rcu > > outside an RCU read-side critical section but under the protection > > of tcp_cong_list_lock. > > > > This is not true. > > There are cases where RCU read lock is held, > and others where the tcp_cong_list_lock is held. > That's true but this patch specifically fixes those occurences of list_for_each_entry_rcu() that are traversed under tcp_cong_list_lock. Moreover, an implicit check is done for being inside RCU read-side critical section along with testing for this newly added lockdep expression. > I believe you need to be more precise in the changelog. > > If there was a bug, net tree would be the target for this patch, > with a required Fixes: tag. > > Otherwise, if net-next tree is the intended target, you have to signal > it, as instructed in Documentation/networking/netdev-FAQ.rst > I don't think this fixes a "bug". However, this may fix potential bugs that may creep in. Should I send it against net-next tree? Thanks Amol > Thanks. > > > > Hence, add corresponding lockdep expression to silence false-positive > > warnings, and harden RCU lists. > > > > Signed-off-by: Amol Grover > > --- > > net/ipv4/tcp_cong.c | 9 ++++++--- > > 1 file changed, 6 insertions(+), 3 deletions(-) > > > > diff --git a/net/ipv4/tcp_cong.c b/net/ipv4/tcp_cong.c > > index 3737ec096650..8d4446ed309e 100644 > > --- a/net/ipv4/tcp_cong.c > > +++ b/net/ipv4/tcp_cong.c > > @@ -25,7 +25,8 @@ static struct tcp_congestion_ops *tcp_ca_find(const char *name) > > { > > struct tcp_congestion_ops *e; > > > > - list_for_each_entry_rcu(e, &tcp_cong_list, list) { > > + list_for_each_entry_rcu(e, &tcp_cong_list, list, > > + lockdep_is_held(&tcp_cong_list_lock)) { > > if (strcmp(e->name, name) == 0) > > return e; > > } > > @@ -55,7 +56,8 @@ struct tcp_congestion_ops *tcp_ca_find_key(u32 key) > > { > > struct tcp_congestion_ops *e; > > > > - list_for_each_entry_rcu(e, &tcp_cong_list, list) { > > + list_for_each_entry_rcu(e, &tcp_cong_list, list, > > + lockdep_is_held(&tcp_cong_list_lock)) { > > if (e->key == key) > > return e; > > } > > @@ -317,7 +319,8 @@ int tcp_set_allowed_congestion_control(char *val) > > } > > > > /* pass 2 clear old values */ > > - list_for_each_entry_rcu(ca, &tcp_cong_list, list) > > + list_for_each_entry_rcu(ca, &tcp_cong_list, list, > > + lockdep_is_held(&tcp_cong_list_lock)) > > ca->flags &= ~TCP_CONG_NON_RESTRICTED; > > > > /* pass 3 mark as allowed */ > >