🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #15327

Re: [PATCH net-next] net: ethtool: request rtnl_lock for ETHTOOL_MSG_PORT_GET

#15327
From: Stanislav Fomichev
Date: Thu, 12 Nov 2026 17:24
42 lines
12623 bytes
On 11/11, Linkui Xiao wrote:
> From: Linkui Xiao <xiaolinkui@kylinos.cn>
> 
> port_prepare_data() resolves the requested port through
> phy_link_topo_get_port(), which requires rtnl_lock to be held before it
> reads topo->ports:
> 
> 	/* ports in the topo are RTNL protected, but may be accessed under
> 	 * netdev_lock for ops-locked devices. For now keep them under rtnl
> 	 * protection, as no ops-locked devices have phy_port capabilities
> 	 * yet.
> 	 */
> 	ASSERT_RTNL();
> 
> The dump side honours this, port_dump_one_dev() takes rtnl_lock()
> itself. The doit side does not. ETHTOOL_MSG_PORT_GET is served by
> ethnl_default_doit(), which keeps rtnl_lock only when the device is not
> ops-locked, or when ethtool_nl_msg_needs_rtnl() asks for it:
> 
> 	need_rtnl = !netdev_need_ops_lock(req_info->dev) ||
> 		    ethtool_nl_msg_needs_rtnl(req_info->dev, cmd);
> 
> ethtool_nl_msg_needs_rtnl() has no case for ETHTOOL_MSG_PORT_GET and
> falls through to "return false", so on a device that opts into the
> instance lock (request_ops_lock, queue_mgmt_ops or net_shaper_ops)
> PORT_GET runs with netdev_lock only. Such a device that does have a
> link topology trips the ASSERT_RTNL() warning and reads topo->ports
> without the protection the xarray is documented to need.
> 
> Add the missing case. Like TSCONFIG_GET/SET, PORT_GET has no
> corresponding ethtool ioctl, so it is Netlink-only and always needs
> rtnl_lock.

[..]

> The bug is latent as no device opts into the instance lock while also
> carrying a link topology, so it cannot be observed yet and the change is
> compile-tested only.

Then why fix it if there is no bug? And phy_link_topo_add_port has
a big comment explaining the expectations?
Technical Details
Message-ID: <avX2MdTZePW5ssrq@devvm16445.scu0.facebook.com>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-362067-linux-kernel-netdev=dewy.ru
References: <20261111072724.3295527-1-xiaolinkui@126.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-362067-linux-kernel-netdev=dewy.ru
From: sdf.kernel@gmail.com (Stanislav Fomichev)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next] net: ethtool: request rtnl_lock for
 ETHTOOL_MSG_PORT_GET
Date: Thu, 12 Nov 2026 09:24:52 -0800
Organization: Usenet Network
Message-ID: <avX2MdTZePW5ssrq@devvm16445.scu0.facebook.com>
References: <20261111072724.3295527-1-xiaolinkui@126.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Injection-Info: usenet.network;
	logging-data="1136315"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:H5qhpsX9Mpq5V8EF++ulwf/gizA= sha256:L/oiRwnVq6GD7ysP7V+Z3ji9+s3JtuHkSJKF2IBLB8Q=
	sha1:hVK+nokfQ0kUhtWLePtsZIZuC9g= sha256:v28+yT19PpaxzX1cCX+KEc848/9zyxaylMNy0nGRPmY=
