diff options
| author | Christian Brauner <brauner@kernel.org> | 2026-06-01 15:56:52 +0200 |
|---|---|---|
| committer | Christian Brauner <brauner@kernel.org> | 2026-06-29 10:53:32 +0200 |
| commit | 14adbd5341aae18e7e14bc3786b49007c26b2503 (patch) | |
| tree | d028db8c49218ec127637d15e29a448dba66fd14 /init | |
| parent | 09eca26e7ee497eef94b3dd7fa5fdefa77bce684 (diff) | |
fs: stop sharing fs_struct between init_task and pid 1
Spawn kernel_init (PID 1) via kernel_clone() directly instead of
user_mode_thread(), without CLONE_FS. This gives PID 1 its own private
copy of init_task's fs_struct rather than sharing it.
This is a prerequisite for isolating kthreads in nullfs: when
init_task's fs is later pointed at nullfs, PID 1 must not share it
or init_userspace_fs() would modify init_task's fs as well, defeating
the isolation.
At this stage PID 1 still gets rootfs (a private copy rather than a
shared reference), so there is no functional change.
Link: https://patch.msgid.link/20260601-work-kthread-nullfs-v4-19-77ee053060e0@kernel.org
Signed-off-by: Christian Brauner (Amutable) <brauner@kernel.org>
Diffstat (limited to 'init')
| -rw-r--r-- | init/main.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/init/main.c b/init/main.c index 9af754e33209..92d34e496a33 100644 --- a/init/main.c +++ b/init/main.c @@ -671,6 +671,11 @@ static __initdata DECLARE_COMPLETION(kthreadd_done); static noinline void __ref __noreturn rest_init(void) { + struct kernel_clone_args init_args = { + .flags = (CLONE_VM | CLONE_UNTRACED), + .fn = kernel_init, + .fn_arg = NULL, + }; struct task_struct *tsk; int pid; @@ -680,7 +685,7 @@ static noinline void __ref __noreturn rest_init(void) * the init task will end up wanting to create kthreads, which, if * we schedule it before we create kthreadd, will OOPS. */ - pid = user_mode_thread(kernel_init, NULL, CLONE_FS); + pid = kernel_clone(&init_args); /* * Pin init on the boot CPU. Task migration is not properly working * until sched_init_smp() has been run. It will set the allowed |
