diff options
| author | Song Liu <[email protected]> | 2023-10-12 05:57:41 +0000 |
|---|---|---|
| committer | Daniel Borkmann <[email protected]> | 2023-10-24 12:25:55 +0000 |
| commit | d35381aa73f7e1e8b25f3ed5283287a64d9ddff5 (patch) | |
| tree | 2e3c4cd03ad2acc9f2c5b5b47b2383c69d9ec037 /drivers/net/netkit.c | |
| parent | xsk: Avoid starving the xsk further down the list (diff) | |
| download | kernel-d35381aa73f7e1e8b25f3ed5283287a64d9ddff5.tar.gz kernel-d35381aa73f7e1e8b25f3ed5283287a64d9ddff5.zip | |
bpf: Fix unnecessary -EBUSY from htab_lock_bucket
htab_lock_bucket uses the following logic to avoid recursion:
1. preempt_disable();
2. check percpu counter htab->map_locked[hash] for recursion;
2.1. if map_lock[hash] is already taken, return -BUSY;
3. raw_spin_lock_irqsave();
However, if an IRQ hits between 2 and 3, BPF programs attached to the IRQ
logic will not able to access the same hash of the hashtab and get -EBUSY.
This -EBUSY is not really necessary. Fix it by disabling IRQ before
checking map_locked:
1. preempt_disable();
2. local_irq_save();
3. check percpu counter htab->map_locked[hash] for recursion;
3.1. if map_lock[hash] is already taken, return -BUSY;
4. raw_spin_lock().
Similarly, use raw_spin_unlock() and local_irq_restore() in
htab_unlock_bucket().
Fixes: 20b6cc34ea74 ("bpf: Avoid hashtab deadlock with map_locked")
Suggested-by: Tejun Heo <[email protected]>
Signed-off-by: Song Liu <[email protected]>
Signed-off-by: Andrii Nakryiko <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
Link: https://lore.kernel.org/bpf/[email protected]
Diffstat (limited to 'drivers/net/netkit.c')
0 files changed, 0 insertions, 0 deletions
