Commit 1f90a7fd authored by Peter Zijlstra's avatar Peter Zijlstra Committed by Aichun Shi
Browse files

x86/mm: Use mm_alloc() in poking_init()

stable inclusion
from stable-v5.10.189
commit 6ee042fd240fb669f4637f8cd89899b15911e5df
category: bugfix
bugzilla: https://gitee.com/openeuler/intel-kernel/issues/I8LVBS
CVE: N/A
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=6ee042fd240fb669f4637f8cd89899b15911e5df



-------------------------------------

Intel-SIG: commit 6ee042fd240f ("x86/mm: Use mm_alloc() in poking_init()")
Backport x86 related patches from 5.10.189 upstream

-------------------------------------

commit 3f4c8211 upstream.

Instead of duplicating init_mm, allocate a fresh mm. The advantage is
that mm_alloc() has much simpler dependencies. Additionally it makes
more conceptual sense, init_mm has no (and must not have) user state
to duplicate.

Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lkml.kernel.org/r/20221025201057.816175235@infradead.org


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarAichun Shi <aichun.shi@intel.com>
parent 050d683a
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@
#include <linux/swapops.h>
#include <linux/kmemleak.h>
#include <linux/sched/task.h>
#include <linux/sched/mm.h>

#include <asm/set_memory.h>
#include <asm/e820/api.h>
@@ -780,7 +781,7 @@ void __init poking_init(void)
	spinlock_t *ptl;
	pte_t *ptep;

	poking_mm = copy_init_mm();
	poking_mm = mm_alloc();
	BUG_ON(!poking_mm);

	/* Xen PV guests need the PGD to be pinned. */
+0 −1
Original line number Diff line number Diff line
@@ -88,7 +88,6 @@ extern void exit_itimers(struct task_struct *);
extern pid_t kernel_clone(struct kernel_clone_args *kargs);
struct task_struct *create_io_thread(int (*fn)(void *), void *arg, int node);
struct task_struct *fork_idle(int);
struct mm_struct *copy_init_mm(void);
extern pid_t kernel_thread(int (*fn)(void *), void *arg, unsigned long flags);
extern long kernel_wait4(pid_t, int __user *, int, struct rusage *);
int kernel_wait(pid_t pid, int *stat);
+0 −5
Original line number Diff line number Diff line
@@ -2540,11 +2540,6 @@ struct task_struct * __init fork_idle(int cpu)
	return task;
}

struct mm_struct *copy_init_mm(void)
{
	return dup_mm(NULL, &init_mm);
}

/*
 * This is like kernel_clone(), but shaved down and tailored to just
 * creating io_uring workers. It returns a created task, or an error pointer.