Jakub Sitnicki
db6a5018b6
bpf, sockmap: Don't sleep while holding RCU lock on tear-down
...
rcu_read_lock is needed to protect access to psock inside sock_map_unref
when tearing down the map. However, we can't afford to sleep in lock_sock
while in RCU read-side critical section. Grab the RCU lock only after we
have locked the socket.
This fixes RCU warnings triggerable on a VM with 1 vCPU when free'ing a
sockmap/sockhash that contains at least one socket:
| =============================
| WARNING: suspicious RCU usage
| 5.5.0-04005-g8fc91b972b73 #450 Not tainted
| -----------------------------
| include/linux/rcupdate.h:272 Illegal context switch in RCU read-side critical section!
|
| other info that might help us debug this:
|
|
| rcu_scheduler_active = 2, debug_locks = 1
| 4 locks held by kworker/0:1/62:
| #0 : ffff88813b019748 ((wq_completion)events){+.+.}, at: process_one_work+0x1d7/0x5e0
| #1 : ffffc900000abe50 ((work_completion)(&map->work)){+.+.}, at: process_one_work+0x1d7/0x5e0
| #2 : ffffffff82065d20 (rcu_read_lock){....}, at: sock_map_free+0x5/0x170
| #3 : ffff8881368c5df8 (&stab->lock){+...}, at: sock_map_free+0x64/0x170
|
| stack backtrace:
| CPU: 0 PID: 62 Comm: kworker/0:1 Not tainted 5.5.0-04005-g8fc91b972b73 #450
| Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS ?-20190727_073836-buildvm-ppc64le-16.ppc.fedoraproject.org-3.fc31 04/01/2014
| Workqueue: events bpf_map_free_deferred
| Call Trace:
| dump_stack+0x71/0xa0
| ___might_sleep+0x105/0x190
| lock_sock_nested+0x28/0x90
| sock_map_free+0x95/0x170
| bpf_map_free_deferred+0x58/0x80
| process_one_work+0x260/0x5e0
| worker_thread+0x4d/0x3e0
| kthread+0x108/0x140
| ? process_one_work+0x5e0/0x5e0
| ? kthread_park+0x90/0x90
| ret_from_fork+0x3a/0x50
| =============================
| WARNING: suspicious RCU usage
| 5.5.0-04005-g8fc91b972b73-dirty #452 Not tainted
| -----------------------------
| include/linux/rcupdate.h:272 Illegal context switch in RCU read-side critical section!
|
| other info that might help us debug this:
|
|
| rcu_scheduler_active = 2, debug_locks = 1
| 4 locks held by kworker/0:1/62:
| #0 : ffff88813b019748 ((wq_completion)events){+.+.}, at: process_one_work+0x1d7/0x5e0
| #1 : ffffc900000abe50 ((work_completion)(&map->work)){+.+.}, at: process_one_work+0x1d7/0x5e0
| #2 : ffffffff82065d20 (rcu_read_lock){....}, at: sock_hash_free+0x5/0x1d0
| #3 : ffff888139966e00 (&htab->buckets[i].lock){+...}, at: sock_hash_free+0x92/0x1d0
|
| stack backtrace:
| CPU: 0 PID: 62 Comm: kworker/0:1 Not tainted 5.5.0-04005-g8fc91b972b73-dirty #452
| Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS ?-20190727_073836-buildvm-ppc64le-16.ppc.fedoraproject.org-3.fc31 04/01/2014
| Workqueue: events bpf_map_free_deferred
| Call Trace:
| dump_stack+0x71/0xa0
| ___might_sleep+0x105/0x190
| lock_sock_nested+0x28/0x90
| sock_hash_free+0xec/0x1d0
| bpf_map_free_deferred+0x58/0x80
| process_one_work+0x260/0x5e0
| worker_thread+0x4d/0x3e0
| kthread+0x108/0x140
| ? process_one_work+0x5e0/0x5e0
| ? kthread_park+0x90/0x90
| ret_from_fork+0x3a/0x50
Fixes: 7e81a3530206 ("bpf: Sockmap, ensure sock lock held during tear down")
Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Link: https://lore.kernel.org/bpf/20200206111652.694507-2-jakub@cloudflare.com
2020-02-07 22:36:26 +01:00
..
2019-09-27 15:10:34 -07:00
2019-12-09 10:36:44 -08:00
2020-01-09 12:13:43 -08:00
2019-09-24 16:37:18 +02:00
2020-01-26 10:40:21 +01:00
2020-01-09 18:41:40 -08:00
2020-01-19 22:10:04 +01:00
2020-01-26 10:34:17 +02:00
2019-12-18 17:05:58 -08:00
2020-01-24 12:58:14 +01:00
2020-01-24 08:12:06 +01:00
2019-12-08 11:52:02 +01:00
2019-11-27 22:28:37 +01:00
2020-02-07 22:36:26 +01:00
2019-12-09 10:36:44 -08:00
2020-01-09 18:41:40 -08:00
2020-01-27 11:12:46 +01:00
2020-01-27 11:09:31 +01:00
2020-01-27 13:47:22 +01:00
2020-01-21 12:03:21 +01:00
2019-11-02 13:54:56 -07:00
2019-09-26 08:56:17 +02:00
2020-01-27 11:00:21 +01:00
2020-01-27 11:00:21 +01:00
2019-12-09 10:36:44 -08:00
2019-09-27 10:27:14 +02:00
2020-01-03 12:26:07 -08:00
2019-12-20 21:19:36 -08:00
2020-01-28 16:02:33 -08:00
2019-12-04 12:27:13 -08:00
2020-01-29 10:39:23 +01:00
2020-01-09 18:36:22 -08:00
2020-01-27 08:54:30 +01:00
2019-09-01 11:45:02 -07:00
2019-12-09 10:36:44 -08:00
2019-10-24 14:53:48 -07:00
2019-12-18 11:57:33 -08:00
2020-01-14 11:48:41 -08:00
2019-12-26 15:19:59 -08:00
2020-01-03 12:25:50 -08:00
2019-11-26 14:40:13 -08:00
2020-01-14 18:36:42 -08:00
2020-01-18 11:48:19 +02:00
2019-12-16 10:15:49 +01:00
2020-01-26 10:40:21 +01:00
2020-01-27 10:56:30 +01:00
2020-01-29 11:58:10 +01:00
2020-01-09 12:13:43 -08:00
2020-01-21 11:39:56 +01:00
2020-01-14 13:30:24 -05:00
2020-01-28 16:02:33 -08:00
2020-01-19 22:10:04 +01:00
2020-01-21 12:18:20 +01:00
2020-01-19 22:10:04 +01:00
2020-01-28 16:02:33 -08:00
2020-01-09 18:39:33 -08:00
2020-01-22 00:08:52 +01:00
2020-01-26 10:40:21 +01:00
2019-11-15 14:38:29 +01:00
2020-01-24 13:44:07 +01:00
2020-01-24 13:44:07 +01:00
2020-01-08 15:02:21 -08:00