Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

bonding: Fix initialize after use for 3ad machine state spinlock

The 3ad machine state spinlock can be used before it is inititialized
while doing bond_enslave() (and the port is being initialized) since
port->slave is set before the lock is prepared, thus causing soft
lock-ups and a multitude of other nasty bugs.

[ Rename __initialize_port_locks() variable name to 'slave' -DaveM ]

Signed-off-by: Nikolay Aleksandrov <nikolay@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

nikolay@redhat.com and committed by
David S. Miller
e0809dbc b59340c2

+4 -5
+4 -5
drivers/net/bonding/bond_3ad.c
··· 389 389 390 390 /** 391 391 * __initialize_port_locks - initialize a port's STATE machine spinlock 392 - * @port: the port we're looking at 392 + * @port: the slave of the port we're looking at 393 393 * 394 394 */ 395 - static inline void __initialize_port_locks(struct port *port) 395 + static inline void __initialize_port_locks(struct slave *slave) 396 396 { 397 397 // make sure it isn't called twice 398 - spin_lock_init(&(SLAVE_AD_INFO(port->slave).state_machine_lock)); 398 + spin_lock_init(&(SLAVE_AD_INFO(slave).state_machine_lock)); 399 399 } 400 400 401 401 //conversions ··· 1910 1910 1911 1911 ad_initialize_port(port, bond->params.lacp_fast); 1912 1912 1913 + __initialize_port_locks(slave); 1913 1914 port->slave = slave; 1914 1915 port->actor_port_number = SLAVE_AD_INFO(slave).id; 1915 1916 // key is determined according to the link speed, duplex and user key(which is yet not supported) ··· 1933 1932 port->next_port_in_aggregator = NULL; 1934 1933 1935 1934 __disable_port(port); 1936 - __initialize_port_locks(port); 1937 - 1938 1935 1939 1936 // aggregator initialization 1940 1937 aggregator = &(SLAVE_AD_INFO(slave).aggregator);