public inbox for linux-um@lists.infradead.org
 help / color / mirror / Atom feed
From: benjamin@sipsolutions.net
To: linux-um@lists.infradead.org
Cc: Benjamin Berg <benjamin.berg@intel.com>
Subject: [PATCH v2 09/12] um: Do not flush MM in flush_thread
Date: Mon, 29 Apr 2024 15:47:56 +0200	[thread overview]
Message-ID: <20240429134759.244517-10-benjamin@sipsolutions.net> (raw)
In-Reply-To: <20240429134759.244517-1-benjamin@sipsolutions.net>

From: Benjamin Berg <benjamin.berg@intel.com>

There should be no need to flush the memory in flush_thread. Doing this
likely worked around some issue where memory was still incorrectly
mapped when creating or cloning an MM.

With the removal of the special clone path, that isn't relevant anymore.
However, add the flush into MM initialization so that any new userspace
MM is guaranteed to be clean.

Signed-off-by: Benjamin Berg <benjamin.berg@intel.com>
---
 arch/um/kernel/exec.c     | 5 -----
 arch/um/kernel/skas/mmu.c | 3 +++
 2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/arch/um/kernel/exec.c b/arch/um/kernel/exec.c
index 5c8836b012e9..2c15bb2c104c 100644
--- a/arch/um/kernel/exec.c
+++ b/arch/um/kernel/exec.c
@@ -24,11 +24,6 @@ void flush_thread(void)
 {
 	arch_flush_thread(&current->thread.arch);
 
-	unmap(&current->mm->context.id, 0, TASK_SIZE);
-	if (syscall_stub_flush(&current->mm->context.id) < 0) {
-		printk(KERN_ERR "%s - clearing address space failed", __func__);
-		force_sig(SIGKILL);
-	}
 	get_safe_registers(current_pt_regs()->regs.gp,
 			   current_pt_regs()->regs.fp);
 
diff --git a/arch/um/kernel/skas/mmu.c b/arch/um/kernel/skas/mmu.c
index 76c0c7d600a8..9bfefcd33f36 100644
--- a/arch/um/kernel/skas/mmu.c
+++ b/arch/um/kernel/skas/mmu.c
@@ -39,6 +39,9 @@ int init_new_context(struct task_struct *task, struct mm_struct *mm)
 		goto out_free;
 	}
 
+	/* Ensure the new MM is clean and nothing unwanted is mapped */
+	unmap(new_id, 0, TASK_SIZE);
+
 	return 0;
 
  out_free:
-- 
2.44.0



  parent reply	other threads:[~2024-04-29 13:48 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-29 13:47 [PATCH v2 00/12] Rework stub syscall and page table handling benjamin
2024-04-29 13:47 ` [PATCH v2 01/12] um: Remove stub-data.h include from common-offsets.h benjamin
2024-04-29 13:47 ` [PATCH v2 02/12] um: Create signal stack memory assignment in stub_data benjamin
2024-04-29 13:47 ` [PATCH v2 03/12] um: Add generic stub_syscall6 function benjamin
2024-04-29 13:47 ` [PATCH v2 04/12] um: Rework syscall handling benjamin
2024-04-29 13:47 ` [PATCH v2 05/12] um: compress memory related stub syscalls while adding them benjamin
2024-04-29 13:47 ` [PATCH v2 06/12] um: remove LDT support benjamin
2024-04-29 13:47 ` [PATCH v2 07/12] um: remove copy_context_skas0 benjamin
2024-04-29 13:47 ` [PATCH v2 08/12] um: Delay flushing syscalls until the thread is restarted benjamin
2024-04-29 13:47 ` benjamin [this message]
2024-04-29 13:47 ` [PATCH v2 10/12] um: remove force_flush_all from fork_handler benjamin
2024-04-29 13:47 ` [PATCH v2 11/12] um: simplify and consolidate TLB updates benjamin
2024-04-29 13:47 ` [PATCH v2 12/12] um: refactor TLB update handling benjamin

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=20240429134759.244517-10-benjamin@sipsolutions.net \
    --to=benjamin@sipsolutions.net \
    --cc=benjamin.berg@intel.com \
    --cc=linux-um@lists.infradead.org \
    /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