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