Content-Disposition: inline
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 1B1F7114322; Thu, 12 Nov 2026 20:31:49 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.149
X-Spam-Status: No, score=-3.149 tagged_above=-9999 required=6.31
	tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
	FREEMAIL_FORGED_FROMDOMAIN=0.001, FREEMAIL_FROM=0.001,
	HEADER_FROM_DIFFERENT_DOMAINS=0.249, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001]
	autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id hlpS_D-6PwCF;
	Thu, 12 Nov 2026 20:31:46 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-362067-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id 4216A11431A; Thu, 12 Nov 2026 20:31:38 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id A8D8864305E; Thu, 12 Nov 2026 17:25:02 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1794504299;
	b=Ffu+fHbPqtkpKmcRaVdCuJI69S13WYGME5adXKhum0dm7zIc5eHAqTnv+fRiRoKI/iKM
	 s+vG9RKKRQxhdFwjuxsh7rdOomPJY1mJcTXzvc7skR6U/LUwxrKBjO9n1/pKVi1u6XL1N
	 QKHiR3faUjp8Wcav8plB+dA+FGbKevrhOgppKtEMqxIknS3TbWGLCzvMBtUUIPoYRCvoP
	 xQ+xwuzS9E9cok/807o+ZDShZRum4anr5FGR8/767pHIhcoypPVALNsL4iinkesnUWAZC
	 vOWxIWKOJjgE7SyqbV86ApnuG6hZe9HmMXCmbFpZCvUrXk9UJK9piSO7xYpWl9tE4ig==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794504299;
	h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
	 X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State:
	 X-Gm-Gg:X-Received:Received:Date:From:To:Cc:Subject:Message-ID:
	 References:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:Content-Type:
	 Content-Disposition:In-Reply-To;
	bh=UEs+nzWRaRp917aoYI9U1JFVkzp5XZBJ5gUnGKU3NGE=;
	b=XY0KHJc3DuFIgOcFWUDOmwNSCvSl3w9fxJDki86VUaIyvhZF7zE7zz73sxqh8BUQonFY
	 edBKBcYL7wq2Ju6KEosUjwDL5mzneQHYTNHg9COqUcMK39QbGNo9HaFkFCq8PtrbNoSpk
	 rmSC729tXb+cyOO2Py2yydy0Rw5Ijwo8a7cWvjhYpTUD/fHlMgvACG1MxISfQIN4cCDEd
	 41+rNS1ooRJCUOktMDisL0FCPXZ+vjp8yAw8IUDCwObgZYs3O+xJ3PguDROmPu3ivUsJa
	 5HIHlsDu1+rI4q44qIffUtBE1UhNNjyvpA1jxluL/ucrKbTsBbLviPQgogGlZLxMN7A==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=S4y2j5j7;
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id CB074606A331;
	Thu, 12 Nov 2026 17:24:59 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=S4y2j5j7
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.229.0
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1794504299;
	b=GxIvPc/vpgKFy2BdZiUuCrYJYZLQsRtffHeQLhbqgHAitU/8yvtM0oY1WHNIhNQeaJwS
	 Xpt1semADQapwL6fSk9hPCrZ4D8QIv5fxJbJdF7tiUhYin36qj8DfibqdafT7UBMmqhdp
	 SYvzqeBVCCG4l8NDhiHrZJ6qoVphBXIphRmBTF4Br8V0cEHyB/oPWHoBfdiPpp7LQlPJW
	 XTzFehuMcXTY9N4yMTGeY2MQpEM/4fd6+km3Fq+VyGSK5+dCklhv8wltU+eMZYCHx6TYX
	 J7fdKW9evVC4Z8LLnb+1DRGucOxs8FBgvy/FQSUd5NsNy3fz+vqG8KqG8NItQvReHJg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794504299;
	h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
	 X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received:
	 Date:From:To:Cc:Subject:Message-ID:References:MIME-Version:
	 Content-Type:Content-Disposition:In-Reply-To;
	bh=UEs+nzWRaRp917aoYI9U1JFVkzp5XZBJ5gUnGKU3NGE=;
	b=Eq7wdKSbzjs/24I10oU/Gb7GysA30IXxeILxhXOB9IlgznVbV3kr8FFbt2E4EKpFOnaZ
	 NzdvQzlXe9UoB4m5KWbb5jR6PVYr6OtRuZtpt4/urKFFAO3f4cQhP6HNgZfiNAohkeaDR
	 8dmZQyV9vHXLcifAdutoM9uQEkoTONUkLI1G+oDjEBQJ89qM2mp7Ht4yD685oyBp+QcIQ
	 C7uxgs78FdFqJZSsp6lrqtvi0ByD/J9N3RvqlQSdfcdjsWq9R6gw2bpYRm9Naivj4bjCd
	 9vtohgO/n/K/WMO+oZkKs5T7m/EDJTKV1EXjPyuwxQ98rhwHuaitzjUuNR6Dopoxezg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dmarc=pass header.from=gmail.com;
	spf=pass smtp.mailfrom=gmail.com;
	dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=S4y2j5j7;
	arc=none smtp.remote-ip=74.125.229.0
