From: Andrew Lunn <andrew@lunn.ch>
To: Jakub Kicinski <kuba@kernel.org>
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>
Subject: Re: [PATCH net] vlan: prevent cross-netns MII register writes
Date: Thu, 12 Nov 2026 17:15:13 +0100 [thread overview]
Message-ID: <706b09ea-49cc-4801-a24b-b22d2ea7d257@lunn.ch> (raw)
In-Reply-To: <20261112075624.23c04230@kernel.org>
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
prev parent reply other threads:[~2026-11-12 16:15 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-06 12:46 Hungyu Lin
2026-11-06 12:51 ` netdev-bot+sinfo
2026-11-10 13:04 ` netdev-bot+sashiko
[not found] ` <20261112075624.23c04230@kernel.org>
2026-11-12 16:15 ` Andrew Lunn [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=706b09ea-49cc-4801-a24b-b22d2ea7d257@lunn.ch \
--to=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=dennylin0707@gmail.com \
--cc=edumazet@kernel.org \
--cc=f.fainelli@gmail.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=n05ec@lzu.edu.cn \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=ylong030@ucr.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®