signal: Remove task argument from force_sig_info
Subsystems (46)
cover signal: Remove task argument from force_sig_info
Folks,
If folks can look this over and see if I have missed something I would appreciate it.
The force_sig_info interface is designed to handle synchronous exceptions like page faults. The locking in force_sig_info does not handle being called on a remote task that is already running. It has been a long standing problem over the years that it is not obvious to people that restriction exists or that force_sig is for exceptions and they call it somewhere inappropriate. A recently fixed example is 6376360ecbe5 ("mm: hwpoison: use do_send_sig_info() instead of force_sig()").
I was looking over the force_sig family of functions not long ago and realized that there really are not that many cases where they are called with on a process other than current and it is possible to remove the current parameter, which should make it hard to make this mistake naively.
I found exactly two legitimate places where force_sig was being called on a non-current task. On mips force_fcr31_sig is called in switch_to on next the task that we are in the middle of making current. On parisc in user_enable_single_step on a task that is stopped in a SIGKILL safe way in ptrace. Both to my eyes appear to meet all of the criterion for being safe to call from force_sig.
While reviewing that last ptrace case I found a funny corner case bug of PTRACE_KILL, and so that fix is included in this patset as well.
Through "signal/cifs: Fix cifs_put_tcp_session to call send_sig instead of force_sig" the patches in this patchset are bug fixes. I don't think any of them are urgent as they have existed for a long time, but definitely worth fixes.
The rest of the changes are cleanups that carefully remove the task parameters from the entire force_sig family of functions. Until at last force_sig_info only takes a struct siginfo.
Eric W. Biederman (26):
signal: Correct namespace fixups of si_pid and si_uid signal/ptrace: Simplify and fix PTRACE_KILL
signal/arm64: Use force_sig not force_sig_fault for SIGKILL signal/drbd: Use send_sig not force_sig
signal/bpfilter: Fix bpfilter_kernl to use send_sig not force_sig signal/pid_namespace: Fix reboot_pid_ns to use send_sig not force_sig signal/cifs: Fix cifs_put_tcp_session to call send_sig instead of force_sig
signal: Remove task parameter from force_sigsegv
signal: Remove task parameter from force_sig
signal: Remove task parameter from force_sig_mceerr
signal/x86: Remove task parameter from send_sigtrap
signal/um: Remove task parameter from send_sigtrap
signal/sh: Remove tsk parameter from force_sig_info_fault signal/riscv: Remove tsk parameter from do_trap
signal/nds32: Remove tsk parameter from send_sigtrap
signal/arm: Remove tsk parameter from ptrace_break
signal/arm: Remove tsk parameter from __do_user_fault signal/unicore32: Remove tsk parameter from __do_user_fault
signal: Explicitly call force_sig_fault on current
signal: Use force_sig_fault_to_task for the two calls that don't deliver to current
signal: Remove the task parameter from force_sig_fault
signal: Properly set TRACE_SIGNAL_LOSE_INFO in __send_signal
signal: Move the computation of force into send_signal and correct it.
signal: Generate the siginfo in force_sig
signal: Factor force_sig_info_to_task out of force_sig_info
signal: Remove the signal number and task parameters from force_sig_info
arch/alpha/kernel/signal.c | 4 +- arch/alpha/kernel/traps.c | 2 +- arch/alpha/mm/fault.c | 4 +- arch/arc/kernel/process.c | 4 +- arch/arc/kernel/signal.c | 2 +- arch/arc/kernel/traps.c | 2 +- arch/arc/mm/fault.c | 4 +- arch/arm/include/asm/traps.h | 2 +- arch/arm/kernel/ptrace.c | 6 +- arch/arm/kernel/signal.c | 4 +- arch/arm/kernel/traps.c | 4 +- arch/arm/mm/alignment.c | 2 +- arch/arm/mm/fault.c | 13 +- arch/arm64/kernel/traps.c | 9 +- arch/c6x/kernel/signal.c | 2 +- arch/c6x/kernel/traps.c | 2 +- arch/csky/abiv1/alignment.c | 2 +- arch/csky/abiv2/fpu.c | 2 +- arch/csky/kernel/signal.c | 4 +- arch/csky/kernel/traps.c | 2 +- arch/csky/mm/fault.c | 4 +- arch/h8300/kernel/ptrace_h.c | 4 +- arch/h8300/kernel/ptrace_s.c | 2 +- arch/h8300/kernel/signal.c | 2 +- arch/hexagon/kernel/signal.c | 2 +- arch/hexagon/kernel/traps.c | 12 +- arch/hexagon/mm/vm_fault.c | 4 +- arch/ia64/kernel/brl_emu.c | 6 +- arch/ia64/kernel/signal.c | 8 +- arch/ia64/kernel/traps.c | 24 +-- arch/ia64/kernel/unaligned.c | 2 +- arch/ia64/mm/fault.c | 2 +- arch/m68k/kernel/signal.c | 4 +- arch/m68k/kernel/traps.c | 20 +-- arch/m68k/mm/fault.c | 4 +- arch/microblaze/kernel/exceptions.c | 2 +- arch/microblaze/kernel/signal.c | 2 +- arch/microblaze/mm/fault.c | 2 +- arch/mips/kernel/branch.c | 18 +-- arch/mips/kernel/kprobes.c | 2 +- arch/mips/kernel/signal.c | 8 +- arch/mips/kernel/signal_n32.c | 4 +- arch/mips/kernel/signal_o32.c | 8 +- arch/mips/kernel/traps.c | 50 +++--- arch/mips/kernel/unaligned.c | 20 +-- arch/mips/mm/fault.c | 4 +- arch/mips/sgi-ip22/ip22-berr.c | 2 +- arch/mips/sgi-ip22/ip28-berr.c | 2 +- arch/mips/sgi-ip27/ip27-berr.c | 2 +- arch/mips/sgi-ip32/ip32-berr.c | 2 +- arch/nds32/kernel/fpu.c | 2 +- arch/nds32/kernel/signal.c | 2 +- arch/nds32/kernel/traps.c | 17 +- arch/nds32/mm/fault.c | 4 +- arch/nios2/kernel/signal.c | 4 +- arch/nios2/kernel/traps.c | 2 +- arch/openrisc/kernel/signal.c | 2 +- arch/openrisc/kernel/traps.c | 12 +- arch/openrisc/mm/fault.c | 4 +- arch/parisc/kernel/ptrace.c | 6 +- arch/parisc/kernel/signal.c | 2 +- arch/parisc/kernel/traps.c | 14 +- arch/parisc/kernel/unaligned.c | 4 +- arch/parisc/math-emu/driver.c | 2 +- arch/parisc/mm/fault.c | 4 +- arch/powerpc/kernel/process.c | 2 +- arch/powerpc/kernel/signal_32.c | 6 +- arch/powerpc/kernel/signal_64.c | 2 +- arch/powerpc/kernel/traps.c | 4 +- arch/powerpc/mm/fault.c | 5 +- arch/powerpc/platforms/cell/spufs/fault.c | 9 +- arch/powerpc/platforms/cell/spufs/run.c | 2 +- arch/riscv/include/asm/bug.h | 2 +- arch/riscv/kernel/signal.c | 2 +- arch/riscv/kernel/traps.c | 11 +- arch/riscv/mm/fault.c | 6 +- arch/s390/kernel/compat_signal.c | 4 +- arch/s390/kernel/signal.c | 4 +- arch/s390/kernel/traps.c | 6 +- arch/s390/mm/fault.c | 6 +- arch/sh/kernel/cpu/sh2a/fpu.c | 2 +- arch/sh/kernel/cpu/sh4/fpu.c | 2 +- arch/sh/kernel/cpu/sh5/fpu.c | 4 +- arch/sh/kernel/hw_breakpoint.c | 2 +- arch/sh/kernel/ptrace_64.c | 4 +- arch/sh/kernel/signal_32.c | 4 +- arch/sh/kernel/signal_64.c | 4 +- arch/sh/kernel/traps.c | 4 +- arch/sh/kernel/traps_32.c | 10 +- arch/sh/kernel/traps_64.c | 2 +- arch/sh/math-emu/math.c | 2 +- arch/sh/mm/fault.c | 11 +- arch/sparc/kernel/process_64.c | 4 +- arch/sparc/kernel/signal32.c | 8 +- arch/sparc/kernel/signal_32.c | 4 +- arch/sparc/kernel/signal_64.c | 8 +- arch/sparc/kernel/sys_sparc_32.c | 2 +- arch/sparc/kernel/sys_sparc_64.c | 2 +- arch/sparc/kernel/traps_32.c | 4 +- arch/sparc/kernel/traps_64.c | 41 +++-- arch/sparc/mm/fault_32.c | 4 +- arch/sparc/mm/fault_64.c | 2 +- arch/um/kernel/exec.c | 2 +- arch/um/kernel/ptrace.c | 7 +- arch/um/kernel/skas/mmu.c | 2 +- arch/um/kernel/tlb.c | 4 +- arch/um/kernel/trap.c | 16 +- arch/unicore32/kernel/signal.c | 4 +- arch/unicore32/kernel/traps.c | 2 +- arch/unicore32/mm/fault.c | 13 +- arch/x86/entry/vsyscall/vsyscall_64.c | 4 +- arch/x86/include/asm/ptrace.h | 3 +- arch/x86/kernel/cpu/mce/core.c | 2 +- arch/x86/kernel/ptrace.c | 9 +- arch/x86/kernel/signal.c | 2 +- arch/x86/kernel/traps.c | 10 +- arch/x86/kernel/umip.c | 2 +- arch/x86/kernel/uprobes.c | 2 +- arch/x86/kernel/vm86_32.c | 2 +- arch/x86/mm/fault.c | 9 +- arch/x86/mm/mpx.c | 2 +- arch/x86/um/signal.c | 4 +- arch/xtensa/kernel/signal.c | 2 +- arch/xtensa/kernel/traps.c | 8 +- arch/xtensa/mm/fault.c | 4 +- drivers/block/drbd/drbd_int.h | 2 +- drivers/block/drbd/drbd_main.c | 2 +- drivers/block/drbd/drbd_nl.c | 2 +- drivers/misc/lkdtm/bugs.c | 2 +- fs/cifs/connect.c | 2 +- fs/exec.c | 2 +- include/linux/ptrace.h | 2 +- include/linux/sched/signal.h | 13 +- include/linux/syscalls.h | 2 +- kernel/events/uprobes.c | 4 +- kernel/pid_namespace.c | 2 +- kernel/ptrace.c | 43 +++-- kernel/rseq.c | 4 +- kernel/seccomp.c | 2 +- kernel/signal.c | 182 ++++++++++++++-------- mm/memory-failure.c | 2 +- net/bpfilter/bpfilter_kern.c | 2 +- security/safesetid/lsm.c | 4 +- 143 files changed, 510 insertions(+), 465 deletions(-)
Signature · 1 line
2.21.0
PATCH 1/26 signal: Correct namespace fixups of si_pid and si_uid
The function send_signal was split from __send_signal so that it would be possible to bypass the namespace logic based upon current[1]. As it turns out the si_pid and the si_uid fixup are both inappropriate in the case of kill_pid_usb_asyncio so move that logic into send_signal.
It is difficult to arrange but possible for a signal with an si_code of SI_TIMER or SI_SIGIO to be sent across namespace boundaries. In which case tests for when it is ok to change si_pid and si_uid based on SI_FROMUSER are incorrect. Replace the use of SI_FROMUSER with a new test has_si_pid_and_used based on siginfo_layout.
Now that the uid fixup is no longer present after expanding SEND_SIG_NOINFO properly calculate the si_uid that the target task needs to read.
[1] 7978b567d315 ("signals: add from_ancestor_ns parameter to send_signal()")
--- kernel/signal.c | 67 +++++++++++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 27 deletions(-)
kernel/signal.c +40 -27
@@ -1056,27 +1056,6 @@ static inline bool legacy_queue(struct sigpending *signals, int sig)return (sig <SIGRTMIN ) &&sigismember (&signals->signal, sig); } -#ifdef CONFIG_USER_NS -static inline void userns_fixup_signal_uid (struct kernel_siginfo *info,struct task_struct *t) -{ -if (current_user_ns () ==task_cred_xxx (t, user_ns)) -return ; - -if (SI_FROMKERNEL (info)) -return ; - -rcu_read_lock (); - info->si_uid =from_kuid_munged (task_cred_xxx (t, user_ns), -make_kuid (current_user_ns (), info->si_uid)); -rcu_read_unlock (); -} -#else -static inline void userns_fixup_signal_uid (struct kernel_siginfo *info,struct task_struct *t) -{ -return ; -} -#endif -static int __send_signal (int sig,struct kernel_siginfo *info,struct task_struct *t,enum pid_type type,int from_ancestor_ns) {
@@ -1134,7 +1113,11 @@ static int __send_signal(int sig, struct kernel_siginfo *info, struct task_struc q->info.si_code =SI_USER ; q->info.si_pid =task_tgid_nr_ns (current,task_active_pid_ns (t)); - q->info.si_uid =from_kuid_munged (current_user_ns (),current_uid ()); +rcu_read_lock (); + q->info.si_uid = +from_kuid_munged (task_cred_xxx (t, user_ns), +current_uid ()); +rcu_read_unlock ();break ;case (unsigned long )SEND_SIG_PRIV :clear_siginfo (&q->info);
@@ -1146,13 +1129,8 @@ static int __send_signal(int sig, struct kernel_siginfo *info, struct task_strucbreak ;default :copy_siginfo (&q->info, info); -if (from_ancestor_ns) - q->info.si_pid =0 ;break ; } - -userns_fixup_signal_uid (&q->info, t); - }else if (!is_si_special (info)) {if (sig >=SIGRTMIN && info->si_code !=SI_USER ) {/*
@@ -1196,6 +1174,28 @@ static int __send_signal(int sig, struct kernel_siginfo *info, struct task_strucreturn ret; } +static inline bool has_si_pid_and_uid (struct kernel_siginfo *info) +{ +bool ret = false; +switch (siginfo_layout (info->si_signo, info->si_code)) { +case SIL_KILL : +case SIL_CHLD : +case SIL_RT : + ret = true; +break ; +case SIL_TIMER : +case SIL_POLL : +case SIL_FAULT : +case SIL_FAULT_MCEERR : +case SIL_FAULT_BNDERR : +case SIL_FAULT_PKUERR : +case SIL_SYS : + ret = false; +break ; + } +return ret; +} +static int send_signal (int sig,struct kernel_siginfo *info,struct task_struct *t,enum pid_type type) {
@@ -1205,7 +1205,20 @@ static int send_signal(int sig, struct kernel_siginfo *info, struct task_struct from_ancestor_ns =si_fromuser (info) && !task_pid_nr_ns (current,task_active_pid_ns (t));#endif +if (!is_si_special (info) &&has_si_pid_and_uid (info)) { +struct user_namespace *t_user_ns; +rcu_read_lock (); + t_user_ns =task_cred_xxx (t, user_ns); +if (current_user_ns () != t_user_ns) { +kuid_t uid =make_kuid (current_user_ns (), info->si_uid); + info->si_uid =from_kuid_munged (t_user_ns, uid); + } +rcu_read_unlock (); + +if (!task_pid_nr_ns (current,task_active_pid_ns (t))) + info->si_pid =0 ; + }return __send_signal (sig, info, t, type, from_ancestor_ns); }
Signature · 1 line
2.21.0
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [REVIEW][PATCH 01/26] signal: Correct namespace fixups of si_pid and si_uid
Quoted 101 lines · Sasha Levin
Hi,
[This is an automated email]
This commit has been processed because it contains a "Fixes:" tag,
fixing commit:6588c1e3ff014signals:SI_USER: Masqueradesi_pidwhen crossing pid ns boundary.The bot has tested the following trees: v5.1.4, v5.0.18, v4.19.45, v4.14.121, v4.9.178, v4.4.180, v3.18.140.
v5.1.4: Build OK!
v5.0.18: Build OK!
v4.19.45: Failed to apply! Possible dependencies:
4cd2e0e70af68("signal: Introducecopy_siginfo_from_userand use it's return value")ae7795bc6187a("signal: Distinguish betweenkernel_siginfoand siginfo")efc463adbccf7("signal: Simplifytracehook_report_syscall_exit")v4.14.121: Failed to apply! Possible dependencies:
212a36a17efe4("signal: Unify and correctcopy_siginfo_from_user32")
3eb0f5193b497("signal: Ensure every siginfo we send has all bits initialized")
3f7c86b2382ea("arm64: Updatefault_infotable with new exception types")
526c3ddb6aa27("signal/arm64: Document conflicts withSI_USERand SIGFPE,SIGTRAP,SIGBUS")532826f3712b6("arm64: Mirror arm for unimplemented compat syscalls")
6b4f3d01052a4("usb, signal, security: only pass the cred, not the secid, tokill_pid_info_as_credandsecurity_task_kill")92ff0674f5d80("arm64: mm: Rework unhandled user pagefaults to callarm64_force_sig_info")ae7795bc6187a("signal: Distinguish betweenkernel_siginfoand siginfo")
af40ff687bc9d("arm64: signal: Ensuresi_codeis valid for all fault signals")
b713da69e4c91("signal: unifycompat_siginfo_t")
ea64d5acc8f03("signal: Unify and correctcopy_siginfo_to_user32")
efc463adbccf7("signal: Simplifytracehook_report_syscall_exit")v4.9.178: Failed to apply! Possible dependencies:
359566faefa85("kernel_wait4()/kernel_waitid(): delay copying status to userland")4c48abe91be03("waitid(): switch copyout of siginfo tounsafe_put_user()")4e2648db9c5f7("ARM: remove indirection ofasm/mach-types.h")
4f4ddad395b04("nios2: putsetup.hin uapi")
53d3eaa315082("posix_cpu_timers: Move theadd_device_randomness()call to a proper place")67d7ddded322d("waitid(2): leave copyout of siginfo to syscall itself")6bc51cbaa9d75("signal: Remove non-uapi <asm/siginfo.h>")
7e95a225901a5("move compat wait4 and waitid next to native variants")80dce5e374930("signal/ia64: Document a conflict withSI_USERwith SIGFPE")8f95c90ceb541("sched/wait, RCU: Introduce rcuwait machinery")
96a8fae0fe094("ARM: convert to generated system call tables")
ae7795bc6187a("signal: Distinguish betweenkernel_siginfoand siginfo")b9253a43370e8("signal: Movecopy_siginfo_to_userto <linux/signal.h>")cc731525f26af("signal: Remove kernel interalsi_codemagic")
cc9f72e474a4d("signal/sparc: Document a conflict withSI_USERwith SIGFPE")ce72a16fa705f("wait4(2)/waitid(2): separate copying rusage to userland")d08477aa975e9("fcntl: Don't use ambiguousSIG_POLLsi_codes")
e2bd64d92a10f("signal/alpha: Document a conflict withSI_USERfor SIGTRAP")ea1b75cf91380("signal/mips: Document a conflict withSI_USERwith SIGFPE")ea64d5acc8f03("signal: Unify and correctcopy_siginfo_to_user32")v4.4.180: Failed to apply! Possible dependencies:
2b5e869ecfcb3("MIPS: ELF: Interpret the NAN2008 file header flag")4f4acc9472e54("parisc: Fix SIGSYS signals in compat case")5050e91fa650e("MIPS: Support sendingSIG_SYSto 32bit userspace from 64bit kernel")5fa393c857195("MIPS: Break downcacheops.hdefinitions")6846351052e68("x86/signal: Add SA_{X32,IA32}_ABIsa_flags")694977006a7ba("MIPS: Use enums to makeasm/pgtable-bits.hreadable")745f355878462("MIPS: mm: Unifypte_pagedefinition")
780602d740fc0("MIPS: mm: Standardise on_PAGE_NO_READ, drop_PAGE_READ")7939469da29a8("MIPS64: signal: Fix o32 sigaction syscall")7b2cb64f91f25("MIPS: mm: Fix MIPS32 36b physical addressing (alchemy, netlogic)")80dce5e374930("signal/ia64: Document a conflict withSI_USERwith SIGFPE")97f2645f358b4("tree-wide: replaceconfig_enabled()withIS_ENABLED()")a4455082dc6f0("x86/signals: Add missingsignal_compatcode for x86 features")a60ae81e5e591("MIPS: CM: Fixmips_cm_max_vp_widthfor UP kernels")ae7795bc6187a("signal: Distinguish betweenkernel_siginfoand siginfo")b1b4fad5cc678("MIPS: seccomp: Support compat with both O32 and N32")b27873702b060("mips, thp: remove infrastructure for handling splitting PMDs")b2edcfc814017("MIPS: Loongson: Add Loongson-3A R2 basic support")cc731525f26af("signal: Remove kernel interalsi_codemagic")cc9f72e474a4d("signal/sparc: Document a conflict withSI_USERwith SIGFPE")e2bd64d92a10f("signal/alpha: Document a conflict withSI_USERfor SIGTRAP")ea1b75cf91380("signal/mips: Document a conflict withSI_USERwith SIGFPE")ea64d5acc8f03("signal: Unify and correctcopy_siginfo_to_user32")v3.18.140: Failed to apply! Possible dependencies:
1a3d59579b9f4("MIPS: Tidy up FPU context switching")
304acb717e5b6("MIPS: Set `si_code' for SIGFPE signals sent from emulation too")4227a2d4efc9c("MIPS: Support for hybrid FPRs")
443c44032a54f("MIPS: Always clear FCSR cause bits after emulation")4a7c2371823a4("MIPS: Reindent R6 RI exception emulation")53f037b08b5be("ia64: Sync struct siginfo with general version")5a1aca4469fdc("MIPS: Fix FCSR Cause bit handling for correct SIGFPE issue")5f9f41c474bef("MIPS: kernel: Prepare the JR instruction for emulation on MIPS R6")7c151d3d5d7a0("MIPS: Make use of the ERETNC instruction on MIPS R6")80dce5e374930("signal/ia64: Document a conflict withSI_USERwith SIGFPE")9cc719ab3f4f6("MIPS: MSA: bugfix - disable MSA correctly for new threads/processes.")ae7795bc6187a("signal: Distinguish betweenkernel_siginfoand siginfo")b0a668fb2038d("MIPS: kernel: mips-r2-to-r6-emul: Add R2 emulator for MIPS R6")cc5e9097c9aad("arm64: add SIGSYS siginfo for compat task")cc731525f26af("signal: Remove kernel interalsi_codemagic")e2bd64d92a10f("signal/alpha: Document a conflict withSI_USERfor SIGTRAP")ea1b75cf91380("signal/mips: Document a conflict withSI_USERwith SIGFPE")ea64d5acc8f03("signal: Unify and correctcopy_siginfo_to_user32")ed2d72c1eb364("MIPS: Respect the FCSR exception mask for `si_code'")f51246efee2b6("MIPS: Get rid offinish_arch_switch().")
fad0bfdb893ac("MIPS:mips-r2-to-r6-emul.h: Inline empty `mipsr2_decoder'")
Quoted 1 line
How should we proceed with this patch?
I have not had any reports of anyone having problems, and this only triggers when signals traverse a pid or a user namespace boundary.
So while this is indeed a fix I think the usual best effort backport will be fine.
If backporting further is desired it looks like the only real dependency is the addition of the function siginfo_layout. So it should not be as difficult as the automated scripts suggests.
Eric
PATCH 2/26 signal/ptrace: Simplify and fix PTRACE_KILL
In reply to Eric W. BiedermanSince PTRACE_KILL was introduced in 1.1.78 it has only worked if the process is stopped in do_signal. On a ptraced but non-stopped process PTRACE_KILL has always returned success and done nothing.
Separate the noop case of PTRACE_KILL from the case where it does nothing. This fixes the fact that taking sighand lock in ptrace_resume is not safe if the process could be in the middle of exec or do_exit. The current test for child->state is insufficient to prevent that race.
With the code explicitly implementing the noop people maintaining ptrace no longer need to worry what happens in PTRACE_KILL if the process is not stopped.
The alternative fix is to change the implementation of PTRACE_KILL to just be send_sig(SIGKILL, child, 1); But I don't know if anything depends on the current documented behavior.
--- kernel/ptrace.c | 43 ++++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 17 deletions(-)
kernel/ptrace.c +26 -17
@@ -212,15 +212,18 @@ static void ptrace_unfreeze_traced(struct task_struct *task)* * Check whether @child is being ptraced by %current and ready for further * ptrace operations. If @ignore_state is %false, @child also should be in -* %TASK_TRACED state and on return the child is guaranteed to be traced -* and not executing. If @ignore_state is %true, @child can be in any -* state. +* %TASK_TRACED state and on succesful return the child is guaranteed to be +* traced and not executing. If @ignore_state is %true, @child can be in +* any state on succesful return. * * CONTEXT: * Grabs and releases tasklist_lock and @child->sighand->siglock. * * RETURNS: -* 0 on success, -ESRCH if %child is not ready. +* 0 on success, +* -ESRCH if %child is not traced +* -EAGAIN if %child can not be frozen +* -EBUSY if the wait for %child fails */ static int ptrace_check_attach (struct task_struct *child,bool ignore_state) {
@@ -240,6 +243,7 @@ static int ptrace_check_attach(struct task_struct *child, bool ignore_state)* child->sighand can't be NULL, release_task() * does ptrace_unlink() before __exit_signal(). */ + ret = -EAGAIN ;if (ignore_state ||ptrace_freeze_traced (child)) ret =0 ; }
@@ -253,7 +257,7 @@ static int ptrace_check_attach(struct task_struct *child, bool ignore_state)* so we should not worry about leaking __TASK_TRACED. */ WARN_ON (child->state == __TASK_TRACED); - ret = -ESRCH ; + ret = -EBUSY ; } }
@@ -1074,8 +1078,6 @@ int ptrace_request(struct task_struct *child, long request,return ptrace_resume (child, request, data);case PTRACE_KILL : -if (child->exit_state)/* already dead */ -return 0 ;return ptrace_resume (child, request,SIGKILL );#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
@@ -1147,14 +1149,17 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr, goto out_put_task_struct; } - ret =ptrace_check_attach (child, request ==PTRACE_KILL || - request ==PTRACE_INTERRUPT ); -if (ret <0 ) - goto out_put_task_struct; - - ret =arch_ptrace (child, request, addr, data); -if (ret || request !=PTRACE_DETACH ) -ptrace_unfreeze_traced (child); + ret =ptrace_check_attach (child, request ==PTRACE_INTERRUPT ); +if (!ret) { + ret =arch_ptrace (child, request, addr, data); +if (ret || request !=PTRACE_DETACH ) +ptrace_unfreeze_traced (child); + } +/* PTRACE_KILL is a noop when not attached */ +else if ((request ==PTRACE_KILL ) && (ret != -ESRCH )) + ret =0 ; +else + ret = -ESRCH ; out_put_task_struct:put_task_struct (child);
@@ -1292,13 +1297,17 @@ COMPAT_SYSCALL_DEFINE4(ptrace, compat_long_t, request, compat_long_t, pid, goto out_put_task_struct; } - ret =ptrace_check_attach (child, request ==PTRACE_KILL || - request ==PTRACE_INTERRUPT ); + ret =ptrace_check_attach (child, request ==PTRACE_INTERRUPT );if (!ret) { ret =compat_arch_ptrace (child, request, addr, data);if (ret || request !=PTRACE_DETACH )ptrace_unfreeze_traced (child); } +/* PTRACE_KILL is a noop when not attached */ +else if ((request ==PTRACE_KILL ) && (ret != -ESRCH )) + ret =0 ; +else + ret = -ESRCH ; out_put_task_struct:put_task_struct (child);
Signature · 1 line
2.21.0
Re: [REVIEW][PATCH 02/26] signal/ptrace: Simplify and fix PTRACE_KILL
I am dropping this one for now, as there are no dependencies with the other patches, and this probably deserves some discussion on it's own.
Eric
Quoted 125 lines · Eric W. Biederman
Since
PTRACE_KILLwas introduced in 1.1.78 it has only worked if the process is stopped indo_signal. On a ptraced but non-stopped processPTRACE_KILLhas always returned success and done nothing.Separate the noop case of
PTRACE_KILLfrom the case where it does nothing. This fixes the fact that taking sighand lock inptrace_resumeis not safe if the process could be in the middle of exec ordo_exit. The current test forchild->stateis insufficient to prevent that race.With the code explicitly implementing the noop people maintaining ptrace no longer need to worry what happens in
PTRACE_KILLif the process is not stopped.The alternative fix is to change the implementation of
PTRACE_KILLto just besend_sig(SIGKILL, child, 1); But I don't know if anything depends on the current documented behavior.Cc Oleg Nesterov <[email protected]>Fixes b72c186999e6 ("ptrace: fix race between ptrace_resume() and wait_task_stopped()")Signed-off-by "Eric W. Biederman" <[email protected]>--- kernel/ptrace.c | 43 ++++++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 17 deletions(-)kernel/ptrace.c +26
-17@@ -212,15 +212,18 @@ static void ptrace_unfreeze_traced(struct task_struct *task)* * Check whether @child is being ptraced by %current and ready for further * ptrace operations. If @ignore_state is %false, @child also should be in -* %TASK_TRACED state and on return the child is guaranteed to be traced -* and not executing. If @ignore_state is %true, @child can be in any -* state. +* %TASK_TRACED state and on succesful return the child is guaranteed to be +* traced and not executing. If @ignore_state is %true, @child can be in +* any state on succesful return. * * CONTEXT: * Grabs and releases tasklist_lock and @child->sighand->siglock. * * RETURNS: -* 0 on success, -ESRCH if %child is not ready. +* 0 on success, +* -ESRCH if %child is not traced +* -EAGAIN if %child can not be frozen +* -EBUSY if the wait for %child fails */ static int ptrace_check_attach (struct task_struct *child,bool ignore_state) {@@ -240,6 +243,7 @@ static int ptrace_check_attach(struct task_struct *child, bool ignore_state)* child->sighand can't be NULL, release_task() * does ptrace_unlink() before __exit_signal(). */ + ret = -EAGAIN ;if (ignore_state ||ptrace_freeze_traced (child)) ret =0 ; }@@ -253,7 +257,7 @@ static int ptrace_check_attach(struct task_struct *child, bool ignore_state)* so we should not worry about leaking __TASK_TRACED. */ WARN_ON (child->state == __TASK_TRACED); - ret = -ESRCH ; + ret = -EBUSY ; } }@@ -1074,8 +1078,6 @@ int ptrace_request(struct task_struct *child, long request,return ptrace_resume (child, request, data);case PTRACE_KILL : -if (child->exit_state)/* already dead */ -return 0 ;return ptrace_resume (child, request,SIGKILL );#ifdef CONFIG_HAVE_ARCH_TRACEHOOK @@ -1147,14 +1149,17 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr, goto out_put_task_struct; } - ret =ptrace_check_attach (child, request ==PTRACE_KILL || - request ==PTRACE_INTERRUPT ); -if (ret <0 ) - goto out_put_task_struct; - - ret =arch_ptrace (child, request, addr, data); -if (ret || request !=PTRACE_DETACH ) -ptrace_unfreeze_traced (child); + ret =ptrace_check_attach (child, request ==PTRACE_INTERRUPT ); +if (!ret) { + ret =arch_ptrace (child, request, addr, data); +if (ret || request !=PTRACE_DETACH ) +ptrace_unfreeze_traced (child); + } +/* PTRACE_KILL is a noop when not attached */ +else if ((request ==PTRACE_KILL ) && (ret != -ESRCH )) + ret =0 ; +else + ret = -ESRCH ; out_put_task_struct:put_task_struct (child);@@ -1292,13 +1297,17 @@ COMPAT_SYSCALL_DEFINE4(ptrace, compat_long_t, request, compat_long_t, pid, goto out_put_task_struct; } - ret =ptrace_check_attach (child, request ==PTRACE_KILL || - request ==PTRACE_INTERRUPT ); + ret =ptrace_check_attach (child, request ==PTRACE_INTERRUPT );if (!ret) { ret =compat_arch_ptrace (child, request, addr, data);if (ret || request !=PTRACE_DETACH )ptrace_unfreeze_traced (child); } +/* PTRACE_KILL is a noop when not attached */ +else if ((request ==PTRACE_KILL ) && (ret != -ESRCH )) + ret =0 ; +else + ret = -ESRCH ; out_put_task_struct:put_task_struct (child);
PATCH 3/26 signal/arm64: Use force_sig not force_sig_fault for SIGKILL
In reply to Eric W. BiedermanIt really only matters to debuggers but the SIGKILL does not have any si_codes that use the fault member of the siginfo union. Correct this the simple way and call force_sig instead of force_sig_fault when the signal is SIGKILL.
--- arch/arm64/kernel/traps.c | 5 +++++ 1 file changed, 5 insertions(+)
arch/arm64/kernel/traps.c +5 -0
@@ -282,6 +282,11 @@ void arm64_notify_die(const char *str, struct pt_regs *regs, current->thread.fault_address =0 ; current->thread.fault_code = err; +if (signo ==SIGKILL ) { +arm64_show_signal (signo, str); +force_sig (signo, current); +return ; + }arm64_force_sig_fault (signo, sicode, addr, str); }else {die (str, regs, err);
Signature · 1 line
2.21.0
Re: [REVIEW][PATCH 03/26] signal/arm64: Use force_sig not force_sig_fault for SIGKILL
Quoted 20 lines · Eric W. Biederman
It really only matters to debuggers but the SIGKILL does not have any
si_codesthat use the fault member of the siginfo union. Correct this the simple way and callforce_siginstead offorce_sig_faultwhen the signal is SIGKILL.Cc Dave Martin <[email protected]>Cc James Morse <[email protected]>Cc Will Deacon <[email protected]>Fixes af40ff687bc9 ("arm64: signal: Ensure si_code is valid for all fault signals")Signed-off-by "Eric W. Biederman" <[email protected]>--- arch/arm64/kernel/traps.c | 5 +++++ 1 file changed, 5 insertions(+)arch/arm64/kernel/traps.c +0
-0
arch/arm64/kernel/traps.c void arm64_notify_die(const char *str, struct pt_regs *regs, · line 289
Quoted 8 lines
arch/arm64/kernel/traps.c +5
-0@@ -282,6 +282,11 @@ void arm64_notify_die(const char *str, struct pt_regs *regs, current->thread.fault_address =0 ; current->thread.fault_code = err; +if (signo ==SIGKILL ) { +arm64_show_signal (signo, str); +force_sig (signo, current); +return ; + }
I know it's a bit of a misnomer, but I'd rather do this check inside arm64_force_sig_fault, since I think we have other callers (e.g. do_bad_area()) which also blindly pass in SIGKILL here.
We could rename the thing if necessary.
Will
Re: [REVIEW][PATCH 03/26] signal/arm64: Use force_sig not force_sig_fault for SIGKILL
Quoted 24 lines · Will Deacon
Quoted 23 lines · Eric W. Biederman
It really only matters to debuggers but the SIGKILL does not have any
si_codesthat use the fault member of the siginfo union. Correct this the simple way and callforce_siginstead offorce_sig_faultwhen the signal is SIGKILL.Cc Dave Martin <[email protected]>Cc James Morse <[email protected]>Cc Will Deacon <[email protected]>Fixes af40ff687bc9 ("arm64: signal: Ensure si_code is valid for all fault signals")Signed-off-by "Eric W. Biederman" <[email protected]>--- arch/arm64/kernel/traps.c | 5 +++++ 1 file changed, 5 insertions(+)arch/arm64/kernel/traps.c +0
-0@@ -282,6 +282,11 @@ void arm64_notify_die(const char *str, struct pt_regs *regs, current->thread.fault_address =0 ; current->thread.fault_code = err;
Quoted 9 lines
arch/arm64/kernel/traps.c void arm64_notify_die(const char *str, struct pt_regs *regs, · line 289
Quoted 5 lines
arch/arm64/kernel/traps.c +5
-0+if (signo ==SIGKILL ) { +arm64_show_signal (signo, str); +force_sig (signo, current); +return ; + }I know it's a bit of a misnomer, but I'd rather do this check inside
arm64_force_sig_fault, since I think we have other callers (e.g.do_bad_area()) which also blindly pass in SIGKILL here.
Sigh. You are right.
I thought I had checked for that when I made my change there. But do_bad_area will definitely do that, and that was one of the cases that jumped out at me as needing to be fixed, when I skimmed the arm code.
I will respin this patch to move that lower.
Quoted 1 line
We could rename the thing if necessary.
I would not mind but as long as we aren't misusing the generic bits I won't have alarm bells going of in my head when I look at their users.
Eric
PATCH v2 3/26 signal/arm64: Use force_sig not force_sig_fault for SIGKILL
In reply to Will DeaconI don't think this is userspace visible but SIGKILL does not have any si_codes that use the fault member of the siginfo union. Correct this the simple way and call force_sig instead of force_sig_fault when the signal is SIGKILL.
The two know places where synchronous SIGKILL are generated are do_bad_area and fpsimd_save. The call paths to force_sig_fault are:do_bad_area
arm64_force_sig_fault
force_sig_faultforce_signal_inject
arm64_notify_die
arm64_force_sig_fault
force_sig_fault
Which means correcting this in arm64_force_sig_fault is enough to ensure the arm64 code is not misusing the generic code, which could lead to maintenance problems later.
---
I have also made the corresponding changes to:
09/26 signal: Remove task parameter from force_sig 21/26 signal: Remove the task parameter from force_sig_fault But I will leave off reposting those as for now as the changes are obvious.
arch/arm64/kernel/traps.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
arch/arm64/kernel/traps.c +4 -1
@@ -256,7 +256,10 @@ void arm64_force_sig_fault(int signo, int code, void __user *addr, const char *str) {arm64_show_signal (signo, str); -force_sig_fault (signo, code, addr, current); +if (signo ==SIGKILL ) +force_sig (SIGKILL , current); +else +force_sig_fault (signo, code, addr, current); } void arm64_force_sig_mceerr(int code, void __user *addr, short lsb,
Signature · 1 line
2.21.0.dirty
Re: [REVIEW][PATCHv2 03/26] signal/arm64: Use force_sig not force_sig_fault for SIGKILL
Quoted 5 lines · Eric W. Biederman
arch/arm64/kernel/traps.c +0
-0
arch/arm64/kernel/traps.c void arm64_force_sig_fault(int signo, int code, void __user *addr, · line 263
Quoted 9 lines
arch/arm64/kernel/traps.c +4
-1@@ -256,7 +256,10 @@ void arm64_force_sig_fault(int signo, int code, void __user *addr, const char *str) {arm64_show_signal (signo, str); -force_sig_fault (signo, code, addr, current); +if (signo ==SIGKILL ) +force_sig (SIGKILL , current); +else +force_sig_fault (signo, code, addr, current); }
Are you planning to send this series on, or would you like me to pick this into the arm64 tree?
Will
Re: [REVIEW][PATCHv2 03/26] signal/arm64: Use force_sig not force_sig_fault for SIGKILL
Quoted 18 lines · Will Deacon
Quoted 5 lines · Eric W. Biederman
arch/arm64/kernel/traps.c +0
-0arch/arm64/kernel/traps.c void arm64_force_sig_fault(int signo, int code, void __user *addr, · line 263
Quoted 9 lines
arch/arm64/kernel/traps.c +4
-1@@ -256,7 +256,10 @@ void arm64_force_sig_fault(int signo, int code, void __user *addr, const char *str) {arm64_show_signal (signo, str); -force_sig_fault (signo, code, addr, current); +if (signo ==SIGKILL ) +force_sig (SIGKILL , current); +else +force_sig_fault (signo, code, addr, current); }Acked-by Will Deacon <[email protected]>
Quoted 2 lines
Are you planning to send this series on, or would you like me to pick this into the arm64 tree?
I am planning on taking this through siginfo tree, unless it causes problems.
The rest of my patchset this is a part of is a clean up to remove the task pointer which is always current from all of the force_sig calls.
Eric
Re: [REVIEW][PATCHv2 03/26] signal/arm64: Use force_sig not force_sig_fault for SIGKILL
Quoted 20 lines · Eric W. Biederman
Quoted 18 lines · Will Deacon
Quoted 5 lines · Eric W. Biederman
arch/arm64/kernel/traps.c +0
-0arch/arm64/kernel/traps.c void arm64_force_sig_fault(int signo, int code, void __user *addr, · line 263
Quoted 9 lines
arch/arm64/kernel/traps.c +4
-1@@ -256,7 +256,10 @@ void arm64_force_sig_fault(int signo, int code, void __user *addr, const char *str) {arm64_show_signal (signo, str); -force_sig_fault (signo, code, addr, current); +if (signo ==SIGKILL ) +force_sig (SIGKILL , current); +else +force_sig_fault (signo, code, addr, current); }Acked-by Will Deacon <[email protected]>
Quoted 5 lines
Quoted 2 lines
Are you planning to send this series on, or would you like me to pick this into the arm64 tree?
I am planning on taking this through siginfo tree, unless it causes problems.
Okey doke, it would just be nice to see this patch land in 5.2, that's all.
Will
Re: [REVIEW][PATCHv2 03/26] signal/arm64: Use force_sig not force_sig_fault for SIGKILL
Quoted 21 lines · Will Deacon
Quoted 20 lines · Eric W. Biederman
Quoted 18 lines · Will Deacon
Quoted 5 lines · Eric W. Biederman
arch/arm64/kernel/traps.c +0
-0arch/arm64/kernel/traps.c void arm64_force_sig_fault(int signo, int code, void __user *addr, · line 263
Quoted 9 lines
arch/arm64/kernel/traps.c +4
-1@@ -256,7 +256,10 @@ void arm64_force_sig_fault(int signo, int code, void __user *addr, const char *str) {arm64_show_signal (signo, str); -force_sig_fault (signo, code, addr, current); +if (signo ==SIGKILL ) +force_sig (SIGKILL , current); +else +force_sig_fault (signo, code, addr, current); }Acked-by Will Deacon <[email protected]>
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Are you planning to send this series on, or would you like me to pick this into the arm64 tree?
I am planning on taking this through siginfo tree, unless it causes problems.
Okey doke, it would just be nice to see this patch land in 5.2, that's all.
As this does not appear to have any real world consequences I am aiming at 5.3. If someone else would like to take it and feed it to Linus sooner I won't object.
Eric
Re: [REVIEW][PATCHv2 03/26] signal/arm64: Use force_sig not force_sig_fault for SIGKILL
Quoted 29 lines · Eric W. Biederman
Quoted 27 lines · Will Deacon
Quoted 25 lines · Eric W. Biederman
Quoted 18 lines · Will Deacon
Quoted 5 lines · Eric W. Biederman
arch/arm64/kernel/traps.c +0
-0arch/arm64/kernel/traps.c void arm64_force_sig_fault(int signo, int code, void __user *addr, · line 263
Quoted 9 lines
arch/arm64/kernel/traps.c +4
-1@@ -256,7 +256,10 @@ void arm64_force_sig_fault(int signo, int code, void __user *addr, const char *str) {arm64_show_signal (signo, str); -force_sig_fault (signo, code, addr, current); +if (signo ==SIGKILL ) +force_sig (SIGKILL , current); +else +force_sig_fault (signo, code, addr, current); }Acked-by Will Deacon <[email protected]>Quoted 2 lines
Are you planning to send this series on, or would you like me to pick this into the arm64 tree?
I am planning on taking this through siginfo tree, unless it causes problems.
Quoted 6 lines
Quoted 2 lines
Okey doke, it would just be nice to see this patch land in 5.2, that's all.
As this does not appear to have any real world consequences I am aiming at 5.3. If someone else would like to take it and feed it to Linus sooner I won't object.
Thanks. I've picked this patch up as part of the arm64 fixes I plan to send for -rc3.
Will
Re: [REVIEW][PATCHv2 03/26] signal/arm64: Use force_sig not force_sig_fault for SIGKILL
Quoted 33 lines · Will Deacon
Quoted 32 lines · Eric W. Biederman
Quoted 29 lines · Will Deacon
Quoted 20 lines · Eric W. Biederman
Quoted 18 lines · Will Deacon
Quoted 5 lines · Eric W. Biederman
arch/arm64/kernel/traps.c +0
-0arch/arm64/kernel/traps.c void arm64_force_sig_fault(int signo, int code, void __user *addr, · line 263
Quoted 9 lines
arch/arm64/kernel/traps.c +4
-1@@ -256,7 +256,10 @@ void arm64_force_sig_fault(int signo, int code, void __user *addr, const char *str) {arm64_show_signal (signo, str); -force_sig_fault (signo, code, addr, current); +if (signo ==SIGKILL ) +force_sig (SIGKILL , current); +else +force_sig_fault (signo, code, addr, current); }Acked-by Will Deacon <[email protected]>Quoted 5 lines
Quoted 2 lines
Are you planning to send this series on, or would you like me to pick this into the arm64 tree?
I am planning on taking this through siginfo tree, unless it causes problems.
Okey doke, it would just be nice to see this patch land in 5.2, that's all.
Quoted 6 lines
Quoted 3 lines
As this does not appear to have any real world consequences I am aiming at 5.3. If someone else would like to take it and feed it to Linus sooner I won't object.
Thanks. I've picked this patch up as part of the arm64 fixes I plan to send for -rc3.
Sounds good.
We might have a trivial conflict between our branches as I am also including this in my for-next branch, as I have further patches that go on to remove the task argument from force_sig and force_sig_fault.
But I don't think it is anything to worry about.
Eric
Re: [REVIEW][PATCH 03/26] signal/arm64: Use force_sig not force_sig_fault for SIGKILL
In reply to Eric W. BiedermanQuoted 4 lines · Eric W. Biederman
It really only matters to debuggers but the SIGKILL does not have any
si_codesthat use the fault member of the siginfo union. Correct this the simple way and callforce_siginstead offorce_sig_faultwhen the signal is SIGKILL.
I haven't fully understood the context for this, but why does it matter what's in siginfo for SIGKILL? My understanding is that userspace (including ptrace) never gets to see it anyway for the SIGKILL case.
Here it feels like SIGKILL is logically a synchronous, thread-targeted
fault: we must ensure that no subsequent insn in current executes (just like other fault signal). In this case, I thought we fall back to SIGKILL not because there is no fault, but because we failed to properly diagnose or report the type of fault that occurred.
So maybe handling it consistently with other faults signals makes sense. The fact that delivery of this signal destroys the process before anyone can look at the resulting siginfo feels like a side-effect rather than something obviously wrong.
The siginfo is potentially useful diagnostic information, that we could subsequently provide a means to access post-mortem.
I just dived in on this single patch, so I may be missing something more fundamental, or just being pedantic...
Cheers
---Dave
Quoted 29 lines
Cc Dave Martin <[email protected]>Cc James Morse <[email protected]>Cc Will Deacon <[email protected]>Fixes af40ff687bc9 ("arm64: signal: Ensure si_code is valid for all fault signals")Signed-off-by "Eric W. Biederman" <[email protected]>--- arch/arm64/kernel/traps.c | 5 +++++ 1 file changed, 5 insertions(+)arch/arm64/kernel/traps.c +5
-0@@ -282,6 +282,11 @@ void arm64_notify_die(const char *str, struct pt_regs *regs, current->thread.fault_address =0 ; current->thread.fault_code = err; +if (signo ==SIGKILL ) { +arm64_show_signal (signo, str); +force_sig (signo, current); +return ; + }arm64_force_sig_fault (signo, sicode, addr, str); }else {die (str, regs, err);Signature · 1 line
2.21.0
Re: [REVIEW][PATCH 03/26] signal/arm64: Use force_sig not force_sig_fault for SIGKILL
Quoted 9 lines · Dave Martin
Quoted 4 lines · Eric W. Biederman
It really only matters to debuggers but the SIGKILL does not have any
si_codesthat use the fault member of the siginfo union. Correct this the simple way and callforce_siginstead offorce_sig_faultwhen the signal is SIGKILL.I haven't fully understood the context for this, but why does it matter what's in siginfo for SIGKILL? My understanding is that userspace (including ptrace) never gets to see it anyway for the SIGKILL case.
Yes. In practice I think it would take tracing or something very exotic to notice anything going wrong because the task will be killed.
Quoted 11 lines
Here it feels like SIGKILL is logically a synchronous, thread-targeted
fault: we must ensure that no subsequent insn in current executes (just like other fault signal). In this case, I thought we fall back to SIGKILL not because there is no fault, but because we failed to properly diagnose or report the type of fault that occurred.So maybe handling it consistently with other faults signals makes sense. The fact that delivery of this signal destroys the process before anyone can look at the resulting siginfo feels like a side-effect rather than something obviously wrong.
Quoted 5 lines
The siginfo is potentially useful diagnostic information, that we could subsequently provide a means to access post-mortem.
I just dived in on this single patch, so I may be missing something more fundamental, or just being pedantic...
Not really. I was working on another cleanup and this usage of SIGKILL came up.
A synchronous thread synchronous fault gets us as far as the forc_sig family of functions. That only leaves the question of which union member in struct siginfo we are using. The union members are _kill, _fault, _timer, _rt, _sigchld, _sigfault, _sigpoll, and _sigsys.
As it has prove quite error prone for people to fill out struct siginfo in the past by hand, I have provided a couple of helper functions for the common cases that come up such as: force_sig_fault, force_sig_mceerr, force_sig_bnderr, force_sig_pkuerr. Each of those helper functions takes the information needed to fill out the union member of struct siginfo that kind of fault corresponds to.
For the SIGKILL case the only si_code I see being passed SI_KERNEL. The SI_KERNEL si_code corresponds to the _kill union member while force_sig_fault fills in fields for the _fault union member.
Because of the mismatch of which union member SIGKILL should be using and the union member force_sig_fault applies alarm bells ring in my head when I read the current arm64 kernel code. Somewhat doubly so because the other fields in passed to force_sig_fault appear to be somewhat random when SIGKILL is the signal.
So I figured let's preserve the usage of SIGKILL as a synchronous exception. That seems legitimate and other folks do that as well but let's use force_sig instead of force_sig_fault instead. I don't know if userspace will notice but at the very least we won't be providing a bad example for other kernel code to follow and we won't wind up be making assumptions that are true today and false tomorrow when some implementation detail changes.
For imformation on what signals and si_codes correspond to which union members you can look at siginfo_layout. That function is the keeper of the magic decoder key. Currently the only two si_codes defined for SIGKILL are SI_KERNEL and SI_USER both of which correspond to a _kill union member.
Eric
Quoted 32 lines
Cheers
---DaveQuoted 29 lines
Cc Dave Martin <[email protected]>Cc James Morse <[email protected]>Cc Will Deacon <[email protected]>Fixes af40ff687bc9 ("arm64: signal: Ensure si_code is valid for all fault signals")Signed-off-by "Eric W. Biederman" <[email protected]>--- arch/arm64/kernel/traps.c | 5 +++++ 1 file changed, 5 insertions(+)arch/arm64/kernel/traps.c +5
-0@@ -282,6 +282,11 @@ void arm64_notify_die(const char *str, struct pt_regs *regs, current->thread.fault_address =0 ; current->thread.fault_code = err; +if (signo ==SIGKILL ) { +arm64_show_signal (signo, str); +force_sig (signo, current); +return ; + }arm64_force_sig_fault (signo, sicode, addr, str); }else {die (str, regs, err);Signature · 1 line
2.21.0
Re: [REVIEW][PATCH 03/26] signal/arm64: Use force_sig not force_sig_fault for SIGKILL
Quoted 65 lines · Eric W. Biederman
Quoted 9 lines · Dave Martin
Quoted 4 lines · Eric W. Biederman
It really only matters to debuggers but the SIGKILL does not have any
si_codesthat use the fault member of the siginfo union. Correct this the simple way and callforce_siginstead offorce_sig_faultwhen the signal is SIGKILL.I haven't fully understood the context for this, but why does it matter what's in siginfo for SIGKILL? My understanding is that userspace (including ptrace) never gets to see it anyway for the SIGKILL case.
Yes. In practice I think it would take tracing or something very exotic to notice anything going wrong because the task will be killed.
Quoted 11 lines
Here it feels like SIGKILL is logically a synchronous, thread-targeted
fault: we must ensure that no subsequent insn in current executes (just like other fault signal). In this case, I thought we fall back to SIGKILL not because there is no fault, but because we failed to properly diagnose or report the type of fault that occurred.So maybe handling it consistently with other faults signals makes sense. The fact that delivery of this signal destroys the process before anyone can look at the resulting siginfo feels like a side-effect rather than something obviously wrong.
Quoted 5 lines
The siginfo is potentially useful diagnostic information, that we could subsequently provide a means to access post-mortem.
I just dived in on this single patch, so I may be missing something more fundamental, or just being pedantic...
Not really. I was working on another cleanup and this usage of SIGKILL came up.
A synchronous thread synchronous fault gets us as far as the
forc_sigfamily of functions. That only leaves the question of which union member in struct siginfo we are using. The union members are_kill,_fault,_timer,_rt,_sigchld,_sigfault,_sigpoll, and_sigsys.As it has prove quite error prone for people to fill out struct siginfo in the past by hand, I have provided a couple of helper functions for the common cases that come up such as:
force_sig_fault,force_sig_mceerr,force_sig_bnderr,force_sig_pkuerr. Each of those helper functions takes the information needed to fill out the union member of struct siginfo that kind of fault corresponds to.For the SIGKILL case the only
si_codeI see being passedSI_KERNEL. TheSI_KERNELsi_codecorresponds to the_killunion member whileforce_sig_faultfills in fields for the_faultunion member.Because of the mismatch of which union member SIGKILL should be using and the union member
force_sig_faultapplies alarm bells ring in my head when I read the current arm64 kernel code. Somewhat doubly so because the other fields in passed toforce_sig_faultappear to be somewhat random when SIGKILL is the signal.So I figured let's preserve the usage of SIGKILL as a synchronous exception. That seems legitimate and other folks do that as well but let's use
force_siginstead offorce_sig_faultinstead. I don't know if userspace will notice but at the very least we won't be providing a bad example for other kernel code to follow and we won't wind up be making assumptions that are true today and false tomorrow when some implementation detail changes.
Quoted 5 lines
For imformation on what signals and
si_codescorrespond to which union members you can look atsiginfo_layout. That function is the keeper of the magic decoder key. Currently the only twosi_codesdefined for SIGKILL areSI_KERNELandSI_USERboth of which correspond to a_killunion member.
I see. Assuming we cannot have a dummy internal si_code for this special case (probably a bad idea), I think Will's suggestion of at least pushing the special case handling down into arm64_force_sig_fault() is probably a bit cleaner here, expecially if other callers of that function may pass in SIGKILL (I haven't looked though).
Cheers
---Dave
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
Re: [REVIEW][PATCH 03/26] signal/arm64: Use force_sig not force_sig_fault for SIGKILL
Quoted 72 lines · Dave P Martin
Quoted 65 lines · Eric W. Biederman
Quoted 9 lines · Dave Martin
Quoted 4 lines · Eric W. Biederman
It really only matters to debuggers but the SIGKILL does not have any
si_codesthat use the fault member of the siginfo union. Correct this the simple way and callforce_siginstead offorce_sig_faultwhen the signal is SIGKILL.I haven't fully understood the context for this, but why does it matter what's in siginfo for SIGKILL? My understanding is that userspace (including ptrace) never gets to see it anyway for the SIGKILL case.
Yes. In practice I think it would take tracing or something very exotic to notice anything going wrong because the task will be killed.
Quoted 11 lines
Here it feels like SIGKILL is logically a synchronous, thread-targeted
fault: we must ensure that no subsequent insn in current executes (just like other fault signal). In this case, I thought we fall back to SIGKILL not because there is no fault, but because we failed to properly diagnose or report the type of fault that occurred.So maybe handling it consistently with other faults signals makes sense. The fact that delivery of this signal destroys the process before anyone can look at the resulting siginfo feels like a side-effect rather than something obviously wrong.
Quoted 5 lines
The siginfo is potentially useful diagnostic information, that we could subsequently provide a means to access post-mortem.
I just dived in on this single patch, so I may be missing something more fundamental, or just being pedantic...
Not really. I was working on another cleanup and this usage of SIGKILL came up.
A synchronous thread synchronous fault gets us as far as the
forc_sigfamily of functions. That only leaves the question of which union member in struct siginfo we are using. The union members are_kill,_fault,_timer,_rt,_sigchld,_sigfault,_sigpoll, and_sigsys.As it has prove quite error prone for people to fill out struct siginfo in the past by hand, I have provided a couple of helper functions for the common cases that come up such as:
force_sig_fault,force_sig_mceerr,force_sig_bnderr,force_sig_pkuerr. Each of those helper functions takes the information needed to fill out the union member of struct siginfo that kind of fault corresponds to.For the SIGKILL case the only
si_codeI see being passedSI_KERNEL. TheSI_KERNELsi_codecorresponds to the_killunion member whileforce_sig_faultfills in fields for the_faultunion member.Because of the mismatch of which union member SIGKILL should be using and the union member
force_sig_faultapplies alarm bells ring in my head when I read the current arm64 kernel code. Somewhat doubly so because the other fields in passed toforce_sig_faultappear to be somewhat random when SIGKILL is the signal.So I figured let's preserve the usage of SIGKILL as a synchronous exception. That seems legitimate and other folks do that as well but let's use
force_siginstead offorce_sig_faultinstead. I don't know if userspace will notice but at the very least we won't be providing a bad example for other kernel code to follow and we won't wind up be making assumptions that are true today and false tomorrow when some implementation detail changes.Quoted 5 lines
For imformation on what signals and
si_codescorrespond to which union members you can look atsiginfo_layout. That function is the keeper of the magic decoder key. Currently the only twosi_codesdefined for SIGKILL areSI_KERNELandSI_USERboth of which correspond to a_killunion member.
Quoted 6 lines
I see. Assuming we cannot have a dummy internal
si_codefor this special case (probably a bad idea), I think Will's suggestion of at least pushing the special case handling down intoarm64_force_sig_fault()is probably a bit cleaner here, expecially if other callers of that function may pass in SIGKILL (I haven't looked though).
Done in my v2 version of this patch.
Eric
PATCH 4/26 signal/drbd: Use send_sig not force_sig
In reply to Eric W. BiedermanThe drbd module exclusively sends signals to kernel threads it creates with kthread_create. These kernel threads do not block or ignore signals (only flush signals after they have been delivered), nor can drbd threads possibly be pid namespace init processes so the extra work that force_sig performs that send_sig does not is unnecessary.
Further force_sig is for delivering synchronous signals (aka exceptions). The locking in force_sig is not prepared to deal with running processes, as tsk->sighand may change during exec for a running process.
In short it is not only unnecessary for drbd to use force_sig it is semantically wrong.
With drbd using send_sig it becomes easier to maintain force_sig as only synchronous signals need to be considered.
--- drivers/block/drbd/drbd_int.h | 2 +- drivers/block/drbd/drbd_main.c | 2 +- drivers/block/drbd/drbd_nl.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/block/drbd/drbd_int.h +1 -1
@@ -1972,7 +1972,7 @@ static inline void wake_ack_receiver(struct drbd_connection *connection) {struct task_struct *task = connection->ack_receiver.task;if (task &&get_t_state (&connection->ack_receiver) ==RUNNING ) -force_sig (SIGXCPU , task); +send_sig (SIGXCPU , task,1 ); }static inline void request_ping (struct drbd_connection *connection)
drivers/block/drbd/drbd_main.c +1 -1
@@ -477,7 +477,7 @@ void _drbd_thread_stop(struct drbd_thread *thi, int restart, int wait)smp_mb ();init_completion (&thi->stop);if (thi->task != current) -force_sig (DRBD_SIGKILL , thi->task); +send_sig (DRBD_SIGKILL , thi->task,1 ); }spin_unlock_irqrestore (&thi->t_lock, flags);
drivers/block/drbd/drbd_nl.c +1 -1
@@ -611,7 +611,7 @@ void conn_try_outdate_peer_async(struct drbd_connection *connection)struct task_struct *opa;kref_get (&connection->kref); -/* We may just have force_sig()'ed this thread +/* We may have just sent a signal to this thread * to get it out of some blocking network function. * Clear signals; otherwise kthread_run(), which internally uses * wait_on_completion_killable(), will mistake our pending signal
Signature · 1 line
2.21.0
PATCH 5/26 signal/bpfilter: Fix bpfilter_kernl to use send_sig not force_sig
In reply to Eric W. BiedermanThe locking in force_sig_info is not prepared to deal with a task that exits or execs (as sighand may change). As force_sig is only built to handle synchronous exceptions.
Further the function force_sig_info changes the signal state if the signal is ignored, or blocked or if SIGNAL_UNKILLABLE will prevent the delivery of the signal. The signal SIGKILL can not be ignored and can not be blocked and SIGNAL_UNKILLABLE won't prevent it from being delivered.
So using force_sig rather than send_sig for SIGKILL is pointless.
Because it won't impact the sending of the signal and and because using force_sig is wrong, replace force_sig with send_sig.
--- net/bpfilter/bpfilter_kern.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/bpfilter/bpfilter_kern.c +1 -1
@@ -22,7 +22,7 @@ static void shutdown_umh(void) tsk =get_pid_task (find_vpid (bpfilter_ops.info.pid),PIDTYPE_PID );if (tsk) { -force_sig (SIGKILL , tsk); +send_sig (SIGKILL , tsk,1 );put_task_struct (tsk); } }
Signature · 1 line
2.21.0
PATCH 6/26 signal/pid_namespace: Fix reboot_pid_ns to use send_sig not force_sig
In reply to Eric W. BiedermanThe locking in force_sig_info is not prepared to deal with a task that exits or execs (as sighand may change). The is not a locking problem in force_sig as force_sig is only built to handle synchronous exceptions.
Further the function force_sig_info changes the signal state if the signal is ignored, or blocked or if SIGNAL_UNKILLABLE will prevent the delivery of the signal. The signal SIGKILL can not be ignored and can not be blocked and SIGNAL_UNKILLABLE won't prevent it from being delivered.
So using force_sig rather than send_sig for SIGKILL is confusing and pointless.
Because it won't impact the sending of the signal and and because using force_sig is wrong, replace force_sig with send_sig.
--- kernel/pid_namespace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/pid_namespace.c +1 -1
@@ -325,7 +325,7 @@ int reboot_pid_ns(struct pid_namespace *pid_ns, int cmd) }read_lock (&tasklist_lock); -force_sig (SIGKILL , pid_ns->child_reaper); +send_sig (SIGKILL , pid_ns->child_reaper,1 );read_unlock (&tasklist_lock);do_exit (0 );
Signature · 1 line
2.21.0
PATCH 7/26 signal/cifs: Fix cifs_put_tcp_session to call send_sig instead of force_sig
In reply to Eric W. BiedermanThe locking in force_sig_info is not prepared to deal with a task that exits or execs (as sighand may change). The is not a locking problem in force_sig as force_sig is only built to handle synchronous exceptions.
Further the function force_sig_info changes the signal state if the signal is ignored, or blocked or if SIGNAL_UNKILLABLE will prevent the delivery of the signal. The signal SIGKILL can not be ignored and can not be blocked and SIGNAL_UNKILLABLE won't prevent it from being delivered.
So using force_sig rather than send_sig for SIGKILL is confusing and pointless.
Because it won't impact the sending of the signal and and because using force_sig is wrong, replace force_sig with send_sig.
--- fs/cifs/connect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/cifs/connect.c +1 -1
@@ -2629,7 +2629,7 @@ cifs_put_tcp_session(struct TCP_Server_Info *server, int from_reconnect) task =xchg (&server->tsk,NULL );if (task) -force_sig (SIGKILL , task); +send_sig (SIGKILL , task,1 ); } static struct TCP_Server_Info *
Signature · 1 line
2.21.0
PATCH 8/26 signal: Remove task parameter from force_sigsegv
In reply to Eric W. BiedermanThe function force_sigsegv is always called on the current task so passing in current is redundant and not passing in current makes this fact obvious.
This also makes it clear force_sigsegv always calls force_sig on the current task.
--- arch/arc/kernel/process.c | 2 +- arch/ia64/kernel/signal.c | 6 +++--- arch/nios2/kernel/signal.c | 2 +- arch/sparc/kernel/signal32.c | 4 ++-- arch/sparc/kernel/signal_64.c | 2 +- arch/um/kernel/skas/mmu.c | 2 +- arch/um/kernel/trap.c | 2 +- arch/unicore32/kernel/signal.c | 2 +- fs/exec.c | 2 +- include/linux/sched/signal.h | 2 +- kernel/rseq.c | 2 +- kernel/signal.c | 6 ++++-- 12 files changed, 18 insertions(+), 16 deletions(-)
arch/arc/kernel/process.c +1 -1
@@ -313,7 +313,7 @@ int elf_check_arch(const struct elf32_hdr *x) eflags = x->e_flags;if ((eflags &EF_ARC_OSABI_MSK ) !=EF_ARC_OSABI_CURRENT ) {pr_err ("ABI mismatch - you need newer toolchain\n" ); -force_sigsegv (SIGSEGV , current); +force_sigsegv (SIGSEGV );return 0 ; }
arch/ia64/kernel/signal.c +3 -3
@@ -257,7 +257,7 @@ setup_frame(struct ksignal *ksig, sigset_t *set, struct sigscratch *scr)*/ check_sp = (new_sp -sizeof (*frame)) & -STACK_ALIGN ;if (!likely (on_sig_stack (check_sp))) { -force_sigsegv (ksig->sig, current); +force_sigsegv (ksig->sig);return 1 ; } }
@@ -265,7 +265,7 @@ setup_frame(struct ksignal *ksig, sigset_t *set, struct sigscratch *scr) frame = (void __user *) ((new_sp -sizeof (*frame)) & -STACK_ALIGN );if (!access_ok (frame,sizeof (*frame))) { -force_sigsegv (ksig->sig, current); +force_sigsegv (ksig->sig);return 1 ; }
@@ -282,7 +282,7 @@ setup_frame(struct ksignal *ksig, sigset_t *set, struct sigscratch *scr) err |=setup_sigcontext (&frame->sc, set, scr);if (unlikely (err)) { -force_sigsegv (ksig->sig, current); +force_sigsegv (ksig->sig);return 1 ; }
arch/nios2/kernel/signal.c +1 -1
@@ -211,7 +211,7 @@ static int setup_rt_frame(struct ksignal *ksig, sigset_t *set,return 0 ; give_sigsegv: -force_sigsegv (ksig->sig, current); +force_sigsegv (ksig->sig);return -EFAULT ; }
arch/sparc/kernel/signal32.c +2 -2
@@ -375,7 +375,7 @@ static int setup_frame32(struct ksignal *ksig, struct pt_regs *regs,pr_info ("%s[%d] bad frame in setup_frame32: %08lx TPC %08lx O7 %08lx\n" , current->comm, current->pid, (unsigned long )sf, regs->tpc, regs->u_regs[UREG_I7 ]); -force_sigsegv (ksig->sig, current); +force_sigsegv (ksig->sig);return -EINVAL ; }
@@ -509,7 +509,7 @@ static int setup_rt_frame32(struct ksignal *ksig, struct pt_regs *regs,pr_info ("%s[%d] bad frame in setup_rt_frame32: %08lx TPC %08lx O7 %08lx\n" , current->comm, current->pid, (unsigned long )sf, regs->tpc, regs->u_regs[UREG_I7 ]); -force_sigsegv (ksig->sig, current); +force_sigsegv (ksig->sig);return -EINVAL ; }
arch/sparc/kernel/signal_64.c +1 -1
@@ -374,7 +374,7 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)pr_info ("%s[%d] bad frame in setup_rt_frame: %016lx TPC %016lx O7 %016lx\n" , current->comm, current->pid, (unsigned long )sf, regs->tpc, regs->u_regs[UREG_I7 ]); -force_sigsegv (ksig->sig, current); +force_sigsegv (ksig->sig);return -EINVAL ; }
arch/um/kernel/skas/mmu.c +1 -1
@@ -119,7 +119,7 @@ void uml_setup_stubs(struct mm_struct *mm)return ; out: -force_sigsegv (SIGSEGV , current); +force_sigsegv (SIGSEGV ); }void arch_exit_mmap (struct mm_struct *mm)
arch/um/kernel/trap.c +1 -1
@@ -169,7 +169,7 @@ static void bad_segv(struct faultinfo fi, unsigned long ip)void fatal_sigsegv (void ) { -force_sigsegv (SIGSEGV , current); +force_sigsegv (SIGSEGV );do_signal (¤t->thread.regs);/* * This is to tell gcc that we're not returning - do_signal
arch/unicore32/kernel/signal.c +1 -1
@@ -386,7 +386,7 @@ static void do_signal(struct pt_regs *regs, int syscall) regs->UCreg_pc =KERN_RESTART_CODE ; }else { regs->UCreg_sp +=4 ; -force_sigsegv (0 , current); +force_sigsegv (0 ); } } if (regs->UCreg_00 == -ERESTARTNOHAND ||
fs/exec.c +1 -1
@@ -1662,7 +1662,7 @@ int search_binary_handler(struct linux_binprm *bprm)if (retval <0 && !bprm->mm) {/* we got to flush_old_exec() and failed after it */ read_unlock (&binfmt_lock); -force_sigsegv (SIGSEGV , current); +force_sigsegv (SIGSEGV );return retval; }if (retval != -ENOEXEC || !bprm->file) {
include/linux/sched/signal.h +1 -1
@@ -325,7 +325,7 @@ int force_sig_pkuerr(void __user *addr, u32 pkey);int force_sig_ptrace_errno_trap (int errno,void __user *addr);extern int send_sig_info (int ,struct kernel_siginfo *,struct task_struct *); -extern void force_sigsegv (int sig,struct task_struct *p); +extern void force_sigsegv (int sig);extern int force_sig_info (int ,struct kernel_siginfo *,struct task_struct *);extern int __kill_pgrp_info (int sig,struct kernel_siginfo *info,struct pid *pgrp);extern int kill_pid_info (int sig,struct kernel_siginfo *info,struct pid *pid);
kernel/rseq.c +1 -1
@@ -277,7 +277,7 @@ void __rseq_handle_notify_resume(struct ksignal *ksig, struct pt_regs *regs) error: sig = ksig ? ksig->sig :0 ; -force_sigsegv (sig, t); +force_sigsegv (sig); }#ifdef CONFIG_DEBUG_RSEQ
kernel/signal.c +4 -2
@@ -1607,8 +1607,10 @@ EXPORT_SYMBOL(force_sig);* the problem was already a SIGSEGV, we'll want to * make sure we don't even try to deliver the signal.. */ -void force_sigsegv (int sig,struct task_struct *p) +void force_sigsegv (int sig) { +struct task_struct *p = current; +if (sig ==SIGSEGV ) {unsigned long flags;spin_lock_irqsave (&p->sighand->siglock, flags);
@@ -2717,7 +2719,7 @@ static void signal_delivered(struct ksignal *ksig, int stepping)void signal_setup_done (int failed,struct ksignal *ksig,int stepping) {if (failed) -force_sigsegv (ksig->sig, current); +force_sigsegv (ksig->sig);else signal_delivered (ksig, stepping); }
Signature · 1 line
2.21.0
PATCH 9/26 signal: Remove task parameter from force_sig
In reply to Eric W. BiedermanAll of the remaining callers pass current into force_sig so remove the task parameter to make this obvious and to make misuse more difficult in the future.
This also makes it clear force_sig passes current into force_sig_info.
--- arch/alpha/kernel/signal.c | 4 +-- arch/arc/kernel/process.c | 2 +- arch/arc/kernel/signal.c | 2 +- arch/arm/kernel/signal.c | 4 +-- arch/arm64/kernel/traps.c | 2 +- arch/c6x/kernel/signal.c | 2 +- arch/csky/kernel/signal.c | 4 +-- arch/h8300/kernel/ptrace_h.c | 4 +-- arch/h8300/kernel/ptrace_s.c | 2 +- arch/h8300/kernel/signal.c | 2 +- arch/hexagon/kernel/signal.c | 2 +- arch/hexagon/kernel/traps.c | 10 +++---- arch/ia64/kernel/signal.c | 2 +- arch/ia64/kernel/traps.c | 6 ++--- arch/m68k/kernel/signal.c | 4 +-- arch/m68k/kernel/traps.c | 16 +++++------ arch/microblaze/kernel/signal.c | 2 +- arch/mips/kernel/branch.c | 18 ++++++------- arch/mips/kernel/kprobes.c | 2 +- arch/mips/kernel/signal.c | 8 +++--- arch/mips/kernel/signal_n32.c | 4 +-- arch/mips/kernel/signal_o32.c | 8 +++--- arch/mips/kernel/traps.c | 36 ++++++++++++------------- arch/mips/kernel/unaligned.c | 20 +++++++------- arch/mips/sgi-ip22/ip22-berr.c | 2 +- arch/mips/sgi-ip22/ip28-berr.c | 2 +- arch/mips/sgi-ip27/ip27-berr.c | 2 +- arch/mips/sgi-ip32/ip32-berr.c | 2 +- arch/nds32/kernel/signal.c | 2 +- arch/nds32/kernel/traps.c | 6 ++--- arch/nios2/kernel/signal.c | 2 +- arch/openrisc/kernel/signal.c | 2 +- arch/openrisc/kernel/traps.c | 4 +-- arch/parisc/kernel/signal.c | 2 +- arch/powerpc/kernel/signal_32.c | 6 ++--- arch/powerpc/kernel/signal_64.c | 2 +- arch/powerpc/platforms/cell/spufs/run.c | 2 +- arch/riscv/kernel/signal.c | 2 +- arch/s390/kernel/compat_signal.c | 4 +-- arch/s390/kernel/signal.c | 4 +-- arch/sh/kernel/cpu/sh2a/fpu.c | 2 +- arch/sh/kernel/cpu/sh4/fpu.c | 2 +- arch/sh/kernel/cpu/sh5/fpu.c | 4 +-- arch/sh/kernel/ptrace_64.c | 4 +-- arch/sh/kernel/signal_32.c | 4 +-- arch/sh/kernel/signal_64.c | 4 +-- arch/sh/kernel/traps.c | 4 +-- arch/sh/kernel/traps_32.c | 8 +++--- arch/sh/kernel/traps_64.c | 2 +- arch/sparc/kernel/process_64.c | 2 +- arch/sparc/kernel/signal32.c | 4 +-- arch/sparc/kernel/signal_32.c | 4 +-- arch/sparc/kernel/signal_64.c | 6 ++--- arch/sparc/kernel/traps_64.c | 2 +- arch/sparc/mm/fault_32.c | 2 +- arch/um/kernel/exec.c | 2 +- arch/um/kernel/tlb.c | 4 +-- arch/um/kernel/trap.c | 2 +- arch/unicore32/kernel/signal.c | 2 +- arch/x86/entry/vsyscall/vsyscall_64.c | 2 +- arch/x86/kernel/cpu/mce/core.c | 2 +- arch/x86/kernel/signal.c | 2 +- arch/x86/kernel/traps.c | 4 +-- arch/x86/kernel/uprobes.c | 2 +- arch/x86/kernel/vm86_32.c | 2 +- arch/x86/mm/mpx.c | 2 +- arch/x86/um/signal.c | 4 +-- arch/xtensa/kernel/signal.c | 2 +- arch/xtensa/kernel/traps.c | 6 ++--- drivers/misc/lkdtm/bugs.c | 2 +- include/linux/sched/signal.h | 2 +- include/linux/syscalls.h | 2 +- kernel/events/uprobes.c | 4 +-- kernel/rseq.c | 2 +- kernel/signal.c | 6 ++--- security/safesetid/lsm.c | 4 +-- 76 files changed, 160 insertions(+), 166 deletions(-)
arch/alpha/kernel/signal.c +2 -2
@@ -225,7 +225,7 @@ do_sigreturn(struct sigcontext __user *sc)return ; give_sigsegv: -force_sig (SIGSEGV , current); +force_sig (SIGSEGV ); }asmlinkage void
@@ -253,7 +253,7 @@ do_rt_sigreturn(struct rt_sigframe __user *frame)return ; give_sigsegv: -force_sig (SIGSEGV , current); +force_sig (SIGSEGV ); }
arch/arc/kernel/process.c +1 -1
@@ -100,7 +100,7 @@ SYSCALL_DEFINE3(arc_usr_cmpxchg, int *, uaddr, int, expected, int, new) goto again; fail: -force_sig (SIGSEGV , current); +force_sig (SIGSEGV );return ret; }
arch/arc/kernel/signal.c +1 -1
@@ -197,7 +197,7 @@ SYSCALL_DEFINE0(rt_sigreturn)return regs->r0; badframe: -force_sig (SIGSEGV , current); +force_sig (SIGSEGV );return 0 ; }
arch/arm/kernel/signal.c +2 -2
@@ -250,7 +250,7 @@ asmlinkage int sys_sigreturn(struct pt_regs *regs)return regs->ARM_r0; badframe: -force_sig (SIGSEGV , current); +force_sig (SIGSEGV );return 0 ; }
@@ -283,7 +283,7 @@ asmlinkage int sys_rt_sigreturn(struct pt_regs *regs)return regs->ARM_r0; badframe: -force_sig (SIGSEGV , current); +force_sig (SIGSEGV );return 0 ; }
arch/arm64/kernel/traps.c +1 -1
@@ -284,7 +284,7 @@ void arm64_notify_die(const char *str, struct pt_regs *regs,if (signo ==SIGKILL ) {arm64_show_signal (signo, str); -force_sig (signo, current); +force_sig (signo);return ; }arm64_force_sig_fault (signo, sicode, addr, str);
arch/c6x/kernel/signal.c +1 -1
@@ -93,7 +93,7 @@ asmlinkage int do_rt_sigreturn(struct pt_regs *regs)return regs->a4; badframe: -force_sig (SIGSEGV , current); +force_sig (SIGSEGV );return 0 ; }
arch/csky/kernel/signal.c +1 -3
@@ -61,7 +61,6 @@ SYSCALL_DEFINE0(rt_sigreturn) {struct pt_regs *regs =current_pt_regs ();struct rt_sigframe __user *frame; -struct task_struct *task;sigset_t set;/* Always make any pending restarted system calls return -EINTR */
@@ -86,8 +85,7 @@ SYSCALL_DEFINE0(rt_sigreturn)return regs->a0; badframe: - task = current; -force_sig (SIGSEGV , task); +force_sig (SIGSEGV );return 0 ; }
arch/h8300/kernel/ptrace_h.c +2 -2
@@ -250,7 +250,7 @@ asmlinkage void trace_trap(unsigned long bp) {if ((unsigned long )current->thread.breakinfo.addr == bp) {user_disable_single_step (current); -force_sig (SIGTRAP , current); +force_sig (SIGTRAP ); }else -force_sig (SIGILL , current); +force_sig (SIGILL ); }
arch/h8300/kernel/ptrace_s.c +1 -1
@@ -40,5 +40,5 @@ void user_enable_single_step(struct task_struct *child) asmlinkage void trace_trap(unsigned long bp) { (void )bp; -force_sig (SIGTRAP , current); +force_sig (SIGTRAP ); }
arch/h8300/kernel/signal.c +1 -1
@@ -126,7 +126,7 @@ asmlinkage int sys_rt_sigreturn(void)return er0; badframe: -force_sig (SIGSEGV , current); +force_sig (SIGSEGV );return 0 ; }
arch/hexagon/kernel/signal.c +1 -1
@@ -265,6 +265,6 @@ asmlinkage int sys_rt_sigreturn(void)return regs->r00; badframe: -force_sig (SIGSEGV , current); +force_sig (SIGSEGV );return 0 ; }
arch/hexagon/kernel/traps.c +5 -5
@@ -252,7 +252,7 @@ int die_if_kernel(char *str, struct pt_regs *regs, long err)static void misaligned_instruction (struct pt_regs *regs) {die_if_kernel ("Misaligned Instruction" , regs,0 ); -force_sig (SIGBUS , current); +force_sig (SIGBUS ); }/*
@@ -263,19 +263,19 @@ static void misaligned_instruction(struct pt_regs *regs)static void misaligned_data_load (struct pt_regs *regs) {die_if_kernel ("Misaligned Data Load" , regs,0 ); -force_sig (SIGBUS , current); +force_sig (SIGBUS ); }static void misaligned_data_store (struct pt_regs *regs) {die_if_kernel ("Misaligned Data Store" , regs,0 ); -force_sig (SIGBUS , current); +force_sig (SIGBUS ); }static void illegal_instruction (struct pt_regs *regs) {die_if_kernel ("Illegal Instruction" , regs,0 ); -force_sig (SIGILL , current); +force_sig (SIGILL ); }/*
@@ -285,7 +285,7 @@ static void illegal_instruction(struct pt_regs *regs)static void precise_bus_error (struct pt_regs *regs) {die_if_kernel ("Precise Bus Error" , regs,0 ); -force_sig (SIGBUS , current); +force_sig (SIGBUS ); }/*
arch/ia64/kernel/signal.c +1 -1
@@ -152,7 +152,7 @@ ia64_rt_sigreturn (struct sigscratch *scr)return retval; give_sigsegv: -force_sig (SIGSEGV , current); +force_sig (SIGSEGV );return retval; }
arch/ia64/kernel/traps.c +3 -3
@@ -589,14 +589,14 @@ ia64_fault (unsigned long vector, unsigned long isr, unsigned long ifa,printk (KERN_ERR "Unexpected IA-32 exception (Trap 45)\n" );printk (KERN_ERR " iip - 0x%lx, ifa - 0x%lx, isr - 0x%lx\n" , iip, ifa, isr); -force_sig (SIGSEGV , current); +force_sig (SIGSEGV );return ;case 46 :printk (KERN_ERR "Unexpected IA-32 intercept trap (Trap 46)\n" );printk (KERN_ERR " iip - 0x%lx, ifa - 0x%lx, isr - 0x%lx, iim - 0x%lx\n" , iip, ifa, isr, iim); -force_sig (SIGSEGV , current); +force_sig (SIGSEGV );return ;case 47 :
@@ -608,5 +608,5 @@ ia64_fault (unsigned long vector, unsigned long isr, unsigned long ifa,break ; }if (!die_if_kernel (buf, ®s, error)) -force_sig (SIGILL , current); +force_sig (SIGILL ); }
arch/m68k/kernel/signal.c +2 -2
@@ -803,7 +803,7 @@ asmlinkage int do_sigreturn(struct pt_regs *regs, struct switch_stack *sw)return regs->d0; badframe: -force_sig (SIGSEGV , current); +force_sig (SIGSEGV );return 0 ; }
@@ -825,7 +825,7 @@ asmlinkage int do_rt_sigreturn(struct pt_regs *regs, struct switch_stack *sw)return regs->d0; badframe: -force_sig (SIGSEGV , current); +force_sig (SIGSEGV );return 0 ; }
arch/m68k/kernel/traps.c +8 -8
@@ -431,7 +431,7 @@ static inline void bus_error030 (struct frame *fp)pr_err ("BAD KERNEL BUSERR\n" );die_if_kernel ("Oops" , &fp->ptregs,0 ); -force_sig (SIGKILL , current); +force_sig (SIGKILL );return ; } }else {
@@ -463,7 +463,7 @@ static inline void bus_error030 (struct frame *fp) !(ssw &RW ) ?"write" :"read" , addr, fp->ptregs.pc);die_if_kernel ("Oops" , &fp->ptregs, buserr_type); -force_sig (SIGBUS , current); +force_sig (SIGBUS );return ; }
@@ -493,7 +493,7 @@ static inline void bus_error030 (struct frame *fp) do_page_fault (&fp->ptregs, addr, 0); }else {pr_debug ("protection fault on insn access (segv).\n" ); -force_sig (SIGSEGV , current); +force_sig (SIGSEGV ); } }#else
@@ -571,7 +571,7 @@ static inline void bus_error030 (struct frame *fp) !(ssw &RW ) ?"write" :"read" , addr, fp->ptregs.pc);die_if_kernel ("Oops" ,&fp->ptregs,mmusr); -force_sig (SIGSEGV , current); +force_sig (SIGSEGV );return ; }else {#if 0
@@ -598,7 +598,7 @@ static inline void bus_error030 (struct frame *fp)#endif pr_debug ("Unknown SIGSEGV - 1\n" );die_if_kernel ("Oops" ,&fp->ptregs,mmusr); -force_sig (SIGSEGV , current); +force_sig (SIGSEGV );return ; }
@@ -621,7 +621,7 @@ static inline void bus_error030 (struct frame *fp) buserr:pr_err ("BAD KERNEL BUSERR\n" );die_if_kernel ("Oops" ,&fp->ptregs,0 ); -force_sig (SIGKILL , current); +force_sig (SIGKILL );return ; }
@@ -660,7 +660,7 @@ static inline void bus_error030 (struct frame *fp) addr, fp->ptregs.pc);pr_debug ("Unknown SIGSEGV - 2\n" );die_if_kernel ("Oops" ,&fp->ptregs,mmusr); -force_sig (SIGSEGV , current); +force_sig (SIGSEGV );return ; }
@@ -804,7 +804,7 @@ asmlinkage void buserr_c(struct frame *fp)default :die_if_kernel ("bad frame format" ,&fp->ptregs,0 );pr_debug ("Unknown SIGSEGV - 4\n" ); -force_sig (SIGSEGV , current); +force_sig (SIGSEGV ); } }
arch/microblaze/kernel/signal.c +1 -1
@@ -108,7 +108,7 @@ asmlinkage long sys_rt_sigreturn(struct pt_regs *regs)return rval; badframe: -force_sig (SIGSEGV , current); +force_sig (SIGSEGV );return 0 ; }
arch/mips/kernel/branch.c +9 -9
@@ -32,7 +32,7 @@ int __isa_exception_epc(struct pt_regs *regs)/* Calculate exception PC in branch delay slot. */ if (__get_user (inst, (u16 __user *)msk_isa16_mode (epc))) {/* This should never happen because delay slot was checked. */ -force_sig (SIGSEGV , current); +force_sig (SIGSEGV );return epc; }if (cpu_has_mips16) {
@@ -305,7 +305,7 @@ int __microMIPS_compute_return_epc(struct pt_regs *regs)return 0 ; sigsegv: -force_sig (SIGSEGV , current); +force_sig (SIGSEGV );return -EFAULT ; }
@@ -328,7 +328,7 @@ int __MIPS16e_compute_return_epc(struct pt_regs *regs)/* Read the instruction. */ addr = (u16 __user *)msk_isa16_mode (epc);if (__get_user (inst.full, addr)) { -force_sig (SIGSEGV , current); +force_sig (SIGSEGV );return -EFAULT ; }
@@ -343,7 +343,7 @@ int __MIPS16e_compute_return_epc(struct pt_regs *regs)case MIPS16e_jal_op: addr +=1 ;if (__get_user (inst2, addr)) { -force_sig (SIGSEGV , current); +force_sig (SIGSEGV );return -EFAULT ; } fullinst = ((unsigned )inst.full <<16 ) | inst2;
@@ -829,17 +829,17 @@ int __compute_return_epc_for_insn(struct pt_regs *regs, sigill_dsp:pr_debug ("%s: DSP branch but not DSP ASE - sending SIGILL.\n" , current->comm); -force_sig (SIGILL , current); +force_sig (SIGILL );return -EFAULT ; sigill_r2r6:pr_debug ("%s: R2 branch but r2-to-r6 emulator is not present - sending SIGILL.\n" , current->comm); -force_sig (SIGILL , current); +force_sig (SIGILL );return -EFAULT ; sigill_r6:pr_debug ("%s: R6 branch but no MIPSr6 ISA support - sending SIGILL.\n" , current->comm); -force_sig (SIGILL , current); +force_sig (SIGILL );return -EFAULT ; }EXPORT_SYMBOL_GPL (__compute_return_epc_for_insn);
@@ -859,7 +859,7 @@ int __compute_return_epc(struct pt_regs *regs)*/ addr = (unsigned int __user *) epc;if (__get_user (insn.word, addr)) { -force_sig (SIGSEGV , current); +force_sig (SIGSEGV );return -EFAULT ; }
@@ -867,7 +867,7 @@ int __compute_return_epc(struct pt_regs *regs) unaligned:printk ("%s: unaligned epc - sending SIGBUS.\n" , current->comm); -force_sig (SIGBUS , current); +force_sig (SIGBUS );return -EFAULT ; }
arch/mips/kernel/kprobes.c +1 -1
@@ -232,7 +232,7 @@ static int evaluate_branch_instruction(struct kprobe *p, struct pt_regs *regs, unaligned:pr_notice ("%s: unaligned epc - sending SIGBUS.\n" , current->comm); -force_sig (SIGBUS , current); +force_sig (SIGBUS );return -EFAULT ; }
arch/mips/kernel/signal.c +4 -4
@@ -641,7 +641,7 @@ asmlinkage void sys_sigreturn(void)if (sig <0 ) goto badframe;else if (sig) -force_sig (sig, current); +force_sig (sig);/* * Don't let your children do this ...
@@ -654,7 +654,7 @@ asmlinkage void sys_sigreturn(void)/* Unreached */ badframe: - force_sig(SIGSEGV, current); + force_sig(SIGSEGV); }#endif /* CONFIG_TRAD_SIGNALS */
@@ -678,7 +678,7 @@ asmlinkage void sys_rt_sigreturn(void)if (sig <0 ) goto badframe;else if (sig) -force_sig (sig, current); +force_sig (sig);if (restore_altstack (&frame->rs_uc.uc_stack)) goto badframe;
@@ -694,7 +694,7 @@ asmlinkage void sys_rt_sigreturn(void)/* Unreached */ badframe: -force_sig (SIGSEGV , current); +force_sig (SIGSEGV ); }#ifdef CONFIG_TRAD_SIGNALS
arch/mips/kernel/signal_n32.c +2 -2
@@ -84,7 +84,7 @@ asmlinkage void sysn32_rt_sigreturn(void)if (sig <0 ) goto badframe;else if (sig) -force_sig (sig, current); +force_sig (sig);if (compat_restore_altstack (&frame->rs_uc.uc_stack)) goto badframe;
@@ -100,7 +100,7 @@ asmlinkage void sysn32_rt_sigreturn(void)/* Unreached */ badframe: -force_sig (SIGSEGV , current); +force_sig (SIGSEGV ); } static int setup_rt_frame_n32(void *sig_return, struct ksignal *ksig,
arch/mips/kernel/signal_o32.c +4 -4
@@ -171,7 +171,7 @@ asmlinkage void sys32_rt_sigreturn(void)if (sig <0 ) goto badframe;else if (sig) -force_sig (sig, current); +force_sig (sig);if (compat_restore_altstack (&frame->rs_uc.uc_stack)) goto badframe;
@@ -187,7 +187,7 @@ asmlinkage void sys32_rt_sigreturn(void)/* Unreached */ badframe: -force_sig (SIGSEGV , current); +force_sig (SIGSEGV ); } static int setup_rt_frame_32(void *sig_return, struct ksignal *ksig,
@@ -273,7 +273,7 @@ asmlinkage void sys32_sigreturn(void)if (sig <0 ) goto badframe;else if (sig) -force_sig (sig, current); +force_sig (sig);/* * Don't let your children do this ...
@@ -286,5 +286,5 @@ asmlinkage void sys32_sigreturn(void)/* Unreached */ badframe: -force_sig (SIGSEGV , current); +force_sig (SIGSEGV ); }
arch/mips/kernel/traps.c +18 -18
@@ -482,7 +482,7 @@ asmlinkage void do_be(struct pt_regs *regs) goto out;die_if_kernel ("Oops" , regs); -force_sig (SIGBUS , current); +force_sig (SIGBUS ); out:exception_exit (prev_state);
@@ -765,7 +765,7 @@ int process_fpemu_return(int sig, void __user *fault_addr, unsigned long fcr31)return 1 ;default : -force_sig (sig, current); +force_sig (sig);return 1 ; } }
@@ -947,7 +947,7 @@ void do_trap_or_bp(struct pt_regs *regs, unsigned int code, int si_code,break ;case BRK_BUG :die_if_kernel ("Kernel bug detected" , regs); -force_sig (SIGTRAP , current); +force_sig (SIGTRAP );break ;case BRK_MEMU :/*
@@ -962,7 +962,7 @@ void do_trap_or_bp(struct pt_regs *regs, unsigned int code, int si_code,return ;die_if_kernel ("Math emu break/trap" , regs); -force_sig (SIGTRAP , current); +force_sig (SIGTRAP );break ;default :scnprintf (b,sizeof (b),"%s instruction in kernel code" , str);
@@ -970,7 +970,7 @@ void do_trap_or_bp(struct pt_regs *regs, unsigned int code, int si_code,if (si_code) {force_sig_fault (SIGTRAP , si_code,NULL , current); }else { -force_sig (SIGTRAP , current); +force_sig (SIGTRAP ); } } }
@@ -1063,7 +1063,7 @@ asmlinkage void do_bp(struct pt_regs *regs)return ; out_sigsegv: -force_sig (SIGSEGV , current); +force_sig (SIGSEGV ); goto out; }
@@ -1105,7 +1105,7 @@ asmlinkage void do_tr(struct pt_regs *regs)return ; out_sigsegv: -force_sig (SIGSEGV , current); +force_sig (SIGSEGV ); goto out; }
@@ -1191,7 +1191,7 @@ asmlinkage void do_ri(struct pt_regs *regs)if (unlikely (status >0 )) { regs->cp0_epc = old_epc;/* Undo skip-over. */ regs->regs[31 ] = old31; -force_sig (status, current); +force_sig (status); } out:
@@ -1220,7 +1220,7 @@ static int default_cu2_call(struct notifier_block *nfb, unsigned long action,die_if_kernel ("COP2: Unhandled kernel unaligned access or invalid " "instruction" , regs); -force_sig (SIGILL , current); +force_sig (SIGILL );return NOTIFY_OK ; }
@@ -1383,7 +1383,7 @@ asmlinkage void do_cpu(struct pt_regs *regs)if (unlikely (status >0 )) { regs->cp0_epc = old_epc;/* Undo skip-over. */ regs->regs[31 ] = old31; -force_sig (status, current); +force_sig (status); }break ;
@@ -1403,7 +1403,7 @@ asmlinkage void do_cpu(struct pt_regs *regs)* emulator too. */ if (raw_cpu_has_fpu || !cpu_has_mips_4_5_64_r2_r6) { -force_sig (SIGILL , current); +force_sig (SIGILL );break ; }/* Fall through. */
@@ -1437,7 +1437,7 @@ asmlinkage void do_cpu(struct pt_regs *regs)#else /* CONFIG_MIPS_FP_SUPPORT */ case 1 :case 3 : -force_sig (SIGILL , current); +force_sig (SIGILL );break ;#endif /* CONFIG_MIPS_FP_SUPPORT */
@@ -1464,7 +1464,7 @@ asmlinkage void do_msa_fpe(struct pt_regs *regs, unsigned int msacsr)local_irq_enable ();die_if_kernel ("do_msa_fpe invoked from kernel context!" , regs); -force_sig (SIGFPE , current); +force_sig (SIGFPE ); out:exception_exit (prev_state); }
@@ -1477,7 +1477,7 @@ asmlinkage void do_msa(struct pt_regs *regs) prev_state =exception_enter ();if (!cpu_has_msa ||test_thread_flag (TIF_32BIT_FPREGS )) { -force_sig (SIGILL , current); +force_sig (SIGILL ); goto out; }
@@ -1485,7 +1485,7 @@ asmlinkage void do_msa(struct pt_regs *regs) err =enable_restore_fp_context (1 );if (err) -force_sig (SIGILL , current); +force_sig (SIGILL ); out:exception_exit (prev_state); }
@@ -1495,7 +1495,7 @@ asmlinkage void do_mdmx(struct pt_regs *regs)enum ctx_state prev_state; prev_state =exception_enter (); -force_sig (SIGILL , current); +force_sig (SIGILL );exception_exit (prev_state); }
@@ -1592,7 +1592,7 @@ asmlinkage void do_mt(struct pt_regs *regs) }die_if_kernel ("MIPS MT Thread exception in kernel" , regs); -force_sig (SIGILL , current); +force_sig (SIGILL ); }
@@ -1601,7 +1601,7 @@ asmlinkage void do_dsp(struct pt_regs *regs)if (cpu_has_dsp)panic ("Unexpected DSP exception" ); -force_sig (SIGILL , current); +force_sig (SIGILL ); } asmlinkage void do_reserved(struct pt_regs *regs)
arch/mips/kernel/unaligned.c +10 -10
@@ -1365,20 +1365,20 @@ static void emulate_load_store_insn(struct pt_regs *regs,return ;die_if_kernel ("Unhandled kernel unaligned access" , regs); -force_sig (SIGSEGV , current); +force_sig (SIGSEGV );return ; sigbus:die_if_kernel ("Unhandled kernel unaligned access" , regs); -force_sig (SIGBUS , current); +force_sig (SIGBUS );return ; sigill:die_if_kernel ("Unhandled kernel unaligned access or invalid instruction" , regs); -force_sig (SIGILL , current); +force_sig (SIGILL ); }/* Recode table from 16-bit register notation to 32-bit GPR. */
@@ -1991,20 +1991,20 @@ static void emulate_load_store_microMIPS(struct pt_regs *regs,return ;die_if_kernel ("Unhandled kernel unaligned access" , regs); -force_sig (SIGSEGV , current); +force_sig (SIGSEGV );return ; sigbus:die_if_kernel ("Unhandled kernel unaligned access" , regs); -force_sig (SIGBUS , current); +force_sig (SIGBUS );return ; sigill:die_if_kernel ("Unhandled kernel unaligned access or invalid instruction" , regs); -force_sig (SIGILL , current); +force_sig (SIGILL ); }static void emulate_load_store_MIPS16e (struct pt_regs *regs,void __user * addr)
@@ -2271,20 +2271,20 @@ static void emulate_load_store_MIPS16e(struct pt_regs *regs, void __user * addr)return ;die_if_kernel ("Unhandled kernel unaligned access" , regs); -force_sig (SIGSEGV , current); +force_sig (SIGSEGV );return ; sigbus:die_if_kernel ("Unhandled kernel unaligned access" , regs); -force_sig (SIGBUS , current); +force_sig (SIGBUS );return ; sigill:die_if_kernel ("Unhandled kernel unaligned access or invalid instruction" , regs); -force_sig (SIGILL , current); +force_sig (SIGILL ); } asmlinkage void do_ade(struct pt_regs *regs)
@@ -2364,7 +2364,7 @@ asmlinkage void do_ade(struct pt_regs *regs) sigbus:die_if_kernel ("Kernel unaligned instruction access" , regs); -force_sig (SIGBUS , current); +force_sig (SIGBUS );/* * XXX On return from the signal handler we should advance the epc
arch/mips/sgi-ip22/ip22-berr.c +1 -1
@@ -98,7 +98,7 @@ void ip22_be_interrupt(int irq) field, regs->cp0_epc, field, regs->regs[31]);/* Assume it would be too dangerous to continue ... */ die_if_kernel ("Oops" , regs); -force_sig (SIGBUS , current); +force_sig (SIGBUS ); }static int ip22_be_handler (struct pt_regs *regs,int is_fixup)
arch/mips/sgi-ip22/ip28-berr.c +1 -1
@@ -462,7 +462,7 @@ void ip22_be_interrupt(int irq)if (ip28_be_interrupt (regs) !=MIPS_BE_DISCARD ) {/* Assume it would be too dangerous to continue ... */ die_if_kernel ("Oops" , regs); -force_sig (SIGBUS , current); +force_sig (SIGBUS ); }else if (debug_be_interrupt)show_regs (regs); }
arch/mips/sgi-ip27/ip27-berr.c +1 -1
@@ -74,7 +74,7 @@ int ip27_be_handler(struct pt_regs *regs, int is_fixup)show_regs (regs);dump_tlb_all ();while (1 ); -force_sig (SIGBUS , current); +force_sig (SIGBUS ); }void __init ip27_be_init (void )
arch/mips/sgi-ip32/ip32-berr.c +1 -1
@@ -29,7 +29,7 @@ static int ip32_be_handler(struct pt_regs *regs, int is_fixup)show_regs (regs);dump_tlb_all ();while (1 ); -force_sig (SIGBUS , current); +force_sig (SIGBUS ); }void __init ip32_be_init (void )
arch/nds32/kernel/signal.c +1 -1
@@ -163,7 +163,7 @@ asmlinkage long sys_rt_sigreturn(struct pt_regs *regs)return regs->uregs[0 ]; badframe: -force_sig (SIGSEGV , current); +force_sig (SIGSEGV );return 0 ; }
arch/nds32/kernel/traps.c +3 -3
@@ -288,7 +288,7 @@ void unhandled_interruption(struct pt_regs *regs)show_regs (regs);if (!user_mode (regs))do_exit (SIGKILL ); -force_sig (SIGKILL , current); +force_sig (SIGKILL ); } void unhandled_exceptions(unsigned long entry, unsigned long addr,
@@ -299,7 +299,7 @@ void unhandled_exceptions(unsigned long entry, unsigned long addr,show_regs (regs);if (!user_mode (regs))do_exit (SIGKILL ); -force_sig (SIGKILL , current); +force_sig (SIGKILL ); } extern int do_page_fault(unsigned long entry, unsigned long addr,
@@ -326,7 +326,7 @@ void do_revinsn(struct pt_regs *regs)show_regs (regs);if (!user_mode (regs))do_exit (SIGILL ); -force_sig (SIGILL , current); +force_sig (SIGILL ); }#ifdef CONFIG_ALIGNMENT_TRAP
arch/nios2/kernel/signal.c +1 -1
@@ -120,7 +120,7 @@ asmlinkage int do_rt_sigreturn(struct switch_stack *sw)return rval; badframe: -force_sig (SIGSEGV , current); +force_sig (SIGSEGV );return 0 ; }
arch/openrisc/kernel/signal.c +1 -1
@@ -99,7 +99,7 @@ asmlinkage long _sys_rt_sigreturn(struct pt_regs *regs)return regs->gpr[11 ]; badframe: -force_sig (SIGSEGV , current); +force_sig (SIGSEGV );return 0 ; }
arch/openrisc/kernel/traps.c +2 -2
@@ -376,7 +376,7 @@ static inline void simulate_lwa(struct pt_regs *regs, unsigned long address,if (get_user (value, lwa_addr)) {if (user_mode (regs)) { -force_sig (SIGSEGV , current); +force_sig (SIGSEGV );return ; }
@@ -423,7 +423,7 @@ static inline void simulate_swa(struct pt_regs *regs, unsigned long address,if (put_user (regs->gpr[rb], vaddr)) {if (user_mode (regs)) { -force_sig (SIGSEGV , current); +force_sig (SIGSEGV );return ; }
arch/parisc/kernel/signal.c +1 -1
@@ -164,7 +164,7 @@ sys_rt_sigreturn(struct pt_regs *regs, int in_syscall) give_sigsegv:DBG (1 ,"sys_rt_sigreturn: Sending SIGSEGV\n" ); -force_sig (SIGSEGV , current); +force_sig (SIGSEGV );return ; }
arch/powerpc/kernel/signal_32.c +3 -3
@@ -1249,7 +1249,7 @@ SYSCALL_DEFINE0(rt_sigreturn) current->comm, current->pid, rt_sf, regs->nip, regs->link); -force_sig (SIGSEGV , current); +force_sig (SIGSEGV );return 0 ; }
@@ -1338,7 +1338,7 @@ SYSCALL_DEFINE3(debug_setcontext, struct ucontext __user *, ctx, current->comm, current->pid, ctx, regs->nip, regs->link); -force_sig (SIGSEGV , current); +force_sig (SIGSEGV ); goto out; }
@@ -1516,6 +1516,6 @@ SYSCALL_DEFINE0(sigreturn) current->comm, current->pid, addr, regs->nip, regs->link); -force_sig (SIGSEGV , current); +force_sig (SIGSEGV );return 0 ; }
arch/powerpc/kernel/signal_64.c +1 -1
@@ -812,7 +812,7 @@ SYSCALL_DEFINE0(rt_sigreturn) current->comm, current->pid,"rt_sigreturn" , (long)uc, regs->nip, regs->link); -force_sig (SIGSEGV , current); +force_sig (SIGSEGV );return 0 ; }
arch/powerpc/platforms/cell/spufs/run.c +1 -1
@@ -443,7 +443,7 @@ long spufs_run_spu(struct spu_context *ctx, u32 *npc, u32 *event)else if (unlikely ((status &SPU_STATUS_STOPPED_BY_STOP ) && (status >>SPU_STOP_STATUS_SHIFT ) ==0x3fff )) { -force_sig (SIGTRAP , current); +force_sig (SIGTRAP ); ret = -ERESTARTSYS ; }
arch/riscv/kernel/signal.c +1 -1
@@ -139,7 +139,7 @@ SYSCALL_DEFINE0(rt_sigreturn) task->comm,task_pid_nr (task), __func__, frame, (void *)regs->sepc, (void *)regs->sp); } -force_sig (SIGSEGV , task); +force_sig (SIGSEGV );return 0 ; }
arch/s390/kernel/compat_signal.c +2 -2
@@ -194,7 +194,7 @@ COMPAT_SYSCALL_DEFINE0(sigreturn)load_sigregs ();return regs->gprs[2 ]; badframe: -force_sig (SIGSEGV , current); +force_sig (SIGSEGV );return 0 ; }
@@ -217,7 +217,7 @@ COMPAT_SYSCALL_DEFINE0(rt_sigreturn)load_sigregs ();return regs->gprs[2 ]; badframe: -force_sig (SIGSEGV , current); +force_sig (SIGSEGV );return 0 ; }
arch/s390/kernel/signal.c +2 -2
@@ -232,7 +232,7 @@ SYSCALL_DEFINE0(sigreturn)load_sigregs ();return regs->gprs[2 ]; badframe: -force_sig (SIGSEGV , current); +force_sig (SIGSEGV );return 0 ; }
@@ -256,7 +256,7 @@ SYSCALL_DEFINE0(rt_sigreturn)load_sigregs ();return regs->gprs[2 ]; badframe: -force_sig (SIGSEGV , current); +force_sig (SIGSEGV );return 0 ; }
arch/sh/kernel/cpu/sh2a/fpu.c +1 -1
@@ -568,5 +568,5 @@ BUILD_TRAP_HANDLER(fpu_error)return ; } -force_sig (SIGFPE , tsk); +force_sig (SIGFPE ); }
arch/sh/kernel/cpu/sh4/fpu.c +1 -1
@@ -421,5 +421,5 @@ BUILD_TRAP_HANDLER(fpu_error) } } -force_sig (SIGFPE , tsk); +force_sig (SIGFPE ); }
arch/sh/kernel/cpu/sh5/fpu.c +1 -3
@@ -100,9 +100,7 @@ void restore_fpu(struct task_struct *tsk) asmlinkage void do_fpu_error(unsigned long ex, struct pt_regs *regs) { -struct task_struct *tsk = current; - regs->pc +=4 ; -force_sig (SIGFPE , tsk); +force_sig (SIGFPE ); }
arch/sh/kernel/ptrace_64.c +2 -2
@@ -550,7 +550,7 @@ asmlinkage void do_single_step(unsigned long long vec, struct pt_regs *regs)continually stepping. */ local_irq_enable (); regs->sr &= ~SR_SSTEP ; -force_sig (SIGTRAP , current); +force_sig (SIGTRAP ); }/* Called with interrupts disabled */
@@ -561,7 +561,7 @@ BUILD_TRAP_HANDLER(breakpoint)/* We need to forward step the PC, to counteract the backstep done in signal.c. */ local_irq_enable (); -force_sig (SIGTRAP , current); +force_sig (SIGTRAP ); regs->pc +=4 ; }
arch/sh/kernel/signal_32.c +2 -2
@@ -176,7 +176,7 @@ asmlinkage int sys_sigreturn(void)return r0; badframe: -force_sig (SIGSEGV , current); +force_sig (SIGSEGV );return 0 ; }
@@ -207,7 +207,7 @@ asmlinkage int sys_rt_sigreturn(void)return r0; badframe: -force_sig (SIGSEGV , current); +force_sig (SIGSEGV );return 0 ; }
arch/sh/kernel/signal_64.c +2 -2
@@ -277,7 +277,7 @@ asmlinkage int sys_sigreturn(unsigned long r2, unsigned long r3,return (int ) ret; badframe: -force_sig (SIGSEGV , current); +force_sig (SIGSEGV );return 0 ; }
@@ -311,7 +311,7 @@ asmlinkage int sys_rt_sigreturn(unsigned long r2, unsigned long r3,return (int ) ret; badframe: -force_sig (SIGSEGV , current); +force_sig (SIGSEGV );return 0 ; }
arch/sh/kernel/traps.c +2 -2
@@ -141,7 +141,7 @@ BUILD_TRAP_HANDLER(debug) SIGTRAP) == NOTIFY_STOP)return ; -force_sig (SIGTRAP , current); +force_sig (SIGTRAP ); }/*
@@ -167,7 +167,7 @@ BUILD_TRAP_HANDLER(bug) }#endif -force_sig (SIGTRAP , current); +force_sig (SIGTRAP ); }BUILD_TRAP_HANDLER (nmi)
arch/sh/kernel/traps_32.c +3 -5
@@ -611,7 +611,6 @@ asmlinkage void do_reserved_inst(void) {struct pt_regs *regs =current_pt_regs ();unsigned long error_code; -struct task_struct *tsk = current;#ifdef CONFIG_SH_FPU_EMU unsigned short inst =0 ;
@@ -633,7 +632,7 @@ asmlinkage void do_reserved_inst(void)/* Enable DSP mode, and restart instruction. */ regs->sr |=SR_DSP ;/* Save DSP mode */ - tsk->thread.dsp_status.status |=SR_DSP ; + current->thread.dsp_status.status |=SR_DSP ; return; }#endif
@@ -641,7 +640,7 @@ asmlinkage void do_reserved_inst(void) error_code =lookup_exception_vector ();local_irq_enable (); -force_sig (SIGILL , tsk); +force_sig (SIGILL );die_if_no_fixup ("reserved instruction" , regs, error_code); }
@@ -697,7 +696,6 @@ asmlinkage void do_illegal_slot_inst(void) {struct pt_regs *regs =current_pt_regs ();unsigned long inst; -struct task_struct *tsk = current;if (kprobe_handle_illslot (regs->pc) ==0 )return ;
@@ -716,7 +714,7 @@ asmlinkage void do_illegal_slot_inst(void) inst =lookup_exception_vector ();local_irq_enable (); -force_sig (SIGILL , tsk); +force_sig (SIGILL );die_if_no_fixup ("illegal slot instruction" , regs, inst); }
arch/sh/kernel/traps_64.c +1 -1
@@ -599,7 +599,7 @@ static void do_unhandled_exception(int signr, char *str, unsigned long error, struct pt_regs *regs) {if (user_mode (regs)) -force_sig (signr, current); +force_sig (signr);die_if_no_fixup (str, regs, error); }
arch/sparc/kernel/process_64.c +1 -1
@@ -570,7 +570,7 @@ void fault_in_user_windows(struct pt_regs *regs) barf:set_thread_wsaved (window +1 ); -force_sig (SIGSEGV , current); +force_sig (SIGSEGV ); } asmlinkage long sparc_do_fork(unsigned long clone_flags,
arch/sparc/kernel/signal32.c +2 -2
@@ -170,7 +170,7 @@ void do_sigreturn32(struct pt_regs *regs)return ; segv: -force_sig (SIGSEGV , current); +force_sig (SIGSEGV ); } asmlinkage void do_rt_sigreturn32(struct pt_regs *regs)
@@ -256,7 +256,7 @@ asmlinkage void do_rt_sigreturn32(struct pt_regs *regs)set_current_blocked (&set);return ; segv: -force_sig (SIGSEGV , current); +force_sig (SIGSEGV ); }static void __user *get_sigframe (struct ksignal *ksig,struct pt_regs *regs,unsigned long framesize)
arch/sparc/kernel/signal_32.c +2 -2
@@ -137,7 +137,7 @@ asmlinkage void do_sigreturn(struct pt_regs *regs)return ; segv_and_exit: -force_sig (SIGSEGV , current); +force_sig (SIGSEGV ); } asmlinkage void do_rt_sigreturn(struct pt_regs *regs)
@@ -196,7 +196,7 @@ asmlinkage void do_rt_sigreturn(struct pt_regs *regs)set_current_blocked (&set);return ; segv: -force_sig (SIGSEGV , current); +force_sig (SIGSEGV ); }static inline void __user *get_sigframe (struct ksignal *ksig,struct pt_regs *regs,unsigned long framesize)
arch/sparc/kernel/signal_64.c +3 -3
@@ -134,7 +134,7 @@ asmlinkage void sparc64_set_context(struct pt_regs *regs)exception_exit (prev_state);return ; do_sigsegv: -force_sig (SIGSEGV , current); +force_sig (SIGSEGV ); goto out; }
@@ -228,7 +228,7 @@ asmlinkage void sparc64_get_context(struct pt_regs *regs)exception_exit (prev_state);return ; do_sigsegv: -force_sig (SIGSEGV , current); +force_sig (SIGSEGV ); goto out; }
@@ -320,7 +320,7 @@ void do_rt_sigreturn(struct pt_regs *regs)set_current_blocked (&set);return ; segv: -force_sig (SIGSEGV , current); +force_sig (SIGSEGV ); }static inline void __user *get_sigframe (struct ksignal *ksig,struct pt_regs *regs,unsigned long framesize)
arch/sparc/kernel/traps_64.c +1 -1
@@ -2181,7 +2181,7 @@ bool sun4v_nonresum_error_user_handled(struct pt_regs *regs, addr +=PAGE_SIZE ; } } -force_sig (SIGKILL , current); +force_sig (SIGKILL );return true; }
arch/sparc/mm/fault_32.c +1 -1
@@ -425,7 +425,7 @@ static void force_user_fault(unsigned long address, int write)static void check_stack_aligned (unsigned long sp) {if (sp &0x7UL ) -force_sig (SIGILL , current); +force_sig (SIGILL ); }void window_overflow_fault (void )
arch/um/kernel/exec.c +1 -1
@@ -32,7 +32,7 @@ void flush_thread(void)if (ret) {printk (KERN_ERR "flush_thread - clearing address space failed, " "err = %d\n" , ret); -force_sig (SIGKILL , current); +force_sig (SIGKILL ); }get_safe_registers (current_pt_regs ()->regs.gp,current_pt_regs ()->regs.fp);
arch/um/kernel/tlb.c +2 -2
@@ -329,7 +329,7 @@ void fix_range_common(struct mm_struct *mm, unsigned long start_addr, "process: %d\n", task_tgid_vnr(current));/* We are under mmap_sem, release it such that current can terminate */ up_write (¤t->mm->mmap_sem); -force_sig (SIGKILL , current); +force_sig (SIGKILL );do_signal (¤t->thread.regs); } }
@@ -487,7 +487,7 @@ void flush_tlb_page(struct vm_area_struct *vma, unsigned long address) kill:printk (KERN_ERR "Failed to flush page for address 0x%lx\n" , address); -force_sig (SIGKILL , current); +force_sig (SIGKILL ); }pgd_t *pgd_offset_proc (struct mm_struct *mm,unsigned long address)
arch/um/kernel/trap.c +1 -1
@@ -309,7 +309,7 @@ void relay_signal(int sig, struct siginfo *si, struct uml_pt_regs *regs) }else {printk (KERN_ERR "Attempted to relay unknown signal %d (si_code = %d) with errno %d\n" , sig, code, err); -force_sig (sig, current); +force_sig (sig); } }
arch/unicore32/kernel/signal.c +1 -1
@@ -129,7 +129,7 @@ asmlinkage int __sys_rt_sigreturn(struct pt_regs *regs)return regs->UCreg_00; badframe: -force_sig (SIGSEGV , current); +force_sig (SIGSEGV );return 0 ; }
arch/x86/entry/vsyscall/vsyscall_64.c +1 -1
@@ -268,7 +268,7 @@ bool emulate_vsyscall(struct pt_regs *regs, unsigned long address)return true; sigsegv: -force_sig (SIGSEGV , current); +force_sig (SIGSEGV );return true; }
arch/x86/kernel/cpu/mce/core.c +1 -1
@@ -1329,7 +1329,7 @@ void do_machine_check(struct pt_regs *regs, long error_code)local_irq_enable ();if (kill_it ||do_memory_failure (&m)) -force_sig (SIGBUS , current); +force_sig (SIGBUS );local_irq_disable ();ist_end_non_atomic (); }else {
arch/x86/kernel/signal.c +1 -1
@@ -857,7 +857,7 @@ void signal_fault(struct pt_regs *regs, void __user *frame, char *where)pr_cont ("\n" ); } -force_sig (SIGSEGV , me); +force_sig (SIGSEGV ); }#ifdef CONFIG_X86_X32_ABI
arch/x86/kernel/traps.c +2 -2
@@ -254,7 +254,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,show_signal (tsk, signr,"trap " , str, regs, error_code);if (!sicode) -force_sig (signr, tsk); +force_sig (signr);else force_sig_fault (signr, sicode, addr, tsk); }
@@ -566,7 +566,7 @@ do_general_protection(struct pt_regs *regs, long error_code)show_signal (tsk,SIGSEGV ,"" , desc, regs, error_code); -force_sig (SIGSEGV , tsk); +force_sig (SIGSEGV ); }NOKPROBE_SYMBOL (do_general_protection);
arch/x86/kernel/uprobes.c +1 -1
@@ -1087,7 +1087,7 @@ arch_uretprobe_hijack_return_addr(unsigned long trampoline_vaddr, struct pt_regspr_err ("return address clobbered: pid=%d, %%sp=%#lx, %%ip=%#lx\n" , current->pid, regs->sp, regs->ip); -force_sig (SIGSEGV , current); +force_sig (SIGSEGV ); }return -1 ;
arch/x86/kernel/vm86_32.c +1 -1
@@ -583,7 +583,7 @@ int handle_vm86_trap(struct kernel_vm86_regs *regs, long error_code, int trapno)return 1 ;/* we let this handle by the calling routine */ current->thread.trap_nr = trapno; current->thread.error_code = error_code; -force_sig (SIGTRAP , current); +force_sig (SIGTRAP );return 0 ; }
arch/x86/mm/mpx.c +1 -1
@@ -912,7 +912,7 @@ void mpx_notify_unmap(struct mm_struct *mm, unsigned long start, ret =mpx_unmap_tables (mm, start, end);if (ret) -force_sig (SIGSEGV , current); +force_sig (SIGSEGV ); }/* MPX cannot handle addresses above 47 bits yet. */
arch/x86/um/signal.c +2 -2
@@ -471,7 +471,7 @@ long sys_sigreturn(void)return PT_REGS_SYSCALL_RET (¤t->thread.regs); segfault: -force_sig (SIGSEGV , current); +force_sig (SIGSEGV );return 0 ; }
@@ -577,6 +577,6 @@ long sys_rt_sigreturn(void)return PT_REGS_SYSCALL_RET (¤t->thread.regs); segfault: -force_sig (SIGSEGV , current); +force_sig (SIGSEGV );return 0 ; }
arch/xtensa/kernel/signal.c +1 -1
@@ -270,7 +270,7 @@ asmlinkage long xtensa_rt_sigreturn(long a0, long a1, long a2, long a3,return ret; badframe: -force_sig (SIGSEGV , current); +force_sig (SIGSEGV );return 0 ; }
arch/xtensa/kernel/traps.c +3 -3
@@ -184,7 +184,7 @@ void do_unhandled(struct pt_regs *regs, unsigned long exccause)"\tEXCCAUSE is %ld\n" , current->comm,task_pid_nr (current), regs->pc, exccause); -force_sig (SIGILL , current); +force_sig (SIGILL ); }/*
@@ -306,7 +306,7 @@ do_illegal_instruction(struct pt_regs *regs)pr_info_ratelimited ("Illegal Instruction in '%s' (pid = %d, pc = %#010lx)\n" , current->comm,task_pid_nr (current), regs->pc); -force_sig (SIGILL , current); +force_sig (SIGILL ); }
@@ -354,7 +354,7 @@ do_debug(struct pt_regs *regs)/* If in user mode, send SIGTRAP signal to current process */ -force_sig (SIGTRAP , current); +force_sig (SIGTRAP ); }
drivers/misc/lkdtm/bugs.c +1 -1
@@ -225,7 +225,7 @@ void lkdtm_CORRUPT_USER_DS(void)set_fs (KERNEL_DS );/* Make sure we do not keep running with a KERNEL_DS! */ -force_sig (SIGKILL , current); +force_sig (SIGKILL ); }/* Test that VMAP_STACK is actually allocating with a leading guard page */
include/linux/sched/signal.h +1 -1
@@ -335,7 +335,7 @@ extern int kill_pgrp(struct pid *pid, int sig, int priv);extern int kill_pid (struct pid *pid,int sig,int priv);extern __must_check bool do_notify_parent (struct task_struct *,int );extern void __wake_up_parent (struct task_struct *p,struct task_struct *parent); -extern void force_sig (int ,struct task_struct *); +extern void force_sig (int );extern int send_sig (int ,struct task_struct *,int );extern int zap_other_threads (struct task_struct *p);extern struct sigqueue *sigqueue_alloc (void );
include/linux/syscalls.h +1 -1
@@ -266,7 +266,7 @@ static inline void addr_limit_user_check(void)if (CHECK_DATA_CORRUPTION (!segment_eq (get_fs (),USER_DS ),"Invalid address limit on user-mode return" )) -force_sig (SIGKILL , current); +force_sig (SIGKILL );#ifdef TIF_FSCHECK clear_thread_flag (TIF_FSCHECK );
kernel/events/uprobes.c +2 -2
@@ -2112,7 +2112,7 @@ static void handle_trampoline(struct pt_regs *regs) sigill:uprobe_warn (current,"handle uretprobe, sending SIGILL." ); -force_sig (SIGILL , current); +force_sig (SIGILL ); }
@@ -2228,7 +2228,7 @@ static void handle_singlestep(struct uprobe_task *utask, struct pt_regs *regs)if (unlikely (err)) {uprobe_warn (current,"execute the probed insn, sending SIGILL." ); -force_sig (SIGILL , current); +force_sig (SIGILL ); } }
kernel/rseq.c +1 -1
@@ -296,7 +296,7 @@ void rseq_syscall(struct pt_regs *regs)return ;if (!access_ok (t->rseq,sizeof (*t->rseq)) ||rseq_get_rseq_cs (t, &rseq_cs) ||in_rseq_cs (ip, &rseq_cs)) - force_sig(SIGSEGV, t); + force_sig(SIGSEGV); }#endif
kernel/signal.c +3 -3
@@ -1595,9 +1595,9 @@ send_sig(int sig, struct task_struct *p, int priv) }EXPORT_SYMBOL (send_sig); -void force_sig (int sig,struct task_struct *p) +void force_sig (int sig) { -force_sig_info (sig,SEND_SIG_PRIV , p); +force_sig_info (sig,SEND_SIG_PRIV , current); }EXPORT_SYMBOL (force_sig);
@@ -1617,7 +1617,7 @@ void force_sigsegv(int sig) p->sighand->action[sig -1 ].sa.sa_handler =SIG_DFL ;spin_unlock_irqrestore (&p->sighand->siglock, flags); } -force_sig (SIGSEGV , p); +force_sig (SIGSEGV ); } int force_sig_fault(int sig, int code, void __user *addr
security/safesetid/lsm.c +2 -2
@@ -111,7 +111,7 @@ static int check_uid_transition(kuid_t parent, kuid_t child)* that could arise from a missing whitelist entry preventing a * privileged process from dropping to a lesser-privileged one. */ -force_sig (SIGKILL , current); +force_sig (SIGKILL );return -EACCES ; }
@@ -203,7 +203,7 @@ static int safesetid_task_fix_setuid(struct cred *new,break ;default :pr_warn ("Unknown setid state %d\n" , flags); -force_sig (SIGKILL , current); +force_sig (SIGKILL );return -EINVAL ; }return 0 ;
Signature · 1 line
2.21.0
PATCH 10/26 signal: Remove task parameter from force_sig_mceerr
In reply to Eric W. BiedermanAll of the callers pass current into force_sig_mceer so remove the task parameter to make this obvious.
This also makes it clear that force_sig_mceerr passes current into force_sig_info.
--- arch/arm64/kernel/traps.c | 2 +- arch/parisc/mm/fault.c | 2 +- arch/powerpc/mm/fault.c | 3 +-- arch/x86/mm/fault.c | 2 +- include/linux/sched/signal.h | 2 +- kernel/signal.c | 4 ++-- mm/memory-failure.c | 2 +- 7 files changed, 8 insertions(+), 9 deletions(-)
arch/arm64/kernel/traps.c +1 -1
@@ -263,7 +263,7 @@ void arm64_force_sig_mceerr(int code, void __user *addr, short lsb, const char *str) {arm64_show_signal (SIGBUS , str); -force_sig_mceerr (code, addr, lsb, current); +force_sig_mceerr (code, addr, lsb); } void arm64_force_sig_ptrace_errno_trap(int errno, void __user *addr,
arch/parisc/mm/fault.c +1 -1
@@ -403,7 +403,7 @@ void do_page_fault(struct pt_regs *regs, unsigned long code, lsb =PAGE_SHIFT ;force_sig_mceerr (BUS_MCEERR_AR , (void __user *) address, - lsb, current); + lsb); return; }#endif
arch/powerpc/mm/fault.c +1 -2
@@ -182,8 +182,7 @@ static int do_sigbus(struct pt_regs *regs, unsigned long address,if (fault &VM_FAULT_HWPOISON ) lsb =PAGE_SHIFT ; -force_sig_mceerr (BUS_MCEERR_AR , (void __user *)address, lsb, - current); +force_sig_mceerr (BUS_MCEERR_AR , (void __user *)address, lsb);return 0 ; }
arch/x86/mm/fault.c +1 -1
@@ -1040,7 +1040,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address, lsb =hstate_index_to_shift (VM_FAULT_GET_HINDEX (fault));if (fault &VM_FAULT_HWPOISON ) lsb =PAGE_SHIFT ; -force_sig_mceerr (BUS_MCEERR_AR , (void __user *)address, lsb, tsk); +force_sig_mceerr (BUS_MCEERR_AR , (void __user *)address, lsb); return; }#endif
include/linux/sched/signal.h +1 -1
@@ -316,7 +316,7 @@ int send_sig_fault(int sig, int code, void __user *addr ___ARCH_SI_IA64(int imm, unsigned int flags, unsigned long isr) , struct task_struct *t); -int force_sig_mceerr (int code,void __user *,short ,struct task_struct *); +int force_sig_mceerr (int code,void __user *,short );int send_sig_mceerr (int code,void __user *,short ,struct task_struct *);int force_sig_bnderr (void __user *addr,void __user *lower,void __user *upper);
kernel/signal.c +2 -2
@@ -1666,7 +1666,7 @@ int send_sig_fault(int sig, int code, void __user *addrreturn send_sig_info (info.si_signo, &info, t); } -int force_sig_mceerr (int code,void __user *addr,short lsb,struct task_struct *t) +int force_sig_mceerr (int code,void __user *addr,short lsb) {struct kernel_siginfo info;
@@ -1677,7 +1677,7 @@ int force_sig_mceerr(int code, void __user *addr, short lsb, struct task_struct info.si_code = code; info.si_addr = addr; info.si_addr_lsb = lsb; -return force_sig_info (info.si_signo, &info, t); +return force_sig_info (info.si_signo, &info, current); }int send_sig_mceerr (int code,void __user *addr,short lsb,struct task_struct *t)
mm/memory-failure.c +1 -1
@@ -221,7 +221,7 @@ static int kill_proc(struct to_kill *tk, unsigned long pfn, int flags)if ((flags &MF_ACTION_REQUIRED ) && t->mm == current->mm) { ret =force_sig_mceerr (BUS_MCEERR_AR , (void __user *)tk->addr, - addr_lsb, current); + addr_lsb); }else {/* * Don't use force here, it's convenient if the signal
Signature · 1 line
2.21.0
PATCH 11/26 signal/x86: Remove task parameter from send_sigtrap
In reply to Eric W. BiedermanThe send_sigtrap function is always called with task == current. Make that explicit by removing the task parameter.
This also makes it clear that the x86 send_sigtrap passes current into force_sig_fault.
--- arch/x86/include/asm/ptrace.h | 3 +-- arch/x86/kernel/ptrace.c | 7 ++++--- arch/x86/kernel/traps.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-)
arch/x86/include/asm/ptrace.h +1 -2
@@ -102,8 +102,7 @@ extern unsigned long profile_pc(struct pt_regs *regs);extern unsigned long convert_ip_to_linear (struct task_struct *child,struct pt_regs *regs); -extern void send_sigtrap (struct task_struct *tsk,struct pt_regs *regs, -int error_code,int si_code); +extern void send_sigtrap (struct pt_regs *regs,int error_code,int si_code);static inline unsigned long regs_return_value (struct pt_regs *regs)
arch/x86/kernel/ptrace.c +4 -3
@@ -1360,9 +1360,10 @@ const struct user_regset_view *task_user_regset_view(struct task_struct *task)#endif } -void send_sigtrap (struct task_struct *tsk,struct pt_regs *regs, -int error_code,int si_code) +void send_sigtrap (struct pt_regs *regs,int error_code,int si_code) { +struct task_struct *tsk = current; + tsk->thread.trap_nr =X86_TRAP_DB ; tsk->thread.error_code = error_code;
@@ -1373,5 +1374,5 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,void user_single_step_report (struct pt_regs *regs) { -send_sigtrap (current, regs,0 ,TRAP_BRKPT ); +send_sigtrap (regs,0 ,TRAP_BRKPT ); }
arch/x86/kernel/traps.c +1 -1
@@ -805,7 +805,7 @@ dotraplinkage void do_debug(struct pt_regs *regs, long error_code) } si_code =get_si_code (tsk->thread.debugreg6);if (tsk->thread.debugreg6 & (DR_STEP |DR_TRAP_BITS ) || user_icebp) -send_sigtrap (tsk, regs, error_code, si_code); +send_sigtrap (regs, error_code, si_code);cond_local_irq_disable (regs);debug_stack_usage_dec ();
Signature · 1 line
2.21.0
Re: [REVIEW][PATCH 11/26] signal/x86: Remove task parameter from send_sigtrap
Quoted 7 lines · Eric W. Biederman
The
send_sigtrapfunction is always called with task == current. Make that explicit by removing the task parameter.This also makes it clear that the x86
send_sigtrappasses current intoforce_sig_fault.Signed-off-by "Eric W. Biederman" <[email protected]>
PATCH 12/26 signal/um: Remove task parameter from send_sigtrap
In reply to Eric W. BiedermanThe send_sigtrap function is always called with task == current. Make that explicit by removing the task parameter.
This also makes it clear that the uml send_sigtrap passes current into force_sig_fault.
--- arch/um/kernel/ptrace.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
arch/um/kernel/ptrace.c +4 -4
@@ -112,13 +112,13 @@ long arch_ptrace(struct task_struct *child, long request,return ret; } -static void send_sigtrap (struct task_struct *tsk,struct uml_pt_regs *regs, -int error_code) +static void send_sigtrap (struct uml_pt_regs *regs,int error_code) {/* Send us the fake SIGTRAP */ force_sig_fault (SIGTRAP ,TRAP_BRKPT ,/* User-mode eip? */ -UPT_IS_USER (regs) ? (void __user *)UPT_IP (regs) :NULL , tsk); +UPT_IS_USER (regs) ? (void __user *)UPT_IP (regs) :NULL , + current); }/*
@@ -147,7 +147,7 @@ void syscall_trace_leave(struct pt_regs *regs)/* Fake a debug trap */ if (ptraced &PT_DTRACE ) -send_sigtrap (current, ®s->regs,0 ); +send_sigtrap (®s->regs,0 );if (!test_thread_flag (TIF_SYSCALL_TRACE ))return ;
Signature · 1 line
2.21.0
PATCH 13/26 signal/sh: Remove tsk parameter from force_sig_info_fault
In reply to Eric W. BiedermanThe force_sig_info_fault function is always called with tsk == current. Make that explicit by removing the tsk parameter.
This also makes it clear that the sh force_sig_info_fault passes current into force_sig_fault.
--- arch/sh/mm/fault.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-)
arch/sh/mm/fault.c +4 -7
@@ -39,10 +39,9 @@ static inline int notify_page_fault(struct pt_regs *regs, int trap) }static void -force_sig_info_fault (int si_signo,int si_code,unsigned long address, -struct task_struct *tsk) +force_sig_info_fault (int si_signo,int si_code,unsigned long address) { -force_sig_fault (si_signo, si_code, (void __user *)address, tsk); +force_sig_fault (si_signo, si_code, (void __user *)address, current); }/*
@@ -244,8 +243,6 @@ static void __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code, unsigned long address, int si_code) { - struct task_struct *tsk = current; - /* User mode accesses just cause a SIGSEGV */ if (user_mode(regs)) {/*
@@ -253,7 +250,7 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,*/ local_irq_enable (); -force_sig_info_fault (SIGSEGV , si_code, address, tsk); +force_sig_info_fault (SIGSEGV , si_code, address);return ; }
@@ -308,7 +305,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address)if (!user_mode (regs))no_context (regs, error_code, address); -force_sig_info_fault (SIGBUS ,BUS_ADRERR , address, tsk); +force_sig_info_fault (SIGBUS ,BUS_ADRERR , address); }static noinline int
Signature · 1 line
2.21.0
PATCH 14/26 signal/riscv: Remove tsk parameter from do_trap
In reply to Eric W. BiedermanThe do_trap function is always called with tsk == current. Make that obvious by removing the tsk parameter.
This also makes it clear that do_trap calls force_sig_fault on the current task.
--- arch/riscv/include/asm/bug.h | 2 +- arch/riscv/kernel/traps.c | 7 ++++--- arch/riscv/mm/fault.c | 6 +++--- 3 files changed, 8 insertions(+), 7 deletions(-)
arch/riscv/include/asm/bug.h +1 -1
@@ -94,7 +94,7 @@ struct task_struct;extern void die (struct pt_regs *regs,const char *str);extern void do_trap (struct pt_regs *regs,int signo,int code, -unsigned long addr,struct task_struct *tsk); +unsigned long addr);#endif /* !__ASSEMBLY__ */
arch/riscv/kernel/traps.c +4 -3
@@ -63,9 +63,10 @@ void die(struct pt_regs *regs, const char *str)do_exit (SIGSEGV ); } -void do_trap (struct pt_regs *regs,int signo,int code, -unsigned long addr,struct task_struct *tsk) +void do_trap (struct pt_regs *regs,int signo,int code,unsigned long addr) { +struct task_struct *tsk = current; +if (show_unhandled_signals &&unhandled_signal (tsk, signo) &&printk_ratelimit ()) { pr_info("%s[%d]: unhandled signal %d code 0x%x at 0x" REG_FMT,
@@ -82,7 +83,7 @@ static void do_trap_error(struct pt_regs *regs, int signo, int code, unsigned long addr, const char *str) { if (user_mode(regs)) { -do_trap (regs ,signo ,code ,addr ,current ); +do_trap (regs ,signo ,code ,addr ); } else {if (!fixup_exception (regs))die (regs, str);
arch/riscv/mm/fault.c +3 -3
@@ -181,7 +181,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs)up_read (&mm->mmap_sem);/* User mode accesses just cause a SIGSEGV */ if (user_mode (regs)) { -do_trap (regs,SIGSEGV , code, addr, tsk); +do_trap (regs,SIGSEGV , code, addr);return ; }
@@ -217,7 +217,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs)/* Kernel mode? Handle exceptions or die */ if (!user_mode (regs)) goto no_context; -do_trap (regs,SIGBUS ,BUS_ADRERR , addr, tsk); +do_trap (regs,SIGBUS ,BUS_ADRERR , addr);return ; vmalloc_fault:
@@ -231,7 +231,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs)/* User mode accesses just cause a SIGSEGV */ if (user_mode (regs)) -return do_trap (regs,SIGSEGV , code, addr, tsk); +return do_trap (regs,SIGSEGV , code, addr);/* * Synchronize this task's top level page-table
Signature · 1 line
2.21.0
PATCH 15/26 signal/nds32: Remove tsk parameter from send_sigtrap
In reply to Eric W. BiedermanThe send_sigtrap function is always called with tsk == current. Make that obvious by removing the tsk parameter.
This also makes it clear that send_sigtrap always calls force_sig_fault on the current task.
--- arch/nds32/kernel/traps.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
arch/nds32/kernel/traps.c +4 -3
@@ -255,9 +255,10 @@ void __init early_trap_init(void)cpu_cache_wbinval_page (base, true); } -void send_sigtrap (struct task_struct *tsk,struct pt_regs *regs, -int error_code,int si_code) +static void send_sigtrap (struct pt_regs *regs,int error_code,int si_code) { +struct task_struct *tsk = current; + tsk->thread.trap_no =ENTRY_DEBUG_RELATED ; tsk->thread.error_code = error_code;
@@ -274,7 +275,7 @@ void do_debug_trap(unsigned long entry, unsigned long addr,if (user_mode (regs)) {/* trap_signal */ -send_sigtrap (current, regs,0 ,TRAP_BRKPT ); +send_sigtrap (regs,0 ,TRAP_BRKPT ); }else {/* kernel_trap */ if (!fixup_exception (regs))
Signature · 1 line
2.21.0
PATCH 16/26 signal/arm: Remove tsk parameter from ptrace_break
In reply to Eric W. BiedermanThe ptrace_break function is always called with tsk == current. Make that obvious by removing the tsk parameter.
This also makes it clear that ptrace_break calls force_sig_fault on the current task.
--- arch/arm/include/asm/traps.h | 2 +- arch/arm/kernel/ptrace.c | 6 +++--- arch/arm/kernel/traps.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-)
arch/arm/include/asm/traps.h +1 -1
@@ -30,7 +30,7 @@ static inline int __in_irqentry_text(unsigned long ptr)extern void __init early_trap_init (void *);extern void dump_backtrace_entry (unsigned long where,unsigned long from,unsigned long frame); -extern void ptrace_break (struct task_struct *tsk,struct pt_regs *regs); +extern void ptrace_break (struct pt_regs *regs);extern void *vectors_page;
arch/arm/kernel/ptrace.c +3 -3
@@ -201,15 +201,15 @@ void ptrace_disable(struct task_struct *child)/* * Handle hitting a breakpoint. */ -void ptrace_break (struct task_struct *tsk,struct pt_regs *regs) +void ptrace_break (struct pt_regs *regs) {force_sig_fault (SIGTRAP ,TRAP_BRKPT , - (void __user *)instruction_pointer (regs), tsk); + (void __user *)instruction_pointer (regs), current); }static int break_trap (struct pt_regs *regs,unsigned int instr) { -ptrace_break (current, regs); +ptrace_break (regs);return 0 ; }
arch/arm/kernel/traps.c +1 -1
@@ -606,7 +606,7 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)case NR (breakpoint):/* SWI BREAK_POINT */ regs->ARM_pc -=thumb_mode (regs) ?2 :4 ; -ptrace_break (current, regs); +ptrace_break (regs);return regs->ARM_r0;/*
Signature · 1 line
2.21.0
PATCH 17/26 signal/arm: Remove tsk parameter from __do_user_fault
In reply to Eric W. BiedermanThe __do_user_fault function is always called with tsk == current. Make that obvious by removing the tsk parameter.
This makes it clear that __do_user_fault calls force_sig_fault on the current task.
--- arch/arm/mm/fault.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
arch/arm/mm/fault.c +6 -5
@@ -157,10 +157,11 @@ __do_kernel_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,* User mode accesses just cause a SIGSEGV */ static void -__do_user_fault (struct task_struct *tsk,unsigned long addr, -unsigned int fsr,unsigned int sig,int code, -struct pt_regs *regs) +__do_user_fault (unsigned long addr,unsigned int fsr,unsigned int sig, +int code,struct pt_regs *regs) { +struct task_struct *tsk = current; +if (addr >TASK_SIZE )harden_branch_predictor ();
@@ -196,7 +197,7 @@ void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs)* have no context to handle this fault with. */ if (user_mode (regs)) -__do_user_fault (tsk, addr, fsr,SIGSEGV ,SEGV_MAPERR , regs); +__do_user_fault (addr, fsr,SIGSEGV ,SEGV_MAPERR , regs);else __do_kernel_fault (mm, addr, fsr, regs); }
@@ -392,7 +393,7 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs) SEGV_ACCERR :SEGV_MAPERR ; } -__do_user_fault (tsk, addr, fsr, sig, code, regs); +__do_user_fault (addr, fsr, sig, code, regs);return 0 ; no_context:
Signature · 1 line
2.21.0
PATCH 18/26 signal/unicore32: Remove tsk parameter from __do_user_fault
In reply to Eric W. BiedermanThe __do_user_fault function is always called with tsk == current. Make that obvious by removing the tsk parameter.
This makes it clear that __do_user_fault calls force_sig_fault on the current task.
--- arch/unicore32/mm/fault.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-)
arch/unicore32/mm/fault.c +6 -5
@@ -116,10 +116,11 @@ static void __do_kernel_fault(struct mm_struct *mm, unsigned long addr,* Something tried to access memory that isn't in our memory map.. * User mode accesses just cause a SIGSEGV */ -static void __do_user_fault (struct task_struct *tsk,unsigned long addr, -unsigned int fsr,unsigned int sig,int code, -struct pt_regs *regs) +static void __do_user_fault (unsigned long addr,unsigned int fsr, +unsigned int sig,int code,struct pt_regs *regs) { +struct task_struct *tsk = current; + tsk->thread.address = addr; tsk->thread.error_code = fsr; tsk->thread.trap_no =14 ;
@@ -136,7 +137,7 @@ void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs)* have no context to handle this fault with. */ if (user_mode (regs)) -__do_user_fault (tsk, addr, fsr,SIGSEGV ,SEGV_MAPERR , regs); +__do_user_fault (addr, fsr,SIGSEGV ,SEGV_MAPERR , regs);else __do_kernel_fault (mm, addr, fsr, regs); }
@@ -310,7 +311,7 @@ static int do_pf(unsigned long addr, unsigned int fsr, struct pt_regs *regs) code = fault ==VM_FAULT_BADACCESS ?SEGV_ACCERR :SEGV_MAPERR ; } -__do_user_fault (tsk, addr, fsr, sig, code, regs); +__do_user_fault (addr, fsr, sig, code, regs);return 0 ; no_context:
Signature · 1 line
2.21.0
PATCH 19/26 signal: Explicitly call force_sig_fault on current
In reply to Eric W. BiedermanUpdate the calls of force_sig_fault that pass in a variable that is set to current earlier to explicitly use current.
This is to make the next change that removes the task parameter from force_sig_fault easier to verify.
--- arch/arc/kernel/traps.c | 2 +- arch/arc/mm/fault.c | 4 ++-- arch/arm/mm/fault.c | 2 +- arch/mips/mm/fault.c | 4 ++-- arch/nds32/kernel/traps.c | 2 +- arch/nds32/mm/fault.c | 4 ++-- arch/openrisc/mm/fault.c | 4 ++-- arch/riscv/kernel/traps.c | 2 +- arch/sh/math-emu/math.c | 2 +- arch/unicore32/mm/fault.c | 2 +- arch/x86/kernel/ptrace.c | 2 +- arch/x86/kernel/traps.c | 4 ++-- arch/x86/kernel/umip.c | 2 +- arch/x86/mm/fault.c | 6 +++--- 14 files changed, 21 insertions(+), 21 deletions(-)
arch/arc/kernel/traps.c +1 -1
@@ -50,7 +50,7 @@ unhandled_exception(const char *str, struct pt_regs *regs, tsk->thread.fault_address = (__force unsigned int )addr; -force_sig_fault (signo, si_code, addr, tsk); +force_sig_fault (signo, si_code, addr, current); }else {/* If not due to copy_(to|from)_user, we are doomed */
arch/arc/mm/fault.c +2 -2
@@ -202,7 +202,7 @@ void do_page_fault(unsigned long address, struct pt_regs *regs)/* User mode accesses just cause a SIGSEGV */ if (user_mode (regs)) { tsk->thread.fault_address = address; -force_sig_fault (SIGSEGV , si_code, (void __user *)address, tsk); +force_sig_fault (SIGSEGV , si_code, (void __user *)address, current);return ; }
@@ -237,5 +237,5 @@ void do_page_fault(unsigned long address, struct pt_regs *regs) goto no_context; tsk->thread.fault_address = address; -force_sig_fault (SIGBUS ,BUS_ADRERR , (void __user *)address, tsk); +force_sig_fault (SIGBUS ,BUS_ADRERR , (void __user *)address, current); }
arch/arm/mm/fault.c +1 -1
@@ -184,7 +184,7 @@ __do_user_fault(unsigned long addr, unsigned int fsr, unsigned int sig, tsk->thread.address = addr; tsk->thread.error_code = fsr; tsk->thread.trap_no =14 ; -force_sig_fault (sig, code, (void __user *)addr, tsk); +force_sig_fault (sig, code, (void __user *)addr, current); }void do_bad_area (unsigned long addr,unsigned int fsr,struct pt_regs *regs)
arch/mips/mm/fault.c +2 -2
@@ -223,7 +223,7 @@ static void __kprobes __do_page_fault(struct pt_regs *regs, unsigned long write,pr_cont ("\n" ); } current->thread.trap_nr = (regs->cp0_cause >>2 ) &0x1f ; -force_sig_fault (SIGSEGV , si_code, (void __user *)address, tsk); +force_sig_fault (SIGSEGV , si_code, (void __user *)address, current);return ; }
@@ -279,7 +279,7 @@ static void __kprobes __do_page_fault(struct pt_regs *regs, unsigned long write,#endif current->thread.trap_nr = (regs->cp0_cause >>2 ) &0x1f ; tsk->thread.cp0_badvaddr = address; -force_sig_fault (SIGBUS ,BUS_ADRERR , (void __user *)address, tsk); +force_sig_fault (SIGBUS ,BUS_ADRERR , (void __user *)address, current);return ;#ifndef CONFIG_64BIT
arch/nds32/kernel/traps.c +1 -1
@@ -263,7 +263,7 @@ static void send_sigtrap(struct pt_regs *regs, int error_code, int si_code) tsk->thread.error_code = error_code;force_sig_fault (SIGTRAP , si_code, - (void __user *)instruction_pointer (regs), tsk); + (void __user *)instruction_pointer (regs), current); } void do_debug_trap(unsigned long entry, unsigned long addr,
arch/nds32/mm/fault.c +2 -2
@@ -271,7 +271,7 @@ void do_page_fault(unsigned long entry, unsigned long addr, tsk->thread.address = addr; tsk->thread.error_code = error_code; tsk->thread.trap_no = entry; -force_sig_fault (SIGSEGV , si_code, (void __user *)addr, tsk); +force_sig_fault (SIGSEGV , si_code, (void __user *)addr, current);return ; }
@@ -340,7 +340,7 @@ void do_page_fault(unsigned long entry, unsigned long addr, tsk->thread.address = addr; tsk->thread.error_code = error_code; tsk->thread.trap_no = entry; -force_sig_fault (SIGBUS ,BUS_ADRERR , (void __user *)addr, tsk); +force_sig_fault (SIGBUS ,BUS_ADRERR , (void __user *)addr, current);return ;
arch/openrisc/mm/fault.c +2 -2
@@ -213,7 +213,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long address,/* User mode accesses just cause a SIGSEGV */ if (user_mode (regs)) { -force_sig_fault (SIGSEGV , si_code, (void __user *)address, tsk); +force_sig_fault (SIGSEGV , si_code, (void __user *)address, current);return ; }
@@ -278,7 +278,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long address,* Send a sigbus, regardless of whether we were in kernel * or user mode. */ -force_sig_fault (SIGBUS ,BUS_ADRERR , (void __user *)address, tsk); +force_sig_fault (SIGBUS ,BUS_ADRERR , (void __user *)address, current);/* Kernel mode? Handle exceptions or die */ if (!user_mode (regs))
arch/riscv/kernel/traps.c +1 -1
@@ -76,7 +76,7 @@ void do_trap(struct pt_regs *regs, int signo, int code, unsigned long addr)show_regs (regs); } -force_sig_fault (signo, code, (void __user *)addr, tsk); +force_sig_fault (signo, code, (void __user *)addr, current); } static void do_trap_error(struct pt_regs *regs, int signo, int code,
arch/sh/math-emu/math.c +1 -1
@@ -560,7 +560,7 @@ static int ieee_fpe_handler(struct pt_regs *regs)task_thread_info (tsk)->status |=TS_USEDFPU ; }else {force_sig_fault (SIGFPE ,FPE_FLTINV , - (void __user *)regs->pc, tsk); + (void __user *)regs->pc, current); } regs->pc = nextpc;
arch/unicore32/mm/fault.c +1 -1
@@ -124,7 +124,7 @@ static void __do_user_fault(unsigned long addr, unsigned int fsr, tsk->thread.address = addr; tsk->thread.error_code = fsr; tsk->thread.trap_no =14 ; -force_sig_fault (sig, code, (void __user *)addr, tsk); +force_sig_fault (sig, code, (void __user *)addr, current); }void do_bad_area (unsigned long addr,unsigned int fsr,struct pt_regs *regs)
arch/x86/kernel/ptrace.c +1 -1
@@ -1369,7 +1369,7 @@ void send_sigtrap(struct pt_regs *regs, int error_code, int si_code)/* Send us the fake SIGTRAP */ force_sig_fault (SIGTRAP , si_code, -user_mode (regs) ? (void __user *)regs->ip :NULL , tsk); +user_mode (regs) ? (void __user *)regs->ip :NULL , current); }void user_single_step_report (struct pt_regs *regs)
arch/x86/kernel/traps.c +2 -2
@@ -256,7 +256,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,if (!sicode)force_sig (signr);else -force_sig_fault (signr, sicode, addr, tsk); +force_sig_fault (signr, sicode, addr, current); }NOKPROBE_SYMBOL (do_trap);
@@ -856,7 +856,7 @@ static void math_error(struct pt_regs *regs, int error_code, int trapnr)return ;force_sig_fault (SIGFPE , si_code, - (void __user *)uprobe_get_trap_addr (regs), task); + (void __user *)uprobe_get_trap_addr (regs), current); } dotraplinkage void do_coprocessor_error(struct pt_regs *regs, long error_code)
arch/x86/kernel/umip.c +1 -1
@@ -277,7 +277,7 @@ static void force_sig_info_umip_fault(void __user *addr, struct pt_regs *regs) tsk->thread.error_code =X86_PF_USER |X86_PF_WRITE ; tsk->thread.trap_nr =X86_TRAP_PF ; -force_sig_fault (SIGSEGV ,SEGV_MAPERR , addr, tsk); +force_sig_fault (SIGSEGV ,SEGV_MAPERR , addr, current);if (!(show_unhandled_signals &&unhandled_signal (tsk,SIGSEGV )))return ;
arch/x86/mm/fault.c +3 -3
@@ -757,7 +757,7 @@ no_context(struct pt_regs *regs, unsigned long error_code,/* XXX: hwpoison faults will set the wrong code. */ force_sig_fault (signal, si_code, (void __user *)address, - tsk); + current); }/*
@@ -918,7 +918,7 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,if (si_code ==SEGV_PKUERR )force_sig_pkuerr ((void __user *)address, pkey); -force_sig_fault (SIGSEGV , si_code, (void __user *)address, tsk); +force_sig_fault (SIGSEGV , si_code, (void __user *)address, current);return ; }
@@ -1044,7 +1044,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address, return; }#endif -force_sig_fault (SIGBUS ,BUS_ADRERR , (void __user *)address, tsk); +force_sig_fault (SIGBUS ,BUS_ADRERR , (void __user *)address, current); }static noinline void
Signature · 1 line
2.21.0
PATCH 20/26 signal: Use force_sig_fault_to_task for the two calls that don't deliver to current
In reply to Eric W. BiedermanIn preparation for removing the task parameter from force_sig_fault introduce force_sig_fault_to_task and use it for the two cases where it matters.
On mips force_fcr31_sig calls force_sig_fault and is called on either the current task, or a task that is suspended and is being switched to by the scheduler. This is safe because the task being switched to by the scheduler is guaranteed to be suspended. This ensures that task->sighand is stable while the signal is delivered to it.
On parisc user_enable_single_step calls force_sig_fault and is in turn called by ptrace_request. The function ptrace_request always calls user_enable_single_step on a child that is stopped for tracing. The child being traced and not reaped ensures that child->sighand is not NULL, and that the child will not change child->sighand.
--- arch/mips/kernel/traps.c | 2 +- arch/parisc/kernel/ptrace.c | 6 +++--- include/linux/sched/signal.h | 4 ++++ kernel/signal.c | 12 +++++++++++- 4 files changed, 19 insertions(+), 5 deletions(-)
arch/mips/kernel/traps.c +1 -1
@@ -733,7 +733,7 @@ void force_fcr31_sig(unsigned long fcr31, void __user *fault_addr,else if (fcr31 &FPU_CSR_INE_X ) si_code =FPE_FLTRES ; -force_sig_fault (SIGFPE , si_code, fault_addr, tsk); +force_sig_fault_to_task (SIGFPE , si_code, fault_addr, tsk); }int process_fpemu_return (int sig,void __user *fault_addr,unsigned long fcr31)
arch/parisc/kernel/ptrace.c +3 -3
@@ -88,9 +88,9 @@ void user_enable_single_step(struct task_struct *task)ptrace_disable (task);/* Don't wake up the task, but let the parent know something happened. */ -force_sig_fault (SIGTRAP ,TRAP_TRACE , - (void __user *) (task_regs (task)->iaoq[0 ] & ~3 ), - task); +force_sig_fault_to_task (SIGTRAP ,TRAP_TRACE , + (void __user *) (task_regs (task)->iaoq[0 ] & ~3 ), + task);/* notify_parent(task, SIGCHLD); */ return ; }
include/linux/sched/signal.h +4 -0
@@ -307,6 +307,10 @@ static inline void kernel_signal_stop(void)# define ___ARCH_SI_IA64 (_a1, _a2, _a3)#endif +int force_sig_fault_to_task(int sig, int code, void __user *addr +___ARCH_SI_TRAPNO (int trapno) + ___ARCH_SI_IA64(int imm, unsigned int flags, unsigned long isr) + , struct task_struct *t); int force_sig_fault(int sig, int code, void __user *addr___ARCH_SI_TRAPNO (int trapno) ___ARCH_SI_IA64(int imm, unsigned int flags, unsigned long isr)
kernel/signal.c +11 -1
@@ -1620,7 +1620,7 @@ void force_sigsegv(int sig)force_sig (SIGSEGV ); } -int force_sig_fault(int sig, int code, void __user *addr +int force_sig_fault_to_task(int sig, int code, void __user *addr___ARCH_SI_TRAPNO (int trapno) ___ARCH_SI_IA64(int imm, unsigned int flags, unsigned long isr) , struct task_struct *t)
@@ -1643,6 +1643,16 @@ int force_sig_fault(int sig, int code, void __user *addrreturn force_sig_info (info.si_signo, &info, t); } +int force_sig_fault(int sig, int code, void __user *addr +___ARCH_SI_TRAPNO (int trapno) + ___ARCH_SI_IA64(int imm, unsigned int flags, unsigned long isr) + , struct task_struct *t) +{ + return force_sig_fault_to_task(sig, code, addr +___ARCH_SI_TRAPNO (trapno ) +___ARCH_SI_IA64 (imm, flags, isr),t ); +} + int send_sig_fault(int sig, int code, void __user *addr___ARCH_SI_TRAPNO (int trapno) ___ARCH_SI_IA64(int imm, unsigned int flags, unsigned long isr)
Signature · 1 line
2.21.0
PATCH 21/26 signal: Remove the task parameter from force_sig_fault
In reply to Eric W. BiedermanAs synchronous exceptions really only make sense against the current task (otherwise how are you synchronous) remove the task parameter from from force_sig_fault to make it explicit that is what is going on.
The two known exceptions that deliver a synchronous exception to a stopped ptraced task have already been changed to force_sig_fault_to_task.
The callers have been changed with the following emacs regular expression (with obvious variations on the architectures that take more arguments) to avoid typos:
force_sig_fault[(]\([^,]+\)[,]\([^,]+\)[,]\([^,]+\)[,]\W+current[)] ->force_sig_fault(\1,\2,\3)
--- arch/alpha/kernel/traps.c | 2 +- arch/alpha/mm/fault.c | 4 +-- arch/arc/kernel/traps.c | 2 +- arch/arc/mm/fault.c | 4 +-- arch/arm/kernel/ptrace.c | 2 +- arch/arm/kernel/traps.c | 2 +- arch/arm/mm/alignment.c | 2 +- arch/arm/mm/fault.c | 2 +- arch/arm64/kernel/traps.c | 2 +- arch/c6x/kernel/traps.c | 2 +- arch/csky/abiv1/alignment.c | 2 +- arch/csky/abiv2/fpu.c | 2 +- arch/csky/kernel/traps.c | 2 +- arch/csky/mm/fault.c | 4 +-- arch/hexagon/kernel/traps.c | 2 +- arch/hexagon/mm/vm_fault.c | 4 +-- arch/ia64/kernel/brl_emu.c | 6 ++-- arch/ia64/kernel/traps.c | 18 +++++------ arch/ia64/kernel/unaligned.c | 2 +- arch/ia64/mm/fault.c | 2 +- arch/m68k/kernel/traps.c | 4 +-- arch/m68k/mm/fault.c | 4 +-- arch/microblaze/kernel/exceptions.c | 2 +- arch/microblaze/mm/fault.c | 2 +- arch/mips/kernel/traps.c | 12 +++---- arch/mips/mm/fault.c | 4 +-- arch/nds32/kernel/fpu.c | 2 +- arch/nds32/kernel/traps.c | 4 +-- arch/nds32/mm/fault.c | 4 +-- arch/nios2/kernel/traps.c | 2 +- arch/openrisc/kernel/traps.c | 8 ++--- arch/parisc/kernel/traps.c | 14 ++++---- arch/parisc/kernel/unaligned.c | 4 +-- arch/parisc/math-emu/driver.c | 2 +- arch/parisc/mm/fault.c | 2 +- arch/powerpc/kernel/process.c | 2 +- arch/powerpc/kernel/traps.c | 4 +-- arch/powerpc/mm/fault.c | 2 +- arch/powerpc/platforms/cell/spufs/fault.c | 9 +++--- arch/riscv/kernel/traps.c | 4 +-- arch/s390/kernel/traps.c | 6 ++-- arch/s390/mm/fault.c | 6 ++-- arch/sh/kernel/hw_breakpoint.c | 2 +- arch/sh/kernel/traps_32.c | 2 +- arch/sh/math-emu/math.c | 2 +- arch/sh/mm/fault.c | 2 +- arch/sparc/kernel/process_64.c | 2 +- arch/sparc/kernel/sys_sparc_32.c | 2 +- arch/sparc/kernel/sys_sparc_64.c | 2 +- arch/sparc/kernel/traps_32.c | 4 +-- arch/sparc/kernel/traps_64.c | 39 +++++++++++------------ arch/sparc/mm/fault_32.c | 2 +- arch/sparc/mm/fault_64.c | 2 +- arch/um/kernel/ptrace.c | 3 +- arch/um/kernel/trap.c | 12 +++---- arch/unicore32/kernel/traps.c | 2 +- arch/unicore32/mm/fault.c | 2 +- arch/x86/entry/vsyscall/vsyscall_64.c | 2 +- arch/x86/kernel/ptrace.c | 2 +- arch/x86/kernel/traps.c | 4 +-- arch/x86/kernel/umip.c | 2 +- arch/x86/mm/fault.c | 7 ++-- arch/xtensa/kernel/traps.c | 2 +- arch/xtensa/mm/fault.c | 4 +-- include/linux/sched/signal.h | 3 +- kernel/signal.c | 5 ++- 66 files changed, 134 insertions(+), 148 deletions(-)
arch/alpha/kernel/traps.c +1 -1
@@ -402,7 +402,7 @@ do_entDbg(struct pt_regs *regs) {die_if_kernel ("Instruction fault" , regs,0 ,NULL ); -force_sig_fault (SIGILL ,ILL_ILLOPC , (void __user *)regs->pc,0 , current); +force_sig_fault (SIGILL ,ILL_ILLOPC , (void __user *)regs->pc,0 ); }
arch/alpha/mm/fault.c +2 -2
@@ -221,13 +221,13 @@ do_page_fault(unsigned long address, unsigned long mmcsr,up_read (&mm->mmap_sem);/* Send a sigbus, regardless of whether we were in kernel or user mode. */ -force_sig_fault (SIGBUS ,BUS_ADRERR , (void __user *) address,0 , current); +force_sig_fault (SIGBUS ,BUS_ADRERR , (void __user *) address,0 );if (!user_mode (regs)) goto no_context;return ; do_sigsegv: -force_sig_fault (SIGSEGV , si_code, (void __user *) address,0 , current); +force_sig_fault (SIGSEGV , si_code, (void __user *) address,0 );return ;#ifdef CONFIG_ALPHA_LARGE_VMALLOC
arch/arc/kernel/traps.c +1 -1
@@ -50,7 +50,7 @@ unhandled_exception(const char *str, struct pt_regs *regs, tsk->thread.fault_address = (__force unsigned int )addr; -force_sig_fault (signo, si_code, addr, current); +force_sig_fault (signo, si_code, addr); }else {/* If not due to copy_(to|from)_user, we are doomed */
arch/arc/mm/fault.c +2 -2
@@ -202,7 +202,7 @@ void do_page_fault(unsigned long address, struct pt_regs *regs)/* User mode accesses just cause a SIGSEGV */ if (user_mode (regs)) { tsk->thread.fault_address = address; -force_sig_fault (SIGSEGV , si_code, (void __user *)address, current); +force_sig_fault (SIGSEGV , si_code, (void __user *)address);return ; }
@@ -237,5 +237,5 @@ void do_page_fault(unsigned long address, struct pt_regs *regs) goto no_context; tsk->thread.fault_address = address; -force_sig_fault (SIGBUS ,BUS_ADRERR , (void __user *)address, current); +force_sig_fault (SIGBUS ,BUS_ADRERR , (void __user *)address); }
arch/arm/kernel/ptrace.c +1 -1
@@ -204,7 +204,7 @@ void ptrace_disable(struct task_struct *child)void ptrace_break (struct pt_regs *regs) {force_sig_fault (SIGTRAP ,TRAP_BRKPT , - (void __user *)instruction_pointer (regs), current); + (void __user *)instruction_pointer (regs)); }static int break_trap (struct pt_regs *regs,unsigned int instr)
arch/arm/kernel/traps.c +1 -1
@@ -372,7 +372,7 @@ void arm_notify_die(const char *str, struct pt_regs *regs, current->thread.error_code = err; current->thread.trap_no = trap; -force_sig_fault (signo, si_code, addr, current); +force_sig_fault (signo, si_code, addr); }else {die (str, regs, err); }
arch/arm/mm/alignment.c +1 -1
@@ -948,7 +948,7 @@ do_alignment(unsigned long addr, unsigned int fsr, struct pt_regs *regs) goto fixup;if (ai_usermode &UM_SIGNAL ) { -force_sig_fault (SIGBUS ,BUS_ADRALN , (void __user *)addr, current); +force_sig_fault (SIGBUS ,BUS_ADRALN , (void __user *)addr); }else {/* * We're about to disable the alignment trap and return to
arch/arm/mm/fault.c +1 -1
@@ -184,7 +184,7 @@ __do_user_fault(unsigned long addr, unsigned int fsr, unsigned int sig, tsk->thread.address = addr; tsk->thread.error_code = fsr; tsk->thread.trap_no =14 ; -force_sig_fault (sig, code, (void __user *)addr, current); +force_sig_fault (sig, code, (void __user *)addr); }void do_bad_area (unsigned long addr,unsigned int fsr,struct pt_regs *regs)
arch/arm64/kernel/traps.c +1 -1
@@ -256,7 +256,7 @@ void arm64_force_sig_fault(int signo, int code, void __user *addr, const char *str) {arm64_show_signal (signo, str); -force_sig_fault (signo, code, addr, current); +force_sig_fault (signo, code, addr); } void arm64_force_sig_mceerr(int code, void __user *addr, short lsb,
arch/c6x/kernel/traps.c +1 -1
@@ -253,7 +253,7 @@ static void do_trap(struct exception_info *except_info, struct pt_regs *regs)die_if_kernel (except_info->kernel_str, regs, addr);force_sig_fault (except_info->signo, except_info->code, - (void __user *)addr, current); + (void __user *)addr); }/*
arch/csky/abiv1/alignment.c +1 -1
@@ -283,7 +283,7 @@ void csky_alignment(struct pt_regs *regs)do_exit (SIGKILL ); } -force_sig_fault (SIGBUS ,BUS_ADRALN , (void __user *)addr, current); +force_sig_fault (SIGBUS ,BUS_ADRALN , (void __user *)addr); }static struct ctl_table alignment_tbl[4 ] = {
arch/csky/abiv2/fpu.c +1 -1
@@ -124,7 +124,7 @@ void fpu_fpe(struct pt_regs *regs) code =FPE_FLTRES ; } -force_sig_fault (sig, code, (void __user *)regs->pc, current); +force_sig_fault (sig, code, (void __user *)regs->pc); }#define FMFVR_FPU_REGS (vrx, vry) \
arch/csky/kernel/traps.c +1 -1
@@ -106,7 +106,7 @@ void buserr(struct pt_regs *regs)pr_err ("User mode Bus Error\n" );show_regs (regs); -force_sig_fault (SIGSEGV ,0 , (void __user *)regs->pc, current); +force_sig_fault (SIGSEGV ,0 , (void __user *)regs->pc); }#define USR_BKPT 0x1464
arch/csky/mm/fault.c +2 -2
@@ -179,7 +179,7 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long write, bad_area_nosemaphore:/* User mode accesses just cause a SIGSEGV */ if (user_mode (regs)) { -force_sig_fault (SIGSEGV , si_code, (void __user *)address, current); +force_sig_fault (SIGSEGV , si_code, (void __user *)address);return ; }
@@ -212,5 +212,5 @@ asmlinkage void do_page_fault(struct pt_regs *regs, unsigned long write,if (!user_mode (regs)) goto no_context; -force_sig_fault (SIGBUS ,BUS_ADRERR , (void __user *)address, current); +force_sig_fault (SIGBUS ,BUS_ADRERR , (void __user *)address); }
arch/hexagon/kernel/traps.c +1 -1
@@ -420,7 +420,7 @@ void do_trap0(struct pt_regs *regs)* may want to use a different trap0 flavor. */ force_sig_fault (SIGTRAP ,TRAP_BRKPT , - (void __user *)pt_elr (regs), current); + (void __user *)pt_elr (regs)); }else {#ifdef CONFIG_KGDB kgdb_handle_exception(pt_cause(regs), SIGTRAP,
arch/hexagon/mm/vm_fault.c +2 -2
@@ -148,14 +148,14 @@ void do_page_fault(unsigned long address, long cause, struct pt_regs *regs) si_signo =SIGSEGV ; si_code =SEGV_ACCERR ; } -force_sig_fault (si_signo, si_code, (void __user *)address, current); +force_sig_fault (si_signo, si_code, (void __user *)address);return ; bad_area:up_read (&mm->mmap_sem);if (user_mode (regs)) { -force_sig_fault (SIGSEGV , si_code, (void __user *)address, current); +force_sig_fault (SIGSEGV , si_code, (void __user *)address);return ; }/* Kernel-mode fault falls through */
arch/ia64/kernel/brl_emu.c +3 -3
@@ -197,21 +197,21 @@ ia64_emulate_brl (struct pt_regs *regs, unsigned long ar_ec)*/ printk (KERN_DEBUG "Woah! Unimplemented Instruction Address Trap!\n" );force_sig_fault (SIGILL ,ILL_BADIADDR , (void __user *)NULL , -0 ,0 ,0 , current); +0 ,0 ,0 ); }else if (ia64_psr (regs)->tb) {/* * Branch Tracing is enabled. * Force a taken branch signal. */ force_sig_fault (SIGTRAP ,TRAP_BRANCH , (void __user *)NULL , -0 ,0 ,0 , current); +0 ,0 ,0 ); }else if (ia64_psr (regs)->ss) {/* * Single Step is enabled. * Force a trace signal. */ force_sig_fault (SIGTRAP ,TRAP_TRACE , (void __user *)NULL , -0 ,0 ,0 , current); +0 ,0 ,0 ); }return rv; }
arch/ia64/kernel/traps.c +9 -9
@@ -176,7 +176,7 @@ __kprobes ia64_bad_break (unsigned long break_num, struct pt_regs *regs) }force_sig_fault (sig, code, (void __user *) (regs->cr_iip +ia64_psr (regs)->ri), - break_num,0 /* clear __ISR_VALID */ ,0 , current); + break_num,0 /* clear __ISR_VALID */ ,0 ); }/*
@@ -353,7 +353,7 @@ handle_fpu_swa (int fp_fault, struct pt_regs *regs, unsigned long isr) }force_sig_fault (SIGFPE , si_code, (void __user *) (regs->cr_iip +ia64_psr (regs)->ri), -0 , __ISR_VALID, isr, current); +0 , __ISR_VALID, isr); } }else {if (exception ==-1 ) {
@@ -373,7 +373,7 @@ handle_fpu_swa (int fp_fault, struct pt_regs *regs, unsigned long isr) }force_sig_fault (SIGFPE , si_code, (void __user *) (regs->cr_iip +ia64_psr (regs)->ri), -0 , __ISR_VALID, isr, current); +0 , __ISR_VALID, isr); } }return 0 ;
@@ -408,7 +408,7 @@ ia64_illegal_op_fault (unsigned long ec, long arg1, long arg2, long arg3,force_sig_fault (SIGILL ,ILL_ILLOPC , (void __user *) (regs.cr_iip +ia64_psr (®s)->ri), -0 ,0 ,0 , current); +0 ,0 ,0 );return rv; }
@@ -483,7 +483,7 @@ ia64_fault (unsigned long vector, unsigned long isr, unsigned long ifa, + ia64_psr(®s)->ri); }force_sig_fault (sig, code, addr, - vector, __ISR_VALID, isr, current); + vector, __ISR_VALID, isr);return ; }else if (ia64_done_with_exception (®s))return ;
@@ -493,7 +493,7 @@ ia64_fault (unsigned long vector, unsigned long isr, unsigned long ifa,case 31 :/* Unsupported Data Reference */ if (user_mode (®s)) {force_sig_fault (SIGILL ,ILL_ILLOPN , (void __user *) iip, - vector, __ISR_VALID, isr, current); + vector, __ISR_VALID, isr);return ; }sprintf (buf,"Unsupported data reference" );
@@ -542,7 +542,7 @@ ia64_fault (unsigned long vector, unsigned long isr, unsigned long ifa, == NOTIFY_STOP)return ;force_sig_fault (SIGTRAP , si_code, (void __user *) ifa, -0 , __ISR_VALID, isr, current); +0 , __ISR_VALID, isr);return ;case 32 :/* fp fault */
@@ -550,7 +550,7 @@ ia64_fault (unsigned long vector, unsigned long isr, unsigned long ifa, result =handle_fpu_swa ((vector ==32 ) ?1 :0 , ®s, isr);if ((result <0 ) || (current->thread.flags &IA64_THREAD_FPEMU_SIGFPE )) {force_sig_fault (SIGFPE ,FPE_FLTINV , (void __user *) iip, -0 , __ISR_VALID, isr, current); +0 , __ISR_VALID, isr); }return ;
@@ -578,7 +578,7 @@ ia64_fault (unsigned long vector, unsigned long isr, unsigned long ifa,if (user_mode (®s)) {force_sig_fault (SIGILL ,ILL_BADIADDR , (void __user *) iip, -0 ,0 ,0 , current); +0 ,0 ,0 );return ; }sprintf (buf,"Unimplemented Instruction Address fault" );
arch/ia64/kernel/unaligned.c +1 -1
@@ -1537,6 +1537,6 @@ ia64_handle_unaligned (unsigned long ifa, struct pt_regs *regs) } force_sigbus:force_sig_fault (SIGBUS ,BUS_ADRALN , (void __user *) ifa, -0 ,0 ,0 , current); +0 ,0 ,0 ); goto done; }
arch/ia64/mm/fault.c +1 -1
@@ -249,7 +249,7 @@ ia64_do_page_fault (unsigned long address, unsigned long isr, struct pt_regs *re }if (user_mode (regs)) {force_sig_fault (signal, code, (void __user *) address, -0 , __ISR_VALID, isr, current); +0 , __ISR_VALID, isr);return ; }
arch/m68k/kernel/traps.c +2 -2
@@ -1127,7 +1127,7 @@ asmlinkage void trap_c(struct frame *fp) addr = (void __user *) fp->un.fmtb.daddr;break ; } -force_sig_fault (sig, si_code, addr, current); +force_sig_fault (sig, si_code, addr); }void die_if_kernel (char *str,struct pt_regs *fp,int nr)
@@ -1159,6 +1159,6 @@ asmlinkage void fpsp040_die(void)#ifdef CONFIG_M68KFPU_EMU asmlinkage void fpemu_signal(int signal, int code, void *addr) { -force_sig_fault (signal, code, addr, current); +force_sig_fault (signal, code, addr); }#endif
arch/m68k/mm/fault.c +2 -2
@@ -30,13 +30,13 @@ int send_fault_sig(struct pt_regs *regs)pr_debug ("send_fault_sig: %p,%d,%d\n" , addr, signo, si_code);if (user_mode (regs)) { -force_sig_fault (signo, si_code, addr, current); +force_sig_fault (signo, si_code, addr); }else {if (fixup_exception (regs))return -1 ;//if (signo == SIGBUS) -// force_sig_fault(si_signo, si_code, addr, current); +// force_sig_fault(si_signo, si_code, addr); /* * Oops. The kernel tried to access some bad page. We'll have to
arch/microblaze/kernel/exceptions.c +1 -1
@@ -63,7 +63,7 @@ void _exception(int signr, struct pt_regs *regs, int code, unsigned long addr)if (kernel_mode (regs))die ("Exception in kernel mode" , regs, signr); -force_sig_fault (signr, code, (void __user *)addr, current); +force_sig_fault (signr, code, (void __user *)addr); } asmlinkage void full_exception(struct pt_regs *regs, unsigned int type,
arch/microblaze/mm/fault.c +1 -1
@@ -289,7 +289,7 @@ void do_page_fault(struct pt_regs *regs, unsigned long address, do_sigbus:up_read (&mm->mmap_sem);if (user_mode (regs)) { -force_sig_fault (SIGBUS ,BUS_ADRERR , (void __user *)address, current); +force_sig_fault (SIGBUS ,BUS_ADRERR , (void __user *)address);return ; }bad_page_fault (regs, address,SIGBUS );
arch/mips/kernel/traps.c +6 -6
@@ -705,7 +705,7 @@ asmlinkage void do_ov(struct pt_regs *regs) prev_state =exception_enter ();die_if_kernel ("Integer overflow" , regs); -force_sig_fault (SIGFPE ,FPE_INTOVF , (void __user *)regs->cp0_epc, current); +force_sig_fault (SIGFPE ,FPE_INTOVF , (void __user *)regs->cp0_epc);exception_exit (prev_state); }
@@ -750,7 +750,7 @@ int process_fpemu_return(int sig, void __user *fault_addr, unsigned long fcr31)return 1 ;case SIGBUS : -force_sig_fault (SIGBUS ,BUS_ADRERR , fault_addr, current); +force_sig_fault (SIGBUS ,BUS_ADRERR , fault_addr);return 1 ;case SIGSEGV :
@@ -761,7 +761,7 @@ int process_fpemu_return(int sig, void __user *fault_addr, unsigned long fcr31)else si_code =SEGV_MAPERR ;up_read (¤t->mm->mmap_sem); -force_sig_fault (SIGSEGV , si_code, fault_addr, current); +force_sig_fault (SIGSEGV , si_code, fault_addr);return 1 ;default :
@@ -943,7 +943,7 @@ void do_trap_or_bp(struct pt_regs *regs, unsigned int code, int si_code,die_if_kernel (b, regs);force_sig_fault (SIGFPE , code ==BRK_DIVZERO ?FPE_INTDIV :FPE_INTOVF , - (void __user *) regs->cp0_epc, current); + (void __user *) regs->cp0_epc);break ;case BRK_BUG :die_if_kernel ("Kernel bug detected" , regs);
@@ -968,7 +968,7 @@ void do_trap_or_bp(struct pt_regs *regs, unsigned int code, int si_code,scnprintf (b,sizeof (b),"%s instruction in kernel code" , str);die_if_kernel (b, regs);if (si_code) { -force_sig_fault (SIGTRAP , si_code,NULL , current); +force_sig_fault (SIGTRAP , si_code,NULL ); }else {force_sig (SIGTRAP ); }
@@ -1521,7 +1521,7 @@ asmlinkage void do_watch(struct pt_regs *regs)if (test_tsk_thread_flag (current,TIF_LOAD_WATCH )) {mips_read_watch_registers ();local_irq_enable (); -force_sig_fault (SIGTRAP ,TRAP_HWBKPT ,NULL , current); +force_sig_fault (SIGTRAP ,TRAP_HWBKPT ,NULL ); }else {mips_clear_watch_registers ();local_irq_enable ();
arch/mips/mm/fault.c +2 -2
@@ -223,7 +223,7 @@ static void __kprobes __do_page_fault(struct pt_regs *regs, unsigned long write,pr_cont ("\n" ); } current->thread.trap_nr = (regs->cp0_cause >>2 ) &0x1f ; -force_sig_fault (SIGSEGV , si_code, (void __user *)address, current); +force_sig_fault (SIGSEGV , si_code, (void __user *)address);return ; }
@@ -279,7 +279,7 @@ static void __kprobes __do_page_fault(struct pt_regs *regs, unsigned long write,#endif current->thread.trap_nr = (regs->cp0_cause >>2 ) &0x1f ; tsk->thread.cp0_badvaddr = address; -force_sig_fault (SIGBUS ,BUS_ADRERR , (void __user *)address, current); +force_sig_fault (SIGBUS ,BUS_ADRERR , (void __user *)address);return ;#ifndef CONFIG_64BIT
arch/nds32/kernel/fpu.c +1 -1
@@ -246,7 +246,7 @@ inline void handle_fpu_exception(struct pt_regs *regs) }force_sig_fault (si_signo, si_code, - (void __user *)instruction_pointer (regs), current); + (void __user *)instruction_pointer (regs)); done:own_fpu (); }
arch/nds32/kernel/traps.c +2 -2
@@ -205,7 +205,7 @@ int bad_syscall(int n, struct pt_regs *regs) }force_sig_fault (SIGILL ,ILL_ILLTRP , - (void __user *)instruction_pointer (regs) -4 , current); + (void __user *)instruction_pointer (regs) -4 );die_if_kernel ("Oops - bad syscall" , regs, n);return regs->uregs[0 ]; }
@@ -263,7 +263,7 @@ static void send_sigtrap(struct pt_regs *regs, int error_code, int si_code) tsk->thread.error_code = error_code;force_sig_fault (SIGTRAP , si_code, - (void __user *)instruction_pointer (regs), current); + (void __user *)instruction_pointer (regs)); } void do_debug_trap(unsigned long entry, unsigned long addr,
arch/nds32/mm/fault.c +2 -2
@@ -271,7 +271,7 @@ void do_page_fault(unsigned long entry, unsigned long addr, tsk->thread.address = addr; tsk->thread.error_code = error_code; tsk->thread.trap_no = entry; -force_sig_fault (SIGSEGV , si_code, (void __user *)addr, current); +force_sig_fault (SIGSEGV , si_code, (void __user *)addr);return ; }
@@ -340,7 +340,7 @@ void do_page_fault(unsigned long entry, unsigned long addr, tsk->thread.address = addr; tsk->thread.error_code = error_code; tsk->thread.trap_no = entry; -force_sig_fault (SIGBUS ,BUS_ADRERR , (void __user *)addr, current); +force_sig_fault (SIGBUS ,BUS_ADRERR , (void __user *)addr);return ;
arch/nios2/kernel/traps.c +1 -1
@@ -26,7 +26,7 @@ static DEFINE_SPINLOCK(die_lock);static void _send_sig (int signo,int code,unsigned long addr) { -force_sig_fault (signo, code, (void __user *) addr, current); +force_sig_fault (signo, code, (void __user *) addr); }void die (const char *str,struct pt_regs *regs,long err)
arch/openrisc/kernel/traps.c +4 -4
@@ -249,7 +249,7 @@ void __init trap_init(void) asmlinkage void do_trap(struct pt_regs *regs, unsigned long address) { -force_sig_fault (SIGTRAP ,TRAP_TRACE , (void __user *)address, current); +force_sig_fault (SIGTRAP ,TRAP_TRACE , (void __user *)address); regs->pc +=4 ; }
@@ -258,7 +258,7 @@ asmlinkage void do_unaligned_access(struct pt_regs *regs, unsigned long address) {if (user_mode (regs)) {/* Send a SIGBUS */ -force_sig_fault (SIGBUS ,BUS_ADRALN , (void __user *)address, current); +force_sig_fault (SIGBUS ,BUS_ADRALN , (void __user *)address); }else {printk ("KERNEL: Unaligned Access 0x%.8lx\n" , address);show_registers (regs);
@@ -271,7 +271,7 @@ asmlinkage void do_bus_fault(struct pt_regs *regs, unsigned long address) {if (user_mode (regs)) {/* Send a SIGBUS */ -force_sig_fault (SIGBUS ,BUS_ADRERR , (void __user *)address, current); +force_sig_fault (SIGBUS ,BUS_ADRERR , (void __user *)address); }else {/* Kernel mode */ printk ("KERNEL: Bus error (SIGBUS) 0x%.8lx\n" , address);show_registers (regs);
@@ -466,7 +466,7 @@ asmlinkage void do_illegal_instruction(struct pt_regs *regs,if (user_mode (regs)) {/* Send a SIGILL */ -force_sig_fault (SIGILL ,ILL_ILLOPC , (void __user *)address, current); +force_sig_fault (SIGILL ,ILL_ILLOPC , (void __user *)address); }else {/* Kernel mode */ printk ("KERNEL: Illegal instruction (SIGILL) 0x%.8lx\n" , address);
arch/parisc/kernel/traps.c +7 -7
@@ -275,7 +275,7 @@ void die_if_kernel(char *str, struct pt_regs *regs, long err)static void handle_gdb_break (struct pt_regs *regs,int wot) {force_sig_fault (SIGTRAP , wot, - (void __user *) (regs->iaoq[0 ] & ~3 ), current); + (void __user *) (regs->iaoq[0 ] & ~3 )); }static void handle_break (struct pt_regs *regs)
@@ -609,13 +609,13 @@ void notrace handle_interruption(int code, struct pt_regs *regs) si_code =ILL_PRVREG ; give_sigill:force_sig_fault (SIGILL , si_code, - (void __user *) regs->iaoq[0 ], current); + (void __user *) regs->iaoq[0 ]);return ;case 12 :/* Overflow Trap, let the userland signal handler do the cleanup */ force_sig_fault (SIGFPE ,FPE_INTOVF , - (void __user *) regs->iaoq[0 ], current); + (void __user *) regs->iaoq[0 ]);return ;case 13 :
@@ -627,7 +627,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)* to by si_addr. */ force_sig_fault (SIGFPE ,FPE_CONDTRAP , - (void __user *) regs->iaoq[0 ], current); + (void __user *) regs->iaoq[0 ]);return ; }/* The kernel doesn't want to handle condition codes */
@@ -739,7 +739,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)force_sig_fault (SIGSEGV ,SEGV_MAPERR , (code ==7 )? ((void __user *) regs->iaoq[0 ]) : - ((void __user *) regs->ior), current); + ((void __user *) regs->ior));return ;case 28 :
@@ -754,7 +754,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs) task_pid_nr(current), current->comm);/* SIGBUS, for lack of a better one. */ force_sig_fault (SIGBUS ,BUS_OBJERR , - (void __user *)regs->ior, current); + (void __user *)regs->ior);return ; }pdc_chassis_send_status (PDC_CHASSIS_DIRECT_PANIC );
@@ -770,7 +770,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs) code, fault_space, task_pid_nr(current), current->comm);force_sig_fault (SIGSEGV ,SEGV_MAPERR , - (void __user *)regs->ior, current); + (void __user *)regs->ior);return ; } }
arch/parisc/kernel/unaligned.c +2 -2
@@ -690,14 +690,14 @@ void handle_unaligned(struct pt_regs *regs)if (ret ==ERR_PAGEFAULT ) {force_sig_fault (SIGSEGV ,SEGV_MAPERR , - (void __user *)regs->ior, current); + (void __user *)regs->ior); }else { force_sigbus:/* couldn't handle it ... */ force_sig_fault (SIGBUS ,BUS_ADRALN , - (void __user *)regs->ior, current); + (void __user *)regs->ior); }return ;
arch/parisc/math-emu/driver.c +1 -1
@@ -117,7 +117,7 @@ handle_fpe(struct pt_regs *regs)memcpy (regs->fr, frcopy,sizeof regs->fr);if (signalcode !=0 ) {force_sig_fault (signalcode >>24 , signalcode &0xffffff , - (void __user *) regs->iaoq[0 ], current); + (void __user *) regs->iaoq[0 ]);return -1 ; }
arch/parisc/mm/fault.c +1 -1
@@ -409,7 +409,7 @@ void do_page_fault(struct pt_regs *regs, unsigned long code,#endif show_signal_msg (regs, code, address, tsk, vma); -force_sig_fault (signo, si_code, (void __user *) address, current); +force_sig_fault (signo, si_code, (void __user *) address);return ; }
arch/powerpc/kernel/process.c +1 -1
@@ -643,7 +643,7 @@ void do_break (struct pt_regs *regs, unsigned long address,hw_breakpoint_disable ();/* Deliver the signal to userspace */ - force_sig_fault(SIGTRAP, TRAP_HWBKPT, (void __user *)address, current); + force_sig_fault(SIGTRAP, TRAP_HWBKPT, (void __user *)address); }#endif /* CONFIG_PPC_ADV_DEBUG_REGS */
arch/powerpc/kernel/traps.c +2 -2
@@ -301,7 +301,7 @@ NOKPROBE_SYMBOL(die);void user_single_step_report (struct pt_regs *regs) { -force_sig_fault (SIGTRAP ,TRAP_TRACE , (void __user *)regs->nip, current); +force_sig_fault (SIGTRAP ,TRAP_TRACE , (void __user *)regs->nip); } static void show_signal_msg(int signr, struct pt_regs *regs, int code,
@@ -367,7 +367,7 @@ void _exception(int signr, struct pt_regs *regs, int code, unsigned long addr)if (!exception_common (signr, regs, code, addr))return ; -force_sig_fault (signr, code, (void __user *)addr, current); +force_sig_fault (signr, code, (void __user *)addr); }/*
arch/powerpc/mm/fault.c +1 -1
@@ -187,7 +187,7 @@ static int do_sigbus(struct pt_regs *regs, unsigned long address, }#endif -force_sig_fault (SIGBUS ,BUS_ADRERR , (void __user *)address, current); +force_sig_fault (SIGBUS ,BUS_ADRERR , (void __user *)address);return 0 ; }
arch/powerpc/platforms/cell/spufs/fault.c +4 -5
@@ -44,22 +44,21 @@ static void spufs_handle_event(struct spu_context *ctx,switch (type) {case SPE_EVENT_INVALID_DMA : -force_sig_fault (SIGBUS ,BUS_OBJERR ,NULL , current); +force_sig_fault (SIGBUS ,BUS_OBJERR ,NULL );break ;case SPE_EVENT_SPE_DATA_STORAGE : ctx->ops->restart_dma (ctx); -force_sig_fault (SIGSEGV ,SEGV_ACCERR , (void __user *)ea, - current); +force_sig_fault (SIGSEGV ,SEGV_ACCERR , (void __user *)ea);break ;case SPE_EVENT_DMA_ALIGNMENT :/* DAR isn't set for an alignment fault :( */ -force_sig_fault (SIGBUS ,BUS_ADRALN ,NULL , current); +force_sig_fault (SIGBUS ,BUS_ADRALN ,NULL );break ;case SPE_EVENT_SPE_ERROR :force_sig_fault (SIGILL ,ILL_ILLOPC , (void __user *)(unsigned long ) - ctx->ops->npc_read (ctx) -4 , current); + ctx->ops->npc_read (ctx) -4 );break ; } }
arch/riscv/kernel/traps.c +2 -2
@@ -76,7 +76,7 @@ void do_trap(struct pt_regs *regs, int signo, int code, unsigned long addr)show_regs (regs); } -force_sig_fault (signo, code, (void __user *)addr, current); +force_sig_fault (signo, code, (void __user *)addr); } static void do_trap_error(struct pt_regs *regs, int signo, int code,
@@ -149,7 +149,7 @@ asmlinkage void do_trap_break(struct pt_regs *regs) }#endif /* CONFIG_GENERIC_BUG */ -force_sig_fault (SIGTRAP ,TRAP_BRKPT , (void __user *)(regs->sepc), current); +force_sig_fault (SIGTRAP ,TRAP_BRKPT , (void __user *)(regs->sepc)); }#ifdef CONFIG_GENERIC_BUG
arch/s390/kernel/traps.c +3 -3
@@ -45,7 +45,7 @@ int is_valid_bugaddr(unsigned long addr)void do_report_trap (struct pt_regs *regs,int si_signo,int si_code,char *str) {if (user_mode (regs)) { -force_sig_fault (si_signo, si_code,get_trap_ip (regs), current); +force_sig_fault (si_signo, si_code,get_trap_ip (regs));report_user_fault (regs, si_signo,0 ); }else {const struct exception_table_entry *fixup;
@@ -79,7 +79,7 @@ void do_per_trap(struct pt_regs *regs)if (!current->ptrace)return ;force_sig_fault (SIGTRAP ,TRAP_HWBKPT , - (void __force __user *) current->thread.per_event.address, current); + (void __force __user *) current->thread.per_event.address); }NOKPROBE_SYMBOL (do_per_trap);
@@ -165,7 +165,7 @@ void illegal_op(struct pt_regs *regs)return ;if (*((__u16 *) opcode) ==S390_BREAKPOINT_U16 ) {if (current->ptrace) -force_sig_fault (SIGTRAP ,TRAP_BRKPT , location, current); +force_sig_fault (SIGTRAP ,TRAP_BRKPT , location);else signal =SIGILL ;#ifdef CONFIG_UPROBES
arch/s390/mm/fault.c +2 -4
@@ -243,8 +243,7 @@ static noinline void do_sigsegv(struct pt_regs *regs, int si_code) {report_user_fault (regs,SIGSEGV ,1 );force_sig_fault (SIGSEGV , si_code, - (void __user *)(regs->int_parm_long & __FAIL_ADDR_MASK), - current); + (void __user *)(regs->int_parm_long & __FAIL_ADDR_MASK)); }const struct exception_table_entry *s390_search_extables (unsigned long addr)
@@ -305,8 +304,7 @@ static noinline void do_sigbus(struct pt_regs *regs)* or user mode. */ force_sig_fault (SIGBUS ,BUS_ADRERR , - (void __user *)(regs->int_parm_long & __FAIL_ADDR_MASK), - current); + (void __user *)(regs->int_parm_long & __FAIL_ADDR_MASK)); } static noinline int signal_return(struct pt_regs *regs)
arch/sh/kernel/hw_breakpoint.c +1 -1
@@ -338,7 +338,7 @@ static int __kprobes hw_breakpoint_handler(struct die_args *args)/* Deliver the signal to userspace */ if (!arch_check_bp_in_kernelspace (&bp->hw.info)) {force_sig_fault (SIGTRAP ,TRAP_HWBKPT , - (void __user *)NULL , current); + (void __user *)NULL ); }rcu_read_unlock ();
arch/sh/kernel/traps_32.c +1 -1
@@ -533,7 +533,7 @@ asmlinkage void do_address_error(struct pt_regs *regs,"access (PC %lx PR %lx)\n" , current->comm, regs->pc, regs->pr); -force_sig_fault (SIGBUS , si_code, (void __user *)address, current); +force_sig_fault (SIGBUS , si_code, (void __user *)address); }else {inc_unaligned_kernel_access ();
arch/sh/math-emu/math.c +1 -1
@@ -560,7 +560,7 @@ static int ieee_fpe_handler(struct pt_regs *regs)task_thread_info (tsk)->status |=TS_USEDFPU ; }else {force_sig_fault (SIGFPE ,FPE_FLTINV , - (void __user *)regs->pc, current); + (void __user *)regs->pc); } regs->pc = nextpc;
arch/sh/mm/fault.c +1 -1
@@ -41,7 +41,7 @@ static inline int notify_page_fault(struct pt_regs *regs, int trap)static void force_sig_info_fault (int si_signo,int si_code,unsigned long address) { -force_sig_fault (si_signo, si_code, (void __user *)address, current); +force_sig_fault (si_signo, si_code, (void __user *)address); }/*
arch/sparc/kernel/process_64.c +1 -1
@@ -519,7 +519,7 @@ void synchronize_user_stack(void)static void stack_unaligned (unsigned long sp) { -force_sig_fault (SIGBUS ,BUS_ADRALN , (void __user *) sp,0 , current); +force_sig_fault (SIGBUS ,BUS_ADRALN , (void __user *) sp,0 ); }static const char uwfault32[] =KERN_INFO \
arch/sparc/kernel/sys_sparc_32.c +1 -1
@@ -151,7 +151,7 @@ sparc_breakpoint (struct pt_regs *regs)#ifdef DEBUG_SPARC_BREAKPOINT printk ("TRAP: Entering kernel PC=%x, nPC=%x\n" , regs->pc, regs->npc);#endif -force_sig_fault (SIGTRAP ,TRAP_BRKPT , (void __user *)regs->pc,0 , current); +force_sig_fault (SIGTRAP ,TRAP_BRKPT , (void __user *)regs->pc,0 );#ifdef DEBUG_SPARC_BREAKPOINT printk ("TRAP: Returning to space: PC=%x nPC=%x\n" , regs->pc, regs->npc);
arch/sparc/kernel/sys_sparc_64.c +1 -1
@@ -511,7 +511,7 @@ asmlinkage void sparc_breakpoint(struct pt_regs *regs)#ifdef DEBUG_SPARC_BREAKPOINT printk ("TRAP: Entering kernel PC=%lx, nPC=%lx\n" , regs->tpc, regs->tnpc);#endif -force_sig_fault (SIGTRAP ,TRAP_BRKPT , (void __user *)regs->tpc,0 , current); +force_sig_fault (SIGTRAP ,TRAP_BRKPT , (void __user *)regs->tpc,0 );#ifdef DEBUG_SPARC_BREAKPOINT printk ("TRAP: Returning to space: PC=%lx nPC=%lx\n" , regs->tpc, regs->tnpc);#endif
arch/sparc/kernel/traps_32.c +2 -2
@@ -103,7 +103,7 @@ void do_hw_interrupt(struct pt_regs *regs, unsigned long type)die_if_kernel ("Kernel bad trap" , regs);force_sig_fault (SIGILL ,ILL_ILLTRP , - (void __user *)regs->pc, type -0x80 , current); + (void __user *)regs->pc, type -0x80 ); } void do_illegal_instruction(struct pt_regs *regs, unsigned long pc, unsigned long npc,
@@ -327,7 +327,7 @@ void handle_reg_access(struct pt_regs *regs, unsigned long pc, unsigned long npcprintk ("Register Access Exception at PC %08lx NPC %08lx PSR %08lx\n" , pc, npc, psr);#endif -force_sig_fault (SIGBUS ,BUS_OBJERR , (void __user *)pc,0 , current); +force_sig_fault (SIGBUS ,BUS_OBJERR , (void __user *)pc,0 ); } void handle_cp_disabled(struct pt_regs *regs, unsigned long pc, unsigned long npc,
arch/sparc/kernel/traps_64.c +18 -21
@@ -107,7 +107,7 @@ void bad_trap(struct pt_regs *regs, long lvl) regs->tnpc &=0xffffffff ; }force_sig_fault (SIGILL ,ILL_ILLTRP , - (void __user *)regs->tpc, lvl, current); + (void __user *)regs->tpc, lvl); }void bad_trap_tl1 (struct pt_regs *regs,long lvl)
@@ -201,7 +201,7 @@ void spitfire_insn_access_exception(struct pt_regs *regs, unsigned long sfsr, un regs->tnpc &=0xffffffff ; }force_sig_fault (SIGSEGV ,SEGV_MAPERR , - (void __user *)regs->tpc,0 , current); + (void __user *)regs->tpc,0 ); out:exception_exit (prev_state); }
@@ -236,7 +236,7 @@ void sun4v_insn_access_exception(struct pt_regs *regs, unsigned long addr, unsig regs->tpc &=0xffffffff ; regs->tnpc &=0xffffffff ; } -force_sig_fault (SIGSEGV ,SEGV_MAPERR , (void __user *) addr,0 , current); +force_sig_fault (SIGSEGV ,SEGV_MAPERR , (void __user *) addr,0 ); }void sun4v_insn_access_exception_tl1 (struct pt_regs *regs,unsigned long addr,unsigned long type_ctx)
@@ -321,7 +321,7 @@ void spitfire_data_access_exception(struct pt_regs *regs, unsigned long sfsr, unif (is_no_fault_exception (regs))return ; -force_sig_fault (SIGSEGV ,SEGV_MAPERR , (void __user *)sfar,0 , current); +force_sig_fault (SIGSEGV ,SEGV_MAPERR , (void __user *)sfar,0 ); out:exception_exit (prev_state); }
@@ -385,16 +385,13 @@ void sun4v_data_access_exception(struct pt_regs *regs, unsigned long addr, unsig*/ switch (type) {case HV_FAULT_TYPE_INV_ASI : -force_sig_fault (SIGILL ,ILL_ILLADR , (void __user *)addr,0 , - current); +force_sig_fault (SIGILL ,ILL_ILLADR , (void __user *)addr,0 );break ;case HV_FAULT_TYPE_MCD_DIS : -force_sig_fault (SIGSEGV ,SEGV_ACCADI , (void __user *)addr,0 , - current); +force_sig_fault (SIGSEGV ,SEGV_ACCADI , (void __user *)addr,0 );break ;default : -force_sig_fault (SIGSEGV ,SEGV_MAPERR , (void __user *)addr,0 , - current); +force_sig_fault (SIGSEGV ,SEGV_MAPERR , (void __user *)addr,0 );break ; } }
@@ -571,7 +568,7 @@ static void spitfire_ue_log(unsigned long afsr, unsigned long afar, unsigned lon regs->tpc &=0xffffffff ; regs->tnpc &=0xffffffff ; } -force_sig_fault (SIGBUS ,BUS_OBJERR , (void *)0 ,0 , current); +force_sig_fault (SIGBUS ,BUS_OBJERR , (void *)0 ,0 ); }void spitfire_access_error (struct pt_regs *regs,unsigned long status_encoded,unsigned long afar)
@@ -2073,7 +2070,7 @@ void do_mcd_err(struct pt_regs *regs, struct sun4v_error_entry ent)* code */ force_sig_fault (SIGSEGV ,SEGV_ADIDERR , (void __user *)ent.err_raddr, -0 , current); +0 ); }/* We run with %pil set to PIL_NORMAL_MAX and PSTATE_IE enabled in %pstate.
@@ -2187,7 +2184,7 @@ bool sun4v_nonresum_error_user_handled(struct pt_regs *regs, }if (attrs &SUN4V_ERR_ATTRS_PIO ) {force_sig_fault (SIGBUS ,BUS_ADRERR , - (void __user *)sun4v_get_vaddr (regs),0 , current); + (void __user *)sun4v_get_vaddr (regs),0 );return true; }
@@ -2344,7 +2341,7 @@ static void do_fpe_common(struct pt_regs *regs) code =FPE_FLTRES ; }force_sig_fault (SIGFPE , code, - (void __user *)regs->tpc,0 , current); + (void __user *)regs->tpc,0 ); } }
@@ -2399,7 +2396,7 @@ void do_tof(struct pt_regs *regs) regs->tnpc &=0xffffffff ; }force_sig_fault (SIGEMT ,EMT_TAGOVF , - (void __user *)regs->tpc,0 , current); + (void __user *)regs->tpc,0 ); out:exception_exit (prev_state); }
@@ -2419,7 +2416,7 @@ void do_div0(struct pt_regs *regs) regs->tnpc &=0xffffffff ; }force_sig_fault (SIGFPE ,FPE_INTDIV , - (void __user *)regs->tpc,0 , current); + (void __user *)regs->tpc,0 ); out:exception_exit (prev_state); }
@@ -2615,7 +2612,7 @@ void do_illegal_instruction(struct pt_regs *regs) } } } -force_sig_fault (SIGILL ,ILL_ILLOPC , (void __user *)pc,0 , current); +force_sig_fault (SIGILL ,ILL_ILLOPC , (void __user *)pc,0 ); out:exception_exit (prev_state); }
@@ -2635,7 +2632,7 @@ void mem_address_unaligned(struct pt_regs *regs, unsigned long sfar, unsigned loif (is_no_fault_exception (regs))return ; -force_sig_fault (SIGBUS ,BUS_ADRALN , (void __user *)sfar,0 , current); +force_sig_fault (SIGBUS ,BUS_ADRALN , (void __user *)sfar,0 ); out:exception_exit (prev_state); }
@@ -2653,7 +2650,7 @@ void sun4v_do_mna(struct pt_regs *regs, unsigned long addr, unsigned long type_cif (is_no_fault_exception (regs))return ; -force_sig_fault (SIGBUS ,BUS_ADRALN , (void __user *) addr,0 , current); +force_sig_fault (SIGBUS ,BUS_ADRALN , (void __user *) addr,0 ); }/* sun4v_mem_corrupt_detect_precise() - Handle precise exception on an ADI
@@ -2700,7 +2697,7 @@ void sun4v_mem_corrupt_detect_precise(struct pt_regs *regs, unsigned long addr, regs->tpc &=0xffffffff ; regs->tnpc &=0xffffffff ; } -force_sig_fault (SIGSEGV ,SEGV_ADIPERR , (void __user *)addr,0 , current); +force_sig_fault (SIGSEGV ,SEGV_ADIPERR , (void __user *)addr,0 ); }void do_privop (struct pt_regs *regs)
@@ -2716,7 +2713,7 @@ void do_privop(struct pt_regs *regs) regs->tnpc &=0xffffffff ; }force_sig_fault (SIGILL ,ILL_PRVOPC , - (void __user *)regs->tpc,0 , current); + (void __user *)regs->tpc,0 ); out:exception_exit (prev_state); }
arch/sparc/mm/fault_32.c +1 -1
@@ -131,7 +131,7 @@ static void __do_fault_siginfo(int code, int sig, struct pt_regs *regs,show_signal_msg (regs, sig, code, addr, current); -force_sig_fault (sig, code, (void __user *) addr,0 , current); +force_sig_fault (sig, code, (void __user *) addr,0 ); }static unsigned long compute_si_addr (struct pt_regs *regs,int text_fault)
arch/sparc/mm/fault_64.c +1 -1
@@ -187,7 +187,7 @@ static void do_fault_siginfo(int code, int sig, struct pt_regs *regs,if (unlikely (show_unhandled_signals))show_signal_msg (regs, sig, code, addr, current); -force_sig_fault (sig, code, (void __user *) addr,0 , current); +force_sig_fault (sig, code, (void __user *) addr,0 ); }static unsigned int get_fault_insn (struct pt_regs *regs,unsigned int insn)
arch/um/kernel/ptrace.c +1 -2
@@ -117,8 +117,7 @@ static void send_sigtrap(struct uml_pt_regs *regs, int error_code)/* Send us the fake SIGTRAP */ force_sig_fault (SIGTRAP ,TRAP_BRKPT ,/* User-mode eip? */ -UPT_IS_USER (regs) ? (void __user *)UPT_IP (regs) :NULL , - current); +UPT_IS_USER (regs) ? (void __user *)UPT_IP (regs) :NULL ); }/*
arch/um/kernel/trap.c +4 -8
@@ -163,8 +163,7 @@ static void show_segv_info(struct uml_pt_regs *regs)static void bad_segv (struct faultinfo fi,unsigned long ip) { current->thread.arch.faultinfo = fi; -force_sig_fault (SIGSEGV ,SEGV_ACCERR , (void __user *)FAULT_ADDRESS (fi), - current); +force_sig_fault (SIGSEGV ,SEGV_ACCERR , (void __user *)FAULT_ADDRESS (fi)); }void fatal_sigsegv (void )
@@ -268,13 +267,11 @@ unsigned long segv(struct faultinfo fi, unsigned long ip, int is_user,if (err == -EACCES ) { current->thread.arch.faultinfo = fi; -force_sig_fault (SIGBUS ,BUS_ADRERR , (void __user *)address, - current); +force_sig_fault (SIGBUS ,BUS_ADRERR , (void __user *)address); }else {BUG_ON (err != -EFAULT ); current->thread.arch.faultinfo = fi; -force_sig_fault (SIGSEGV , si_code, (void __user *) address, - current); +force_sig_fault (SIGSEGV , si_code, (void __user *) address); } out:
@@ -304,8 +301,7 @@ void relay_signal(int sig, struct siginfo *si, struct uml_pt_regs *regs)if ((err ==0 ) && (siginfo_layout (sig, code) ==SIL_FAULT )) {struct faultinfo *fi =UPT_FAULTINFO (regs); current->thread.arch.faultinfo = *fi; -force_sig_fault (sig, code, (void __user *)FAULT_ADDRESS (*fi), - current); +force_sig_fault (sig, code, (void __user *)FAULT_ADDRESS (*fi)); }else {printk (KERN_ERR "Attempted to relay unknown signal %d (si_code = %d) with errno %d\n" , sig, code, err);
arch/unicore32/kernel/traps.c +1 -1
@@ -248,7 +248,7 @@ void uc32_notify_die(const char *str, struct pt_regs *regs, current->thread.error_code = err; current->thread.trap_no = trap; -force_sig_fault (sig, code, addr, current); +force_sig_fault (sig, code, addr); }else die (str, regs, err); }
arch/unicore32/mm/fault.c +1 -1
@@ -124,7 +124,7 @@ static void __do_user_fault(unsigned long addr, unsigned int fsr, tsk->thread.address = addr; tsk->thread.error_code = fsr; tsk->thread.trap_no =14 ; -force_sig_fault (sig, code, (void __user *)addr, current); +force_sig_fault (sig, code, (void __user *)addr); }void do_bad_area (unsigned long addr,unsigned int fsr,struct pt_regs *regs)
arch/x86/entry/vsyscall/vsyscall_64.c +1 -1
@@ -106,7 +106,7 @@ static bool write_ok_or_segv(unsigned long ptr, size_t size) thread->cr2 = ptr; thread->trap_nr =X86_TRAP_PF ; -force_sig_fault (SIGSEGV ,SEGV_MAPERR , (void __user *)ptr, current); +force_sig_fault (SIGSEGV ,SEGV_MAPERR , (void __user *)ptr);return false; }else {return true;
arch/x86/kernel/ptrace.c +1 -1
@@ -1369,7 +1369,7 @@ void send_sigtrap(struct pt_regs *regs, int error_code, int si_code)/* Send us the fake SIGTRAP */ force_sig_fault (SIGTRAP , si_code, -user_mode (regs) ? (void __user *)regs->ip :NULL , current); +user_mode (regs) ? (void __user *)regs->ip :NULL ); }void user_single_step_report (struct pt_regs *regs)
arch/x86/kernel/traps.c +2 -2
@@ -256,7 +256,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,if (!sicode)force_sig (signr);else -force_sig_fault (signr, sicode, addr, current); +force_sig_fault (signr, sicode, addr); }NOKPROBE_SYMBOL (do_trap);
@@ -856,7 +856,7 @@ static void math_error(struct pt_regs *regs, int error_code, int trapnr)return ;force_sig_fault (SIGFPE , si_code, - (void __user *)uprobe_get_trap_addr (regs), current); + (void __user *)uprobe_get_trap_addr (regs)); } dotraplinkage void do_coprocessor_error(struct pt_regs *regs, long error_code)
arch/x86/kernel/umip.c +1 -1
@@ -277,7 +277,7 @@ static void force_sig_info_umip_fault(void __user *addr, struct pt_regs *regs) tsk->thread.error_code =X86_PF_USER |X86_PF_WRITE ; tsk->thread.trap_nr =X86_TRAP_PF ; -force_sig_fault (SIGSEGV ,SEGV_MAPERR , addr, current); +force_sig_fault (SIGSEGV ,SEGV_MAPERR , addr);if (!(show_unhandled_signals &&unhandled_signal (tsk,SIGSEGV )))return ;
arch/x86/mm/fault.c +3 -4
@@ -756,8 +756,7 @@ no_context(struct pt_regs *regs, unsigned long error_code,set_signal_archinfo (address, error_code);/* XXX: hwpoison faults will set the wrong code. */ -force_sig_fault (signal, si_code, (void __user *)address, - current); +force_sig_fault (signal, si_code, (void __user *)address); }/*
@@ -918,7 +917,7 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,if (si_code ==SEGV_PKUERR )force_sig_pkuerr ((void __user *)address, pkey); -force_sig_fault (SIGSEGV , si_code, (void __user *)address, current); +force_sig_fault (SIGSEGV , si_code, (void __user *)address);return ; }
@@ -1044,7 +1043,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address, return; }#endif -force_sig_fault (SIGBUS ,BUS_ADRERR , (void __user *)address, current); +force_sig_fault (SIGBUS ,BUS_ADRERR , (void __user *)address); }static noinline void
arch/xtensa/kernel/traps.c +1 -1
@@ -330,7 +330,7 @@ do_unaligned_user (struct pt_regs *regs)"(pid = %d, pc = %#010lx)\n" , regs->excvaddr, current->comm, task_pid_nr(current), regs->pc); - force_sig_fault(SIGBUS, BUS_ADRALN, (void *) regs->excvaddr, current); + force_sig_fault(SIGBUS, BUS_ADRALN, (void *) regs->excvaddr); }#endif
arch/xtensa/mm/fault.c +2 -2
@@ -157,7 +157,7 @@ void do_page_fault(struct pt_regs *regs)if (user_mode (regs)) { current->thread.bad_vaddr = address; current->thread.error_code = is_write; -force_sig_fault (SIGSEGV , code, (void *) address, current); +force_sig_fault (SIGSEGV , code, (void *) address);return ; }bad_page_fault (regs, address,SIGSEGV );
@@ -182,7 +182,7 @@ void do_page_fault(struct pt_regs *regs)* or user mode. */ current->thread.bad_vaddr = address; -force_sig_fault (SIGBUS ,BUS_ADRERR , (void *) address, current); +force_sig_fault (SIGBUS ,BUS_ADRERR , (void *) address);/* Kernel mode? Handle exceptions or die */ if (!user_mode (regs))
include/linux/sched/signal.h +1 -2
@@ -313,8 +313,7 @@ int force_sig_fault_to_task(int sig, int code, void __user *addr , struct task_struct *t); int force_sig_fault(int sig, int code, void __user *addr___ARCH_SI_TRAPNO (int trapno) - ___ARCH_SI_IA64(int imm, unsigned int flags, unsigned long isr) - , struct task_struct *t); + ___ARCH_SI_IA64(int imm, unsigned int flags, unsigned long isr)); int send_sig_fault(int sig, int code, void __user *addr___ARCH_SI_TRAPNO (int trapno) ___ARCH_SI_IA64(int imm, unsigned int flags, unsigned long isr)
kernel/signal.c +2 -3
@@ -1645,12 +1645,11 @@ int force_sig_fault_to_task(int sig, int code, void __user *addr int force_sig_fault(int sig, int code, void __user *addr___ARCH_SI_TRAPNO (int trapno) - ___ARCH_SI_IA64(int imm, unsigned int flags, unsigned long isr) - , struct task_struct *t) + ___ARCH_SI_IA64(int imm, unsigned int flags, unsigned long isr)) { return force_sig_fault_to_task(sig, code, addr ___ARCH_SI_TRAPNO(trapno) -___ARCH_SI_IA64 (imm, flags, isr),t ); +___ARCH_SI_IA64 (imm, flags, isr), current); } int send_sig_fault(int sig, int code, void __user *addr
Signature · 1 line
2.21.0
PATCH 22/26 signal: Properly set TRACE_SIGNAL_LOSE_INFO in __send_signal
In reply to Eric W. BiedermanAny time siginfo is not stored in the signal queue information is lost. Therefore set TRACE_SIGNAL_LOSE_INFO every time the code does not allocate a signal queue entry, and a queue overflow abort is not triggered.
--- kernel/signal.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-)
kernel/signal.c +16 -17
@@ -1131,23 +1131,22 @@ static int __send_signal(int sig, struct kernel_siginfo *info, struct task_struccopy_siginfo (&q->info, info);break ; } - }else if (!is_si_special (info)) { -if (sig >=SIGRTMIN && info->si_code !=SI_USER ) { -/* -* Queue overflow, abort. We may abort if the -* signal was rt and sent by user using something -* other than kill(). -*/ - result =TRACE_SIGNAL_OVERFLOW_FAIL ; - ret = -EAGAIN ; - goto ret; - }else { -/* -* This is a silent loss of information. We still -* send the signal, but the *info bits are lost. -*/ - result =TRACE_SIGNAL_LOSE_INFO ; - } + }else if (!is_si_special (info) && + sig >=SIGRTMIN && info->si_code !=SI_USER ) { +/* +* Queue overflow, abort. We may abort if the +* signal was rt and sent by user using something +* other than kill(). +*/ + result =TRACE_SIGNAL_OVERFLOW_FAIL ; + ret = -EAGAIN ; + goto ret; + }else { +/* +* This is a silent loss of information. We still +* send the signal, but the *info bits are lost. +*/ + result =TRACE_SIGNAL_LOSE_INFO ; } out_set:
Signature · 1 line
2.21.0
PATCH 23/26 signal: Move the computation of force into send_signal and correct it.
In reply to Eric W. BiedermanForcing a signal or not allowing a pid namespace init to ignore SIGKILL or SIGSTOP is more cleanly computed in send_signal.
There are two cases where we don't allow a pid namespace init to ignore SIGKILL or SIGSTOP. If the sending process is from an ancestor pid namespace and as such is effectively the god to the target process, and if the it is the kernel that is sending the signal, not another application.
It is known that a process is from an ancestor pid namespace if it can see it's target but it's target does not have a pid for the sender in it's pid namespace.
It is know that a signal is sent from the kernel if si_code is set to SI_KERNEL or info is SEND_SIG_PRIV (which ultimately generates a signal with si_code == SI_KERNEL).
The only signals that matter are SIGKILL and SIGSTOP neither of which can really be caught, and both of which always have a siginfo layout that includes si_uid and si_pid. Therefore we never need to worry about forcing a signal when si_pid and si_uid are absent.
So handle the two special cases of info and the case when si_pid and si_uid are present.
--- kernel/signal.c | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-)
kernel/signal.c +22 -13
@@ -1057,7 +1057,7 @@ static inline bool legacy_queue(struct sigpending *signals, int sig) }static int __send_signal (int sig,struct kernel_siginfo *info,struct task_struct *t, -enum pid_type type,int from_ancestor_ns) +enum pid_type type,bool force) {struct sigpending *pending;struct sigqueue *q;
@@ -1067,8 +1067,7 @@ static int __send_signal(int sig, struct kernel_siginfo *info, struct task_strucassert_spin_locked (&t->sighand->siglock); result =TRACE_SIGNAL_IGNORED ; -if (!prepare_signal (sig, t, - from_ancestor_ns || (info ==SEND_SIG_PRIV ))) +if (!prepare_signal (sig, t, force)) goto ret; pending = (type !=PIDTYPE_PID ) ? &t->signal->shared_pending : &t->pending;
@@ -1198,13 +1197,17 @@ static inline bool has_si_pid_and_uid(struct kernel_siginfo *info)static int send_signal (int sig,struct kernel_siginfo *info,struct task_struct *t,enum pid_type type) { -int from_ancestor_ns =0 ; - -#ifdef CONFIG_PID_NS - from_ancestor_ns =si_fromuser (info) && - !task_pid_nr_ns (current,task_active_pid_ns (t)); -#endif -if (!is_si_special (info) &&has_si_pid_and_uid (info)) { +/* Should SIGKILL or SIGSTOP be received by a pid namespace init? */ +bool force = false; + +if (info ==SEND_SIG_NOINFO ) { +/* Force if sent from an ancestor pid namespace */ + force = !task_pid_nr_ns (current,task_active_pid_ns (t)); + }else if (info ==SEND_SIG_PRIV ) { +/* Don't ignore kernel generated signals */ + force = true; + }else if (has_si_pid_and_uid (info)) { +/* SIGKILL and SIGSTOP is special or has ids */ struct user_namespace *t_user_ns;rcu_read_lock ();
@@ -1215,10 +1218,16 @@ static int send_signal(int sig, struct kernel_siginfo *info, struct task_struct }rcu_read_unlock (); -if (!task_pid_nr_ns (current,task_active_pid_ns (t))) +/* A kernel generated signal? */ + force = (info->si_code ==SI_KERNEL ); + +/* From an ancestor pid namespace? */ +if (!task_pid_nr_ns (current,task_active_pid_ns (t))) { info->si_pid =0 ; + force = true; + } } -return __send_signal (sig, info, t, type, from_ancestor_ns); +return __send_signal (sig, info, t, type, force); }static void print_fatal_signal (int signr)
@@ -1509,7 +1518,7 @@ int kill_pid_usb_asyncio(int sig, int errno, sigval_t addr,if (sig) {if (lock_task_sighand (p, &flags)) { - ret =__send_signal (sig, &info, p,PIDTYPE_TGID ,0 ); + ret =__send_signal (sig, &info, p,PIDTYPE_TGID , false);unlock_task_sighand (p, &flags); }else ret = -ESRCH ;
Signature · 1 line
2.21.0
PATCH 24/26 signal: Generate the siginfo in force_sig
In reply to Eric W. BiedermanIn preparation for removing the special case in force_sig_info for only having a signal number generate an appropriate siginfo in force_sig the last caller of force_sig_info that does not pass a filled out siginfo.
--- kernel/signal.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
kernel/signal.c +9 -1
@@ -1605,7 +1605,15 @@ EXPORT_SYMBOL(send_sig);void force_sig (int sig) { -force_sig_info (sig,SEND_SIG_PRIV , current); +struct kernel_siginfo info; + +clear_siginfo (&info); + info.si_signo = sig; + info.si_errno =0 ; + info.si_code =SI_KERNEL ; + info.si_pid =0 ; + info.si_uid =0 ; +force_sig_info (info.si_signo, &info, current); }EXPORT_SYMBOL (force_sig);
Signature · 1 line
2.21.0
PATCH 25/26 signal: Factor force_sig_info_to_task out of force_sig_info
In reply to Eric W. BiedermanAll callers of force_sig_info pass info.si_signo in for the signal by definition as well as in practice.
Further all callers of force_sig_info except force_sig_fault_to_task pass current as the target task to force_sig_info.
Factor out a static force_sig_info_to_task thatforce_sig_fault_to_task can call.
This prepares the way for force_sig_info to have it's task and signal parameters removed.
--- kernel/signal.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
kernel/signal.c +9 -3
@@ -1294,12 +1294,13 @@ int do_send_sig_info(int sig, struct kernel_siginfo *info, struct task_struct *p* We don't want to have recursive SIGSEGV's etc, for example, * that is why we also clear SIGNAL_UNKILLABLE. */ -int -force_sig_info (int sig,struct kernel_siginfo *info,struct task_struct *t) +static int +force_sig_info_to_task (struct kernel_siginfo *info,struct task_struct *t) {unsigned long int flags;int ret, blocked, ignored;struct k_sigaction *action; +int sig = info->si_signo;spin_lock_irqsave (&t->sighand->siglock, flags); action = &t->sighand->action[sig-1 ];
@@ -1324,6 +1325,11 @@ force_sig_info(int sig, struct kernel_siginfo *info, struct task_struct *t)return ret; } +int force_sig_info (int sig,struct kernel_siginfo *info,struct task_struct *t) +{ +return force_sig_info_to_task (info, t); +} +/* * Nuke all other threads in the group. */
@@ -1656,7 +1662,7 @@ int force_sig_fault_to_task(int sig, int code, void __user *addr info.si_flags = flags; info.si_isr = isr;#endif -return force_sig_info (info.si_signo, &info, t); +return force_sig_info_to_task (&info, t); } int force_sig_fault(int sig, int code, void __user *addr
Signature · 1 line
2.21.0
PATCH 26/26 signal: Remove the signal number and task parameters from force_sig_info
In reply to Eric W. Biedermanforce_sig_info always delivers to the current task and the signal parameter always matches info.si_signo. So remove those parameters to make it a simpler less error prone interface, and to make it clear that none of the callers are doing anything clever.
This guarantees that force_sig_info will not grow any new buggy callers that attempt to call force_sig on a non-current task, or that pass an signal number that does not match info.si_signo.
--- include/linux/ptrace.h | 2 +- include/linux/sched/signal.h | 2 +- kernel/seccomp.c | 2 +- kernel/signal.c | 14 +++++++------- 4 files changed, 10 insertions(+), 10 deletions(-)
include/linux/ptrace.h +1 -1
@@ -355,7 +355,7 @@ static inline void user_single_step_report(struct pt_regs *regs) info.si_code =SI_USER ; info.si_pid =0 ; info.si_uid =0 ; - force_sig_info(info.si_signo, &info, current); + force_sig_info(&info); }#endif
include/linux/sched/signal.h +1 -1
@@ -329,7 +329,7 @@ int force_sig_ptrace_errno_trap(int errno, void __user *addr);extern int send_sig_info (int ,struct kernel_siginfo *,struct task_struct *);extern void force_sigsegv (int sig); -extern int force_sig_info (int ,struct kernel_siginfo *,struct task_struct *); +extern int force_sig_info (struct kernel_siginfo *);extern int __kill_pgrp_info (int sig,struct kernel_siginfo *info,struct pid *pgrp);extern int kill_pid_info (int sig,struct kernel_siginfo *info,struct pid *pid); extern int kill_pid_usb_asyncio(int sig, int errno, sigval_t addr, struct pid *,
kernel/seccomp.c +1 -1
@@ -609,7 +609,7 @@ static void seccomp_send_sigsys(int syscall, int reason) {struct kernel_siginfo info;seccomp_init_siginfo (&info, syscall, reason); -force_sig_info (SIGSYS , &info, current); +force_sig_info (&info); }#endif /* CONFIG_SECCOMP_FILTER */
kernel/signal.c +7 -7
@@ -1325,9 +1325,9 @@ force_sig_info_to_task(struct kernel_siginfo *info, struct task_struct *t)return ret; } -int force_sig_info (int sig,struct kernel_siginfo *info,struct task_struct *t) +int force_sig_info (struct kernel_siginfo *info) { -return force_sig_info_to_task (info, t); +return force_sig_info_to_task (info, current); }/*
@@ -1619,7 +1619,7 @@ void force_sig(int sig) info.si_code =SI_KERNEL ; info.si_pid =0 ; info.si_uid =0 ; -force_sig_info (info.si_signo, &info, current); +force_sig_info (&info); }EXPORT_SYMBOL (force_sig);
@@ -1708,7 +1708,7 @@ int force_sig_mceerr(int code, void __user *addr, short lsb) info.si_code = code; info.si_addr = addr; info.si_addr_lsb = lsb; -return force_sig_info (info.si_signo, &info, current); +return force_sig_info (&info); }int send_sig_mceerr (int code,void __user *addr,short lsb,struct task_struct *t)
@@ -1737,7 +1737,7 @@ int force_sig_bnderr(void __user *addr, void __user *lower, void __user *upper) info.si_addr = addr; info.si_lower = lower; info.si_upper = upper; -return force_sig_info (info.si_signo, &info, current); +return force_sig_info (&info); }#ifdef SEGV_PKUERR
@@ -1751,7 +1751,7 @@ int force_sig_pkuerr(void __user *addr, u32 pkey) info.si_code =SEGV_PKUERR ; info.si_addr = addr; info.si_pkey = pkey; - return force_sig_info(info.si_signo, &info, current); + return force_sig_info(&info); }#endif
@@ -1767,7 +1767,7 @@ int force_sig_ptrace_errno_trap(int errno, void __user *addr) info.si_errno = errno; info.si_code =TRAP_HWBKPT ; info.si_addr = addr; -return force_sig_info (info.si_signo, &info, current); +return force_sig_info (&info); }int kill_pgrp (struct pid *pid,int sig,int priv)
Signature · 1 line
2.21.0
Oleg,
Any comments on this patchset?
Eric
Quoted 28 lines · Eric W. Biederman
Folks,
If folks can look this over and see if I have missed something I would appreciate it.
The
force_sig_infointerface is designed to handle synchronous exceptions like page faults. The locking inforce_sig_infodoes not handle being called on a remote task that is already running. It has been a long standing problem over the years that it is not obvious to people that restriction exists or thatforce_sigis for exceptions and they call it somewhere inappropriate. A recently fixed example is6376360ecbe5("mm: hwpoison: usedo_send_sig_info()instead offorce_sig()").I was looking over the
force_sigfamily of functions not long ago and realized that there really are not that many cases where they are called with on a process other than current and it is possible to remove the current parameter, which should make it hard to make this mistake naively.I found exactly two legitimate places where
force_sigwas being called on a non-current task. On mipsforce_fcr31_sigis called inswitch_toon next the task that we are in the middle of making current. On parisc inuser_enable_single_stepon a task that is stopped in a SIGKILL safe way in ptrace. Both to my eyes appear to meet all of the criterion for being safe to call fromforce_sig.While reviewing that last ptrace case I found a funny corner case bug of
PTRACE_KILL, and so that fix is included in this patset as well.
Quoted 8 lines
Through "signal/cifs: Fix
cifs_put_tcp_sessionto callsend_siginstead offorce_sig" the patches in this patchset are bug fixes. I don't think any of them are urgent as they have existed for a long time, but definitely worth fixes.The rest of the changes are cleanups that carefully remove the task parameters from the entire
force_sigfamily of functions. Until at lastforce_sig_infoonly takes a struct siginfo.
It has been a week. I have applied this to my siginfo-next branch.
Eric
Quoted 174 lines
Eric W. Biederman (26):
signal: Correct namespace fixups ofsi_pidandsi_uidsignal/ptrace: Simplify and fixPTRACE_KILL
signal/arm64: Useforce_signotforce_sig_faultfor SIGKILL signal/drbd: Usesend_signotforce_sig
signal/bpfilter: Fixbpfilter_kernlto usesend_signotforce_sigsignal/pid_namespace: Fixreboot_pid_nsto usesend_signotforce_sigsignal/cifs: Fixcifs_put_tcp_sessionto callsend_siginstead offorce_sigsignal: Remove task parameter from
force_sigsegv
signal: Remove task parameter fromforce_sig
signal: Remove task parameter fromforce_sig_mceerr
signal/x86: Remove task parameter fromsend_sigtrap
signal/um: Remove task parameter fromsend_sigtrap
signal/sh: Remove tsk parameter fromforce_sig_info_faultsignal/riscv: Remove tsk parameter fromdo_trap
signal/nds32: Remove tsk parameter fromsend_sigtrap
signal/arm: Remove tsk parameter fromptrace_break
signal/arm: Remove tsk parameter from__do_user_faultsignal/unicore32: Remove tsk parameter from__do_user_fault
signal: Explicitly callforce_sig_faulton current
signal: Useforce_sig_fault_to_taskfor the two calls that don't deliver to current
signal: Remove the task parameter fromforce_sig_fault
signal: Properly setTRACE_SIGNAL_LOSE_INFOin__send_signal
signal: Move the computation of force intosend_signaland correct it.
signal: Generate the siginfo inforce_sig
signal: Factorforce_sig_info_to_taskout offorce_sig_info
signal: Remove the signal number and task parameters fromforce_sig_infoarch/alpha/kernel/signal.c | 4 +- arch/alpha/kernel/traps.c | 2 +- arch/alpha/mm/fault.c | 4 +- arch/arc/kernel/process.c | 4 +- arch/arc/kernel/signal.c | 2 +- arch/arc/kernel/traps.c | 2 +- arch/arc/mm/fault.c | 4 +- arch/arm/include/asm/traps.h | 2 +- arch/arm/kernel/ptrace.c | 6 +- arch/arm/kernel/signal.c | 4 +- arch/arm/kernel/traps.c | 4 +- arch/arm/mm/alignment.c | 2 +- arch/arm/mm/fault.c | 13 +- arch/arm64/kernel/traps.c | 9 +- arch/c6x/kernel/signal.c | 2 +- arch/c6x/kernel/traps.c | 2 +- arch/csky/abiv1/alignment.c | 2 +- arch/csky/abiv2/fpu.c | 2 +- arch/csky/kernel/signal.c | 4 +- arch/csky/kernel/traps.c | 2 +- arch/csky/mm/fault.c | 4 +- arch/h8300/kernel/ptrace_h.c | 4 +- arch/h8300/kernel/ptrace_s.c | 2 +- arch/h8300/kernel/signal.c | 2 +- arch/hexagon/kernel/signal.c | 2 +- arch/hexagon/kernel/traps.c | 12 +- arch/hexagon/mm/vm_fault.c | 4 +- arch/ia64/kernel/brl_emu.c | 6 +- arch/ia64/kernel/signal.c | 8 +- arch/ia64/kernel/traps.c | 24 +-- arch/ia64/kernel/unaligned.c | 2 +- arch/ia64/mm/fault.c | 2 +- arch/m68k/kernel/signal.c | 4 +- arch/m68k/kernel/traps.c | 20 +-- arch/m68k/mm/fault.c | 4 +- arch/microblaze/kernel/exceptions.c | 2 +- arch/microblaze/kernel/signal.c | 2 +- arch/microblaze/mm/fault.c | 2 +- arch/mips/kernel/branch.c | 18 +-- arch/mips/kernel/kprobes.c | 2 +- arch/mips/kernel/signal.c | 8 +- arch/mips/kernel/signal_n32.c | 4 +- arch/mips/kernel/signal_o32.c | 8 +- arch/mips/kernel/traps.c | 50 +++--- arch/mips/kernel/unaligned.c | 20 +-- arch/mips/mm/fault.c | 4 +- arch/mips/sgi-ip22/ip22-berr.c | 2 +- arch/mips/sgi-ip22/ip28-berr.c | 2 +- arch/mips/sgi-ip27/ip27-berr.c | 2 +- arch/mips/sgi-ip32/ip32-berr.c | 2 +- arch/nds32/kernel/fpu.c | 2 +- arch/nds32/kernel/signal.c | 2 +- arch/nds32/kernel/traps.c | 17 +- arch/nds32/mm/fault.c | 4 +- arch/nios2/kernel/signal.c | 4 +- arch/nios2/kernel/traps.c | 2 +- arch/openrisc/kernel/signal.c | 2 +- arch/openrisc/kernel/traps.c | 12 +- arch/openrisc/mm/fault.c | 4 +- arch/parisc/kernel/ptrace.c | 6 +- arch/parisc/kernel/signal.c | 2 +- arch/parisc/kernel/traps.c | 14 +- arch/parisc/kernel/unaligned.c | 4 +- arch/parisc/math-emu/driver.c | 2 +- arch/parisc/mm/fault.c | 4 +- arch/powerpc/kernel/process.c | 2 +- arch/powerpc/kernel/signal_32.c | 6 +- arch/powerpc/kernel/signal_64.c | 2 +- arch/powerpc/kernel/traps.c | 4 +- arch/powerpc/mm/fault.c | 5 +- arch/powerpc/platforms/cell/spufs/fault.c | 9 +- arch/powerpc/platforms/cell/spufs/run.c | 2 +- arch/riscv/include/asm/bug.h | 2 +- arch/riscv/kernel/signal.c | 2 +- arch/riscv/kernel/traps.c | 11 +- arch/riscv/mm/fault.c | 6 +- arch/s390/kernel/compat_signal.c | 4 +- arch/s390/kernel/signal.c | 4 +- arch/s390/kernel/traps.c | 6 +- arch/s390/mm/fault.c | 6 +- arch/sh/kernel/cpu/sh2a/fpu.c | 2 +- arch/sh/kernel/cpu/sh4/fpu.c | 2 +- arch/sh/kernel/cpu/sh5/fpu.c | 4 +- arch/sh/kernel/hw_breakpoint.c | 2 +- arch/sh/kernel/ptrace_64.c | 4 +- arch/sh/kernel/signal_32.c | 4 +- arch/sh/kernel/signal_64.c | 4 +- arch/sh/kernel/traps.c | 4 +- arch/sh/kernel/traps_32.c | 10 +- arch/sh/kernel/traps_64.c | 2 +- arch/sh/math-emu/math.c | 2 +- arch/sh/mm/fault.c | 11 +- arch/sparc/kernel/process_64.c | 4 +- arch/sparc/kernel/signal32.c | 8 +- arch/sparc/kernel/signal_32.c | 4 +- arch/sparc/kernel/signal_64.c | 8 +- arch/sparc/kernel/sys_sparc_32.c | 2 +- arch/sparc/kernel/sys_sparc_64.c | 2 +- arch/sparc/kernel/traps_32.c | 4 +- arch/sparc/kernel/traps_64.c | 41 +++-- arch/sparc/mm/fault_32.c | 4 +- arch/sparc/mm/fault_64.c | 2 +- arch/um/kernel/exec.c | 2 +- arch/um/kernel/ptrace.c | 7 +- arch/um/kernel/skas/mmu.c | 2 +- arch/um/kernel/tlb.c | 4 +- arch/um/kernel/trap.c | 16 +- arch/unicore32/kernel/signal.c | 4 +- arch/unicore32/kernel/traps.c | 2 +- arch/unicore32/mm/fault.c | 13 +- arch/x86/entry/vsyscall/vsyscall_64.c | 4 +- arch/x86/include/asm/ptrace.h | 3 +- arch/x86/kernel/cpu/mce/core.c | 2 +- arch/x86/kernel/ptrace.c | 9 +- arch/x86/kernel/signal.c | 2 +- arch/x86/kernel/traps.c | 10 +- arch/x86/kernel/umip.c | 2 +- arch/x86/kernel/uprobes.c | 2 +- arch/x86/kernel/vm86_32.c | 2 +- arch/x86/mm/fault.c | 9 +- arch/x86/mm/mpx.c | 2 +- arch/x86/um/signal.c | 4 +- arch/xtensa/kernel/signal.c | 2 +- arch/xtensa/kernel/traps.c | 8 +- arch/xtensa/mm/fault.c | 4 +- drivers/block/drbd/drbd_int.h | 2 +- drivers/block/drbd/drbd_main.c | 2 +- drivers/block/drbd/drbd_nl.c | 2 +- drivers/misc/lkdtm/bugs.c | 2 +- fs/cifs/connect.c | 2 +- fs/exec.c | 2 +- include/linux/ptrace.h | 2 +- include/linux/sched/signal.h | 13 +- include/linux/syscalls.h | 2 +- kernel/events/uprobes.c | 4 +- kernel/pid_namespace.c | 2 +- kernel/ptrace.c | 43 +++-- kernel/rseq.c | 4 +- kernel/seccomp.c | 2 +- kernel/signal.c | 182 ++++++++++++++-------- mm/memory-failure.c | 2 +- net/bpfilter/bpfilter_kern.c | 2 +- security/safesetid/lsm.c | 4 +- 143 files changed, 510 insertions(+), 465 deletions(-)