Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 356663
b: refs/heads/master
c: 207bdae
h: refs/heads/master
i:
  356661: d8a0c16
  356659: 0efda6c
  356655: d2b320c
v: v3
  • Loading branch information
Al Viro committed Feb 14, 2013
1 parent 7c2672f commit e948991
Show file tree
Hide file tree
Showing 14 changed files with 70 additions and 87 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 50bcb7e4734df09ee5e479a45992b85118bd1834
refs/heads/master: 207bdae452e6d3eeba19cc3912e5dfb088adc376
3 changes: 0 additions & 3 deletions trunk/arch/arm/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,6 @@ config ARM
select HAVE_MOD_ARCH_SPECIFIC if ARM_UNWIND
select MODULES_USE_ELF_REL
select CLONE_BACKWARDS
select GENERIC_SIGALTSTACK
select OLD_SIGSUSPEND3
select OLD_SIGACTION
help
The ARM series is a line of low-power-consumption RISC chip designs
licensed by ARM Ltd and targeted at embedded applications and
Expand Down
7 changes: 7 additions & 0 deletions trunk/arch/arm/include/asm/signal.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ typedef struct {
unsigned long sig[_NSIG_WORDS];
} sigset_t;

struct old_sigaction {
__sighandler_t sa_handler;
old_sigset_t sa_mask;
unsigned long sa_flags;
__sigrestore_t sa_restorer;
};

#define __ARCH_HAS_SA_RESTORER

#include <asm/sigcontext.h>
Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/arm/kernel/calls.S
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@
CALL(sys_getcwd)
CALL(sys_capget)
/* 185 */ CALL(sys_capset)
CALL(sys_sigaltstack)
CALL(sys_sigaltstack_wrapper)
CALL(sys_sendfile)
CALL(sys_ni_syscall) /* getpmsg */
CALL(sys_ni_syscall) /* putpmsg */
Expand Down
5 changes: 5 additions & 0 deletions trunk/arch/arm/kernel/entry-common.S
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,11 @@ sys_rt_sigreturn_wrapper:
b sys_rt_sigreturn
ENDPROC(sys_rt_sigreturn_wrapper)

sys_sigaltstack_wrapper:
ldr r2, [sp, #S_OFF + S_SP]
b do_sigaltstack
ENDPROC(sys_sigaltstack_wrapper)

sys_statfs64_wrapper:
teq r1, #88
moveq r1, #84
Expand Down
52 changes: 50 additions & 2 deletions trunk/arch/arm/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,48 @@ const unsigned long sigreturn_codes[7] = {
MOV_R7_NR_RT_SIGRETURN, SWI_SYS_RT_SIGRETURN, SWI_THUMB_RT_SIGRETURN,
};

/*
* atomically swap in the new signal mask, and wait for a signal.
*/
asmlinkage int sys_sigsuspend(int restart, unsigned long oldmask, old_sigset_t mask)
{
sigset_t blocked;
siginitset(&blocked, mask);
return sigsuspend(&blocked);
}

asmlinkage int
sys_sigaction(int sig, const struct old_sigaction __user *act,
struct old_sigaction __user *oact)
{
struct k_sigaction new_ka, old_ka;
int ret;

if (act) {
old_sigset_t mask;
if (!access_ok(VERIFY_READ, act, sizeof(*act)) ||
__get_user(new_ka.sa.sa_handler, &act->sa_handler) ||
__get_user(new_ka.sa.sa_restorer, &act->sa_restorer) ||
__get_user(new_ka.sa.sa_flags, &act->sa_flags) ||
__get_user(mask, &act->sa_mask))
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)) ||
__put_user(old_ka.sa.sa_handler, &oact->sa_handler) ||
__put_user(old_ka.sa.sa_restorer, &oact->sa_restorer) ||
__put_user(old_ka.sa.sa_flags, &oact->sa_flags) ||
__put_user(old_ka.sa.sa_mask.sig[0], &oact->sa_mask))
return -EFAULT;
}

return ret;
}

