Skip to content

fork: Make init and umh ordinary tasks

Eric W. Biederman linux-arch lkml oe-kbuild-all stable 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest7 patches 12 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/7kthread: Don't allocate kthread_struct for init and umhfs/exec.c include/linux/sched/task.h init/main.c +2 more+30 -84 replies
2/7fork: Pass struct kernel_clone_args into copy_threadarch/alpha/kernel/process.c arch/arc/kernel/process.c arch/arm/kernel/process.c +22 more+116 -581 reply
3/7fork: Explicity test for idle tasks in copy_threadarch/ia64/kernel/process.c arch/parisc/kernel/process.c include/linux/sched/task.h +1 more+12 -20 replies
4/7fork: Generalize PF_IO_WORKER handlingarch/alpha/kernel/process.c arch/arc/kernel/process.c arch/arm/kernel/process.c +25 more+95 -1160 replies
5/7init: Deal with the init process being a user mode processinit/initramfs.c+2 -00 replies
6/7fork: Explicitly set PF_KTHREADkernel/fork.c+3 -00 replies
7/7fork: Stop allowing kthreads to call execvefs/exec.c+3 -30 replies

Reviews trailers per patch

None of the 7 patches has a Reviewed-by or Acked-by.

PatchQian Cai
SeriesT-b T-b
1/7
2/7
3/7
4/7
5/7
6/7
7/7

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/7] fork: Make init and umh ordinary tasks

In commit 40966e316f86 ("kthread: Ensure struct kthread is present for all kthreads") caused init and the user mode helper threads that call kernel_execve to have struct kthread allocated for them.

I believe my first patch in this series is enough to fix the bug and is simple enough and obvious enough to be backportable.

The rest of the changes pass struct kernel_clone_args to clean things up and cause the code to make sense.

There is one rough spot in this change. In the init process before the user space init process is exec'd there is a lot going on. I have found when async_schedule_domain is low on memory or has more than 32K callers executing do_populate_rootfs will now run in a user space thread making flush_delayed_fput meaningless, and __fput_sync is unusable. I solved this as I did in usermode_driver.c with an added explicit task_work_run. I point this out as I have seen some talk about making flushing file handles more explicit.

Eric W. Biederman (7):
kthread: Don't allocate kthread_struct for init and umh
fork: Pass struct kernel_clone_args into copy_thread
fork: Explicity test for idle tasks in copy_thread
fork: Generalize PF_IO_WORKER handling
init: Deal with the init process being a user mode process
fork: Explicitly set PF_KTHREAD
fork: Stop allowing kthreads to call execve

 arch/alpha/kernel/process.c      | 13 ++++++------
 arch/arc/kernel/process.c        | 13 ++++++------
 arch/arm/kernel/process.c        | 12 ++++++-----
 arch/arm64/kernel/process.c      | 12 ++++++-----
 arch/csky/kernel/process.c       | 15 ++++++-------
 arch/h8300/kernel/process.c      | 10 ++++-----
 arch/hexagon/kernel/process.c    | 12 ++++++-----
 arch/ia64/kernel/process.c       | 15 +++++++------
 arch/m68k/kernel/process.c       | 12 ++++++-----
 arch/microblaze/kernel/process.c | 12 ++++++-----
 arch/mips/kernel/process.c       | 13 ++++++------
 arch/nios2/kernel/process.c      | 12 ++++++-----
 arch/openrisc/kernel/process.c   | 12 ++++++-----
 arch/parisc/kernel/process.c     | 18 +++++++++-------
 arch/powerpc/kernel/process.c    | 15 +++++++------
 arch/riscv/kernel/process.c      | 12 ++++++-----
 arch/s390/kernel/process.c       | 12 ++++++-----
 arch/sh/kernel/process_32.c      | 12 ++++++-----
 arch/sparc/kernel/process_32.c   | 12 ++++++-----
 arch/sparc/kernel/process_64.c   | 12 ++++++-----
 arch/um/kernel/process.c         | 15 +++++++------
 arch/x86/include/asm/fpu/sched.h |  2 +-
 arch/x86/include/asm/switch_to.h |  8 +++----
 arch/x86/kernel/fpu/core.c       |  4 ++--
 arch/x86/kernel/process.c        | 18 +++++++++-------
 arch/xtensa/kernel/process.c     | 17 ++++++++-------
 fs/exec.c                        |  8 ++++---
 include/linux/sched/task.h       |  8 +++++--
 init/initramfs.c                 |  2 ++
 init/main.c                      |  2 +-
 kernel/fork.c                    | 46 +++++++++++++++++++++++++++++++++-------
 kernel/umh.c                     |  6 +++---
 32 files changed, 233 insertions(+), 159 deletions(-)

Eric