2005-04-16 16:20:36 -06:00
|
|
|
/*
|
|
|
|
* This file is subject to the terms and conditions of the GNU General Public
|
|
|
|
* License. See the file "COPYING" in the main directory of this archive
|
|
|
|
* for more details.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1991, 1992 Linus Torvalds
|
|
|
|
* Copyright (C) 1994 - 2000 Ralf Baechle
|
|
|
|
* Copyright (C) 1999, 2000 Silicon Graphics, Inc.
|
|
|
|
*/
|
2005-06-15 07:00:12 -06:00
|
|
|
#include <linux/cache.h>
|
2005-04-16 16:20:36 -06:00
|
|
|
#include <linux/sched.h>
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/personality.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/compiler.h>
|
2009-02-08 09:00:26 -07:00
|
|
|
#include <linux/syscalls.h>
|
2007-04-16 08:19:44 -06:00
|
|
|
#include <linux/uaccess.h>
|
2009-09-09 01:30:21 -06:00
|
|
|
#include <linux/tracehook.h>
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2005-05-31 05:49:19 -06:00
|
|
|
#include <asm/abi.h>
|
2005-04-16 16:20:36 -06:00
|
|
|
#include <asm/asm.h>
|
|
|
|
#include <linux/bitops.h>
|
|
|
|
#include <asm/cacheflush.h>
|
|
|
|
#include <asm/fpu.h>
|
|
|
|
#include <asm/sim.h>
|
|
|
|
#include <asm/ucontext.h>
|
|
|
|
#include <asm/cpu-features.h>
|
2005-06-15 07:00:12 -06:00
|
|
|
#include <asm/war.h>
|
2010-02-18 17:13:05 -07:00
|
|
|
#include <asm/vdso.h>
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
#include "signal-common.h"
|
|
|
|
|
2009-11-24 12:35:41 -07:00
|
|
|
static int (*save_fp_context)(struct sigcontext __user *sc);
|
|
|
|
static int (*restore_fp_context)(struct sigcontext __user *sc);
|
|
|
|
|
|
|
|
extern asmlinkage int _save_fp_context(struct sigcontext __user *sc);
|
|
|
|
extern asmlinkage int _restore_fp_context(struct sigcontext __user *sc);
|
|
|
|
|
|
|
|
extern asmlinkage int fpu_emulator_save_context(struct sigcontext __user *sc);
|
|
|
|
extern asmlinkage int fpu_emulator_restore_context(struct sigcontext __user *sc);
|
|
|
|
|
2007-02-12 18:31:48 -07:00
|
|
|
struct sigframe {
|
|
|
|
u32 sf_ass[4]; /* argument save space for o32 */
|
2010-02-18 17:13:05 -07:00
|
|
|
u32 sf_pad[2]; /* Was: signal trampoline */
|
2007-02-12 18:31:48 -07:00
|
|
|
struct sigcontext sf_sc;
|
|
|
|
sigset_t sf_mask;
|
|
|
|
};
|
|
|
|
|
2007-02-05 07:24:21 -07:00
|
|
|
struct rt_sigframe {
|
|
|
|
u32 rs_ass[4]; /* argument save space for o32 */
|
2010-02-18 17:13:05 -07:00
|
|
|
u32 rs_pad[2]; /* Was: signal trampoline */
|
2007-02-05 07:24:21 -07:00
|
|
|
struct siginfo rs_info;
|
|
|
|
struct ucontext rs_uc;
|
|
|
|
};
|
|
|
|
|
2007-02-05 07:24:20 -07:00
|
|
|
/*
|
|
|
|
* Helper routines
|
|
|
|
*/
|
2007-04-16 08:19:44 -06:00
|
|
|
static int protected_save_fp_context(struct sigcontext __user *sc)
|
|
|
|
{
|
|
|
|
int err;
|
|
|
|
while (1) {
|
|
|
|
lock_fpu_owner();
|
|
|
|
own_fpu_inatomic(1);
|
|
|
|
err = save_fp_context(sc); /* this might fail */
|
|
|
|
unlock_fpu_owner();
|
|
|
|
if (likely(!err))
|
|
|
|
break;
|
|
|
|
/* touch the sigcontext and try again */
|
|
|
|
err = __put_user(0, &sc->sc_fpregs[0]) |
|
|
|
|
__put_user(0, &sc->sc_fpregs[31]) |
|
|
|
|
__put_user(0, &sc->sc_fpc_csr);
|
|
|
|
if (err)
|
|
|
|
break; /* really bad sigcontext */
|
|
|
|
}
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int protected_restore_fp_context(struct sigcontext __user *sc)
|
|
|
|
{
|
2011-01-24 15:51:34 -07:00
|
|
|
int err, tmp __maybe_unused;
|
2007-04-16 08:19:44 -06:00
|
|
|
while (1) {
|
|
|
|
lock_fpu_owner();
|
|
|
|
own_fpu_inatomic(0);
|
|
|
|
err = restore_fp_context(sc); /* this might fail */
|
|
|
|
unlock_fpu_owner();
|
|
|
|
if (likely(!err))
|
|
|
|
break;
|
|
|
|
/* touch the sigcontext and try again */
|
|
|
|
err = __get_user(tmp, &sc->sc_fpregs[0]) |
|
|
|
|
__get_user(tmp, &sc->sc_fpregs[31]) |
|
|
|
|
__get_user(tmp, &sc->sc_fpc_csr);
|
|
|
|
if (err)
|
|
|
|
break; /* really bad sigcontext */
|
|
|
|
}
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2007-02-05 07:24:20 -07:00
|
|
|
int setup_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc)
|
|
|
|
{
|
|
|
|
int err = 0;
|
|
|
|
int i;
|
2007-03-09 09:07:45 -07:00
|
|
|
unsigned int used_math;
|
2007-02-05 07:24:20 -07:00
|
|
|
|
|
|
|
err |= __put_user(regs->cp0_epc, &sc->sc_pc);
|
|
|
|
|
|
|
|
err |= __put_user(0, &sc->sc_regs[0]);
|
|
|
|
for (i = 1; i < 32; i++)
|
|
|
|
err |= __put_user(regs->regs[i], &sc->sc_regs[i]);
|
|
|
|
|
2007-02-02 09:41:47 -07:00
|
|
|
#ifdef CONFIG_CPU_HAS_SMARTMIPS
|
|
|
|
err |= __put_user(regs->acx, &sc->sc_acx);
|
|
|
|
#endif
|
2007-02-05 07:24:20 -07:00
|
|
|
err |= __put_user(regs->hi, &sc->sc_mdhi);
|
|
|
|
err |= __put_user(regs->lo, &sc->sc_mdlo);
|
|
|
|
if (cpu_has_dsp) {
|
|
|
|
err |= __put_user(mfhi1(), &sc->sc_hi1);
|
|
|
|
err |= __put_user(mflo1(), &sc->sc_lo1);
|
|
|
|
err |= __put_user(mfhi2(), &sc->sc_hi2);
|
|
|
|
err |= __put_user(mflo2(), &sc->sc_lo2);
|
|
|
|
err |= __put_user(mfhi3(), &sc->sc_hi3);
|
|
|
|
err |= __put_user(mflo3(), &sc->sc_lo3);
|
|
|
|
err |= __put_user(rddsp(DSP_MASK), &sc->sc_dsp);
|
|
|
|
}
|
|
|
|
|
2007-03-09 09:07:45 -07:00
|
|
|
used_math = !!used_math();
|
|
|
|
err |= __put_user(used_math, &sc->sc_used_math);
|
2007-02-05 07:24:20 -07:00
|
|
|
|
2007-03-09 09:07:45 -07:00
|
|
|
if (used_math) {
|
2007-02-05 07:24:20 -07:00
|
|
|
/*
|
|
|
|
* Save FPU state to signal context. Signal handler
|
|
|
|
* will "inherit" current FPU state.
|
|
|
|
*/
|
2007-04-16 08:19:44 -06:00
|
|
|
err |= protected_save_fp_context(sc);
|
2007-02-05 07:24:20 -07:00
|
|
|
}
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2007-03-09 09:03:48 -07:00
|
|
|
int fpcsr_pending(unsigned int __user *fpcsr)
|
|
|
|
{
|
|
|
|
int err, sig = 0;
|
|
|
|
unsigned int csr, enabled;
|
|
|
|
|
|
|
|
err = __get_user(csr, fpcsr);
|
|
|
|
enabled = FPU_CSR_UNI_X | ((csr & FPU_CSR_ALL_E) << 5);
|
|
|
|
/*
|
|
|
|
* If the signal handler set some FPU exceptions, clear it and
|
|
|
|
* send SIGFPE.
|
|
|
|
*/
|
|
|
|
if (csr & enabled) {
|
|
|
|
csr &= ~enabled;
|
|
|
|
err |= __put_user(csr, fpcsr);
|
|
|
|
sig = SIGFPE;
|
|
|
|
}
|
|
|
|
return err ?: sig;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
check_and_restore_fp_context(struct sigcontext __user *sc)
|
|
|
|
{
|
|
|
|
int err, sig;
|
|
|
|
|
|
|
|
err = sig = fpcsr_pending(&sc->sc_fpc_csr);
|
|
|
|
if (err > 0)
|
|
|
|
err = 0;
|
2007-04-16 08:19:44 -06:00
|
|
|
err |= protected_restore_fp_context(sc);
|
2007-03-09 09:03:48 -07:00
|
|
|
return err ?: sig;
|
|
|
|
}
|
|
|
|
|
2007-02-05 07:24:20 -07:00
|
|
|
int restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc)
|
|
|
|
{
|
|
|
|
unsigned int used_math;
|
|
|
|
unsigned long treg;
|
|
|
|
int err = 0;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* Always make any pending restarted system calls return -EINTR */
|
|
|
|
current_thread_info()->restart_block.fn = do_no_restart_syscall;
|
|
|
|
|
|
|
|
err |= __get_user(regs->cp0_epc, &sc->sc_pc);
|
2007-02-02 09:41:47 -07:00
|
|
|
|
|
|
|
#ifdef CONFIG_CPU_HAS_SMARTMIPS
|
|
|
|
err |= __get_user(regs->acx, &sc->sc_acx);
|
|
|
|
#endif
|
2007-02-05 07:24:20 -07:00
|
|
|
err |= __get_user(regs->hi, &sc->sc_mdhi);
|
|
|
|
err |= __get_user(regs->lo, &sc->sc_mdlo);
|
|
|
|
if (cpu_has_dsp) {
|
|
|
|
err |= __get_user(treg, &sc->sc_hi1); mthi1(treg);
|
|
|
|
err |= __get_user(treg, &sc->sc_lo1); mtlo1(treg);
|
|
|
|
err |= __get_user(treg, &sc->sc_hi2); mthi2(treg);
|
|
|
|
err |= __get_user(treg, &sc->sc_lo2); mtlo2(treg);
|
|
|
|
err |= __get_user(treg, &sc->sc_hi3); mthi3(treg);
|
|
|
|
err |= __get_user(treg, &sc->sc_lo3); mtlo3(treg);
|
|
|
|
err |= __get_user(treg, &sc->sc_dsp); wrdsp(treg, DSP_MASK);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 1; i < 32; i++)
|
|
|
|
err |= __get_user(regs->regs[i], &sc->sc_regs[i]);
|
|
|
|
|
|
|
|
err |= __get_user(used_math, &sc->sc_used_math);
|
|
|
|
conditional_used_math(used_math);
|
|
|
|
|
2007-03-09 09:07:45 -07:00
|
|
|
if (used_math) {
|
2007-02-05 07:24:20 -07:00
|
|
|
/* restore fpu context if we have used it before */
|
2007-03-09 09:03:48 -07:00
|
|
|
if (!err)
|
|
|
|
err = check_and_restore_fp_context(sc);
|
2007-02-05 07:24:20 -07:00
|
|
|
} else {
|
|
|
|
/* signal handler may have used FPU. Give it up. */
|
2007-03-09 09:07:45 -07:00
|
|
|
lose_fpu(0);
|
2007-02-05 07:24:20 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
void __user *get_sigframe(struct k_sigaction *ka, struct pt_regs *regs,
|
|
|
|
size_t frame_size)
|
|
|
|
{
|
|
|
|
unsigned long sp;
|
|
|
|
|
|
|
|
/* Default to using normal stack */
|
|
|
|
sp = regs->regs[29];
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FPU emulator may have it's own trampoline active just
|
|
|
|
* above the user stack, 16-bytes before the next lowest
|
|
|
|
* 16 byte boundary. Try to avoid trashing it.
|
|
|
|
*/
|
|
|
|
sp -= 32;
|
|
|
|
|
|
|
|
/* This is the X/Open sanctioned signal stack switching. */
|
|
|
|
if ((ka->sa.sa_flags & SA_ONSTACK) && (sas_ss_flags (sp) == 0))
|
|
|
|
sp = current->sas_ss_sp + current->sas_ss_size;
|
|
|
|
|
|
|
|
return (void __user *)((sp - frame_size) & (ICACHE_REFILLS_WORKAROUND_WAR ? ~(cpu_icache_line_size()-1) : ALMASK));
|
|
|
|
}
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
/*
|
|
|
|
* Atomically swap in the new signal mask, and wait for a signal.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef CONFIG_TRAD_SIGNALS
|
2007-02-05 07:24:27 -07:00
|
|
|
asmlinkage int sys_sigsuspend(nabi_no_regargs struct pt_regs regs)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2006-02-08 05:58:41 -07:00
|
|
|
sigset_t newset;
|
2005-03-01 12:22:29 -07:00
|
|
|
sigset_t __user *uset;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2005-03-01 12:22:29 -07:00
|
|
|
uset = (sigset_t __user *) regs.regs[4];
|
2005-04-16 16:20:36 -06:00
|
|
|
if (copy_from_user(&newset, uset, sizeof(sigset_t)))
|
|
|
|
return -EFAULT;
|
|
|
|
sigdelsetmask(&newset, ~_BLOCKABLE);
|
|
|
|
|
|
|
|
spin_lock_irq(¤t->sighand->siglock);
|
2006-02-08 05:58:41 -07:00
|
|
|
current->saved_sigmask = current->blocked;
|
2005-04-16 16:20:36 -06:00
|
|
|
current->blocked = newset;
|
|
|
|
recalc_sigpending();
|
|
|
|
spin_unlock_irq(¤t->sighand->siglock);
|
|
|
|
|
2006-02-08 05:58:41 -07:00
|
|
|
current->state = TASK_INTERRUPTIBLE;
|
|
|
|
schedule();
|
|
|
|
set_thread_flag(TIF_RESTORE_SIGMASK);
|
|
|
|
return -ERESTARTNOHAND;
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-02-05 07:24:27 -07:00
|
|
|
asmlinkage int sys_rt_sigsuspend(nabi_no_regargs struct pt_regs regs)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2006-02-08 05:58:41 -07:00
|
|
|
sigset_t newset;
|
2005-03-01 12:22:29 -07:00
|
|
|
sigset_t __user *unewset;
|
2005-04-16 16:20:36 -06:00
|
|
|
size_t sigsetsize;
|
|
|
|
|
|
|
|
/* XXX Don't preclude handling different sized sigset_t's. */
|
|
|
|
sigsetsize = regs.regs[5];
|
|
|
|
if (sigsetsize != sizeof(sigset_t))
|
|
|
|
return -EINVAL;
|
|
|
|
|
2005-03-01 12:22:29 -07:00
|
|
|
unewset = (sigset_t __user *) regs.regs[4];
|
2005-04-16 16:20:36 -06:00
|
|
|
if (copy_from_user(&newset, unewset, sizeof(newset)))
|
|
|
|
return -EFAULT;
|
|
|
|
sigdelsetmask(&newset, ~_BLOCKABLE);
|
|
|
|
|
|
|
|
spin_lock_irq(¤t->sighand->siglock);
|
2006-02-08 05:58:41 -07:00
|
|
|
current->saved_sigmask = current->blocked;
|
2005-04-16 16:20:36 -06:00
|
|
|
current->blocked = newset;
|
2007-02-04 17:10:11 -07:00
|
|
|
recalc_sigpending();
|
2005-04-16 16:20:36 -06:00
|
|
|
spin_unlock_irq(¤t->sighand->siglock);
|
|
|
|
|
2006-02-08 05:58:41 -07:00
|
|
|
current->state = TASK_INTERRUPTIBLE;
|
|
|
|
schedule();
|
|
|
|
set_thread_flag(TIF_RESTORE_SIGMASK);
|
|
|
|
return -ERESTARTNOHAND;
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_TRAD_SIGNALS
|
2009-02-08 09:00:26 -07:00
|
|
|
SYSCALL_DEFINE3(sigaction, int, sig, const struct sigaction __user *, act,
|
|
|
|
struct sigaction __user *, oact)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
|
|
|
struct k_sigaction new_ka, old_ka;
|
|
|
|
int ret;
|
|
|
|
int err = 0;
|
|
|
|
|
|
|
|
if (act) {
|
|
|
|
old_sigset_t mask;
|
|
|
|
|
|
|
|
if (!access_ok(VERIFY_READ, act, sizeof(*act)))
|
|
|
|
return -EFAULT;
|
|
|
|
err |= __get_user(new_ka.sa.sa_handler, &act->sa_handler);
|
|
|
|
err |= __get_user(new_ka.sa.sa_flags, &act->sa_flags);
|
|
|
|
err |= __get_user(mask, &act->sa_mask.sig[0]);
|
|
|
|
if (err)
|
|
|
|
return -EFAULT;
|
|
|
|
|
|
|
|
siginitset(&new_ka.sa.sa_mask, mask);
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = do_sigaction(sig, act ? &new_ka : NULL, oact ? &old_ka : NULL);
|
|
|
|
|
|
|
|
if (!ret && oact) {
|
|
|
|
if (!access_ok(VERIFY_WRITE, oact, sizeof(*oact)))
|
2007-02-04 17:10:11 -07:00
|
|
|
return -EFAULT;
|
2005-04-16 16:20:36 -06:00
|
|
|
err |= __put_user(old_ka.sa.sa_flags, &oact->sa_flags);
|
|
|
|
err |= __put_user(old_ka.sa.sa_handler, &oact->sa_handler);
|
|
|
|
err |= __put_user(old_ka.sa.sa_mask.sig[0], oact->sa_mask.sig);
|
|
|
|
err |= __put_user(0, &oact->sa_mask.sig[1]);
|
|
|
|
err |= __put_user(0, &oact->sa_mask.sig[2]);
|
|
|
|
err |= __put_user(0, &oact->sa_mask.sig[3]);
|
|
|
|
if (err)
|
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
asmlinkage int sys_sigaltstack(nabi_no_regargs struct pt_regs regs)
|
|
|
|
{
|
2005-03-01 12:22:29 -07:00
|
|
|
const stack_t __user *uss = (const stack_t __user *) regs.regs[4];
|
|
|
|
stack_t __user *uoss = (stack_t __user *) regs.regs[5];
|
2005-04-16 16:20:36 -06:00
|
|
|
unsigned long usp = regs.regs[29];
|
|
|
|
|
|
|
|
return do_sigaltstack(uss, uoss, usp);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_TRAD_SIGNALS
|
2007-02-05 07:24:27 -07:00
|
|
|
asmlinkage void sys_sigreturn(nabi_no_regargs struct pt_regs regs)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2006-01-31 09:41:09 -07:00
|
|
|
struct sigframe __user *frame;
|
2005-04-16 16:20:36 -06:00
|
|
|
sigset_t blocked;
|
2007-03-09 09:03:48 -07:00
|
|
|
int sig;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2006-01-31 09:41:09 -07:00
|
|
|
frame = (struct sigframe __user *) regs.regs[29];
|
2005-04-16 16:20:36 -06:00
|
|
|
if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
|
|
|
|
goto badframe;
|
|
|
|
if (__copy_from_user(&blocked, &frame->sf_mask, sizeof(blocked)))
|
|
|
|
goto badframe;
|
|
|
|
|
|
|
|
sigdelsetmask(&blocked, ~_BLOCKABLE);
|
|
|
|
spin_lock_irq(¤t->sighand->siglock);
|
|
|
|
current->blocked = blocked;
|
|
|
|
recalc_sigpending();
|
|
|
|
spin_unlock_irq(¤t->sighand->siglock);
|
|
|
|
|
2007-03-09 09:03:48 -07:00
|
|
|
sig = restore_sigcontext(®s, &frame->sf_sc);
|
|
|
|
if (sig < 0)
|
2005-04-16 16:20:36 -06:00
|
|
|
goto badframe;
|
2007-03-09 09:03:48 -07:00
|
|
|
else if (sig)
|
|
|
|
force_sig(sig, current);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Don't let your children do this ...
|
|
|
|
*/
|
|
|
|
__asm__ __volatile__(
|
|
|
|
"move\t$29, %0\n\t"
|
|
|
|
"j\tsyscall_exit"
|
|
|
|
:/* no outputs */
|
|
|
|
:"r" (®s));
|
|
|
|
/* Unreached */
|
|
|
|
|
|
|
|
badframe:
|
|
|
|
force_sig(SIGSEGV, current);
|
|
|
|
}
|
2005-05-31 05:49:19 -06:00
|
|
|
#endif /* CONFIG_TRAD_SIGNALS */
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2007-02-05 07:24:27 -07:00
|
|
|
asmlinkage void sys_rt_sigreturn(nabi_no_regargs struct pt_regs regs)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2006-01-31 09:41:09 -07:00
|
|
|
struct rt_sigframe __user *frame;
|
2005-04-16 16:20:36 -06:00
|
|
|
sigset_t set;
|
2007-03-09 09:03:48 -07:00
|
|
|
int sig;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2006-01-31 09:41:09 -07:00
|
|
|
frame = (struct rt_sigframe __user *) regs.regs[29];
|
2005-04-16 16:20:36 -06:00
|
|
|
if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
|
|
|
|
goto badframe;
|
|
|
|
if (__copy_from_user(&set, &frame->rs_uc.uc_sigmask, sizeof(set)))
|
|
|
|
goto badframe;
|
|
|
|
|
|
|
|
sigdelsetmask(&set, ~_BLOCKABLE);
|
|
|
|
spin_lock_irq(¤t->sighand->siglock);
|
|
|
|
current->blocked = set;
|
|
|
|
recalc_sigpending();
|
|
|
|
spin_unlock_irq(¤t->sighand->siglock);
|
|
|
|
|
2007-03-09 09:03:48 -07:00
|
|
|
sig = restore_sigcontext(®s, &frame->rs_uc.uc_mcontext);
|
|
|
|
if (sig < 0)
|
2005-04-16 16:20:36 -06:00
|
|
|
goto badframe;
|
2007-03-09 09:03:48 -07:00
|
|
|
else if (sig)
|
|
|
|
force_sig(sig, current);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/* It is more difficult to avoid calling this function than to
|
|
|
|
call it and ignore errors. */
|
2010-09-28 11:50:57 -06:00
|
|
|
do_sigaltstack(&frame->rs_uc.uc_stack, NULL, regs.regs[29]);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Don't let your children do this ...
|
|
|
|
*/
|
|
|
|
__asm__ __volatile__(
|
|
|
|
"move\t$29, %0\n\t"
|
|
|
|
"j\tsyscall_exit"
|
|
|
|
:/* no outputs */
|
|
|
|
:"r" (®s));
|
|
|
|
/* Unreached */
|
|
|
|
|
|
|
|
badframe:
|
|
|
|
force_sig(SIGSEGV, current);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_TRAD_SIGNALS
|
2010-02-18 17:13:05 -07:00
|
|
|
static int setup_frame(void *sig_return, struct k_sigaction *ka,
|
|
|
|
struct pt_regs *regs, int signr, sigset_t *set)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2006-01-31 09:41:09 -07:00
|
|
|
struct sigframe __user *frame;
|
2005-04-16 16:20:36 -06:00
|
|
|
int err = 0;
|
|
|
|
|
|
|
|
frame = get_sigframe(ka, regs, sizeof(*frame));
|
|
|
|
if (!access_ok(VERIFY_WRITE, frame, sizeof (*frame)))
|
|
|
|
goto give_sigsegv;
|
|
|
|
|
|
|
|
err |= setup_sigcontext(regs, &frame->sf_sc);
|
|
|
|
err |= __copy_to_user(&frame->sf_mask, set, sizeof(*set));
|
|
|
|
if (err)
|
|
|
|
goto give_sigsegv;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Arguments to signal handler:
|
|
|
|
*
|
|
|
|
* a0 = signal number
|
|
|
|
* a1 = 0 (should be cause)
|
|
|
|
* a2 = pointer to struct sigcontext
|
|
|
|
*
|
|
|
|
* $25 and c0_epc point to the signal handler, $29 points to the
|
|
|
|
* struct sigframe.
|
|
|
|
*/
|
|
|
|
regs->regs[ 4] = signr;
|
|
|
|
regs->regs[ 5] = 0;
|
|
|
|
regs->regs[ 6] = (unsigned long) &frame->sf_sc;
|
|
|
|
regs->regs[29] = (unsigned long) frame;
|
2010-02-18 17:13:05 -07:00
|
|
|
regs->regs[31] = (unsigned long) sig_return;
|
2005-04-16 16:20:36 -06:00
|
|
|
regs->cp0_epc = regs->regs[25] = (unsigned long) ka->sa.sa_handler;
|
|
|
|
|
2007-02-05 07:24:24 -07:00
|
|
|
DEBUGP("SIG deliver (%s:%d): sp=0x%p pc=0x%lx ra=0x%lx\n",
|
2005-04-16 16:20:36 -06:00
|
|
|
current->comm, current->pid,
|
2007-02-05 07:24:24 -07:00
|
|
|
frame, regs->cp0_epc, regs->regs[31]);
|
2007-02-04 17:10:11 -07:00
|
|
|
return 0;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
give_sigsegv:
|
|
|
|
force_sigsegv(signr, current);
|
2006-02-08 05:58:41 -07:00
|
|
|
return -EFAULT;
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2010-02-18 17:13:05 -07:00
|
|
|
static int setup_rt_frame(void *sig_return, struct k_sigaction *ka,
|
|
|
|
struct pt_regs *regs, int signr, sigset_t *set,
|
|
|
|
siginfo_t *info)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2006-01-31 09:41:09 -07:00
|
|
|
struct rt_sigframe __user *frame;
|
2005-04-16 16:20:36 -06:00
|
|
|
int err = 0;
|
|
|
|
|
|
|
|
frame = get_sigframe(ka, regs, sizeof(*frame));
|
|
|
|
if (!access_ok(VERIFY_WRITE, frame, sizeof (*frame)))
|
|
|
|
goto give_sigsegv;
|
|
|
|
|
|
|
|
/* Create siginfo. */
|
|
|
|
err |= copy_siginfo_to_user(&frame->rs_info, info);
|
|
|
|
|
|
|
|
/* Create the ucontext. */
|
|
|
|
err |= __put_user(0, &frame->rs_uc.uc_flags);
|
2006-02-01 09:26:34 -07:00
|
|
|
err |= __put_user(NULL, &frame->rs_uc.uc_link);
|
2006-02-19 07:46:44 -07:00
|
|
|
err |= __put_user((void __user *)current->sas_ss_sp,
|
2005-04-16 16:20:36 -06:00
|
|
|
&frame->rs_uc.uc_stack.ss_sp);
|
|
|
|
err |= __put_user(sas_ss_flags(regs->regs[29]),
|
|
|
|
&frame->rs_uc.uc_stack.ss_flags);
|
|
|
|
err |= __put_user(current->sas_ss_size,
|
|
|
|
&frame->rs_uc.uc_stack.ss_size);
|
|
|
|
err |= setup_sigcontext(regs, &frame->rs_uc.uc_mcontext);
|
|
|
|
err |= __copy_to_user(&frame->rs_uc.uc_sigmask, set, sizeof(*set));
|
|
|
|
|
|
|
|
if (err)
|
|
|
|
goto give_sigsegv;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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] = signr;
|
|
|
|
regs->regs[ 5] = (unsigned long) &frame->rs_info;
|
|
|
|
regs->regs[ 6] = (unsigned long) &frame->rs_uc;
|
|
|
|
regs->regs[29] = (unsigned long) frame;
|
2010-02-18 17:13:05 -07:00
|
|
|
regs->regs[31] = (unsigned long) sig_return;
|
2005-04-16 16:20:36 -06:00
|
|
|
regs->cp0_epc = regs->regs[25] = (unsigned long) ka->sa.sa_handler;
|
|
|
|
|
2007-02-05 07:24:24 -07:00
|
|
|
DEBUGP("SIG deliver (%s:%d): sp=0x%p pc=0x%lx ra=0x%lx\n",
|
2005-04-16 16:20:36 -06:00
|
|
|
current->comm, current->pid,
|
|
|
|
frame, regs->cp0_epc, regs->regs[31]);
|
2007-02-05 07:24:24 -07:00
|
|
|
|
2006-02-08 05:58:41 -07:00
|
|
|
return 0;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
give_sigsegv:
|
|
|
|
force_sigsegv(signr, current);
|
2006-02-08 05:58:41 -07:00
|
|
|
return -EFAULT;
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
2007-02-15 04:40:37 -07:00
|
|
|
struct mips_abi mips_abi = {
|
|
|
|
#ifdef CONFIG_TRAD_SIGNALS
|
|
|
|
.setup_frame = setup_frame,
|
2010-02-18 17:13:05 -07:00
|
|
|
.signal_return_offset = offsetof(struct mips_vdso, signal_trampoline),
|
2007-02-15 04:40:37 -07:00
|
|
|
#endif
|
|
|
|
.setup_rt_frame = setup_rt_frame,
|
2010-02-18 17:13:05 -07:00
|
|
|
.rt_signal_return_offset =
|
|
|
|
offsetof(struct mips_vdso, rt_signal_trampoline),
|
2007-02-15 04:40:37 -07:00
|
|
|
.restart = __NR_restart_syscall
|
|
|
|
};
|
|
|
|
|
2007-02-05 07:24:28 -07:00
|
|
|
static int handle_signal(unsigned long sig, siginfo_t *info,
|
2005-04-16 16:20:36 -06:00
|
|
|
struct k_sigaction *ka, sigset_t *oldset, struct pt_regs *regs)
|
|
|
|
{
|
2005-07-11 14:45:51 -06:00
|
|
|
int ret;
|
2010-02-18 17:13:05 -07:00
|
|
|
struct mips_abi *abi = current->thread.abi;
|
|
|
|
void *vdso = current->mm->context.vdso;
|
2005-07-11 14:45:51 -06:00
|
|
|
|
2010-09-28 11:50:37 -06:00
|
|
|
if (regs->regs[0]) {
|
|
|
|
switch(regs->regs[2]) {
|
|
|
|
case ERESTART_RESTARTBLOCK:
|
|
|
|
case ERESTARTNOHAND:
|
2005-04-16 16:20:36 -06:00
|
|
|
regs->regs[2] = EINTR;
|
|
|
|
break;
|
2010-09-28 11:50:37 -06:00
|
|
|
case ERESTARTSYS:
|
|
|
|
if (!(ka->sa.sa_flags & SA_RESTART)) {
|
|
|
|
regs->regs[2] = EINTR;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* fallthrough */
|
|
|
|
case ERESTARTNOINTR:
|
|
|
|
regs->regs[7] = regs->regs[26];
|
|
|
|
regs->regs[2] = regs->regs[0];
|
|
|
|
regs->cp0_epc -= 4;
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
2010-09-28 11:50:37 -06:00
|
|
|
regs->regs[0] = 0; /* Don't deal with this again. */
|
|
|
|
}
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2005-05-31 05:49:19 -06:00
|
|
|
if (sig_uses_siginfo(ka))
|
2010-02-18 17:13:05 -07:00
|
|
|
ret = abi->setup_rt_frame(vdso + abi->rt_signal_return_offset,
|
|
|
|
ka, regs, sig, oldset, info);
|
2005-04-16 16:20:36 -06:00
|
|
|
else
|
2010-02-18 17:13:05 -07:00
|
|
|
ret = abi->setup_frame(vdso + abi->signal_return_offset,
|
|
|
|
ka, regs, sig, oldset);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2010-09-28 11:50:17 -06:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
|
|
|
|
[PATCH] convert signal handling of NODEFER to act like other Unix boxes.
It has been reported that the way Linux handles NODEFER for signals is
not consistent with the way other Unix boxes handle it. I've written a
program to test the behavior of how this flag affects signals and had
several reports from people who ran this on various Unix boxes,
confirming that Linux seems to be unique on the way this is handled.
The way NODEFER affects signals on other Unix boxes is as follows:
1) If NODEFER is set, other signals in sa_mask are still blocked.
2) If NODEFER is set and the signal is in sa_mask, then the signal is
still blocked. (Note: this is the behavior of all tested but Linux _and_
NetBSD 2.0 *).
The way NODEFER affects signals on Linux:
1) If NODEFER is set, other signals are _not_ blocked regardless of
sa_mask (Even NetBSD doesn't do this).
2) If NODEFER is set and the signal is in sa_mask, then the signal being
handled is not blocked.
The patch converts signal handling in all current Linux architectures to
the way most Unix boxes work.
Unix boxes that were tested: DU4, AIX 5.2, Irix 6.5, NetBSD 2.0, SFU
3.5 on WinXP, AIX 5.3, Mac OSX, and of course Linux 2.6.13-rcX.
* NetBSD was the only other Unix to behave like Linux on point #2. The
main concern was brought up by point #1 which even NetBSD isn't like
Linux. So with this patch, we leave NetBSD as the lonely one that
behaves differently here with #2.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-08-29 09:44:09 -06:00
|
|
|
spin_lock_irq(¤t->sighand->siglock);
|
2007-10-11 16:46:15 -06:00
|
|
|
sigorsets(¤t->blocked, ¤t->blocked, &ka->sa.sa_mask);
|
[PATCH] convert signal handling of NODEFER to act like other Unix boxes.
It has been reported that the way Linux handles NODEFER for signals is
not consistent with the way other Unix boxes handle it. I've written a
program to test the behavior of how this flag affects signals and had
several reports from people who ran this on various Unix boxes,
confirming that Linux seems to be unique on the way this is handled.
The way NODEFER affects signals on other Unix boxes is as follows:
1) If NODEFER is set, other signals in sa_mask are still blocked.
2) If NODEFER is set and the signal is in sa_mask, then the signal is
still blocked. (Note: this is the behavior of all tested but Linux _and_
NetBSD 2.0 *).
The way NODEFER affects signals on Linux:
1) If NODEFER is set, other signals are _not_ blocked regardless of
sa_mask (Even NetBSD doesn't do this).
2) If NODEFER is set and the signal is in sa_mask, then the signal being
handled is not blocked.
The patch converts signal handling in all current Linux architectures to
the way most Unix boxes work.
Unix boxes that were tested: DU4, AIX 5.2, Irix 6.5, NetBSD 2.0, SFU
3.5 on WinXP, AIX 5.3, Mac OSX, and of course Linux 2.6.13-rcX.
* NetBSD was the only other Unix to behave like Linux on point #2. The
main concern was brought up by point #1 which even NetBSD isn't like
Linux. So with this patch, we leave NetBSD as the lonely one that
behaves differently here with #2.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-08-29 09:44:09 -06:00
|
|
|
if (!(ka->sa.sa_flags & SA_NODEFER))
|
2007-10-11 16:46:15 -06:00
|
|
|
sigaddset(¤t->blocked, sig);
|
[PATCH] convert signal handling of NODEFER to act like other Unix boxes.
It has been reported that the way Linux handles NODEFER for signals is
not consistent with the way other Unix boxes handle it. I've written a
program to test the behavior of how this flag affects signals and had
several reports from people who ran this on various Unix boxes,
confirming that Linux seems to be unique on the way this is handled.
The way NODEFER affects signals on other Unix boxes is as follows:
1) If NODEFER is set, other signals in sa_mask are still blocked.
2) If NODEFER is set and the signal is in sa_mask, then the signal is
still blocked. (Note: this is the behavior of all tested but Linux _and_
NetBSD 2.0 *).
The way NODEFER affects signals on Linux:
1) If NODEFER is set, other signals are _not_ blocked regardless of
sa_mask (Even NetBSD doesn't do this).
2) If NODEFER is set and the signal is in sa_mask, then the signal being
handled is not blocked.
The patch converts signal handling in all current Linux architectures to
the way most Unix boxes work.
Unix boxes that were tested: DU4, AIX 5.2, Irix 6.5, NetBSD 2.0, SFU
3.5 on WinXP, AIX 5.3, Mac OSX, and of course Linux 2.6.13-rcX.
* NetBSD was the only other Unix to behave like Linux on point #2. The
main concern was brought up by point #1 which even NetBSD isn't like
Linux. So with this patch, we leave NetBSD as the lonely one that
behaves differently here with #2.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-08-29 09:44:09 -06:00
|
|
|
recalc_sigpending();
|
|
|
|
spin_unlock_irq(¤t->sighand->siglock);
|
2005-07-11 14:45:51 -06:00
|
|
|
|
|
|
|
return ret;
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
2007-02-15 04:40:37 -07:00
|
|
|
static void do_signal(struct pt_regs *regs)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
|
|
|
struct k_sigaction ka;
|
2006-02-08 05:58:41 -07:00
|
|
|
sigset_t *oldset;
|
2005-04-16 16:20:36 -06:00
|
|
|
siginfo_t info;
|
|
|
|
int signr;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We want the common case to go fast, which is why we may in certain
|
|
|
|
* cases get here from kernel mode. Just return without doing anything
|
|
|
|
* if so.
|
|
|
|
*/
|
|
|
|
if (!user_mode(regs))
|
2006-02-08 06:38:18 -07:00
|
|
|
return;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2006-02-08 05:58:41 -07:00
|
|
|
if (test_thread_flag(TIF_RESTORE_SIGMASK))
|
|
|
|
oldset = ¤t->saved_sigmask;
|
|
|
|
else
|
2005-04-16 16:20:36 -06:00
|
|
|
oldset = ¤t->blocked;
|
|
|
|
|
|
|
|
signr = get_signal_to_deliver(&info, &ka, regs, NULL);
|
2006-02-08 05:58:41 -07:00
|
|
|
if (signr > 0) {
|
|
|
|
/* Whee! Actually deliver the signal. */
|
|
|
|
if (handle_signal(signr, &info, &ka, oldset, regs) == 0) {
|
|
|
|
/*
|
|
|
|
* A signal was successfully delivered; the saved
|
|
|
|
* sigmask will have been stored in the signal frame,
|
|
|
|
* and will be restored by sigreturn, so we can simply
|
|
|
|
* clear the TIF_RESTORE_SIGMASK flag.
|
|
|
|
*/
|
|
|
|
if (test_thread_flag(TIF_RESTORE_SIGMASK))
|
|
|
|
clear_thread_flag(TIF_RESTORE_SIGMASK);
|
|
|
|
}
|
2006-08-03 14:54:13 -06:00
|
|
|
|
|
|
|
return;
|
2006-02-08 05:58:41 -07:00
|
|
|
}
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
if (regs->regs[0]) {
|
|
|
|
if (regs->regs[2] == ERESTARTNOHAND ||
|
|
|
|
regs->regs[2] == ERESTARTSYS ||
|
|
|
|
regs->regs[2] == ERESTARTNOINTR) {
|
2010-09-28 11:50:37 -06:00
|
|
|
regs->regs[2] = regs->regs[0];
|
2005-04-16 16:20:36 -06:00
|
|
|
regs->regs[7] = regs->regs[26];
|
2010-09-28 11:50:37 -06:00
|
|
|
regs->cp0_epc -= 4;
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
if (regs->regs[2] == ERESTART_RESTARTBLOCK) {
|
2007-02-15 04:40:37 -07:00
|
|
|
regs->regs[2] = current->thread.abi->restart;
|
2005-04-16 16:20:36 -06:00
|
|
|
regs->regs[7] = regs->regs[26];
|
|
|
|
regs->cp0_epc -= 4;
|
|
|
|
}
|
2006-08-07 20:47:01 -06:00
|
|
|
regs->regs[0] = 0; /* Don't deal with this again. */
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
2006-02-08 05:58:41 -07:00
|
|
|
|
|
|
|
/*
|
|
|
|
* If there's no signal to deliver, we just put the saved sigmask
|
|
|
|
* back
|
|
|
|
*/
|
|
|
|
if (test_thread_flag(TIF_RESTORE_SIGMASK)) {
|
|
|
|
clear_thread_flag(TIF_RESTORE_SIGMASK);
|
|
|
|
sigprocmask(SIG_SETMASK, ¤t->saved_sigmask, NULL);
|
|
|
|
}
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* notification of userspace execution resumption
|
2006-02-08 05:58:41 -07:00
|
|
|
* - triggered by the TIF_WORK_MASK flags
|
2005-04-16 16:20:36 -06:00
|
|
|
*/
|
2006-02-08 05:58:41 -07:00
|
|
|
asmlinkage void do_notify_resume(struct pt_regs *regs, void *unused,
|
2005-04-16 16:20:36 -06:00
|
|
|
__u32 thread_info_flags)
|
|
|
|
{
|
|
|
|
/* deal with pending signal delivery */
|
2006-02-08 05:58:41 -07:00
|
|
|
if (thread_info_flags & (_TIF_SIGPENDING | _TIF_RESTORE_SIGMASK))
|
2007-02-15 04:40:37 -07:00
|
|
|
do_signal(regs);
|
2009-09-02 02:14:16 -06:00
|
|
|
|
|
|
|
if (thread_info_flags & _TIF_NOTIFY_RESUME) {
|
|
|
|
clear_thread_flag(TIF_NOTIFY_RESUME);
|
|
|
|
tracehook_notify_resume(regs);
|
KEYS: Add a keyctl to install a process's session keyring on its parent [try #6]
Add a keyctl to install a process's session keyring onto its parent. This
replaces the parent's session keyring. Because the COW credential code does
not permit one process to change another process's credentials directly, the
change is deferred until userspace next starts executing again. Normally this
will be after a wait*() syscall.
To support this, three new security hooks have been provided:
cred_alloc_blank() to allocate unset security creds, cred_transfer() to fill in
the blank security creds and key_session_to_parent() - which asks the LSM if
the process may replace its parent's session keyring.
The replacement may only happen if the process has the same ownership details
as its parent, and the process has LINK permission on the session keyring, and
the session keyring is owned by the process, and the LSM permits it.
Note that this requires alteration to each architecture's notify_resume path.
This has been done for all arches barring blackfin, m68k* and xtensa, all of
which need assembly alteration to support TIF_NOTIFY_RESUME. This allows the
replacement to be performed at the point the parent process resumes userspace
execution.
This allows the userspace AFS pioctl emulation to fully emulate newpag() and
the VIOCSETTOK and VIOCSETTOK2 pioctls, all of which require the ability to
alter the parent process's PAG membership. However, since kAFS doesn't use
PAGs per se, but rather dumps the keys into the session keyring, the session
keyring of the parent must be replaced if, for example, VIOCSETTOK is passed
the newpag flag.
This can be tested with the following program:
#include <stdio.h>
#include <stdlib.h>
#include <keyutils.h>
#define KEYCTL_SESSION_TO_PARENT 18
#define OSERROR(X, S) do { if ((long)(X) == -1) { perror(S); exit(1); } } while(0)
int main(int argc, char **argv)
{
key_serial_t keyring, key;
long ret;
keyring = keyctl_join_session_keyring(argv[1]);
OSERROR(keyring, "keyctl_join_session_keyring");
key = add_key("user", "a", "b", 1, keyring);
OSERROR(key, "add_key");
ret = keyctl(KEYCTL_SESSION_TO_PARENT);
OSERROR(ret, "KEYCTL_SESSION_TO_PARENT");
return 0;
}
Compiled and linked with -lkeyutils, you should see something like:
[dhowells@andromeda ~]$ keyctl show
Session Keyring
-3 --alswrv 4043 4043 keyring: _ses
355907932 --alswrv 4043 -1 \_ keyring: _uid.4043
[dhowells@andromeda ~]$ /tmp/newpag
[dhowells@andromeda ~]$ keyctl show
Session Keyring
-3 --alswrv 4043 4043 keyring: _ses
1055658746 --alswrv 4043 4043 \_ user: a
[dhowells@andromeda ~]$ /tmp/newpag hello
[dhowells@andromeda ~]$ keyctl show
Session Keyring
-3 --alswrv 4043 4043 keyring: hello
340417692 --alswrv 4043 4043 \_ user: a
Where the test program creates a new session keyring, sticks a user key named
'a' into it and then installs it on its parent.
Signed-off-by: David Howells <dhowells@redhat.com>
Signed-off-by: James Morris <jmorris@namei.org>
2009-09-02 02:14:21 -06:00
|
|
|
if (current->replacement_session_keyring)
|
|
|
|
key_replace_session_keyring();
|
2009-09-02 02:14:16 -06:00
|
|
|
}
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
2009-11-24 12:35:41 -07:00
|
|
|
|
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
static int smp_save_fp_context(struct sigcontext __user *sc)
|
|
|
|
{
|
|
|
|
return raw_cpu_has_fpu
|
|
|
|
? _save_fp_context(sc)
|
|
|
|
: fpu_emulator_save_context(sc);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int smp_restore_fp_context(struct sigcontext __user *sc)
|
|
|
|
{
|
|
|
|
return raw_cpu_has_fpu
|
|
|
|
? _restore_fp_context(sc)
|
|
|
|
: fpu_emulator_restore_context(sc);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static int signal_setup(void)
|
|
|
|
{
|
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
/* For now just do the cpu_has_fpu check when the functions are invoked */
|
|
|
|
save_fp_context = smp_save_fp_context;
|
|
|
|
restore_fp_context = smp_restore_fp_context;
|
|
|
|
#else
|
|
|
|
if (cpu_has_fpu) {
|
|
|
|
save_fp_context = _save_fp_context;
|
|
|
|
restore_fp_context = _restore_fp_context;
|
|
|
|
} else {
|
|
|
|
save_fp_context = fpu_emulator_save_context;
|
|
|
|
restore_fp_context = fpu_emulator_restore_context;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
arch_initcall(signal_setup);
|