#ifdef CONFIG_CRUNCH
static int preserve_crunch_context(struct crunch_sigframe __user *frame)
{
Expand Down Expand Up @@ -258,7 +300,7 @@ asmlinkage int sys_rt_sigreturn(struct pt_regs *regs)
if (restore_sigframe(regs, &frame->sig))
goto badframe;

if (restore_altstack(&frame->sig.uc.uc_stack))
if (do_sigaltstack(&frame->sig.uc.uc_stack, NULL, regs->ARM_sp) == -EFAULT)
goto badframe;

return regs->ARM_r0;
Expand Down Expand Up @@ -444,6 +486,7 @@ setup_rt_frame(int usig, struct k_sigaction *ka, siginfo_t *info,
sigset_t *set, struct pt_regs *regs)
{
struct rt_sigframe __user *frame = get_sigframe(ka, regs, sizeof(*frame));
stack_t stack;
int err = 0;

if (!frame)
Expand All @@ -454,7 +497,12 @@ setup_rt_frame(int usig, struct k_sigaction *ka, siginfo_t *info,
__put_user_error(0, &frame->sig.uc.uc_flags, err);
__put_user_error(NULL, &frame->sig.uc.uc_link, err);

err |= __save_altstack(&frame->sig.uc.uc_stack, regs->ARM_sp);
memset(&stack, 0, sizeof(stack));
stack.ss_sp = (void __user *)current->sas_ss_sp;
stack.ss_flags = sas_ss_flags(regs->ARM_sp);
stack.ss_size = current->sas_ss_size;
err |= __copy_to_user(&frame->sig.uc.uc_stack, &stack, sizeof(stack));

err |= setup_sigframe(&frame->sig, regs, set);
if (err == 0)
err = setup_return(regs, ka, frame->sig.retcode, frame, usig);
Expand Down
1 change: 1 addition & 0 deletions trunk/arch/arm64/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ config ARM64
select GENERIC_IOMAP
select GENERIC_IRQ_PROBE
select GENERIC_IRQ_SHOW
select GENERIC_SIGALTSTACK
select GENERIC_SMP_IDLE_THREAD
select GENERIC_TIME_VSYSCALL
select HARDIRQS_SW_RESEND
Expand Down
2 changes: 0 additions & 2 deletions trunk/arch/arm64/include/asm/syscalls.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
* System call wrappers implemented in kernel/entry.S.
*/
asmlinkage long sys_rt_sigreturn_wrapper(void);
asmlinkage long sys_sigaltstack_wrapper(const stack_t __user *uss,
stack_t __user *uoss);

#include <asm-generic/syscalls.h>

Expand Down
2 changes: 1 addition & 1 deletion trunk/arch/arm64/include/asm/unistd32.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ __SYSCALL(182, sys_chown16)
__SYSCALL(183, sys_getcwd)
__SYSCALL(184, sys_capget)
__SYSCALL(185, sys_capset)
__SYSCALL(186, compat_sys_sigaltstack_wrapper)
__SYSCALL(186, compat_sys_sigaltstack)
__SYSCALL(187, compat_sys_sendfile)
__SYSCALL(188, sys_ni_syscall) /* 188 reserved */
__SYSCALL(189, sys_ni_syscall) /* 189 reserved */
Expand Down
5 changes: 0 additions & 5 deletions trunk/arch/arm64/kernel/entry.S
Original file line number Diff line number Diff line change
Expand Up @@ -677,10 +677,5 @@ ENTRY(sys_rt_sigreturn_wrapper)
b sys_rt_sigreturn
ENDPROC(sys_rt_sigreturn_wrapper)

ENTRY(sys_sigaltstack_wrapper)
ldr x2, [sp, #S_SP]
b sys_sigaltstack
ENDPROC(sys_sigaltstack_wrapper)

ENTRY(handle_arch_irq)
.quad 0
17 changes: 2 additions & 15 deletions trunk/arch/arm64/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,7 @@ asmlinkage long sys_rt_sigreturn(struct pt_regs *regs)
if (restore_sigframe(regs, frame))
goto badframe;

if (do_sigaltstack(&frame->uc.uc_stack,
NULL, regs->sp) == -EFAULT)
if (restore_altstack(&frame->uc.uc_stack))
goto badframe;

return regs->regs[0];
Expand All @@ -164,12 +163,6 @@ asmlinkage long sys_rt_sigreturn(struct pt_regs *regs)
return 0;
}

asmlinkage long sys_sigaltstack(const stack_t __user *uss, stack_t __user *uoss,
unsigned long sp)
{
return do_sigaltstack(uss, uoss, sp);
}

static int setup_sigframe(struct rt_sigframe __user *sf,
struct pt_regs *regs, sigset_t *set)
{
Expand Down Expand Up @@ -250,7 +243,6 @@ static int setup_rt_frame(int usig, struct k_sigaction *ka, siginfo_t *info,
sigset_t *set, struct pt_regs *regs)
{
struct rt_sigframe __user *frame;
stack_t stack;
int err = 0;

frame = get_sigframe(ka, regs);
Expand All @@ -260,12 +252,7 @@ static int setup_rt_frame(int usig, struct k_sigaction *ka, siginfo_t *info,
__put_user_error(0, &frame->uc.uc_flags, err);
__put_user_error(NULL, &frame->uc.uc_link, err);

memset(&stack, 0, sizeof(stack));
stack.ss_sp = (void __user *)current->sas_ss_sp;
stack.ss_flags = sas_ss_flags(regs->sp);
stack.ss_size = current->sas_ss_size;
err |= __copy_to_user(&frame->uc.uc_stack, &stack, sizeof(stack));

err |= __save_altstack(&frame->uc.uc_stack, regs->sp);
err |= setup_sigframe(frame, regs, set);
if (err == 0) {
setup_return(regs, ka, frame, usig);
Expand Down
53 changes: 2 additions & 51 deletions trunk/arch/arm64/kernel/signal32.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,6 @@ struct compat_old_sigaction {
compat_uptr_t sa_restorer;
};

typedef struct compat_sigaltstack {
compat_uptr_t ss_sp;
int ss_flags;
compat_size_t ss_size;
} compat_stack_t;

struct compat_sigcontext {
/* We always set these two fields to 0 */
compat_ulong_t trap_no;
Expand Down Expand Up @@ -423,43 +417,6 @@ asmlinkage int compat_sys_rt_sigaction(int sig,
return ret;
}

int compat_do_sigaltstack(compat_uptr_t compat_uss, compat_uptr_t compat_uoss,
compat_ulong_t sp)
{
compat_stack_t __user *newstack = compat_ptr(compat_uss);
compat_stack_t __user *oldstack = compat_ptr(compat_uoss);
compat_uptr_t ss_sp;
int ret;
mm_segment_t old_fs;
stack_t uss, uoss;

/* Marshall the compat new stack into a stack_t */
if (newstack) {
if (get_user(ss_sp, &newstack->ss_sp) ||
__get_user(uss.ss_flags, &newstack->ss_flags) ||
__get_user(uss.ss_size, &newstack->ss_size))
return -EFAULT;
uss.ss_sp = compat_ptr(ss_sp);
}

old_fs = get_fs();
set_fs(KERNEL_DS);
/* The __user pointer casts are valid because of the set_fs() */
ret = do_sigaltstack(
newstack ? (stack_t __user *) &uss : NULL,
oldstack ? (stack_t __user *) &uoss : NULL,
(unsigned long)sp);
set_fs(old_fs);

/* Convert the old stack_t into a compat stack. */
if (!ret && oldstack &&
(put_user(ptr_to_compat(uoss.ss_sp), &oldstack->ss_sp) ||
__put_user(uoss.ss_flags, &oldstack->ss_flags) ||
__put_user(uoss.ss_size, &oldstack->ss_size)))
return -EFAULT;
return ret;
}

static int compat_restore_sigframe(struct pt_regs *regs,
struct compat_sigframe __user *sf)
{
Expand Down Expand Up @@ -562,9 +519,7 @@ asmlinkage int compat_sys_rt_sigreturn(struct pt_regs *regs)
if (compat_restore_sigframe(regs, &frame->sig))
goto badframe;

if (compat_do_sigaltstack(ptr_to_compat(&frame->sig.uc.uc_stack),
ptr_to_compat((void __user *)NULL),
regs->compat_sp) == -EFAULT)
if (compat_restore_altstack(&frame->sig.uc.uc_stack))
goto badframe;

return regs->regs[0];
Expand Down Expand Up @@ -705,11 +660,7 @@ int compat_setup_rt_frame(int usig, struct k_sigaction *ka, siginfo_t *info,
__put_user_error(0, &frame->sig.uc.uc_flags, err);
__put_user_error(NULL, &frame->sig.uc.uc_link, err);

memset(&stack, 0, sizeof(stack));
stack.ss_sp = (compat_uptr_t)current->sas_ss_sp;
stack.ss_flags = sas_ss_flags(regs->compat_sp);
stack.ss_size = current->sas_ss_size;
err |= __copy_to_user(&frame->sig.uc.uc_stack, &stack, sizeof(stack));
err |= __compat_save_altstack(&frame->sig.uc.uc_stack, regs->compat_sp);

err |= compat_setup_sigframe(&frame->sig, regs, set);

Expand Down
1 change: 0 additions & 1 deletion trunk/arch/arm64/kernel/sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ asmlinkage long sys_mmap(unsigned long addr, unsigned long len,
* Wrappers to pass the pt_regs argument.
*/
#define sys_rt_sigreturn sys_rt_sigreturn_wrapper
#define sys_sigaltstack sys_sigaltstack_wrapper

#include <asm/syscalls.h>

Expand Down
5 changes: 0 additions & 5 deletions trunk/arch/arm64/kernel/sys32.S
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@ compat_sys_rt_sigreturn_wrapper:
b compat_sys_rt_sigreturn
ENDPROC(compat_sys_rt_sigreturn_wrapper)

compat_sys_sigaltstack_wrapper:
ldr x2, [sp, #S_COMPAT_SP]
b compat_do_sigaltstack
ENDPROC(compat_sys_sigaltstack_wrapper)

compat_sys_statfs64_wrapper:
mov w3, #84
cmp w1, #88
Expand Down

0 comments on commit e948991

Please sign in to comment.