From: Al Viro <viro@zeniv.linux.org.uk>
To: david laight <david.laight@runbox.com>
Cc: "Russell King (Oracle)" <linux@armlinux.org.uk>,
Xie Yuanbin <xieyuanbin1@huawei.com>,
brauner@kernel.org, jack@suse.cz, will@kernel.org,
nico@fluxnic.net, akpm@linux-foundation.org, hch@lst.de,
jack@suse.com, wozizhi@huaweicloud.com,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org,
lilinjie8@huawei.com, liaohua4@huawei.com,
wangkefeng.wang@huawei.com, pangliyuan1@huawei.com
Subject: Re: [RFC PATCH] vfs: Fix might sleep in load_unaligned_zeropad() with rcu read lock held
Date: Wed, 26 Nov 2025 23:51:30 +0000 [thread overview]
Message-ID: <20251126235130.GG3538@ZenIV> (raw)
In-Reply-To: <20251126222505.1638a66d@pumpkin>
On Wed, Nov 26, 2025 at 10:25:05PM +0000, david laight wrote:
> Can you fix it with a flag on the exception table entry that means
> 'don't try to fault in a page'?
>
> I think the logic would be the same as 'disabling pagefaults', just
> checking a different flag.
> After all the fault itself happens in both cases.
The problem is getting to the point where you search the exception table
without blocking.
x86 #PF had been done that way from well before the point when
load_unaligned_zeropad() had been introduced, so everything worked
there from the very beginning.
arm and arm64, OTOH, were different - there had been logics for
"if trylock fails, check if we are in kernel space and have no
matching exception table entry; bugger off if so, otherwise we
are safe to grab mmap_sem - it's something like get_user() and
we *want* mmap_sem there", but it did exactly the wrong thing for
this case.
The only thing that prevented serious breakage from the very beginning
was that these faults are very rare - and hard to arrange without
KFENCE. So it didn't blow up. In 2017 arm64 side of problem had
been spotted and (hopefully) fixed. arm counterpart stayed unnoticed
(perhaps for the lack of good reproducer) until now.
Most of the faults are from userland code, obviously, so we don't
want to search through the exception table on the common path.
So hanging that on a flag in exception table entry is not a good
idea - we need a cheaper predicate checked first.
x86 starts with separating the fault on kernel address from that on
userland; we are not going anywhere near mmap_sem (and VMAs in general)
in the former case and that's where load_unaligned_zeropad() faults
end up. arm64 fix consisted of using do_translation_fault() instead
of do_page_fault(), with the former falling back to the latter for
userland addresses and using do_bad_area() for kernel ones.
Assuming that the way it's hooked up covers everything, we should
be fine there.
One potential problem _might_ be with the next PTE present, but
write-only. Note that it has to cope with symlink bodies as well
and those might come from page cache rather than kmem_cache_alloc().
I'm nowhere near being uptodate on arm64 virtual memory setup, though,
so take that with a cartload of salt...
next prev parent reply other threads:[~2025-11-26 23:51 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-26 9:05 [Bug report] hash_name() may cross page boundary and trigger sleep in RCU context Zizhi Wo
2025-11-26 10:19 ` [RFC PATCH] vfs: Fix might sleep in load_unaligned_zeropad() with rcu read lock held Xie Yuanbin
2025-11-26 18:10 ` Al Viro
2025-11-26 18:48 ` Al Viro
2025-11-26 19:05 ` Russell King (Oracle)
2025-11-26 19:26 ` Al Viro
2025-11-26 19:51 ` Russell King (Oracle)
2025-11-26 20:02 ` Al Viro
2025-11-26 22:25 ` david laight
2025-11-26 23:51 ` Al Viro [this message]
2025-11-26 23:31 ` Russell King (Oracle)
2025-11-27 3:03 ` Xie Yuanbin
2025-11-27 7:20 ` Sebastian Andrzej Siewior
2025-11-27 11:20 ` Xie Yuanbin
2025-11-28 1:39 ` Xie Yuanbin
2025-11-26 20:42 ` Al Viro
2025-11-26 10:27 ` [Bug report] hash_name() may cross page boundary and trigger sleep in RCU context Zizhi Wo
2025-11-26 21:12 ` Linus Torvalds
2025-11-27 10:27 ` Will Deacon
2025-11-27 10:57 ` Russell King (Oracle)
2025-11-28 17:06 ` Linus Torvalds
2025-11-29 1:01 ` Zizhi Wo
2025-11-29 1:35 ` Linus Torvalds
2025-11-29 4:08 ` [Bug report] hash_name() may cross page boundary and trigger Xie Yuanbin
2025-11-29 9:08 ` Al Viro
2025-11-29 9:25 ` Xie Yuanbin
2025-11-29 9:44 ` Al Viro
2025-11-29 10:05 ` Xie Yuanbin
2025-11-29 10:45 ` david laight
2025-11-29 8:54 ` [Bug report] hash_name() may cross page boundary and trigger sleep in RCU context Al Viro
2025-12-01 2:08 ` Zizhi Wo
2025-11-29 2:18 ` [Bug report] hash_name() may cross page boundary and trigger Xie Yuanbin
2025-12-01 13:28 ` [Bug report] hash_name() may cross page boundary and trigger sleep in RCU context Will Deacon
2025-12-02 12:43 ` Russell King (Oracle)
2025-12-02 13:02 ` Xie Yuanbin
2025-12-02 22:07 ` Linus Torvalds
2025-12-03 1:48 ` Xie Yuanbin
2025-12-05 12:08 ` Russell King (Oracle)
2025-11-26 18:55 ` Al Viro
2025-11-27 2:24 ` Zizhi Wo
2025-11-29 3:37 ` Al Viro
2025-11-30 3:01 ` [RFC][alpha] saner vmalloc handling (was Re: [Bug report] hash_name() may cross page boundary and trigger sleep in RCU context) Al Viro
2025-11-30 11:32 ` david laight
2025-11-30 16:43 ` Al Viro
2025-11-30 18:14 ` Magnus Lindholm
2025-11-30 19:03 ` david laight
2025-11-30 20:31 ` Al Viro
2025-11-30 20:32 ` Al Viro
2025-11-30 22:16 ` Linus Torvalds
2025-11-30 23:37 ` Al Viro
2025-12-01 2:03 ` [Bug report] hash_name() may cross page boundary and trigger sleep in RCU context Zizhi Wo
2025-11-27 12:59 ` Will Deacon
2025-11-28 1:17 ` Zizhi Wo
2025-11-28 1:18 ` Zizhi Wo
2025-11-28 1:39 ` Zizhi Wo
2025-11-28 12:25 ` Will Deacon
2025-11-29 1:02 ` Zizhi Wo
2025-11-29 3:55 ` Al Viro
2025-12-01 2:38 ` Zizhi Wo
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=20251126235130.GG3538@ZenIV \
--to=viro@zeniv.linux.org.uk \
--cc=akpm@linux-foundation.org \
--cc=brauner@kernel.org \
--cc=david.laight@runbox.com \
--cc=hch@lst.de \
--cc=jack@suse.com \
--cc=jack@suse.cz \
--cc=liaohua4@huawei.com \
--cc=lilinjie8@huawei.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux@armlinux.org.uk \
--cc=nico@fluxnic.net \
--cc=pangliyuan1@huawei.com \
--cc=wangkefeng.wang@huawei.com \
--cc=will@kernel.org \
--cc=wozizhi@huaweicloud.com \
--cc=xieyuanbin1@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