]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
net/mdiobus: Fix potential out-of-bounds read/write access
authorJakub Raczynski <j.raczynski@samsung.com>
Mon, 9 Jun 2025 15:31:46 +0000 (17:31 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 19 Jun 2025 13:32:29 +0000 (15:32 +0200)
commitb02d9d2732483e670bc34cb233d28e1d43b15da4
tree7affdd6e03c4367624513d57eabff34701cf1979
parent78fa7b723e4e00a2a3d205bfc8618668a6e2cbd9
net/mdiobus: Fix potential out-of-bounds read/write access

[ Upstream commit 0e629694126ca388916f059453a1c36adde219c4 ]

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>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/phy/mdio_bus.c