s390/qeth: fix race when setting MAC address
authorJulian Wiedmann <jwi@linux.ibm.com>
Fri, 29 Jun 2018 17:45:51 +0000 (19:45 +0200)
committerDavid S. Miller <davem@davemloft.net>
Sat, 30 Jun 2018 12:19:48 +0000 (21:19 +0900)
commit4789a21880488048105590049fc41a99f53d565d
tree28a075539a81f63fd8ead48dd743abb10c9840de
parent4664610537d398d55be19432f9cd9c29c831e159
s390/qeth: fix race when setting MAC address

When qeth_l2_set_mac_address() finds the card in a non-reachable state,
it merely copies the new MAC address into dev->dev_addr so that
__qeth_l2_set_online() can later register it with the HW.

But __qeth_l2_set_online() may very well be running concurrently, so we
can't trust the card state without appropriate locking:
If the online sequence is past the point where it registers
dev->dev_addr (but not yet in SOFTSETUP state), any address change needs
to be properly programmed into the HW. Otherwise the netdevice ends up
with a different MAC address than what's set in the HW, and inbound
traffic is not forwarded as expected.

This is most likely to occur for OSD in LPAR, where
commit 21b1702af12e ("s390/qeth: improve fallback to random MAC address")
now triggers eg. systemd to immediately change the MAC when the netdevice
is registered with a NET_ADDR_RANDOM address.

Fixes: bcacfcbc82b4 ("s390/qeth: fix MAC address update sequence")
Signed-off-by: Julian Wiedmann <jwi@linux.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/s390/net/qeth_l2_main.c