[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251126235130.GG3538@ZenIV>
Date: Wed, 26 Nov 2025 23:51:30 +0000
From: Al Viro <viro@...iv.linux.org.uk>
To: david laight <david.laight@...box.com>
Cc: "Russell King (Oracle)" <linux@...linux.org.uk>,
Xie Yuanbin <xieyuanbin1@...wei.com>, brauner@...nel.org,
jack@...e.cz, will@...nel.org, nico@...xnic.net,
akpm@...ux-foundation.org, hch@....de, jack@...e.com,
wozizhi@...weicloud.com, linux-fsdevel@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
linux-mm@...ck.org, lilinjie8@...wei.com, liaohua4@...wei.com,
wangkefeng.wang@...wei.com, pangliyuan1@...wei.com
Subject: Re: [RFC PATCH] vfs: Fix might sleep in load_unaligned_zeropad()
with rcu read lock held
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...
Powered by blists - more mailing lists