mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Ayaan Mirza Baig <ayaanmirzabaig85@gmail.com>
Cc: linux-kernel@vger.kernel.org,
	syzbot+80e5d6f453f14a53383a@syzkaller.appspotmail.com,
	"Paul E. McKenney" <paulmck@kernel.org>
Subject: Re: [PATCH 1/1] radix-tree: Prevent NULL pointer dereference in radix_tree_node_rcu_free
Date: Mon, 24 Feb 2025 20:27:23 -0800	[thread overview]
Message-ID: <20250224202723.aa20e103b6b3bc3de65ca7e4@linux-foundation.org> (raw)
In-Reply-To: <20250223200603.38895-1-ayaanmirzabaig85@gmail.com>

On Mon, 24 Feb 2025 01:31:08 +0530 Ayaan Mirza Baig <ayaanmirzabaig85@gmail.com> wrote:

> syzkaller reported a kernel NULL pointer dereference:
> 
> BUG: kernel NULL pointer dereference, address: 0000000000000000
> PGD 0 P4D 0
> Oops: Oops: 0010 [#1] PREEMPT SMP KASAN NOPTI
> 
> Call Trace:
>  <IRQ>
>  rcu_do_batch kernel/rcu/tree.c:2546 [inline]
>  rcu_core+0xaaa/0x17a0 kernel/rcu/tree.c:2802
>  handle_softirqs+0x2d4/0x9b0 kernel/softirq.c:561
>  __do_softirq kernel/softirq.c:595 [inline]
>  invoke_softirq kernel/softirq.c:435 [inline]
>  __irq_exit_rcu+0xf7/0x220 kernel/softirq.c:662
>  irq_exit_rcu+0x9/0x30 kernel/softirq.c:678
>  instr_sysvec_apic_timer_interrupt arch/x86/kernel/apic/apic.c:1049 [inline]
>  sysvec_apic_timer_interrupt+0xa6/0xc0 arch/x86/kernel/apic/apic.c:1049
>  </IRQ>
>  <TASK>
>  asm_sysvec_apic_timer_interrupt+0x1a/0x20 arch/x86/include/asm/idtentry.h:702
> RIP: 0010:__raw_spin_unlock_irqrestore include/linux/spinlock_api_smp.h:152 [inline]
> RIP: 0010:_raw_spin_unlock_irqrestore+0xd8/0x140 kernel/locking/spinlock.c:194
> 
> Reported-by: syzbot+80e5d6f453f14a53383a@syzkaller.appspotmail.com
> 
> Link: https://syzkaller.appspot.com/bug?extid=80e5d6f453f14a53383a
> Signed-off-by: Ayaan Mirza Baig <ayaanmirzabaig85@gmail.com>
> ---
>  lib/radix-tree.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/lib/radix-tree.c b/lib/radix-tree.c
> index 976b9bd02a1b..5cefbfd7677e 100644
> --- a/lib/radix-tree.c
> +++ b/lib/radix-tree.c
> @@ -292,6 +292,9 @@ void radix_tree_node_rcu_free(struct rcu_head *head)
>  	struct radix_tree_node *node =
>  			container_of(head, struct radix_tree_node, rcu_head);
>  
> +	if (unlikely(!node))
> +		return; //Prevent NULL deref
> +
>  	/*
>  	 * Must only free zeroed nodes into the slab.  We can be left with
>  	 * non-NULL entries by radix_tree_free_nodes, so clear the entries

Well, we should work out why this happened.  Cc Paul ;)

  reply	other threads:[~2025-02-25  4:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-23 20:01 Ayaan Mirza Baig
2025-02-25  4:27 ` Andrew Morton [this message]
2025-02-25 18:44   ` Ayaan Mirza Baig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250224202723.aa20e103b6b3bc3de65ca7e4@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=ayaanmirzabaig85@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulmck@kernel.org \
    --cc=syzbot+80e5d6f453f14a53383a@syzkaller.appspotmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®