linux/drivers/net
Cong Wang 3b23a32a63 net: fix dev_ifsioc_locked() race condition
dev_ifsioc_locked() is called with only RCU read lock, so when
there is a parallel writer changing the mac address, it could
get a partially updated mac address, as shown below:

Thread 1			Thread 2
// eth_commit_mac_addr_change()
memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
				// dev_ifsioc_locked()
				memcpy(ifr->ifr_hwaddr.sa_data,
					dev->dev_addr,...);

Close this race condition by guarding them with a RW semaphore,
like netdev_get_name(). We can not use seqlock here as it does not
allow blocking. The writers already take RTNL anyway, so this does
not affect the slow path. To avoid bothering existing
dev_set_mac_address() callers in drivers, introduce a new wrapper
just for user-facing callers on ioctl and rtnetlink paths.

Note, bonding also changes slave mac addresses but that requires
a separate patch due to the complexity of bonding code.

Fixes: 3710becf8a ("net: RCU locking for simple ioctl()")
Reported-by: "Gong, Sishuai" <sishuai@purdue.edu>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Cong Wang <cong.wang@bytedance.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2021-02-11 18:14:19 -08:00
..
appletalk
arcnet
bonding bonding: 3ad: Print an error for unknown speeds 2021-02-11 14:28:21 -08:00
caif
can
dsa net: dsa: xrs700x: add HSR offloading support 2021-02-11 13:24:45 -08:00
ethernet net: mvpp2: fix interrupt mask/unmask skip condition 2021-02-11 18:05:05 -08:00
fddi
fjes
hamradio
hippi
hyperv Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2021-02-10 13:30:12 -08:00
ieee802154
ipa Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2021-02-10 13:30:12 -08:00
ipvlan
mdio
mhi net: mhi: Add mbim proto 2021-02-10 15:11:51 -08:00
netdevsim netdevsim: fib: Add debugfs to debug route offload failure 2021-02-08 16:47:03 -08:00
pcs net: pcs: add pcs-lynx 1000BASE-X support 2021-02-06 14:35:21 -08:00
phy net: phy: icplus: add MDI/MDIX support for IP101A/G 2021-02-11 13:53:26 -08:00
plip
ppp
slip
team
usb Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2021-02-10 13:30:12 -08:00
vmxnet3
wan Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2021-02-10 13:30:12 -08:00
wireguard
wireless Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2021-02-10 13:30:12 -08:00
xen-netback xen/events: link interdomain events to associated xenbus device 2021-02-11 14:47:00 -08:00
bareudp.c udp: call udp_encap_enable for v6 sockets when enabling encap 2021-02-04 18:37:14 -08:00
dummy.c
eql.c
geneve.c
gtp.c gtp: update rx_length_errors for abnormally short packets 2021-02-04 09:29:58 -08:00
ifb.c
Kconfig
LICENSE.SRC
loopback.c Revert "net-loopback: set lo dev initial state to UP" 2021-02-11 13:10:44 -08:00
macsec.c
macvlan.c
macvtap.c
Makefile net: mhi: Add dedicated folder 2021-02-10 15:11:51 -08:00
mdio.c
mii.c
net_failover.c
netconsole.c
nlmon.c
ntb_netdev.c
rionet.c
sb1000.c
Space.c
sungem_phy.c
tap.c net: fix dev_ifsioc_locked() race condition 2021-02-11 18:14:19 -08:00
thunderbolt.c
tun.c net: fix dev_ifsioc_locked() race condition 2021-02-11 18:14:19 -08:00
veth.c
virtio_net.c
vrf.c
vsockmon.c
vxlan.c
xen-netfront.c drivers: net: xen-netfront: Simplify the calculation of variables 2021-02-04 10:55:24 -08:00