lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5ce7d9c3db722ebb46d1e10ef79812c83bab010f.camel@redhat.com>
Date:   Tue, 17 Jan 2023 12:31:59 +0100
From:   Paolo Abeni <pabeni@...hat.com>
To:     Heiner Kallweit <hkallweit1@...il.com>,
        Andrew Lunn <andrew@...n.ch>,
        Russell King - ARM Linux <linux@...linux.org.uk>,
        David Miller <davem@...emloft.net>,
        Jakub Kicinski <kuba@...nel.org>,
        Eric Dumazet <edumazet@...gle.com>
Cc:     "netdev@...r.kernel.org" <netdev@...r.kernel.org>
Subject: Re: [PATCH net] net: mdio: validate parameter addr in
 mdiobus_get_phy()

On Sun, 2023-01-15 at 11:54 +0100, Heiner Kallweit wrote:
> 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@...il.com>
> ---
>  drivers/net/phy/mdio_bus.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
> index 902e1c88e..132dd1f90 100644
> --- a/drivers/net/phy/mdio_bus.c
> +++ b/drivers/net/phy/mdio_bus.c
> @@ -108,7 +108,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;

Speaking of possible follow-ups, would it make sense to add a
WARN_ON_ONCE() or similar on the above condition?

Thanks!

Paolo
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