Re: [syzbot] [bpf?] possible deadlock in kvfree_call_rcu

From: Hillf Danton
Date: Thu Mar 28 2024 - 19:13:27 EST


On Wed, 27 Mar 2024 16:27:19 -0700
> syzbot has found a reproducer for the following issue on:
>
> HEAD commit: 443574b03387 riscv, bpf: Fix kfunc parameters incompatibil..
> git tree: bpf
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=16ca53c9180000

#syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master

--- x/kernel/rcu/tree.c
+++ y/kernel/rcu/tree.c
@@ -5149,6 +5149,8 @@ static void __init rcu_dump_rcu_node_tre

struct workqueue_struct *rcu_gp_wq;

+static DEFINE_PER_CPU(struct lock_class_key, krc_lock_key);
+
static void __init kfree_rcu_batch_init(void)
{
int cpu;
@@ -5169,6 +5171,11 @@ static void __init kfree_rcu_batch_init(

for_each_possible_cpu(cpu) {
struct kfree_rcu_cpu *krcp = per_cpu_ptr(&krc, cpu);
+ struct lock_class_key *key = per_cpu_ptr(&krc_lock_key, cpu);
+ char name[32] = {0};
+
+ sprintf(name, "krc%d", cpu);
+ lockdep_set_class_and_name(&krcp->lock, key, name);

for (i = 0; i < KFREE_N_BATCHES; i++) {
INIT_RCU_WORK(&krcp->krw_arr[i].rcu_work, kfree_rcu_work);
--