netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Russell King (Oracle)" <linux@armlinux.org.uk>
To: Jakub Raczynski <j.raczynski@samsung.com>
Cc: andrew@lunn.ch, hkallweit1@gmail.com, netdev@vger.kernel.org,
	wenjing.shan@samsung.com
Subject: Re: [PATCH] net/mdiobus: Fix potential out-of-bounds read/write access
Date: Mon, 9 Jun 2025 15:57:29 +0100	[thread overview]
Message-ID: <aEb2WfLHcGBdI3_G@shell.armlinux.org.uk> (raw)
In-Reply-To: <20250609143758.1407718-1-j.raczynski@samsung.com>

On Mon, Jun 09, 2025 at 04:37:58PM +0200, Jakub Raczynski wrote:
> When using publicly available tools like 'mdio-tools' to read/write data
> from/to network interface and its PHY via mdiobus, there is no verification of
> parameters passed to the ioctl and it accepts any mdio address.
> Currently there is support for 32 addresses in kernel via PHY_MAX_ADDR define,
> but it is possible to pass higher value than that via ioctl.
> While read/write operation should generally fail in this case,
> mdiobus provides stats array, where wrong address may allow out-of-bounds
> read/write.
> 
> Fix that by adding address verification before read/write operation.
> While this excludes this access from any statistics, it improves security of
> read/write operation.
> 
> Fixes: 080bb352fad00 ("net: phy: Maintain MDIO device and bus statistics")
> Signed-off-by: Jakub Raczynski <j.raczynski@samsung.com>
> Reported-by: Wenjing Shan <wenjing.shan@samsung.com>

This is insufficient on its own. If you check the clause 45 accessors,
they have the same issue, so this should also be fixed.

Your patch would've been fine for the blamed commit, but we've had
4e4aafcddbbf ("net: mdio: Add dedicated C45 API to MDIO bus drivers")
in v6.3.

For easier back-porting, it probably makes sense to have this patch
and another separate patch addressing the ones introduced in the
more recent commit - and the two patches sent as a patch series.

Thanks.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

  reply	other threads:[~2025-06-09 14:57 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20250609144014eucas1p2ee94d7aabff15fbadcc1af1fa64ce22d@eucas1p2.samsung.com>
2025-06-09 14:37 ` [PATCH] net/mdiobus: Fix potential out-of-bounds read/write access Jakub Raczynski
2025-06-09 14:57   ` Russell King (Oracle) [this message]
     [not found]     ` <CGME20250609153151eucas1p12def205b1e442c456d043ab444418a56@eucas1p1.samsung.com>
2025-06-09 15:31       ` [PATCH 1/2] " Jakub Raczynski
     [not found]         ` <CGME20250609153156eucas1p2cf6399b609395de4d4a33b0cf6b4c15d@eucas1p2.samsung.com>
2025-06-09 15:31           ` [PATCH 2/2] net/mdiobus: Fix potential out-of-bounds clause 45 " Jakub Raczynski
2025-06-11 12:10         ` [PATCH 1/2] net/mdiobus: Fix potential out-of-bounds " patchwork-bot+netdevbpf
2025-06-25 15:23         ` Dan Carpenter
2025-06-25 16:38           ` Andrew Lunn
2025-06-26  7:15           ` Russell King (Oracle)
     [not found]           ` <CGME20250609153151eucas1p12def205b1e442c456d043ab444418a56@eucms1p3>
2025-06-26  8:55             ` Jakub Raczynski

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=aEb2WfLHcGBdI3_G@shell.armlinux.org.uk \
    --to=linux@armlinux.org.uk \
    --cc=andrew@lunn.ch \
    --cc=hkallweit1@gmail.com \
    --cc=j.raczynski@samsung.com \
    --cc=netdev@vger.kernel.org \
    --cc=wenjing.shan@samsung.com \
    /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;
as well as URLs for NNTP newsgroup(s).