From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4D75AC43381 for ; Wed, 20 Feb 2019 17:22:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1DA7621841 for ; Wed, 20 Feb 2019 17:22:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726180AbfBTRW6 (ORCPT ); Wed, 20 Feb 2019 12:22:58 -0500 Received: from mx1.redhat.com ([209.132.183.28]:4260 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725806AbfBTRW5 (ORCPT ); Wed, 20 Feb 2019 12:22:57 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 79402A077F; Wed, 20 Feb 2019 17:22:57 +0000 (UTC) Received: from localhost.localdomain (unknown [10.32.181.131]) by smtp.corp.redhat.com (Postfix) with ESMTP id A157160141; Wed, 20 Feb 2019 17:22:56 +0000 (UTC) Message-ID: <7bf3b6ff2f6d4f876783c3a154fd030805f55fc5.camel@redhat.com> Subject: Re: [PATCH net 1/2] ipv6: route: enforce RCU protection in rt6_update_exception_stamp_rt() From: Paolo Abeni To: netdev@vger.kernel.org Cc: David Ahern , "David S. Miller" Date: Wed, 20 Feb 2019 18:22:55 +0100 In-Reply-To: <1ac484e7626a5d5e7c22de13485575de30ad7fe0.1550682516.git.pabeni@redhat.com> References: <1ac484e7626a5d5e7c22de13485575de30ad7fe0.1550682516.git.pabeni@redhat.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.30.5 (3.30.5-1.fc29) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 20 Feb 2019 17:22:57 +0000 (UTC) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On Wed, 2019-02-20 at 18:10 +0100, Paolo Abeni wrote: > We must access rt6_info->from under RCU read lock: move the > dereference under such lock, with proper annotation, and use > rcu_access_pointer() to check for null value outside the lock. > > Fixes: a68886a69180 ("net/ipv6: Make from in rt6_info rcu protected") > Signed-off-by: Paolo Abeni > --- > net/ipv6/route.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/net/ipv6/route.c b/net/ipv6/route.c > index bd09abd1fb22..cbaa8745d9ff 100644 > --- a/net/ipv6/route.c > +++ b/net/ipv6/route.c > @@ -1610,15 +1610,15 @@ static int rt6_remove_exception_rt(struct rt6_info *rt) > static void rt6_update_exception_stamp_rt(struct rt6_info *rt) > { > struct rt6_exception_bucket *bucket; > - struct fib6_info *from = rt->from; > struct in6_addr *src_key = NULL; > struct rt6_exception *rt6_ex; > + struct fib6_info *from; > > - if (!from || > - !(rt->rt6i_flags & RTF_CACHE)) > + if (!rcu_access_pointer(rt->from) || !(rt->rt6i_flags & RTF_CACHE)) > return; > > rcu_read_lock(); > + from = rcu_dereference(rt->from); -ELOWONCOFFEE: even this one is racy, as rt->from can go away due to underlying device removal between the two fetch operation. I'll send a v2. Again, I'm sorry for the noise, Paolo