X-Received: from mail-dy2-f0.google.com (mail-dy2-f0.google.com [74.125.229.0])
	(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9F1E1606A321
	for <netdev@vger.kernel.org>; Thu, 12 Nov 2026 17:24:58 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9F1E1606A321
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-dy2-f0.google.com with SMTP id 5a478bee46e88-3117f9b9e64so13992eec.0
        for <netdev@vger.kernel.org>; Thu, 12 Nov 2026 09:24:58 -0800 (PST)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20260707; t=1794504298; x=1795109098; darn=vger.kernel.org;
        h=in-reply-to:content-disposition:content-type:mime-version
         :references:message-id:subject:cc:to:from:date:from:to:cc:subject
         :date:message-id:reply-to:content-type;
        bh=UEs+nzWRaRp917aoYI9U1JFVkzp5XZBJ5gUnGKU3NGE=;
        b=S4y2j5j7eEmQWSOHqnVtpeUI9RpdBZ9lvLBNkDHNvYXEWFRQI54XWg0Sn7wz79Z77m
         8UoX7W2fsYxj0wFOX/x4blpkW928Nrfc2rxLxYYgIVg0hUedDAxEOyPPaF+kUUcwXne1
         VKjWv1ftJ/6FOBxqdkqKcGhWBgqNzf/niatC5R2jQ0k0LM182TbJl8yVoIREQZTOA0yg
         ZnDLmeH53vcMnOG5FYCoZUlrgWBTitOgd5+q3vY1ucXWdvZ7zd4Wrw1e6PufrYqPfy2Z
         lA/N9rAxMfBlARwHcg09FhIr/jidSK4fhxoennVOCup+lc/pPdxqSkByl4HRPJ5pY2x2
         +jDA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1794504298; x=1795109098;
        h=in-reply-to:content-disposition:content-type:mime-version
         :references:message-id:subject:cc:to:from:date:x-gm-gg
         :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to
         :content-type;
        bh=UEs+nzWRaRp917aoYI9U1JFVkzp5XZBJ5gUnGKU3NGE=;
        b=0eBX3K1wht3hpThCXTK2S6kJkvOvVLmP1sYwzSPadyoEXp1ZmyAqYyBYi7wf1lCyPN
         Z5k+W8LrDs/Of5Bl/FJoW5bDa94Iuo+lCHF3Vy69v0JG6RvM1VE67U9WH2w+KwmOH5AQ
         vbfptNICa6KcS/hZK5BsId4dJ5v4iuCKJRwQRGYGxvda2s3zI1vrLZa3IsHvHE9ENRUC
         wTFHeXCFF04IY+TEt/SexyK1BMlPrvu5L9WHzYCgmjbDEHCuC0qXTLxZRvGM0lyoVqeW
         aky13VJg3r3aYfjKDrUo40KNQKvMFI/86xuTBuU3Er+DY40H31P9uVKFrfp52uwjrV59
         5ubA==
X-Forwarded-Encrypted: i=1; AL+hErH0EgiJGo9obGOoAIMBaORd41c2n5c/kpMsX/KkSNPY+Y1SAV/STeThTXZzbbSn4ZPnPzy82fQ=@vger.kernel.org
X-Gm-Message-State: APuU4Z+SmApEqFOIohuJ0QxdbvsE0wmrBISWuCXOHl9HSMR8h/48pv9B
	Tc8uZc2mglsMw8yuQsrkmZslWUm/RBGCb9zRB7I9RhfC7Gt0dtVzPq3k
X-Gm-Gg: AYBFou1+QXHisgyWY3obhzXVLH9A6KpH4clu5pcdmheUa0ttMDGDoMNTEYCQD91K5jc
	ZFWfo2YR1+vF52OdV7Mh85xKkf8C6yPP9hSgqRKIrx2wocqO1NJ9GwZIYVsUhYJ0XgtmC7XWi0i
	mT3pk3B9sC2iY5Cn4k3X5pL1Lj24YvVH73eZE65xi00Yhl9qlMJbkv09uu4ENz0xz1YCrxgyBYv
	zjYvlEdCfh7BxPu8JFpjo7iEMeTL9Ic5Cd1hyuZnNxFqkxaYaUJ4Tpv0ICzsRP/pfF/3cl0IMp9
	qyA+bhCD+LuJmfxJDe5ITb3lqETfdhNMhJoVVFnyLSe0tnKmtewAZk21U0RFVI0yVDncpxpBTm3
	119haVh+bD0VrViva32hVL+3ZjNz93LvhrwaFa2dbps3WD+K4E9PonKcVi/vxbtytYevpvmNdlN
	XfQ42MbRIXAosDVDy1o7AOSoVq/VqgCqMyTY7q/gvFqeEXB2pvq1UDhO179vDp52bXrwvJl7cA5
	+QEBfXe87lRwHLehy0mpamVy9/u+f6Vt3R54OAQEz0IJWfQ3cestoedb2Sk0JbkiAsCjEb2yIZ6
	1F1V09N8sdmnkVTYTxRM/CQ=
X-Received: by 2002:a05:7301:dd81:b0:36c:dd3b:a3e4 with SMTP id 5a478bee46e88-377deaeab9dmr2596773eec.3.1794504297384;
        Thu, 12 Nov 2026 09:24:57 -0800 (PST)
X-Received: from localhost ([2a03:2880:9ff:71::])
        by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3792624fe41sm1107451eec.22.2026.11.12.09.24.56
        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
        Thu, 12 Nov 2026 09:24:56 -0800 (PST)
X-Cc: andrew@lunn.ch, kuba@kernel.org, davem@davemloft.net, 
	edumazet@kernel.org, pabeni@redhat.com, horms@kernel.org, sdf@fomichev.me, 
	jacob.e.keller@intel.com, bjorn@kernel.org, alexanderduyck@fb.com, netdev@vger.kernel.org, 
	linux-kernel@vger.kernel.org, Linkui Xiao <xiaolinkui@kylinos.cn>
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-In-Reply-To: <20261111072724.3295527-1-xiaolinkui@126.com>