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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 18 Apr 2018 17:14:36 -0700
From:   Florian Fainelli <f.fainelli@...il.com>
To:     Andrew Lunn <andrew@...n.ch>, David Miller <davem@...emloft.net>
Cc:     netdev <netdev@...r.kernel.org>,
        Vivien Didelot <vivien.didelot@...oirfairelinux.com>
Subject: Re: [PATCH net-next] net: phy: mdio-boardinfo: Allow recursive
 mdiobus_register()

On 04/18/2018 05:00 PM, Andrew Lunn wrote:
> mdiobus_register will search for any mdiobus board info registered for
> the bus being registered. If found, it will probe devices on the bus.
> That device, if for example it is an ethernet switch, may then try to
> register an mdio bus. Thus we need to allow recursive calls to
> mdiobus_register.
> 
> Holding the mdio_board_lock will cause a deadlock during this
> recursion. Release the lock and use list_for_each_entry_safe.
> 
> Signed-off-by: Andrew Lunn <andrew@...n.ch>
> ---
>  drivers/net/phy/mdio-boardinfo.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/phy/mdio-boardinfo.c b/drivers/net/phy/mdio-boardinfo.c
> index 1861f387820d..863496fa5d13 100644
> --- a/drivers/net/phy/mdio-boardinfo.c
> +++ b/drivers/net/phy/mdio-boardinfo.c
> @@ -30,17 +30,20 @@ void mdiobus_setup_mdiodev_from_board_info(struct mii_bus *bus,
>  					    struct mdio_board_info *bi))
>  {
>  	struct mdio_board_entry *be;
> +	struct mdio_board_entry *tmp;
>  	struct mdio_board_info *bi;
>  	int ret;
>  
>  	mutex_lock(&mdio_board_lock);

Don't you need to drop that lock here?

> -	list_for_each_entry(be, &mdio_board_list, list) {
> +	list_for_each_entry_safe(be, tmp, &mdio_board_list, list) {
>  		bi = &be->board_info;
>  
>  		if (strcmp(bus->id, bi->bus_id))
>  			continue;
>  
> +		mutex_unlock(&mdio_board_lock);
>  		ret = cb(bus, bi);
> +		mutex_lock(&mdio_board_lock);
>  		if (ret)
>  			continue;
>  

And conversely drop the unlock from the end of this function?

Also, would you rather target "net" for this change since this appears
to be a bug fix?
-- 
Florian

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