Merge branch 'exit-cleanups-for-v5.16' of git://git.kernel.org/pub/scm/linux/kernel...
authorLinus Torvalds <torvalds@linux-foundation.org>
Thu, 11 Nov 2021 00:15:54 +0000 (16:15 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 11 Nov 2021 00:15:54 +0000 (16:15 -0800)
Pull exit cleanups from Eric Biederman:
 "While looking at some issues related to the exit path in the kernel I
  found several instances where the code is not using the existing
  abstractions properly.

  This set of changes introduces force_fatal_sig a way of sending a
  signal and not allowing it to be caught, and corrects the misuse of
  the existing abstractions that I found.

  A lot of the misuse of the existing abstractions are silly things such
  as doing something after calling a no return function, rolling BUG by
  hand, doing more work than necessary to terminate a kernel thread, or
  calling do_exit(SIGKILL) instead of calling force_sig(SIGKILL).

  In the review a deficiency in force_fatal_sig and force_sig_seccomp
  where ptrace or sigaction could prevent the delivery of the signal was
  found. I have added a change that adds SA_IMMUTABLE to change that
  makes it impossible to interrupt the delivery of those signals, and
  allows backporting to fix force_sig_seccomp

  And Arnd found an issue where a function passed to kthread_run had the
  wrong prototype, and after my cleanup was failing to build."

* 'exit-cleanups-for-v5.16' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace: (23 commits)
  soc: ti: fix wkup_m3_rproc_boot_thread return type
  signal: Add SA_IMMUTABLE to ensure forced siganls do not get changed
  signal: Replace force_sigsegv(SIGSEGV) with force_fatal_sig(SIGSEGV)
  exit/r8188eu: Replace the macro thread_exit with a simple return 0
  exit/rtl8712: Replace the macro thread_exit with a simple return 0
  exit/rtl8723bs: Replace the macro thread_exit with a simple return 0
  signal/x86: In emulate_vsyscall force a signal instead of calling do_exit
  signal/sparc32: In setup_rt_frame and setup_fram use force_fatal_sig
  signal/sparc32: Exit with a fatal signal when try_to_clear_window_buffer fails
  exit/syscall_user_dispatch: Send ordinary signals on failure
  signal: Implement force_fatal_sig
  exit/kthread: Have kernel threads return instead of calling do_exit
  signal/s390: Use force_sigsegv in default_trap_handler
  signal/vm86_32: Properly send SIGSEGV when the vm86 state cannot be saved.
  signal/vm86_32: Replace open coded BUG_ON with an actual BUG_ON
  signal/sparc: In setup_tsb_params convert open coded BUG into BUG
  signal/powerpc: On swapcontext failure force SIGSEGV
  signal/sh: Use force_sig(SIGKILL) instead of do_group_exit(SIGKILL)
  signal/mips: Update (_save|_restore)_fp_context to fail with -EFAULT
  signal/sparc32: Remove unreachable do_exit in do_sparc_fault
  ...

17 files changed:
1  2 
arch/m68k/kernel/traps.c
arch/powerpc/kernel/signal_32.c
arch/powerpc/kernel/signal_64.c
arch/s390/kernel/dumpstack.c
arch/s390/kernel/traps.c
arch/xtensa/kernel/traps.c
drivers/staging/r8188eu/core/rtw_cmd.c
drivers/staging/r8188eu/include/osdep_service.h
drivers/staging/rtl8723bs/core/rtw_cmd.c
drivers/staging/rtl8723bs/core/rtw_xmit.c
drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c
fs/exec.c
fs/ocfs2/journal.c
include/linux/sched/signal.h
kernel/kthread.c
kernel/signal.c
net/batman-adv/tp_meter.c

Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
Simple merge
@@@ -321,11 -345,43 +321,11 @@@ post_process
                rtw_free_cmd_obj(pcmd);
        } while (1);
  
 -      up(&pcmdpriv->terminate_cmdthread_sema);
 +      complete(&pcmdpriv->stop_cmd_thread);
  
-       thread_exit();
+       return 0;
  }
  
 -u8 rtw_setstandby_cmd(struct adapter *padapter, uint action)
 -{
 -      struct cmd_obj *ph2c;
 -      struct usb_suspend_parm *psetusbsuspend;
 -      struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
 -
 -      u8 ret = _SUCCESS;
 -
 -      ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC);
 -      if (!ph2c) {
 -              ret = _FAIL;
 -              goto exit;
 -      }
 -
 -      psetusbsuspend = kzalloc(sizeof(struct usb_suspend_parm), GFP_ATOMIC);
 -      if (!psetusbsuspend) {
 -              kfree(ph2c);
 -              ret = _FAIL;
 -              goto exit;
 -      }
 -
 -      psetusbsuspend->action = action;
 -
 -      init_h2fwcmd_w_parm_no_rsp(ph2c, psetusbsuspend, GEN_CMD_CODE(_SetUsbSuspend));
 -
 -      ret = rtw_enqueue_cmd(pcmdpriv, ph2c);
 -
 -exit:
 -
 -      return ret;
 -}
 -
  /*
  rtw_sitesurvey_cmd(~)
        ### NOTE:#### (!!!!)
@@@ -516,9 -522,9 +516,9 @@@ post_process
        } while (1);
  
        complete(&pcmdpriv->terminate_cmdthread_comp);
 -      atomic_set(&(pcmdpriv->cmdthd_running), false);
 +      atomic_set(&pcmdpriv->cmdthd_running, false);
  
-       thread_exit();
+       return 0;
  }
  
  /*
diff --cc fs/exec.c
Simple merge
Simple merge
Simple merge
Simple merge
diff --cc kernel/signal.c
Simple merge
Simple merge