mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-24 19:50:53 +07:00
5ad18b2e60
Pull force_sig() argument change from Eric Biederman: "A source of error over the years has been that force_sig has taken a task parameter when it is only safe to use force_sig with the current task. The force_sig function is built for delivering synchronous signals such as SIGSEGV where the userspace application caused a synchronous fault (such as a page fault) and the kernel responded with a signal. Because the name force_sig does not make this clear, and because the force_sig takes a task parameter the function force_sig has been abused for sending other kinds of signals over the years. Slowly those have been fixed when the oopses have been tracked down. This set of changes fixes the remaining abusers of force_sig and carefully rips out the task parameter from force_sig and friends making this kind of error almost impossible in the future" * 'siginfo-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace: (27 commits) signal/x86: Move tsk inside of CONFIG_MEMORY_FAILURE in do_sigbus signal: Remove the signal number and task parameters from force_sig_info signal: Factor force_sig_info_to_task out of force_sig_info signal: Generate the siginfo in force_sig signal: Move the computation of force into send_signal and correct it. signal: Properly set TRACE_SIGNAL_LOSE_INFO in __send_signal signal: Remove the task parameter from force_sig_fault signal: Use force_sig_fault_to_task for the two calls that don't deliver to current signal: Explicitly call force_sig_fault on current signal/unicore32: Remove tsk parameter from __do_user_fault signal/arm: Remove tsk parameter from __do_user_fault signal/arm: Remove tsk parameter from ptrace_break signal/nds32: Remove tsk parameter from send_sigtrap signal/riscv: Remove tsk parameter from do_trap signal/sh: Remove tsk parameter from force_sig_info_fault signal/um: Remove task parameter from send_sigtrap signal/x86: Remove task parameter from send_sigtrap signal: Remove task parameter from force_sig_mceerr signal: Remove task parameter from force_sig signal: Remove task parameter from force_sigsegv ...
150 lines
3.8 KiB
C
150 lines
3.8 KiB
C
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
/*
|
|
* Copyright (C) 2003 Broadcom Corporation
|
|
*/
|
|
#include <linux/cache.h>
|
|
#include <linux/sched.h>
|
|
#include <linux/mm.h>
|
|
#include <linux/smp.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/signal.h>
|
|
#include <linux/errno.h>
|
|
#include <linux/wait.h>
|
|
#include <linux/ptrace.h>
|
|
#include <linux/unistd.h>
|
|
#include <linux/compat.h>
|
|
#include <linux/bitops.h>
|
|
|
|
#include <asm/abi.h>
|
|
#include <asm/asm.h>
|
|
#include <asm/cacheflush.h>
|
|
#include <asm/compat-signal.h>
|
|
#include <asm/sim.h>
|
|
#include <linux/uaccess.h>
|
|
#include <asm/ucontext.h>
|
|
#include <asm/fpu.h>
|
|
#include <asm/cpu-features.h>
|
|
#include <asm/war.h>
|
|
|
|
#include "signal-common.h"
|
|
|
|
/*
|
|
* Including <asm/unistd.h> would give use the 64-bit syscall numbers ...
|
|
*/
|
|
#define __NR_N32_restart_syscall 6214
|
|
|
|
extern int setup_sigcontext(struct pt_regs *, struct sigcontext __user *);
|
|
extern int restore_sigcontext(struct pt_regs *, struct sigcontext __user *);
|
|
|
|
struct ucontextn32 {
|
|
u32 uc_flags;
|
|
s32 uc_link;
|
|
compat_stack_t uc_stack;
|
|
struct sigcontext uc_mcontext;
|
|
compat_sigset_t uc_sigmask; /* mask last for extensibility */
|
|
};
|
|
|
|
struct rt_sigframe_n32 {
|
|
u32 rs_ass[4]; /* argument save space for o32 */
|
|
u32 rs_pad[2]; /* Was: signal trampoline */
|
|
struct compat_siginfo rs_info;
|
|
struct ucontextn32 rs_uc;
|
|
};
|
|
|
|
asmlinkage void sysn32_rt_sigreturn(void)
|
|
{
|
|
struct rt_sigframe_n32 __user *frame;
|
|
struct pt_regs *regs;
|
|
sigset_t set;
|
|
int sig;
|
|
|
|
regs = current_pt_regs();
|
|
frame = (struct rt_sigframe_n32 __user *)regs->regs[29];
|
|
if (!access_ok(frame, sizeof(*frame)))
|
|
goto badframe;
|
|
if (__copy_conv_sigset_from_user(&set, &frame->rs_uc.uc_sigmask))
|
|
goto badframe;
|
|
|
|
set_current_blocked(&set);
|
|
|
|
sig = restore_sigcontext(regs, &frame->rs_uc.uc_mcontext);
|
|
if (sig < 0)
|
|
goto badframe;
|
|
else if (sig)
|
|
force_sig(sig);
|
|
|
|
if (compat_restore_altstack(&frame->rs_uc.uc_stack))
|
|
goto badframe;
|
|
|
|
/*
|
|
* Don't let your children do this ...
|
|
*/
|
|
__asm__ __volatile__(
|
|
"move\t$29, %0\n\t"
|
|
"j\tsyscall_exit"
|
|
: /* no outputs */
|
|
: "r" (regs));
|
|
/* Unreached */
|
|
|
|
badframe:
|
|
force_sig(SIGSEGV);
|
|
}
|
|
|
|
static int setup_rt_frame_n32(void *sig_return, struct ksignal *ksig,
|
|
struct pt_regs *regs, sigset_t *set)
|
|
{
|
|
struct rt_sigframe_n32 __user *frame;
|
|
int err = 0;
|
|
|
|
frame = get_sigframe(ksig, regs, sizeof(*frame));
|
|
if (!access_ok(frame, sizeof (*frame)))
|
|
return -EFAULT;
|
|
|
|
/* Create siginfo. */
|
|
err |= copy_siginfo_to_user32(&frame->rs_info, &ksig->info);
|
|
|
|
/* Create the ucontext. */
|
|
err |= __put_user(0, &frame->rs_uc.uc_flags);
|
|
err |= __put_user(0, &frame->rs_uc.uc_link);
|
|
err |= __compat_save_altstack(&frame->rs_uc.uc_stack, regs->regs[29]);
|
|
err |= setup_sigcontext(regs, &frame->rs_uc.uc_mcontext);
|
|
err |= __copy_conv_sigset_to_user(&frame->rs_uc.uc_sigmask, set);
|
|
|
|
if (err)
|
|
return -EFAULT;
|
|
|
|
/*
|
|
* Arguments to signal handler:
|
|
*
|
|
* a0 = signal number
|
|
* a1 = 0 (should be cause)
|
|
* a2 = pointer to ucontext
|
|
*
|
|
* $25 and c0_epc point to the signal handler, $29 points to
|
|
* the struct rt_sigframe.
|
|
*/
|
|
regs->regs[ 4] = ksig->sig;
|
|
regs->regs[ 5] = (unsigned long) &frame->rs_info;
|
|
regs->regs[ 6] = (unsigned long) &frame->rs_uc;
|
|
regs->regs[29] = (unsigned long) frame;
|
|
regs->regs[31] = (unsigned long) sig_return;
|
|
regs->cp0_epc = regs->regs[25] = (unsigned long) ksig->ka.sa.sa_handler;
|
|
|
|
DEBUGP("SIG deliver (%s:%d): sp=0x%p pc=0x%lx ra=0x%lx\n",
|
|
current->comm, current->pid,
|
|
frame, regs->cp0_epc, regs->regs[31]);
|
|
|
|
return 0;
|
|
}
|
|
|
|
struct mips_abi mips_abi_n32 = {
|
|
.setup_rt_frame = setup_rt_frame_n32,
|
|
.restart = __NR_N32_restart_syscall,
|
|
|
|
.off_sc_fpregs = offsetof(struct sigcontext, sc_fpregs),
|
|
.off_sc_fpc_csr = offsetof(struct sigcontext, sc_fpc_csr),
|
|
.off_sc_used_math = offsetof(struct sigcontext, sc_used_math),
|
|
|
|
.vdso = &vdso_image_n32,
|
|
};
|