bpf_common_lru_pop_free uses raw_spin_lock_irqsave. This function is used by htab_lru_map_update_elem() which can be called from an NMI. A deadlock can happen if a bpf program holding the lock is interrupted by the same program in NMI. Use raw_spin_trylock_irqsave if in NMI. Fixes: 3a08c2fd7634 (bpf: LRU list) Signed-off-by: Priya Bala Govindasamy <pgovind2@xxxxxxx> Signed-off-by: Amery Hung <ameryhung@xxxxxxxxx> --- kernel/bpf/bpf_lru_list.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/kernel/bpf/bpf_lru_list.c b/kernel/bpf/bpf_lru_list.c index c4a9e861369b..c575f27ddc31 100644 --- a/kernel/bpf/bpf_lru_list.c +++ b/kernel/bpf/bpf_lru_list.c @@ -450,7 +450,12 @@ static struct bpf_lru_node *bpf_common_lru_pop_free(struct bpf_lru *lru, loc_l = per_cpu_ptr(clru->local_list, cpu); - raw_spin_lock_irqsave(&loc_l->lock, flags); + if (in_nmi()) { + if (!raw_spin_trylock_irqsave(&loc_l->lock, flags)) + return NULL; + } else { + raw_spin_lock_irqsave(&loc_l->lock, flags); + } node = __local_list_pop_free(loc_l); if (!node) {