linux/arch/sparc/kernel
Linus Torvalds 1ec6574a3c This set of changes updates init and user mode helper tasks to be
ordinary user mode tasks.
 
 In commit 40966e316f ("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.  This struct
 kthread going away during execve in turned made a use after free of
 struct kthread possible.
 
 The commit 343f4c49f2 ("kthread: Don't allocate kthread_struct for
 init and umh") is enough to fix the use after free and is simple 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.
 
 In making init and the user mode helpers tasks purely user mode tasks
 I ran into two complications.  The function task_tick_numa was
 detecting tasks without an mm by testing for the presence of
 PF_KTHREAD.  The initramfs code in populate_initrd_image was using
 flush_delayed_fput to ensuere the closing of all it's file descriptors
 was complete, and flush_delayed_fput does not work in a userspace thread.
 
 I have looked and looked and more complications and in my code review
 I have not found any, and neither has anyone else with the code sitting
 in linux-next.
 
 Link: https://lkml.kernel.org/r/87mtfu4up3.fsf@email.froward.int.ebiederm.org
 
 Eric W. Biederman (8):
       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
       sched: Update task_tick_numa to ignore tasks without an mm
 
  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/sched/fair.c              |  2 +-
  kernel/umh.c                     |  6 +++---
  33 files changed, 234 insertions(+), 160 deletions(-)
 
 Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEgjlraLDcwBA2B+6cC/v6Eiajj0AFAmKaR/MACgkQC/v6Eiaj
 j0Aayg/7Bx66872d9c6igkJ+MPCTuh+v9QKCGwiYEmiU4Q5sVAFB0HPJO27qC14u
 630X0RFNZTkPzNNEJNIW4kw6Dj8s8YRKf+FgQAVt4SzdRwT7eIPDjk1nGraopPJ3
 O04pjvuTmUyidyViRyFcf2ptx/pnkrwP8jUSc+bGTgfASAKAgAokqKE5ecjewbBc
 Y/EAkQ6QW7KxPjeSmpAHwI+t3BpBev9WEC4PbhRhsBCQFO2+PJiklvqdhVNBnIjv
 qUezll/1xv9UYgniB15Q4Nb722SmnWSU3r8as1eFPugzTHizKhufrrpyP+KMK1A0
 tdtEJNs5t2DZF7ZbGTFSPqJWmyTYLrghZdO+lOmnaSjHxK4Nda1d4NzbefJ0u+FE
 tutewowvHtBX6AFIbx+H3O+DOJM2IgNMf+ReQDU/TyNyVf3wBrTbsr9cLxypIJIp
 zze8npoLMlB7B4yxVo5ES5e63EXfi3iHl0L3/1EhoGwriRz1kWgVLUX/VZOUpscL
 RkJHsW6bT8sqxPWAA5kyWjEN+wNR2PxbXi8OE4arT0uJrEBMUgDCzydzOv5tJB00
 mSQdytxH9LVdsmxBKAOBp5X6WOLGA4yb1cZ6E/mEhlqXMpBDF1DaMfwbWqxSYi4q
 sp5zU3SBAW0qceiZSsWZXInfbjrcQXNV/DkDRDO9OmzEZP4m1j0=
 =x6fy
 -----END PGP SIGNATURE-----

Merge tag 'kthread-cleanups-for-v5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace

Pull kthread updates from Eric Biederman:
 "This updates init and user mode helper tasks to be ordinary user mode
  tasks.

  Commit 40966e316f ("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. This struct
  kthread going away during execve in turned made a use after free of
  struct kthread possible.

  Here, commit 343f4c49f2 ("kthread: Don't allocate kthread_struct for
  init and umh") is enough to fix the use after free and is simple
  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.

  In making init and the user mode helpers tasks purely user mode tasks
  I ran into two complications. The function task_tick_numa was
  detecting tasks without an mm by testing for the presence of
  PF_KTHREAD. The initramfs code in populate_initrd_image was using
  flush_delayed_fput to ensuere the closing of all it's file descriptors
  was complete, and flush_delayed_fput does not work in a userspace
  thread.

  I have looked and looked and more complications and in my code review
  I have not found any, and neither has anyone else with the code
  sitting in linux-next"

* tag 'kthread-cleanups-for-v5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace:
  sched: Update task_tick_numa to ignore tasks without an mm
  fork: Stop allowing kthreads to call execve
  fork: Explicitly set PF_KTHREAD
  init: Deal with the init process being a user mode process
  fork: Generalize PF_IO_WORKER handling
  fork: Explicity test for idle tasks in copy_thread
  fork: Pass struct kernel_clone_args into copy_thread
  kthread: Don't allocate kthread_struct for init and umh
2022-06-03 16:03:05 -07:00
..
syscalls arch: syscalls: simplify uapi/kapi directory creation 2022-03-31 12:03:46 +09:00
.gitignore
adi_64.c
apc.c
asm-offsets.c
audit.c audit: add support for the openat2 syscall 2021-10-01 16:52:48 -04:00
auxio_32.c
auxio_64.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
btext.c treewide: Convert macro and uses of __section(foo) to __section("foo") 2020-10-25 14:51:49 -07:00
central.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
cherrs.S
chmc.c
compat_audit.c audit: add support for the openat2 syscall 2021-10-01 16:52:48 -04:00
cpu.c
cpumap.c
cpumap.h
devices.c
ds.c sparc/vio: make remove callback return void 2021-05-14 13:45:58 +02:00
dtlb_miss.S
dtlb_prot.S
ebus.c
entry.h
entry.S Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc 2021-02-23 15:09:53 -08:00
etrap_32.S
etrap_64.S
fpu_traps.S
ftrace.c ftrace: Cleanup ftrace_dyn_arch_init() 2021-10-08 19:41:39 -04:00
getsetcc.S
head_32.S sparc32: get rid of fake_swapper_regs 2021-01-03 20:10:55 -05:00
head_64.S sparc64: get rid of fake_swapper_regs 2021-01-03 20:10:54 -05:00
helpers.S
hvapi.c
hvcalls.S
hvtramp.S
idprom.c
iommu-common.c dma-mapping: introduce dma_get_seg_boundary_nr_pages() 2020-09-03 18:12:15 +02:00
iommu.c sparc/iommu: don't set failed sg dma_address to DMA_MAPPING_ERROR 2021-08-09 17:13:06 +02:00
iommu_common.h
ioport.c sparc: Remove usage of the deprecated "pci-dma-compat.h" API 2022-02-25 17:19:21 +01:00
irq.h
irq_32.c
irq_64.c softirq: Move do_softirq_own_stack() to generic asm header 2021-02-10 23:34:16 +01:00
itlb_miss.S
ivec.S
jump_label.c
kernel.h
kgdb_32.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
kgdb_64.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
kprobes.c kprobes: treewide: Make it harder to refer kretprobe_trampoline directly 2021-09-30 21:24:06 -04:00
kstack.h
ktlb.S
ldc.c
led.c proc: make the proc_create[_data]() stubs static inlines 2022-01-20 08:52:52 +02:00
leon_kernel.c
leon_pci.c
leon_pci_grpci1.c
leon_pci_grpci2.c
leon_pmc.c sched/idle: Fix arch_cpu_idle() vs tracing 2020-11-24 16:47:35 +01:00
leon_smp.c mm: remove unneeded includes of <asm/pgalloc.h> 2020-08-07 11:33:26 -07:00
Makefile
mdesc.c sparc: avoid stringop-overread errors 2021-09-15 13:42:33 -07:00
misctrap.S
module.c
nmi.c
of_device_32.c
of_device_64.c
of_device_common.c
of_device_common.h
pci.c PCI: Rename pcibios_add_device() to pcibios_device_add() 2021-09-21 15:26:09 -05:00
pci_common.c
pci_fire.c
pci_impl.h
pci_msi.c genirq/msi, treewide: Use a named struct for PCI/MSI attributes 2021-12-09 11:52:21 +01:00
pci_psycho.c
pci_sabre.c
pci_schizo.c
pci_sun4v.c sparc/iommu: don't set failed sg dma_address to DMA_MAPPING_ERROR 2021-08-09 17:13:06 +02:00
pci_sun4v.h
pci_sun4v_asm.S
pcic.c
pcr.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
perf_event.c
pmc.c
power.c
process.c sparc: switch to kernel_clone() 2020-08-20 13:12:58 +02:00
process_32.c fork: Generalize PF_IO_WORKER handling 2022-05-07 09:01:59 -05:00
process_64.c fork: Generalize PF_IO_WORKER handling 2022-05-07 09:01:59 -05:00
prom.h
prom_32.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
prom_64.c
prom_common.c
prom_irqtrans.c
psycho_common.c
psycho_common.h
ptrace_32.c ptrace: Create ptrace_report_syscall_{entry,exit} in ptrace.h 2022-03-10 13:35:08 -06:00
ptrace_64.c ptrace: Create ptrace_report_syscall_{entry,exit} in ptrace.h 2022-03-10 13:35:08 -06:00
reboot.c
rtrap_32.S sparc32: Preserve clone syscall flags argument for restarts due to signals 2021-02-18 16:15:11 -08:00
rtrap_64.S
sbus.c
setup_32.c sparc32: get rid of fake_swapper_regs 2021-01-03 20:10:55 -05:00
setup_64.c sparc64: get rid of fake_swapper_regs 2021-01-03 20:10:54 -05:00
signal32.c signal: Deliver SIGTRAP on perf event asynchronously if blocked 2022-04-22 12:14:05 +02:00
signal_32.c ptrace: Cleanups for v5.18 2022-03-28 17:29:53 -07:00
signal_64.c signal: Deliver SIGTRAP on perf event asynchronously if blocked 2022-04-22 12:14:05 +02:00
sigutil.h
sigutil_32.c
sigutil_64.c
smp_32.c sched/core: Initialize the idle task with preemption disabled 2021-05-12 13:01:45 +02:00
smp_64.c mm: percpu: add generic pcpu_populate_pte() function 2022-01-20 08:52:52 +02:00
sparc_ksyms.c
spiterrs.S
sstate.c kernel.h: split out panic and oops helpers 2021-07-01 11:06:04 -07:00
stacktrace.c
starfire.c
sun4d_irq.c
sun4d_smp.c
sun4m_irq.c mm: remove unneeded includes of <asm/pgalloc.h> 2020-08-07 11:33:26 -07:00
sun4m_smp.c
sun4v_ivec.S
sun4v_mcd.S
sun4v_tlb_miss.S
sys32.S
sys_sparc32.c
sys_sparc_32.c signal/sparc: si_trapno is only used with SIGILL ILL_ILLTRP 2021-07-23 13:08:57 -05:00
sys_sparc_64.c signal/sparc: si_trapno is only used with SIGILL ILL_ILLTRP 2021-07-23 13:08:57 -05:00
syscalls.S
sysfs.c drivers/base/node: consolidate node device subsystem initialization in node_dev_init() 2022-03-22 15:57:10 -07:00
systbls.h
systbls_32.S sparc: syscalls: switch to generic syscalltbl.sh 2021-05-02 00:43:34 +09:00
systbls_64.S sparc: syscalls: switch to generic syscalltbl.sh 2021-05-02 00:43:34 +09:00
time_32.c
time_64.c
trampoline_32.S
trampoline_64.S
traps_32.c exit: Add and use make_task_dead. 2021-12-13 12:04:45 -06:00
traps_64.c sparc64: remove CONFIG_SET_FS support 2022-02-25 09:36:06 +01:00
tsb.S
ttable_32.S
ttable_64.S
una_asm_32.S
una_asm_64.S
unaligned_32.c signal/sparc: si_trapno is only used with SIGILL ILL_ILLTRP 2021-07-23 13:08:57 -05:00
unaligned_64.c
uprobes.c
urtt_fill.S
utrap.S
vdso.c locking/seqlock, headers: Untangle the spaghetti monster 2020-08-06 16:13:13 +02:00
vio.c bus: Make remove callback return void 2021-07-21 11:53:42 +02:00
viohs.c
visemul.c
vmlinux.lds.S vmlinux.lds.h: Split ELF_DETAILS from STABS_DEBUG 2020-09-01 09:50:35 +02:00
windows.c signal: Replace force_fatal_sig with force_exit_sig when in doubt 2021-11-19 09:15:58 -06:00
winfixup.S
wof.S
wuf.S