From: Lorenzo Stoakes <ljs@kernel.org>
To: Xie Yuanbin <xieyuanbin1@huawei.com>
Cc: linux@armlinux.org.uk, akpm@linux-foundation.org,
david@kernel.org, liam@infradead.org, liaohua4@huawei.com,
lilinjie8@huawei.com, linusw@kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
mhocko@suse.com, rppt@kernel.org, sunnanyong@huawei.com,
surenb@google.com, vbabka@kernel.org,
wangkefeng.wang@huawei.com, xiqi2@huawei.com
Subject: Re: [PATCH v3 1/2] ARM: mm: fix use-after-free in __do_user_fault() under CONFIG_DEBUG_USER
Date: Sat, 11 Jul 2026 09:05:03 +0100 [thread overview]
Message-ID: <alH4-zEWkSDK5EvK@lucifer> (raw)
In-Reply-To: <20260711075651.3114-1-xieyuanbin1@huawei.com>
On Sat, Jul 11, 2026 at 03:56:51PM +0800, Xie Yuanbin wrote:
> On Sat, 11 Jul 2026 08:27:23 +0100, Lorenzo Stoakes wrote:
> > In general yeah but with mmap_write_trylock() after you add the attached
> > patch to a series (making sure to cc- the right people etc.)... but also,
> > wouldn't you just generally want this in show_pte()?
> >
> > Seems to me best way is to put the existing show_pte() into a __show_pte()
> > and then do show_pte() like (untested top of my head thing):
> >
> > void show_pte(const char *lvl, struct mm_struct *mm, unsigned long addr,
> > bool is_user)
> > {
> > /* Write lock needed to account for concurrent downgraded munmap(). */
> > if (is_user && !mmap_write_trylock(mm)) {
> > printk("%s[%08lx] unable to acquire lock for PTE output\n",
> > lvl, addr);
> > return;
> > }
> > __show_pte(lvl, mm, addr);
> > if (is_user)
> > mmap_write_unlock(mm);
> > }
>
> For user faults, I think we don't need to worry about deadlock issues.
>
> As Russell King described, deadlock problems can only occur in kernel faults.
> On Tue, 7 Jul 2026 16:34:21 +0100, Russell King wrote:
> > Unconditionally taking the lock could lead to a deadlock. Consider
> > the case where the mmap lock is held, and we get an unrecognised
> > abort from the kernel.
>
> As we never return to user mode with mmap lock held, so for user faults,
> it is safe to acquire mmap lock. This is just the same with the syscall
> entry of `pkey_alloc`, we immediately acquire the mmap write lock:
> Link: https://elixir.bootlin.com/linux/v7.2-rc2/source/mm/mprotect.c#L1011
>
> For the kernel, the user faults entry and the system call entry are not
> fundamentally different; they are both kernel entry points.
OK given arm32 can't do any of the stuff that makes kernel faults an issue, and
if it's certain you can't deadlock on mmap write lock for VMA or non-VMA ranges
on user fault, then no need for the mmap write trylock, and just take the mmap
write lock unconditionally for user faults, and no lock for kernel faults I
guess?
next prev parent reply other threads:[~2026-07-11 8:54 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-26 7:30 [PATCH v3 0/2] ARM: mm: fix use-after-free in show_pte() Qi Xi
2026-06-26 7:30 ` [PATCH v3 1/2] ARM: mm: fix use-after-free in __do_user_fault() under CONFIG_DEBUG_USER Qi Xi
2026-06-26 9:44 ` Russell King
2026-06-27 1:39 ` Qi Xi
2026-07-06 13:32 ` Xie Yuanbin
2026-07-07 11:48 ` Qi Xi
2026-07-07 11:57 ` Russell King
2026-07-07 12:47 ` Qi Xi
2026-07-07 12:47 ` Lorenzo Stoakes
2026-07-07 13:14 ` Xie Yuanbin
2026-07-07 13:20 ` Lorenzo Stoakes
2026-07-07 14:04 ` Xie Yuanbin
2026-07-07 15:34 ` Russell King
2026-07-10 2:32 ` Qi Xi
2026-07-11 7:27 ` Lorenzo Stoakes
2026-07-11 7:56 ` Xie Yuanbin
2026-07-11 8:05 ` Lorenzo Stoakes [this message]
2026-07-11 8:13 ` Xie Yuanbin
2026-07-07 12:46 ` Lorenzo Stoakes
2026-07-07 13:35 ` Xie Yuanbin
2026-07-11 6:43 ` Lorenzo Stoakes
2026-06-26 7:30 ` [PATCH v3 2/2] ARM: mm: protect show_pte() in do_DataAbort() fallback path Qi Xi
2026-06-26 9:45 ` Russell King
2026-06-26 10:16 ` Xie Yuanbin
2026-06-26 12:37 ` Russell King
2026-06-27 1:22 ` Xie Yuanbin
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=alH4-zEWkSDK5EvK@lucifer \
--to=ljs@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=david@kernel.org \
--cc=liam@infradead.org \
--cc=liaohua4@huawei.com \
--cc=lilinjie8@huawei.com \
--cc=linusw@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux@armlinux.org.uk \
--cc=mhocko@suse.com \
--cc=rppt@kernel.org \
--cc=sunnanyong@huawei.com \
--cc=surenb@google.com \
--cc=vbabka@kernel.org \
--cc=wangkefeng.wang@huawei.com \
--cc=xieyuanbin1@huawei.com \
--cc=xiqi2@huawei.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