signal: Replace force_fatal_sig with force_exit_sig when in doubt
Recently to prevent issues with SECCOMP_RET_KILL and similar signals
being changed before they are delivered SA_IMMUTABLE was added.
Unfortunately this broke debuggers[1][2] which reasonably expect
to be able to trap synchronous SIGTRAP and SIGSEGV even when
the target process is not configured to handle those signals.
Add force_exit_sig and use it instead of force_fatal_sig where
historically the code has directly called do_exit. This has the
implementation benefits of going through the signal exit path
(including generating core dumps) without the danger of allowing
userspace to ignore or change these signals.
This avoids userspace regressions as older kernels exited with do_exit
which debuggers also can not intercept.
In the future is should be possible to improve the quality of
implementation of the kernel by changing some of these force_exit_sig
calls to force_fatal_sig. That can be done where it matters on
a case-by-case basis with careful analysis.
Reported-by: Kyle Huey <me@kylehuey.com>
Reported-by: kernel test robot <oliver.sang@intel.com>
[1] https://lkml.kernel.org/r/CAP045AoMY4xf8aC_4QU_-j7obuEPYgTcnQQP3Yxk=2X90jtpjw@mail.gmail.com
[2] https://lkml.kernel.org/r/
20211117150258.GB5403@xsang-OptiPlex-9020
Fixes: a2a2dd8f85de ("signal: Add SA_IMMUTABLE to ensure forced siganls do not get changed")
Fixes: 856705c39f8a ("signal/m68k: Use force_sigsegv(SIGSEGV) in fpsp040_die")
Fixes: fc99908855da ("signal/powerpc: On swapcontext failure force SIGSEGV")
Fixes: 21d81bf71bfe ("signal/s390: Use force_sigsegv in default_trap_handler")
Fixes: e98d91d2e629 ("signal/sparc32: In setup_rt_frame and setup_fram use force_fatal_sig")
Fixes: 908486441621 ("signal/sparc32: Exit with a fatal signal when try_to_clear_window_buffer fails")
Fixes: eed3b85106a0 ("signal/x86: In emulate_vsyscall force a signal instead of calling do_exit")
Fixes: cac0eb1efcc3 ("signal/vm86_32: Properly send SIGSEGV when the vm86 state cannot be saved.")
Fixes: 05466dc15414 ("exit/syscall_user_dispatch: Send ordinary signals on failure")
Link: https://lkml.kernel.org/r/871r3dqfv8.fsf_-_@email.froward.int.ebiederm.org
Reviewed-by: Kees Cook <keescook@chromium.org>
Tested-by: Kees Cook <keescook@chromium.org>
Tested-by: Kyle Huey <khuey@kylehuey.com>
Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>