Article View: linux.kernel.netdev
Article #13909Re: [PATCH net] vlan: prevent cross-netns MII register writes
From: netdev-bot+sashiko
Date: Tue, 10 Nov 2026 13:04
Date: Tue, 10 Nov 2026 13:04
113 lines
11734 bytes
11734 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 ยท High: 0 ยท Medium: 1 ยท Low: 0
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [Medium] The patch only partly isolates the host PHY from the VLAN's
network namespace.
--
vlan: prevent cross-netns MII register writes
This commit makes vlan_dev_ioctl() reject SIOCSMIIREG when the VLAN
device and its real device are in different network namespaces.
SIOCGMIIPHY and SIOCGMIIREG are still forwarded across namespaces on
purpose, and writes are still allowed when both devices share a
namespace.
> diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
> index bca0a3693636c..0d0904103302f 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;
[Severity: Medium]
Can the VLAN's namespace still change host PHY state through
SIOCGMIIREG?
The commit message describes the threat as letting the VLAN namespace
"modify PHY registers on the host's real device". It also says the
patch will "Preserve MII reads across namespaces". MII reads are not
always free of side effects, though.
For phylib drivers, the read path ends in phy_mii_ioctl() in
drivers/net/phy/phy.c. That function does a raw bus read at a phy_id
and reg_num chosen by the caller:
drivers/net/phy/phy.c:phy_mii_ioctl() {
...
case SIOCGMIIREG:
if (mdio_phy_id_is_c45(mii_data->phy_id)) {
...
ret = mdiobus_c45_read(phydev->mdio.bus, prtad, devad,
mii_data->reg_num);
} else {
ret = mdiobus_read(phydev->mdio.bus, mii_data->phy_id,
mii_data->reg_num);
}
...
}
The BMSR link status bit is latched low, and genphy_update_link() in
drivers/net/phy/phy_device.c depends on that latch:
/* The link state is latched low so that momentary link
* drops can be detected. ...
*/
Vendor interrupt and event status registers are also often
clear-on-read. A read from inside the container could consume a
latched link drop, or acknowledge a pending PHY interrupt, before the
host's phylib state machine or IRQ handler sees it. Would the host
then miss link-change events?
The read also isn't limited to the PHY attached to real_dev.
mii_data->phy_id can name any C22 or C45 address on the host's MDIO
bus, including other PHYs or switches unrelated to the VLAN.
The only privilege check on this path is in dev_ioctl() in
net/core/dev_ioctl.c, and it is against the VLAN namespace's user
namespace:
case SIOCGMIIPHY:
case SIOCGMIIREG:
case SIOCSIFNAME:
dev_load(net, ifr->ifr_name);
if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
return -EPERM;
Container root can satisfy this check once the VLAN has been moved
into its namespace.
The write side here follows the vlan_dev_hwtstamp_set()/get split,
where only set has a net_eq() check. Hardware timestamp get has no
hardware side effects, but MII reads can.
Should SIOCGMIIPHY and SIOCGMIIREG also be rejected when
dev_net(dev) and dev_net(real_dev) differ? If not, could the commit
message explain why these cross-namespace reads are acceptable?
> }
--
Sashiko AI review ยท https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261106124639.12584-1-dennylin0707%40gmail.com
Technical Details
Message-ID:
<179431587680.994134.9895439231970781828@kernel.org>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!2.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!peer03.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-360213-linux-kernel-netdev=dewy.ruReferences:
<20261106124639.12584-1-dennylin0707@gmail.com>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!2.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!peer03.ams4!peer.am4.highwinds-media.com!news.highwinds-media.com!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-360213-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net] vlan: prevent cross-netns MII register writes Date: Tue, 10 Nov 2026 13:04:36 +0000 Organization: Usenet Network Message-ID: <179431587680.994134.9895439231970781828@kernel.org> References: <20261106124639.12584-1-dennylin0707@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="614786"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:OFoset8YN5ER4B3BegpFTyB0jcQ= sha256:MB8iw5FbBh4QHOkTYYMV7JvtuLrE8HIEcpdm/Evtb1E= sha1:yaE1ZFkFq/FBcaI/QhodyLCj4B0= sha256:7+bH6+2U//3G638atLkweT6uC4FUZGma5mgUNlEduqg= 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 83369113BA1; Tue, 10 Nov 2026 16:28:13 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.4 X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org 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 59OLXbZXqjn7; Tue, 10 Nov 2026 16:28:09 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-360213-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 6BEAD113B74; Tue, 10 Nov 2026 16:28:01 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by tor.lore.kernel.org (Postfix) with ESMTP id 9D8E4142776; Tue, 10 Nov 2026 13:08: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=1794315879; b=yoXnsNsKjjp41EkD/itjE29OE449pySTB+tQtTTzXvWccgE4jszhV8eoJRgKYwCCNUaL t5ySoMDAxvB71E8Z2HaHbs7SMzZKR0dg/c5UePfWXwB7QDY+ztlDfj2MQPex7MNxd41+M QWH2IRWtyehnkeVp9IGb41TIeU5r8/Z81aOtZMEmQ0KhlgnBoou6FdKPmbbz6TUJeVlls XBpEkdHqH0v9bFFAtZutCkuKgcM/QnprLjCREOrPse9w8E2CqJ/Ii34W29uq3bP1ElA25 scVzvIpWguPvDYwoxV9zIOgmdxB1jOuQwlmwePIuNEYu1gqIqf14kXiWmImgcUh8cWA== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794315879; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=EnWbVDYQ/6puggi0QqXD0bxXsZrTtGcnJLqSymIBlOI=; b=o4fmumtlyfWkfODKuVS4a6SYI/jSzFxQ6WQpfcReWsX5wG5lis8eYXEuHO8/2x43XyFW QhcQKAUyhHmvjuhfUrQ94eEE2CnfFfE3NRtJ7HKY6T+BgD8ZMZnF1+LdSeAh0Z1jy1XgJ VcPNAj0zOP/lT3DPh1XyXmdkFq0MAcHHmxrhlpLsoYSrWI/g0plGwLgPg72nUtb6s8aaE 7Mp/4MKIyO2sVWYgkURldtYzlaOZcFWODihcuce/yT2PJ64734TfK9S2YZFf3Vf0y3wdn A1R6pafy3MSIc3kPR1Ce4ywXvocLqZTKXmUTxmOwAYWA+C5he4n8zWuFyq/if2quezg== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=lDw8Liv9; 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 63AD3606D5D3; Tue, 10 Nov 2026 13:04:39 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=lDw8Liv9 X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794315878; b=mEIPzYGhiuJCY1cJ8pa4tqEtgH5JySCmgtHMZ5zkexUcDRoZf7PBI2TmeCNhRjFljeBZ VW8b+U1DE2YgMQmOcB17ry++bpuJRgh8Mi8UUPFQrhcPrYqJKAXAVq9XA6+1g0MuG5zsd 4gKbHbHKQV1HrVElXPPfW/wv9eINANW/n6YjIaTcmuklJTPbpG9jFvzlrQ4A/giIbQ1Bv Tof0H7Csok1mK9iNO0eszeoMOooTI+H6BkaGVHVSuPVNnNLCXKCZVpgUG9hXeMzULaEW1 XIxHdpWxNmeZ2zlrNWuV9r/fyfjlxLnUjh2Ki0SBw75KqqUZvfG/1OcT4XAYLfs+xwA== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794315878; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=EnWbVDYQ/6puggi0QqXD0bxXsZrTtGcnJLqSymIBlOI=; b=tTYli00ylTVCfTL1+M2Rc4/LLmdQw+0EG8G/9Nv6tVrfJ9fljmJc19G64mIyjwkmLz33 kVKVLVqDGHv/4qwK+QuEdWpzhLwZJTyHdoqU4dkd+ucPfUmTPJQJ3RoigFCfKesYqi104 qkDX3INJVSGpIzi6jCy+m2dnRb3jRIDhe4RZn//0mprHnKNcJ0/zhzQ17b1thrROtFjSy 7sTXHahw38IG9tIMZUUgb1ltL1VJ9t07bDDWyduHsYzcSRYGW0Orknt8H8J5Xgzw4rmgH PXYm27s9CTlQgWxkXZIq0lqAcetRZMV05wIwN50MuxBbh4E9F5BZUK1VvxyxbT92/5A== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=lDw8Liv9; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3F4E3606A336; Tue, 10 Nov 2026 13:04:38 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 459E01F0089F; Tue, 10 Nov 2026 13:04:37 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794315877; bh=EnWbVDYQ/6puggi0QqXD0bxXsZrTtGcnJLqSymIBlOI=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=lDw8Liv9Ggm6qVu6iULhp3dA8tGCXo1zz7IlG3Z1ClryFeLIADN2w499Nvu34XeKI tlcdHc+3bb1iQp4Xs4EEV32OVK/zqc0JXsl5qRJJr2F9tbjSG5JO27KHxUBL3nPyU7 2KkatvBT/FN4EQDfUoITl3Boswqr44ktlPlA6N+x1AuqmugRrACbB/k7uWZ/al2DTn OFwhNNUr42DYI+72hCCzrLGtpZWMuNYpP8v/iKQZ2i8a/TA2bTNwqWjLpdhduLhZDU DRSEibh9cMMf/OyGpG+rTUaJKPoQu/P5mFo/s3fz9Sy2+B2qw80vhoD1pbuLqu2b9Z 2l29J8hWdPOGg== X-Cc: davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, n05ec@lzu.edu.cn, ylong030@ucr.edu, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, sashiko-bot@kernel.org, stable@vger.kernel.org X-In-Reply-To: <20261106124639.12584-1-dennylin0707@gmail.com> X-sashiko-severity: Medium 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-Received-Bytes: 11448