mirror of
git://git.yoctoproject.org/linux-yocto.git
synced 2025-07-05 21:35:46 +02:00
net/mdiobus: Fix potential out-of-bounds clause 45 read/write access
[ Upstream commit 260388f79e94fb3026c419a208ece8358bb7b555 ]
When using publicly available tools like 'mdio-tools' to read/write data
from/to network interface and its PHY via C45 (clause 45) 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 C45 read/write operation.
While this excludes this access from any statistics, it improves security of
read/write operation.
Fixes: 4e4aafcddb
("net: mdio: Add dedicated C45 API to MDIO bus drivers")
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>
This commit is contained in:
parent
bab6bca083
commit
abb0605ca0
|
@ -946,6 +946,9 @@ int __mdiobus_c45_read(struct mii_bus *bus, int addr, int devad, u32 regnum)
|
||||||
|
|
||||||
lockdep_assert_held_once(&bus->mdio_lock);
|
lockdep_assert_held_once(&bus->mdio_lock);
|
||||||
|
|
||||||
|
if (addr >= PHY_MAX_ADDR)
|
||||||
|
return -ENXIO;
|
||||||
|
|
||||||
if (bus->read_c45)
|
if (bus->read_c45)
|
||||||
retval = bus->read_c45(bus, addr, devad, regnum);
|
retval = bus->read_c45(bus, addr, devad, regnum);
|
||||||
else
|
else
|
||||||
|
@ -977,6 +980,9 @@ int __mdiobus_c45_write(struct mii_bus *bus, int addr, int devad, u32 regnum,
|
||||||
|
|
||||||
lockdep_assert_held_once(&bus->mdio_lock);
|
lockdep_assert_held_once(&bus->mdio_lock);
|
||||||
|
|
||||||
|
if (addr >= PHY_MAX_ADDR)
|
||||||
|
return -ENXIO;
|
||||||
|
|
||||||
if (bus->write_c45)
|
if (bus->write_c45)
|
||||||
err = bus->write_c45(bus, addr, devad, regnum, val);
|
err = bus->write_c45(bus, addr, devad, regnum, val);
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue
Block a user