From: Yeoreum Yun <yeoreum.yun@arm.com>
To: Andrey Konovalov <andreyknvl@gmail.com>
Cc: glider@google.com, dvyukov@google.com, vincenzo.frascino@arm.com,
akpm@linux-foundation.org, bigeasy@linutronix.de,
clrkwllms@kernel.org, rostedt@goodmis.org, byungchul@sk.com,
max.byungchul.park@gmail.com, ysk@kzalloc.com,
kasan-dev@googlegroups.com, linux-mm@kvack.org,
linux-kernel@vger.kernel.org, linux-rt-devel@lists.linux.dev,
Andrey Ryabinin <ryabinin.a.a@gmail.com>
Subject: Re: [PATCH v2] kasan: remove kasan_find_vm_area() to prevent possible deadlock
Date: Thu, 3 Jul 2025 20:13:11 +0100 [thread overview]
Message-ID: <aGbWR+Q8XHtpdc8P@e129823.arm.com> (raw)
In-Reply-To: <CA+fCnZfq570HfXpS1LLUVm0sHXW+rpkSOMLVzafZ2q_ogha47g@mail.gmail.com>
Hi Andrey,
> > > > find_vm_area() couldn't be called in atomic_context.
> > > > If find_vm_area() is called to reports vm area information,
> > > > kasan can trigger deadlock like:
> > > >
> > > > CPU0 CPU1
> > > > vmalloc();
> > > > alloc_vmap_area();
> > > > spin_lock(&vn->busy.lock)
> > > > spin_lock_bh(&some_lock);
> > > > <interrupt occurs>
> > > > <in softirq>
> > > > spin_lock(&some_lock);
> > > > <access invalid address>
> > > > kasan_report();
> > > > print_report();
> > > > print_address_description();
> > > > kasan_find_vm_area();
> > > > find_vm_area();
> > > > spin_lock(&vn->busy.lock) // deadlock!
> > > >
> > > > To prevent possible deadlock while kasan reports, remove kasan_find_vm_area().
> > >
> > > Can we keep it for when we are in_task()?
> >
> > We couldn't do. since when kasan_find_vm_area() is called,
> > the report_lock is grabbed with irq disabled.
> >
> > Please check discuss with Andrey Ryabinin:
> > https://lore.kernel.org/all/4599f645-f79c-4cce-b686-494428bb9e2a@gmail.com/
>
> That was about checking for !in_interrupt(), but I believe checking
> for in_task() is different? But I'm not an expert on these checks.
I think below secnario can explain why we couldn't use in_task().
CPU0 CPU1
vmalloc();
alloc_vmap_area();
spin_lock(&vn->busy.lock)
spin_lock_irqsaved(&some_lock);
<interrupt occurs>
<in softirq>
spin_lock(&some_lock);
<access invalid address>
kasan_report();
print_report();
print_address_description();
kasan_find_vm_area();
find_vm_area();
spin_lock(&vn->busy.lock) // deadlock!
If you call in_task() in CPU1 before calling find_vm_area(),
it returns true and try to call find_vm_area() so it still makes a
deadlock situation.
Thanks
--
Sincerely,
Yeoreum Yun
next prev parent reply other threads:[~2025-07-03 19:13 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-03 18:10 [PATCH v2] kasan: remove kasan_find_vm_area() to prevent possible deadlock Yeoreum Yun
2025-07-03 18:44 ` Andrey Konovalov
2025-07-03 18:55 ` Yeoreum Yun
2025-07-03 19:05 ` Andrey Konovalov
2025-07-03 19:13 ` Yeoreum Yun [this message]
2025-07-04 13:07 ` Andrey Ryabinin
2025-07-03 18:57 ` Yeo Reum Yun
2025-07-03 20:35 ` Andrew Morton
2025-07-04 12:40 ` Andrey Ryabinin
2025-07-07 8:30 ` Sebastian Andrzej Siewior
2025-07-07 8:33 ` Yeoreum Yun
2025-07-07 8:44 ` Sebastian Andrzej Siewior
2025-07-07 13:49 ` Yeoreum Yun
2025-07-10 12:43 ` Andrey Konovalov
2025-07-11 2:08 ` Byungchul Park
2025-07-11 2:11 ` Byungchul Park
2025-07-11 8:54 ` Uladzislau Rezki
2025-07-12 15:46 ` Yeo Reum Yun
2025-07-13 23:27 ` Byungchul Park
2025-07-16 9:09 ` Uladzislau Rezki
2025-07-16 15:28 ` Marco Elver
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=aGbWR+Q8XHtpdc8P@e129823.arm.com \
--to=yeoreum.yun@arm.com \
--cc=akpm@linux-foundation.org \
--cc=andreyknvl@gmail.com \
--cc=bigeasy@linutronix.de \
--cc=byungchul@sk.com \
--cc=clrkwllms@kernel.org \
--cc=dvyukov@google.com \
--cc=glider@google.com \
--cc=kasan-dev@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-rt-devel@lists.linux.dev \
--cc=max.byungchul.park@gmail.com \
--cc=rostedt@goodmis.org \
--cc=ryabinin.a.a@gmail.com \
--cc=vincenzo.frascino@arm.com \
--cc=ysk@kzalloc.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;
as well as URLs for NNTP newsgroup(s).