Patch "net: mdio: validate parameter addr in mdiobus_get_phy()" has been added to the 5.4-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    net: mdio: validate parameter addr in mdiobus_get_phy()

to the 5.4-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     net-mdio-validate-parameter-addr-in-mdiobus_get_phy.patch
and it can be found in the queue-5.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 459da7fcf2a45acdca2f4a0be4f80b7d960dfb28
Author: Heiner Kallweit <hkallweit1@xxxxxxxxx>
Date:   Sun Jan 15 11:54:06 2023 +0100

    net: mdio: validate parameter addr in mdiobus_get_phy()
    
    [ Upstream commit 867dbe784c5010a466f00a7d1467c1c5ea569c75 ]
    
    The caller may pass any value as addr, what may result in an out-of-bounds
    access to array mdio_map. One existing case is stmmac_init_phy() that
    may pass -1 as addr. Therefore validate addr before using it.
    
    Fixes: 7f854420fbfe ("phy: Add API for {un}registering an mdio device to a bus.")
    Signed-off-by: Heiner Kallweit <hkallweit1@xxxxxxxxx>
    Reviewed-by: Andrew Lunn <andrew@xxxxxxx>
    Link: https://lore.kernel.org/r/cdf664ea-3312-e915-73f8-021678d08887@xxxxxxxxx
    Signed-off-by: Paolo Abeni <pabeni@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index 757763735e1f..fdf8221f46fa 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -117,7 +117,12 @@ EXPORT_SYMBOL(mdiobus_unregister_device);
 
 struct phy_device *mdiobus_get_phy(struct mii_bus *bus, int addr)
 {
-	struct mdio_device *mdiodev = bus->mdio_map[addr];
+	struct mdio_device *mdiodev;
+
+	if (addr < 0 || addr >= ARRAY_SIZE(bus->mdio_map))
+		return NULL;
+
+	mdiodev = bus->mdio_map[addr];
 
 	if (!mdiodev)
 		return NULL;



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux