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
..
2021-01-27 10:01:46 +01:00
2020-12-28 20:34:33 +01:00
2020-12-17 12:52:23 -08:00
2021-01-29 21:24:30 -08:00
2020-12-16 16:38:41 -08:00
2020-12-15 16:18:23 -08:00
2020-12-16 16:38:41 -08:00
2021-02-10 20:47:12 -08:00
2020-12-16 18:48:16 +01:00
2021-01-13 15:08:41 +00:00
2020-12-23 15:06:22 -08:00
2021-01-28 21:24:40 -08:00
2021-01-21 12:35:42 +00:00
2021-01-09 13:51:36 -08:00
2020-12-22 14:12:10 -08:00
2021-02-11 14:55:03 -08:00
2020-12-15 14:10:09 -08:00
2021-01-25 15:59:12 -05:00
2021-02-03 14:22:21 -08:00
2021-01-07 17:44:00 +01:00
2020-12-15 22:46:16 -08:00
2020-12-15 22:46:15 -08:00
2021-01-01 12:58:07 -08:00
2021-01-01 12:58:07 -08:00
2021-01-12 17:24:30 -08:00
2021-01-12 17:24:30 -08:00
2021-01-07 14:46:09 -08:00
2021-01-12 17:24:30 -08:00
2020-12-29 15:36:49 -08:00
2021-01-14 19:29:58 -08:00
2020-12-14 15:26:13 +01:00
2020-12-15 12:13:40 -08:00
2020-12-20 17:17:25 -08:00
2020-12-20 17:17:01 -08:00
2020-12-15 12:13:45 -08:00
2020-12-19 11:18:38 -08:00
2021-01-04 10:47:38 -08:00
2021-01-15 10:04:49 +00:00
2020-12-16 11:06:49 -08:00
2021-01-08 11:02:18 -08:00
2020-12-15 19:24:18 +01:00
2020-12-15 22:46:15 -08:00
2021-01-21 20:12:40 +01:00
2021-01-08 15:57:29 -05:00
2020-12-15 10:57:29 +01:00
2020-12-22 13:19:43 -08:00
2020-12-16 16:38:41 -08:00
2020-12-14 11:51:46 +01:00
2020-12-14 16:24:19 +01:00
2021-02-06 00:21:42 +01:00
2021-02-03 18:37:29 -08:00
2021-01-14 18:34:29 -08:00
2020-12-25 10:54:29 -08:00
2020-12-17 11:18:00 -08:00
2021-02-06 11:57:28 -08:00
2020-12-15 12:53:37 -08:00
2020-12-15 12:13:44 -08:00
2021-02-05 11:03:47 -08:00
2021-02-04 18:37:56 -08:00
2021-02-11 13:24:44 -08:00
2020-12-16 11:06:07 -08:00
2021-02-04 18:06:26 -08:00
2021-01-07 14:35:14 +00:00
2020-12-15 16:19:30 +01:00
2020-12-15 22:46:15 -08:00
2021-02-02 15:57:23 +01:00
2020-12-15 16:39:06 -08:00
2021-01-26 18:39:45 -08:00
2021-02-05 20:48:28 +01:00
2020-12-15 16:19:31 +01:00
2020-12-15 15:03:31 -08:00
2020-12-17 13:30:45 -05:00
2020-12-22 12:55:08 -08:00
2021-02-05 11:03:47 -08:00
2021-01-07 14:17:29 +01:00
2020-12-29 15:36:49 -08:00
2020-12-15 16:19:31 +01:00
2020-12-15 22:46:15 -08:00
2021-01-29 15:39:48 -05:00
2021-01-22 15:09:42 +01:00
2021-01-12 21:13:01 +01:00
2021-01-14 17:18:25 +01:00
2020-12-15 13:22:29 -08:00
2020-12-15 22:46:16 -08:00
2020-12-16 11:01:04 -08:00
2020-12-15 22:46:15 -08:00
2021-01-19 12:02:20 -08:00
2021-01-19 11:47:31 -08:00
2021-01-12 18:12:54 -08:00
2020-12-17 13:34:25 -08:00
2021-01-27 16:45:21 +05:30
2020-12-15 12:13:45 -08:00
2020-12-15 14:55:10 -08:00
2021-02-04 18:20:13 -08:00
2020-12-15 12:13:41 -08:00
2020-12-19 11:18:37 -08:00
2020-12-15 14:48:04 -08:00
2020-12-17 13:01:31 -08:00
2020-12-22 12:55:08 -08:00
2021-01-30 01:22:31 +01:00
2021-02-11 13:24:44 -08:00
2021-02-11 18:14:19 -08:00
2021-01-25 22:06:11 +01:00
2021-02-04 18:05:59 -08:00
2021-01-18 18:58:18 +01:00
2020-12-15 14:02:26 -08:00
2020-12-15 12:13:38 -08:00
2020-12-22 12:55:08 -08:00
2020-12-15 14:55:10 -08:00
2020-12-15 12:13:39 -08:00
2020-12-15 15:11:08 -06:00
2020-12-14 17:34:12 -08:00
2021-02-11 13:09:58 -08:00
2020-12-15 15:03:31 -08:00
2020-12-15 15:26:14 +01:00
2020-12-15 12:13:46 -08:00
2020-12-15 15:03:31 -08:00
2020-12-15 22:46:15 -08:00
2020-12-17 14:19:01 +01:00
2020-12-15 22:46:15 -08:00
2021-01-04 10:55:19 -08:00
2020-12-15 22:46:18 -08:00
2020-12-15 22:46:18 -08:00
2020-12-15 12:13:39 -08:00
2020-12-20 10:12:06 -08:00
2020-12-15 15:57:25 -08:00
2020-12-22 12:55:07 -08:00
2020-12-16 16:38:41 -08:00
2020-12-16 11:30:10 -08:00
2020-12-16 11:01:04 -08:00
2020-12-15 12:13:43 -08:00
2020-12-15 12:13:39 -08:00
2020-12-29 15:36:49 -08:00
2021-02-06 11:57:28 -08:00
2020-12-15 12:13:37 -08:00
2020-12-22 12:55:08 -08:00
2020-12-15 14:48:04 -08:00
2020-12-28 11:58:59 +01:00
2021-01-22 18:20:52 -08:00
2021-02-06 00:21:42 +01:00
2020-12-14 16:40:27 -08:00
2020-12-16 00:07:17 -08:00
2020-12-16 12:33:35 -08:00
2021-02-02 09:32:02 -05:00
2021-01-25 12:08:07 -08:00
2021-02-04 18:56:56 -08:00
2020-12-15 22:46:15 -08:00
2020-12-18 16:14:31 -05:00
2021-02-05 11:03:47 -08:00
2020-12-15 12:13:40 -08:00