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:	Thu, 11 Apr 2013 17:40:01 +0400
From:	Sergei Shtylyov <sergei.shtylyov@...entembedded.com>
To:	Nikolay Aleksandrov <nikolay@...hat.com>
CC:	netdev@...r.kernel.org, andy@...yhouse.net, fubar@...ibm.com,
	davem@...emloft.net
Subject: Re: [PATCH 1/2] bonding: fix netdev event NULL pointer dereference

Hello.

On 10-04-2013 0:17, Nikolay Aleksandrov wrote:

> In commit 471cb5a33dcbd7c529684a2ac7ba4451414ee4a7 ("bonding: remove
> usage of dev->master") a bug was introduced which causes a NULL pointer
> dereference. If a bond device is in mode 6 (ALB) and a slave is added
> it will dereference a NULL pointer in bond_slave_netdev_event().
> This is because in bond_enslave we have bond_alb_init_slave() which
> changes the MAC address of the slave and causes a NETDEV_CHANGEADDR.
> Then we have in bond_slave_netdev_event():
>          struct slave *slave = bond_slave_get_rtnl(slave_dev);
>          struct bonding *bond = slave->bond;
> bond_slave_get_rtnl() dereferences slave_dev->rx_handler_data which at
> that time is NULL since netdev_rx_handler_register() is called later.

> This is fixed by checking if slave is NULL before dereferencing it.

> Signed-off-by: Nikolay Aleksandrov <nikolay@...hat.com>
[...]

    Minor formatting nit.

> diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
> index 171b10f..9995ddc 100644
> --- a/drivers/net/bonding/bond_main.c
> +++ b/drivers/net/bonding/bond_main.c
> @@ -3168,11 +3168,21 @@ static int bond_slave_netdev_event(unsigned long event,
>   				   struct net_device *slave_dev)
>   {
>   	struct slave *slave = bond_slave_get_rtnl(slave_dev);
> -	struct bonding *bond = slave->bond;
> -	struct net_device *bond_dev = slave->bond->dev;
> +	struct bonding *bond;
> +	struct net_device *bond_dev;
>   	u32 old_speed;
>   	u8 old_duplex;
>
> +	/*
> +	 * A netdev event can be generated while enslaving a device
> +	 * before netdev_rx_handler_register is called in which case
> +	 * slave will be NULL
> +	 */

    The preferred multi-line comment style in the networking code is:

/* bla
  * bla
  */

WBR, Sergei

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists