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=-6.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 814F8C43381 for ; Fri, 22 Feb 2019 23:08:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4AC9E206C0 for ; Fri, 22 Feb 2019 23:08:43 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jQ7NiCLk" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726870AbfBVXIl (ORCPT ); Fri, 22 Feb 2019 18:08:41 -0500 Received: from mail-yb1-f195.google.com ([209.85.219.195]:46861 "EHLO mail-yb1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725911AbfBVXIl (ORCPT ); Fri, 22 Feb 2019 18:08:41 -0500 Received: by mail-yb1-f195.google.com with SMTP id 66so1485288ybo.13 for ; Fri, 22 Feb 2019 15:08:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language:content-transfer-encoding; bh=J1upixmcZjwWdePtN9bRq47ZzbzJYbOyavs5cTqxMWs=; b=jQ7NiCLkGAWUy93NUPncLw4oARu8WrllnCXi+eM9okRrbiHlPIEx9iBYJOLuhbZaBL a1I+dCXor5N6V05RQ2K8lDfbm+grZEaH9xktLAVl8F9OwvAhArvfkEg9eWVO70nf1TD8 PB2Uf2dHPTfHuK64P6+jEdQgWxyEXIm9vQwhgcNz53aDSxNlJlZ0J4osMguIW2icS/Dg pNIzBXkf3rqsCssOq4Oeb2Xo01dkC9MxgjFw3PcCwn8k21Pl7UU3JbH3fH7oPDI3N7SF XzYDdglyUvNw+9KuaefnOxdntAZKHQ/wSAF3B00me1rC63yawZPJAn33sUwoe6RPwgve /1DQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=J1upixmcZjwWdePtN9bRq47ZzbzJYbOyavs5cTqxMWs=; b=RTuVlwPzC3AprJpexUsWjIgVIzmpL9o6Vt7jZlj0P9nlpfKClzid52lr2mGsYlVw8s vWp7sqirgRirivPtaaQnGalZ6bVE2obx3554EnY++DWc7+BWgmfx92LKZYk2k4c+7t0U ZzFi5KC/wP461FZEiwedAL3JQHN8ETGcSTMqIEEKUMbuA1ix4QazRSs1zeK/H2zHR+Tu VrQOE9sDvC4wfAH1sv3+UZdXVwDhrcBOE5Wm38OuS+iNPE1LfITNh2/vBALVhMrYoEb1 QJ3h24EdHwj3L2eVo/1qYLsHwvoKOlDcMcM03sHolrqDTwMMdpzgUk4hGKIk28cyBf1X JB/g== X-Gm-Message-State: AHQUAuZBefaA+R+uJRXLofYf/l0hf82WtX31bQLXVkQrYZGLdYAMXxhR kGuhrKwBMNlt/Pt8+RxFaVcJ2KpV X-Google-Smtp-Source: AHgI3IZ9ysj7EYveY5BK6NilJfvtZ5J1L8nvDiby43yY5enAV6jwEwk3VomvBiNS73Bk6qSs6Tr6XA== X-Received: by 2002:a25:35d5:: with SMTP id c204mr5602455yba.325.1550876920180; Fri, 22 Feb 2019 15:08:40 -0800 (PST) Received: from [192.168.86.235] (c-73-241-150-70.hsd1.ca.comcast.net. [73.241.150.70]) by smtp.gmail.com with ESMTPSA id a190sm903036ywg.76.2019.02.22.15.08.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Feb 2019 15:08:39 -0800 (PST) Subject: Re: [PATCH][net-next] ipv6: sanitize RCU usage on fib6_next To: Li RongQing , netdev@vger.kernel.org References: <1550828682-10608-1-git-send-email-lirongqing@baidu.com> From: Eric Dumazet Message-ID: <48790843-066f-668b-c840-6ab34fc2fcf4@gmail.com> Date: Fri, 22 Feb 2019 15:08:38 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <1550828682-10608-1-git-send-email-lirongqing@baidu.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On 02/22/2019 01:44 AM, Li RongQing wrote: > using rcu_assign_pointer when setting, which has a memory > barrier to ensure the initialization is seen first. > > using rcu_dereference when dereference this pointer > > Signed-off-by: Zhang Yu > Signed-off-by: Li RongQing > --- > net/ipv6/ip6_fib.c | 6 ++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > > diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c > index 6613d8dbb0e5..b73d40d68178 100644 > --- a/net/ipv6/ip6_fib.c > +++ b/net/ipv6/ip6_fib.c > @@ -1143,7 +1143,7 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct fib6_info *rt, > > atomic_inc(&rt->fib6_ref); > rcu_assign_pointer(rt->fib6_node, fn); > - rt->fib6_next = iter->fib6_next; > + rcu_assign_pointer(rt->fib6_next, iter->fib6_next); We do not need a barrier here, the object is still private. > rcu_assign_pointer(*ins, rt); > if (!info->skip_notify) > inet6_rt_notify(RTM_NEWROUTE, rt, info, NLM_F_REPLACE); > @@ -1761,7 +1761,9 @@ static void fib6_del_route(struct fib6_table *table, struct fib6_node *fn, > RT6_TRACE("fib6_del_route\n"); > > /* Unlink it */ > - *rtp = rt->fib6_next; > + *rtp = rcu_dereference_protected(rt->fib6_next, > + lockdep_is_held(&rt->fib6_table->tb6_lock)); This change will likely add a sparse bug. > + > rt->fib6_node = NULL; > net->ipv6.rt6_stats->fib_rt_entries--; > net->ipv6.rt6_stats->fib_discarded_routes++; > Really I do not believe these changes are needed. barriers should be added blindly.