archive mirror
 help / color / mirror / Atom feed
From: Petr Tesarik <>
To: Richard Weinberger <>,
	Anton Ivanov <>,
	Johannes Berg <>, (open list:USER-MODE LINUX (UML)), (open list)
Cc: Roberto Sassu <>,,
	Petr Tesarik <>
Subject: [PATCH 2/2] um: oops on accessing an non-present page in the vmalloc area
Date: Fri, 15 Dec 2023 13:14:31 +0100	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <>

From: Petr Tesarik <>

If a segmentation fault is caused by an address in the vmalloc area, check
that the target page is present.

Currently, if the kernel hits a guard page the vmalloc area, UML assumes
that the fault is caused merely by a stale mapping and will be fixed by
flush_tlb_kernel_vm(). Of course, this will not create any mapping for a
guard page, so the faulting instruction will cause exactly the same fault
when it is executed again, effectively creating a beautiful (but useless)
infinite loop.

Signed-off-by: Petr Tesarik <>
 arch/um/kernel/trap.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/arch/um/kernel/trap.c b/arch/um/kernel/trap.c
index 1124a382fd14..ca9b5fd83c52 100644
--- a/arch/um/kernel/trap.c
+++ b/arch/um/kernel/trap.c
@@ -214,11 +214,15 @@ unsigned long segv(struct faultinfo fi, unsigned long ip, int is_user,
 	int err;
 	int is_write = FAULT_WRITE(fi);
 	unsigned long address = FAULT_ADDRESS(fi);
+	pte_t *pte;
 	if (!is_user && regs)
 		current->thread.segv_regs = container_of(regs, struct pt_regs, regs);
 	if (!is_user && (address >= start_vm) && (address < end_vm)) {
+		pte = virt_to_pte(&init_mm, address);
+		if (!pte_present(*pte))
+			page_fault_oops(regs, address, ip);
 		goto out;

  parent reply	other threads:[~2023-12-15 12:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-15 12:14 [PATCH 0/2] um: improve UML page fault handling Petr Tesarik
2023-12-15 12:14 ` [PATCH 1/2] um: do not panic on kernel mode faults Petr Tesarik
2023-12-15 12:14 ` Petr Tesarik [this message]
2024-01-03 12:51 ` [PATCH 0/2] um: improve UML page fault handling Petr Tesařík
2024-01-04 23:22 ` Richard Weinberger
2024-01-05  6:51   ` Petr Tesařík
2024-01-26  9:55     ` Petr Tesařík

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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \ \ \ \ \

* 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).