Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp147458rwd; Wed, 14 Jun 2023 13:39:04 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ64CVjsRaG4J7jtkySDh7j/PpgythY5MhVtt6EoNTZfiMYIioSkIbrfP8wszXVhAP3fJXSO X-Received: by 2002:a17:902:e5c5:b0:1a6:b23c:3bf2 with SMTP id u5-20020a170902e5c500b001a6b23c3bf2mr16774624plf.10.1686775144154; Wed, 14 Jun 2023 13:39:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686775144; cv=none; d=google.com; s=arc-20160816; b=AYm/DPy4Fb0r6XBU3rI9NPdVYDIqQjS7cLXdr2cpyr/ZwVZBhnhNaSFCVPw7HxsCVo 7jmhCfTQ9GQmcfILtI1ujNJzD4hD5bzJmHtJGK2/CZC//mRSW1lH/i4r4b8Ym4cmQTOc WOR8n+iOi3ZX3cYMLBQR2+Pd3tYVPk3e/FurComsSGSFA7TAweyySfBdZfxRT0ao7VEc 8d6KdO0+P+mBtj9BRjl+1qZJQBMTo3ovIQ3YZIWruUohkr8GVrXQg46El6DHUvF+q3MW nAAIX1f7q0SyYKsgUVnDkQBwEuyWudBHPI45IbpeS+cWnm/iR0u1vpL0Ild9Cyt3Kaym ykvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :dkim-filter; bh=U4qamVRGUE/7lnj5A2E6uk72VsqqwBoh4BujNKmSg44=; b=RxAgTwhAaP1UYrKBnpofK/2r3Md1JPDPReuwEwleN0vrJbONblC2PLzTuGa1tav8pe FDf77OzQItsh7jCS72VRFaxGbJHBn2u33+ZhlTha+CGLNk9amm5Ixi81irM/oaeoobdm V+kFsrtio+XbjkXzVHXWKu5gyO1PJcTbJ/vwIJyYlb/8ntnIrMrQ0y+pkkLAIV5FR+TA En2++Rgd4ehHEUF+gq7DUGgixbS/uCr2gztDgru/SzVzbO+D8IuNYVXp3o6aU2uIhGgc 7fREyHBlIB0lBgvuCIL4uSQgsJJi9sNyvlYegMwN5+gzIz4zyAKi0XbFEsZlLZhJaJjh fxvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ispras.ru header.s=default header.b=PfFc1tSs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ispras.ru Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p15-20020a170902e74f00b001b3cd6a8378si6346637plf.303.2023.06.14.13.38.51; Wed, 14 Jun 2023 13:39:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ispras.ru header.s=default header.b=PfFc1tSs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ispras.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236144AbjFNURZ (ORCPT + 99 others); Wed, 14 Jun 2023 16:17:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232203AbjFNURX (ORCPT ); Wed, 14 Jun 2023 16:17:23 -0400 Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7911B1BCE; Wed, 14 Jun 2023 13:17:22 -0700 (PDT) Received: from fpc (unknown [10.10.165.2]) by mail.ispras.ru (Postfix) with ESMTPSA id C903D40755F4; Wed, 14 Jun 2023 20:17:19 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru C903D40755F4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ispras.ru; s=default; t=1686773839; bh=U4qamVRGUE/7lnj5A2E6uk72VsqqwBoh4BujNKmSg44=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=PfFc1tSsnUYTpkTrFOMKDL9XFDefo9nF9mmMA+YzekVgmNUhjkYgif4IrnYk64C+3 MBVCCe4euQmKS3DmyP6wARjaKSqxymXR3DjcBf5WYXT6Tsu6eqWNnzUU1fu1M5W6aL i6pFA2nzj8u53T505tJNWhXh2tmpLgFPQvdl94Gw= Date: Wed, 14 Jun 2023 23:17:14 +0300 From: Fedor Pchelkin To: Jakub Kicinski Cc: Sabrina Dubroca , "David S. Miller" , Eric Dumazet , Paolo Abeni , Raed Salem , Lior Nahmanson , Saeed Mahameed , Hannes Frederic Sowa , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Alexey Khoroshilov , lvc-project@linuxtesting.org Subject: Re: [PATCH] net: macsec: fix double free of percpu stats Message-ID: <20230614201714.lgwpk4wyojribbyj@fpc> References: <20230613192220.159407-1-pchelkin@ispras.ru> <20230613200150.361bc462@kernel.org> <20230614090126.149049b1@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230614090126.149049b1@kernel.org> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham 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 On Wed, Jun 14, 2023 at 09:01:26AM -0700, Jakub Kicinski wrote: > On Wed, 14 Jun 2023 14:26:14 +0200 Sabrina Dubroca wrote: > > > What prevents the device from being opened and used before > > > macsec_add_dev() has finished? I think we need a fix which > > > would move this code before register_netdev(), instead :( > > > > Can the device be opened in parallel? We're under rtnl here. > > > > If we want to move that code, then we'll also have to move the > > eth_hw_addr_inherit call that's currently in macsec's ndo_init: in > > case the user didn't give an SCI, we have to make it up based on the > > device's mac address (dev_to_sci(dev, ...)), whether it's set by the > > user or inherited. I can't remember if I had a good reason to put the > > inherit in ndo_init. > > Ah, you're right, this is a link creation path. My reply probably won't give any new information now but if the code of macsec_add_dev() and the parts from ndo_init it depends on which Sabrina mentioned would be moved before registering netdev then the problem will go away on its own. Is it worth moving that code if rtnl_lock is held? Maybe it will be more persistent to initialize the device for as maximum as possible before calling register_netdevice()? Overall, it all depends on the reasons why the code was implemented so initially.