From: "Barry Song (Xiaomi)" <baohua@kernel.org>
To: akpm@linux-foundation.org, linux-mm@kvack.org
Cc: x86@kernel.org, linux-arm-kernel@lists.infradead.org,
surenb@google.com, liam@infradead.org, ljs@kernel.org,
vbabka@kernel.org, shakeel.butt@linux.dev, david@kernel.org,
linux-kernel@vger.kernel.org, zhanghongru@xiaomi.com,
willy@infradead.org, zhangbo56@xiaomi.com,
"Barry Song (Xiaomi)" <baohua@kernel.org>
Subject: [RFC PATCH v1 2/2] arm64/mm: use VMA lock for kernel faults on user addresses
Date: Sun, 2 Aug 2026 15:40:18 +0800 [thread overview]
Message-ID: <20260802074018.73887-3-baohua@kernel.org> (raw)
In-Reply-To: <20260802074018.73887-1-baohua@kernel.org>
Use the VMA lock for kernel faults on user addresses. This also
makes the existing code below meaningful:
/* Quick path to respond to signals */
if (fault_signal_pending(fault, regs)) {
if (!user_mode(regs))
goto no_context;
return 0;
}
Right now, the code above is dead because !user_mode always
takes the mmap_lock path.
Co-developed-by: Bo Zhang <zhangbo56@xiaomi.com>
Signed-off-by: Bo Zhang <zhangbo56@xiaomi.com>
Signed-off-by: Barry Song (Xiaomi) <baohua@kernel.org>
---
arch/arm64/mm/fault.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/arch/arm64/mm/fault.c b/arch/arm64/mm/fault.c
index 85e23388f9bb..241f1ab07ab3 100644
--- a/arch/arm64/mm/fault.c
+++ b/arch/arm64/mm/fault.c
@@ -607,6 +607,7 @@ static int __kprobes do_page_fault(unsigned long far, unsigned long esr,
unsigned int mm_flags = FAULT_FLAG_DEFAULT;
unsigned long addr = untagged_addr(far);
struct vm_area_struct *vma;
+ bool uaccess = false;
int si_code;
int pkey = -1;
@@ -663,6 +664,7 @@ static int __kprobes do_page_fault(unsigned long far, unsigned long esr,
if (!insn_may_access_user(regs->pc, esr))
die_kernel_fault("access to user memory outside uaccess routines",
addr, esr, regs);
+ uaccess = true;
}
if (is_pkvm_stage2_abort(esr)) {
@@ -674,7 +676,7 @@ static int __kprobes do_page_fault(unsigned long far, unsigned long esr,
perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, addr);
- if (!(mm_flags & FAULT_FLAG_USER))
+ if (!(mm_flags & FAULT_FLAG_USER) && !uaccess)
goto lock_mmap;
vma = lock_vma_under_rcu(mm, addr);
--
2.39.3 (Apple Git-146)
next prev parent reply other threads:[~2026-08-02 7:40 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-02 7:40 [RFC PATCH v1 0/2] mm: use VMA lock for kernel faults on user addresses Barry Song (Xiaomi)
2026-08-02 7:40 ` [RFC PATCH v1 1/2] x86/mm: " Barry Song (Xiaomi)
2026-08-03 15:18 ` Lorenzo Stoakes (ARM)
2026-08-03 15:47 ` Suren Baghdasaryan
2026-08-03 22:37 ` Barry Song
2026-08-04 14:46 ` Lorenzo Stoakes (ARM)
2026-08-02 7:40 ` Barry Song (Xiaomi) [this message]
2026-08-02 8:49 ` [RFC PATCH v1 2/2] arm64/mm: " Barry Song
2026-08-03 15:32 ` Lorenzo Stoakes (ARM)
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=20260802074018.73887-3-baohua@kernel.org \
--to=baohua@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=david@kernel.org \
--cc=liam@infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=shakeel.butt@linux.dev \
--cc=surenb@google.com \
--cc=vbabka@kernel.org \
--cc=willy@infradead.org \
--cc=x86@kernel.org \
--cc=zhangbo56@xiaomi.com \
--cc=zhanghongru@xiaomi.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.