Article View: linux.kernel.netdev
Article #15308Re: [PATCH net] vlan: prevent cross-netns MII register writes
From: Andrew Lunn
Date: Thu, 12 Nov 2026 16:15
Date: Thu, 12 Nov 2026 16:15
49 lines
10051 bytes
10051 bytes
On Thu, Nov 12, 2026 at 07:56:24AM -0800, Jakub Kicinski wrote:
> On Fri, 6 Nov 2026 12:46:39 +0000 Hungyu Lin wrote:
> > vlan_dev_ioctl() forwards SIOCSMIIREG to the underlying real
> > device without checking whether the VLAN device and real device
> > belong to the same network namespace.
> >
> > A VLAN device can be moved into another network namespace while
> > its real device remains in the host namespace. This allows a
> > process with the required privileges in the VLAN device's
> > namespace to modify PHY registers on the host's real device.
> >
> > Reject SIOCSMIIREG when the two devices belong to different
> > network namespaces. Preserve MII reads across namespaces and
> > allow MII writes when both devices belong to the same namespace.
> >
> > Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Hungyu Lin <dennylin0707@gmail.com>
>
> > diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
> > index bca0a3693636..0d0904103302 100644
> > --- a/net/8021q/vlan_dev.c
> > +++ b/net/8021q/vlan_dev.c
> > @@ -416,9 +416,12 @@ static int vlan_dev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
> > ifrr.ifr_ifru = ifr->ifr_ifru;
> >
> > switch (cmd) {
> > + case SIOCSMIIREG:
> > + if (!net_eq(dev_net(dev), dev_net(real_dev)))
> > + break;
> > + fallthrough;
> > case SIOCGMIIPHY:
> > case SIOCGMIIREG:
> > - case SIOCSMIIREG:
> > err = dev_eth_ioctl(real_dev, &ifrr, cmd);
> > break;
> > }
>
> Andrew, Florian, any idea if we could delete this completely?
> Why would anyone want to run MII/PHY commands on a VLAN?
It does seem questionable.
Hungyu, do any other virtual devices forward these ioctl calls to the
physical device below? I assume they have the same problem. So we need
a fix for them all.
Andrew
Technical Details
Message-ID:
<706b09ea-49cc-4801-a24b-b22d2ea7d257@lunn.ch>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-361996-linux-kernel-netdev=dewy.ruReferences:
<20261106124639.12584-1-dennylin0707@gmail.com> <20261112075624.23c04230@kernel.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-361996-linux-kernel-netdev=dewy.ru From: andrew@lunn.ch (Andrew Lunn) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net] vlan: prevent cross-netns MII register writes Date: Thu, 12 Nov 2026 17:15:13 +0100 Organization: Usenet Network Message-ID: <706b09ea-49cc-4801-a24b-b22d2ea7d257@lunn.ch> References: <20261106124639.12584-1-dennylin0707@gmail.com> <20261112075624.23c04230@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: usenet.network; logging-data="1133615"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:nNFfEGzsDel//ddQLkM/Qv9VD3E= sha256:m+0zC8Y75d9909scjmdkI4AnAr8BP0XMunpnYdq59u8= sha1:BaLszomKXBz0Smso+ug6btqp/vA= sha256:U1I82GSl2agOH64bKh0YYThItv3KaZBjWHb1eljtrxk= 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 36D3411430F; Thu, 12 Nov 2026 20:19:26 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.051 X-Spam-Status: No, score=-3.051 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, 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 (1024-bit key) header.d=lunn.ch 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 llbw6yTE8dng; Thu, 12 Nov 2026 20:19:22 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-361996-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=lunn.ch X-Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) by mail.dewy.ru (Postfix) with ESMTPS id 2C3A51142E3; Thu, 12 Nov 2026 20:19:11 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sin.lore.kernel.org (Postfix) with ESMTP id E63B714676B; Thu, 12 Nov 2026 16:16:15 +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=1794500140; b=LRscViS8eyG7+xPRkA6VInlEojvOCN4NspZAma78gLXUKtO0wuTEx2OpXvr8o/31OjeD /+chDT4zH8A0hhoY0IqQkMO1x1vNCq7niNOVHvKM3e+m8T85hR1dW6srHR3DC/oPRhTl/ K6IaXNfLu8fomTl5Nl6VVyun2s4PaQQysr5lCnGes1ZPhjIqhtun1Fw1HNkyGUEXxI+48 myh3d4beJnP6IyLQw4oYDN9ZfAf4EA5Zhncu1pOCz6zB5AfelIcLk+zbEAmqt5Jk+UGAh wo3S+I/nKohQdObbnb0PtXPAE1IEP4HRQOjsFHZngM81KZWiPZlu81zxPFf/60Cz2ew== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794500140; h=X-Original-To:Received:DMARC-Filter:DKIM-Signature: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=E+lPQFUisVnZ0dm/OJdC+O18hBtu9MYe0Vq+o6Ob5tw=; b=RIbP0cFhMGt30QHoXekSgP3bZp8CX20M25/l+gkFuWCPRiFEjPycs/DuamLkkkAeCneM jA2isZjDmY+rROtoJt8PrUdII4KGoHkq3CXZ0wawH96Adif6Vq/hbR658gFi8kr2ZR/H3 sc1bNXG2KY3kSX/ebp11XML1zc8Wkgk73gcAFOKsDOCSV3zJjEGIo9xnyE2V9oxQe3hTG o7CI+WgZKPcy4oRPhuWJF4GSgA5GUTitqISzyInWmo2I86jpjrvXE7GvXtZIq5q+0Kdi2 hREcHJJaebp1id7UVNtmlqoUs6dlcv/KJWZWLzQj75x2cXr4h7IKceSHqxSW5FJKXxQ== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=lunn.ch header.i=@lunn.ch header.a=rsa-sha256 header.s=20171124 header.b=YL8JYSvP; dmarc=pass header.from=lunn.ch; spf=pass smtp.mailfrom=lunn.ch; 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 54B65606A33B; Thu, 12 Nov 2026 16:15:40 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=lunn.ch header.i=@lunn.ch header.a=rsa-sha256 header.s=20171124 header.b=YL8JYSvP X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=156.67.10.101 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794500134; b=fHeU8FHLAiO6logpr/fVIweHGLbvMZuuIt0CjY/d1YhSb2RXpUK0ZVRhPCbSwv/fQXAW vtWW274WYaEZC0j2LnDkNO5rxvm1y5LSFEZd74lxRgrsNJ2Qq+aT64NvL7NPgAnK1M9qc maZvAryl9P37iprKq6SJmEFD6Hf7vT1Y1hPByuXEunAxi2SaFoGsrxECXpdRWgB5VWoJo +u+DNWraeAPla9/J+WCh8lJLhsRjt/QcLFm1l9ckYsjKRSxtMELFf9m/XJaZICnOLP8IC GBEeWTzANJwZrgDRci1RlLu2Aphr6uOyZP52CYKnDfXMERoP+A/m9DkfKKYj8C8Ca/g== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794500134; h=DMARC-Filter:DKIM-Signature:Received:Date:From:To:Cc:Subject: Message-ID:References:MIME-Version:Content-Type:Content-Disposition: In-Reply-To; bh=E+lPQFUisVnZ0dm/OJdC+O18hBtu9MYe0Vq+o6Ob5tw=; b=osD5SlZxQGdp3UdB/00lysKIGjNhkSjHV3A8WV/Hln8GW11/4yi8oRJKaBBJ7M6j6c3u 7S1N7Zox06v8VG4f5H0nXGRS4u5yPG9d0a4RApj+hcqG0Ynid+v5Nk8Uaj4fmOYUyQgNf wONTJRUUfQTEfoR7IcgRPen+Z/bPdlESrpFMPNx7+hwrC/ZMTTMW6wos6PHCYy52+fXyg 3jvK0cy9uecZqdI+fEINlvxwL8HInEYqSykN+BHJkuqXmUCZVwUaKRD9esQ35Y8qktkBE 6WU+/7ow+M6rUFGXYZFhIcAFvL3uyyt3HZ2Wg9fYsM1kxgs6bclgj7plaGTDbB0YU4w== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=lunn.ch; spf=pass smtp.mailfrom=lunn.ch; dkim=pass header.d=lunn.ch header.i=@lunn.ch header.a=rsa-sha256 header.s=20171124 header.b=YL8JYSvP; arc=none smtp.remote-ip=156.67.10.101 X-Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AAEC5606A32E; Thu, 12 Nov 2026 16:15:33 +0000 (UTC) X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org AAEC5606A32E X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=lunn.ch X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=lunn.ch X-DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=E+lPQFUisVnZ0dm/OJdC+O18hBtu9MYe0Vq+o6Ob5tw=; b=YL8JYSvPAzt1jdXgOvy7T68YhR L07tbukDoNe8lhW4ZtRnr3BLMgF73ulQcKd2L3CxLsBEhDpgeVA3IPRtl6Q+8vmZ/DG8PJhY5wRki HTtG0i5PfnUxtqGuaV55ytsQVbntKsQLXmkSQO0pUWC7HdNrAQkr18oyDjdLLMbGwGbE=; X-Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from <andrew@lunn.ch>) id 1xRXSD-00G3yy-KR; Thu, 12 Nov 2026 17:15:13 +0100 X-Cc: Hungyu Lin <dennylin0707@gmail.com>, davem@davemloft.net, edumazet@kernel.org, pabeni@redhat.com, horms@kernel.org, n05ec@lzu.edu.cn, ylong030@ucr.edu, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Florian Fainelli <f.fainelli@gmail.com> 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: <20261112075624.23c04230@kernel.org>