Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp130130iob; Tue, 17 May 2022 21:14:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzKxLDACULF+TI5UBLSJXnEKyYHe3IcaGv9WXMHoK3ItHZTbAS5SuaTu3sI4N6Ifjhq2JHY X-Received: by 2002:a63:ea4f:0:b0:3c6:6534:d8f2 with SMTP id l15-20020a63ea4f000000b003c66534d8f2mr22080924pgk.187.1652847275720; Tue, 17 May 2022 21:14:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652847275; cv=none; d=google.com; s=arc-20160816; b=u/jnqNDI1l7B6yR6EqNqXCfiZDFmOF4Cke5Avv93iiK7O5I6wD9CojRUUJtiA9Zb1e 16RVCr2+r5viSYunR7+vWoo8fEsUdzAlGj1gC2Ck9Y3ayPewmXlj3MZP36SFaQJ9qSgq XZMY2Zyrz8aNWTfZbJBe9cb9QD5gZtsmztE0Xz4awTTPLfrxks9gakgSdb9nRD6qEAEg R7ITkPzKHiNzFdY2vWWBAJvwB9VmZoigvsmolP4W7ggGZWqxU+NpYaV777R/9V6sCe8F 3YEJuz4TG3UlLbb85wNoVUnYrhNhoHec15fIxHERR27/gTZh9w/egvHRj2mZv1Zey0vA ES6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=LGLIFlTQ2OG0Nit+kOZYpbPmMvBDDMh/ziDLpygha+E=; b=TkUgOY9nOO3WVzxvhttTCHFAAATM3i1sIQKzdoP909KAF6W2fi2SpkxCTlUntN8xpB e3G5wYHu6RUsXRP4RXhxqtowm1XOfldyUodp0kBJA4jd0OH7c0cFAY58YqKt46zhgeow YmJrHIkgwmqqfQ4CZujzQ5WGUaFLB7QuFlvFKbmngooCClSOFujp5f8oR7QJoDx1z4mp RHCLi6XV+27HXxPT6YLXG4XI/tsaaHk4BJW0hWUoZlJljkU+GF+DK3TYpK6o+sBy1USz XvZXYgwnFcgo9ccrCmOcf3/0j00aGaJ62Npm5Ytl1X66E2GZz89IcBdeZIPSxLN7INw2 sHEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=i4pQegMj; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id bf12-20020a170902b90c00b0015caeda8720si1379599plb.106.2022.05.17.21.14.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 May 2022 21:14:35 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=i4pQegMj; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 543B46D1B4; Tue, 17 May 2022 20:44:06 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229828AbiEQRd1 (ORCPT + 99 others); Tue, 17 May 2022 13:33:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351447AbiEQRdZ (ORCPT ); Tue, 17 May 2022 13:33:25 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0B6E23A18E for ; Tue, 17 May 2022 10:33:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652808804; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LGLIFlTQ2OG0Nit+kOZYpbPmMvBDDMh/ziDLpygha+E=; b=i4pQegMjADJUz20HOFBJN7TwR/hT7gjcGQd6Y0br+RcxSPb3cDP3TD4E1pby+BqhnuZmvB SxSlpfxXkSG7mmVlUHnxIYTAWnfZhJw/rZvhbMD7Arc0qGbAZqBdNfML6R7lzb5EB8/V6K GRgyJyzHmm4ke0XPwQO9rzaSqNzf+s8= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-296-IzFfBergOc-7ZtGOxWWsKg-1; Tue, 17 May 2022 13:33:22 -0400 X-MC-Unique: IzFfBergOc-7ZtGOxWWsKg-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3462685A5BE; Tue, 17 May 2022 17:33:21 +0000 (UTC) Received: from jtoppins.rdu.csb (unknown [10.22.8.76]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8F570492C14; Tue, 17 May 2022 17:33:19 +0000 (UTC) From: Jonathan Toppins To: liuhangbin@gmail.com Cc: andy@greyhouse.net, davem@davemloft.net, dsahern@gmail.com, eric.dumazet@gmail.com, j.vosburgh@gmail.com, jtoppins@redhat.com, kuba@kernel.org, netdev@vger.kernel.org, pabeni@redhat.com, syzbot+92beb3d46aab498710fa@syzkaller.appspotmail.com, vfalico@gmail.com, vladimir.oltean@nxp.com, Eric Dumazet , linux-kernel@vger.kernel.org Subject: Re: [PATCHv2 net] bonding: fix missed rcu protection Date: Tue, 17 May 2022 13:32:58 -0400 Message-Id: In-Reply-To: <20220517082312.805824-1-liuhangbin@gmail.com> References: <20220517082312.805824-1-liuhangbin@gmail.com> MIME-Version: 1.0 Content-Type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Signed-off-by: Jonathan Toppins --- RESEND, list still didn't receive my last version The diffstat is slightly larger but IMO a slightly more readable version. When I was reading v2 I found myself jumping around. I only compile tested it, so YMMV. If this amount of change is too much v2 from Hangbin looks correct to me. drivers/net/bonding/bond_main.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 38e152548126..f9d27b63c454 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -5591,23 +5591,32 @@ static int bond_ethtool_get_ts_info(struct net_device *bond_dev, const struct ethtool_ops *ops; struct net_device *real_dev; struct phy_device *phydev; + int ret = 0; + rcu_read_lock(); real_dev = bond_option_active_slave_get_rcu(bond); - if (real_dev) { - ops = real_dev->ethtool_ops; - phydev = real_dev->phydev; - - if (phy_has_tsinfo(phydev)) { - return phy_ts_info(phydev, info); - } else if (ops->get_ts_info) { - return ops->get_ts_info(real_dev, info); - } - } + if (real_dev) + dev_hold(real_dev); + rcu_read_unlock(); + + if (!real_dev) + goto software; + ops = real_dev->ethtool_ops; + phydev = real_dev->phydev; + + if (phy_has_tsinfo(phydev)) + ret = phy_ts_info(phydev, info); + else if (ops->get_ts_info) + ret = ops->get_ts_info(real_dev, info); + + dev_put(real_dev); + return ret; + +software: info->so_timestamping = SOF_TIMESTAMPING_RX_SOFTWARE | SOF_TIMESTAMPING_SOFTWARE; info->phc_index = -1; - return 0; } -- 2.27.0