Cong Wang
1fc205d9e4
net: fix dev_ifsioc_locked() race condition
...
commit 3b23a32a63 upstream.
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 >
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org >
2021-03-07 12:34:07 +01:00
..
2020-11-03 22:30:31 +01:00
2020-10-29 17:22:59 -05:00
2020-11-24 15:13:54 +01:00
2020-12-30 11:54:19 +01:00
2020-10-29 17:22:59 -05:00
2021-03-04 11:38:07 +01:00
2021-02-03 23:28:44 +01:00
2020-10-25 14:51:49 -07:00
2020-12-08 12:57:39 +01:00
2020-11-27 13:18:40 +01:00
2020-10-17 11:18:18 -07:00
2021-01-09 13:46:24 +01:00
2020-10-24 10:39:22 -07:00
2021-03-04 11:38:14 +01:00
2020-11-12 15:05:34 +00:00
2021-02-13 13:55:12 +01:00
2020-10-28 13:18:56 +01:00
2021-01-19 18:27:27 +01:00
2020-10-28 11:13:36 +00:00
2020-10-16 11:11:20 -07:00
2021-01-12 20:18:17 +01:00
2021-01-12 20:18:17 +01:00
2020-11-19 08:55:44 -05:00
2020-10-22 09:59:21 -07:00
2021-03-04 11:37:22 +01:00
2020-12-11 14:02:14 -08:00
2020-10-16 11:11:19 -07:00
2020-10-25 14:51:49 -07:00
2020-10-25 14:51:49 -07:00
2020-10-29 20:01:46 -07:00
2020-11-22 10:48:22 -08:00
2021-01-19 18:27:21 +01:00
2020-11-14 11:26:03 -08:00
2020-10-16 11:11:21 -07:00
2020-10-25 14:51:49 -07:00
2020-11-10 18:31:17 +01:00
2020-10-16 12:21:15 -07:00
2020-10-19 14:28:30 -07:00
2020-10-30 08:37:39 +01:00
2021-03-04 11:38:44 +01:00
2021-01-27 11:55:18 +01:00
2021-01-19 18:27:22 +01:00
2020-10-20 10:41:07 +02:00
2020-10-20 10:41:07 +02:00
2020-10-25 14:51:49 -07:00
2020-12-11 14:02:14 -08:00
2021-03-04 11:38:41 +01:00
2020-10-25 14:51:49 -07:00
2020-10-16 11:11:22 -07:00
2021-03-04 11:37:22 +01:00
2020-10-25 14:51:49 -07:00
2020-12-30 11:53:49 +01:00
2020-12-26 16:02:43 +01:00
2020-12-30 11:54:18 +01:00
2020-11-12 13:59:04 -07:00
2020-10-22 22:44:35 +02:00
2021-02-10 09:29:20 +01:00
2021-03-04 11:38:46 +01:00
2020-10-16 11:11:20 -07:00
2020-10-25 14:51:49 -07:00
2020-10-25 14:51:49 -07:00
2021-01-12 20:18:24 +01:00
2020-10-25 14:51:49 -07:00
2020-11-04 10:22:56 -07:00
2020-10-20 07:10:14 -06:00
2020-11-04 08:52:46 -08:00
2021-03-04 11:38:01 +01:00
2020-10-16 11:11:18 -07:00
2021-03-04 11:38:46 +01:00
2021-02-10 09:29:17 +01:00
2020-11-30 12:21:31 +01:00
2020-11-19 22:38:29 -05:00
2020-10-29 13:17:58 -05:00
2020-10-16 11:11:19 -07:00
2021-01-09 13:46:23 +01:00
2020-10-25 14:51:49 -07:00
2021-03-04 11:37:50 +01:00
2021-03-04 11:37:59 +01:00
2021-03-04 11:38:46 +01:00
2021-03-04 11:38:20 +01:00
2021-02-10 09:29:16 +01:00
2021-02-07 15:37:17 +01:00
2020-10-23 03:42:13 -04:00
2021-02-03 23:28:40 +01:00
2020-10-16 11:11:20 -07:00
2020-10-25 14:51:49 -07:00
2020-11-26 09:35:49 -08:00
2020-11-22 10:48:22 -08:00
2021-03-04 11:38:21 +01:00
2020-10-16 11:11:19 -07:00
2020-12-30 11:53:54 +01:00
2021-02-26 10:13:01 +01:00
2020-10-16 11:11:19 -07:00
2020-10-28 14:08:54 +00:00
2020-10-25 14:51:49 -07:00
2021-02-10 09:29:17 +01:00
2021-03-07 12:34:07 +01:00
2020-10-30 12:57:39 +01:00
2020-10-30 12:57:39 +01:00
2020-10-21 18:24:08 -07:00
2020-11-30 10:52:22 -05:00
2020-10-21 10:31:20 -04:00
2020-10-16 11:11:18 -07:00
2020-10-16 11:11:19 -07:00
2020-11-22 10:48:22 -08:00
2021-02-07 15:37:16 +01:00
2020-10-25 14:51:49 -07:00
2020-12-30 11:54:28 +01:00
2020-10-17 11:18:18 -07:00
2020-10-16 11:11:15 -07:00
2020-10-16 11:11:16 -07:00
2020-11-22 10:48:22 -08:00
2020-10-22 13:00:44 -07:00
2020-10-25 14:51:49 -07:00
2020-11-09 18:12:34 +01:00
2020-11-09 18:12:34 +01:00
2020-11-16 16:57:18 +01:00
2020-10-28 11:41:15 -06:00
2020-10-18 09:27:10 -07:00
2020-11-16 09:37:01 -08:00
2020-10-24 20:21:57 +02:00
2020-10-25 14:51:49 -07:00
2020-12-30 11:53:56 +01:00
2020-10-24 10:39:22 -07:00
2021-03-04 11:38:35 +01:00
2020-10-28 11:41:15 -06:00
2021-03-04 11:38:21 +01:00
2021-01-09 13:46:24 +01:00
2020-11-22 13:26:07 -08:00
2020-12-10 16:01:47 -08:00
2020-12-30 11:53:42 +01:00
2020-11-06 10:05:18 -08:00
2020-10-25 14:51:49 -07:00
2020-10-29 13:17:58 -05:00
2020-10-25 11:39:02 -07:00
2020-10-25 14:51:49 -07:00
2020-10-22 14:15:51 -06:00
2020-12-08 14:52:29 -08:00
2020-11-16 14:58:23 -08:00
2021-01-17 14:16:59 +01:00
2020-10-17 15:05:30 -06:00
2020-10-26 11:48:11 +01:00
2021-03-04 11:38:29 +01:00
2020-10-25 14:51:49 -07:00
2020-12-30 11:53:42 +01:00
2020-10-17 15:04:36 -06:00
2021-02-10 09:29:16 +01:00
2021-03-04 11:37:36 +01:00
2021-01-27 11:55:30 +01:00
2020-10-24 10:57:57 -07:00
2021-02-17 11:02:28 +01:00
2020-12-21 13:30:08 +01:00
2020-10-23 11:55:27 -04:00
2020-10-23 11:00:57 -07:00
2021-02-10 09:29:21 +01:00
2020-10-16 11:11:19 -07:00
2020-10-20 14:39:37 -07:00
2020-12-06 10:19:07 -08:00