Skip to content

Commit

Permalink
arm64: Use get_signal() signal_setup_done()
Browse files Browse the repository at this point in the history
Use the more generic functions get_signal() signal_setup_done()
for signal delivery.

Signed-off-by: Richard Weinberger <richard@nod.at>
  • Loading branch information
Richard Weinberger authored and Richard Weinberger committed Aug 6, 2014
1 parent f6dd2a3 commit 00554fa
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 41 deletions.
11 changes: 5 additions & 6 deletions arch/arm64/include/asm/signal32.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,21 @@

extern const compat_ulong_t aarch32_sigret_code[6];

int compat_setup_frame(int usig, struct k_sigaction *ka, sigset_t *set,
int compat_setup_frame(int usig, struct ksignal *ksig, sigset_t *set,
struct pt_regs *regs);
int compat_setup_rt_frame(int usig, struct k_sigaction *ka, siginfo_t *info,
sigset_t *set, struct pt_regs *regs);
int compat_setup_rt_frame(int usig, struct ksignal *ksig, sigset_t *set,
struct pt_regs *regs);

void compat_setup_restart_syscall(struct pt_regs *regs);
#else

static inline int compat_setup_frame(int usid, struct k_sigaction *ka,
static inline int compat_setup_frame(int usid, struct ksignal *ksig,
sigset_t *set, struct pt_regs *regs)
{
return -ENOSYS;
}

static inline int compat_setup_rt_frame(int usig, struct k_sigaction *ka,
siginfo_t *info, sigset_t *set,
static inline int compat_setup_rt_frame(int usig, struct ksignal *ksig, sigset_t *set,
struct pt_regs *regs)
{
return -ENOSYS;
Expand Down
48 changes: 20 additions & 28 deletions arch/arm64/kernel/signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,13 +253,13 @@ static void setup_return(struct pt_regs *regs, struct k_sigaction *ka,
regs->regs[30] = (unsigned long)sigtramp;
}

static int setup_rt_frame(int usig, struct k_sigaction *ka, siginfo_t *info,
sigset_t *set, struct pt_regs *regs)
static int setup_rt_frame(int usig, struct ksignal *ksig, sigset_t *set,
struct pt_regs *regs)
{
struct rt_sigframe __user *frame;
int err = 0;

frame = get_sigframe(ka, regs);
frame = get_sigframe(&ksig->ka, regs);
if (!frame)
return 1;

Expand All @@ -269,9 +269,9 @@ static int setup_rt_frame(int usig, struct k_sigaction *ka, siginfo_t *info,
err |= __save_altstack(&frame->uc.uc_stack, regs->sp);
err |= setup_sigframe(frame, regs, set);
if (err == 0) {
setup_return(regs, ka, frame, usig);
if (ka->sa.sa_flags & SA_SIGINFO) {
err |= copy_siginfo_to_user(&frame->info, info);
setup_return(regs, &ksig->ka, frame, usig);
if (ksig->ka.sa.sa_flags & SA_SIGINFO) {
err |= copy_siginfo_to_user(&frame->info, &ksig->info);
regs->regs[1] = (unsigned long)&frame->info;
regs->regs[2] = (unsigned long)&frame->uc;
}
Expand All @@ -291,13 +291,12 @@ static void setup_restart_syscall(struct pt_regs *regs)
/*
* OK, we're invoking a handler
*/
static void handle_signal(unsigned long sig, struct k_sigaction *ka,
siginfo_t *info, struct pt_regs *regs)
static void handle_signal(struct ksignal *ksig, struct pt_regs *regs)
{
struct thread_info *thread = current_thread_info();
struct task_struct *tsk = current;
sigset_t *oldset = sigmask_to_save();
int usig = sig;
int usig = ksig->sig;
int ret;

/*
Expand All @@ -310,32 +309,27 @@ static void handle_signal(unsigned long sig, struct k_sigaction *ka,
* Set up the stack frame
*/
if (is_compat_task()) {
if (ka->sa.sa_flags & SA_SIGINFO)
ret = compat_setup_rt_frame(usig, ka, info, oldset,
regs);
if (ksig->ka.sa.sa_flags & SA_SIGINFO)
ret = compat_setup_rt_frame(usig, ksig, oldset, regs);
else
ret = compat_setup_frame(usig, ka, oldset, regs);
ret = compat_setup_frame(usig, ksig, oldset, regs);
} else {
ret = setup_rt_frame(usig, ka, info, oldset, regs);
ret = setup_rt_frame(usig, ksig, oldset, regs);
}

/*
* Check that the resulting registers are actually sane.
*/
ret |= !valid_user_regs(&regs->user_regs);

if (ret != 0) {
force_sigsegv(sig, tsk);
return;
}

/*
* Fast forward the stepping logic so we step into the signal
* handler.
*/
user_fastforward_single_step(tsk);
if (!ret)
user_fastforward_single_step(tsk);

signal_delivered(sig, info, ka, regs, 0);
signal_setup_done(ret, ksig, 0);
}

/*
Expand All @@ -350,10 +344,9 @@ static void handle_signal(unsigned long sig, struct k_sigaction *ka,
static void do_signal(struct pt_regs *regs)
{
unsigned long continue_addr = 0, restart_addr = 0;
struct k_sigaction ka;
siginfo_t info;
int signr, retval = 0;
int retval = 0;
int syscall = (int)regs->syscallno;
struct ksignal ksig;

/*
* If we were from a system call, check for system call restarting...
Expand Down Expand Up @@ -387,8 +380,7 @@ static void do_signal(struct pt_regs *regs)
* Get the signal to deliver. When running under ptrace, at this point
* the debugger may change all of our registers.
*/
signr = get_signal_to_deliver(&info, &ka, regs, NULL);
if (signr > 0) {
if (get_signal(&ksig)) {
/*
* Depending on the signal settings, we may need to revert the
* decision to restart the system call, but skip this if a
Expand All @@ -398,12 +390,12 @@ static void do_signal(struct pt_regs *regs)
(retval == -ERESTARTNOHAND ||
retval == -ERESTART_RESTARTBLOCK ||
(retval == -ERESTARTSYS &&
!(ka.sa.sa_flags & SA_RESTART)))) {
!(ksig.ka.sa.sa_flags & SA_RESTART)))) {
regs->regs[0] = -EINTR;
regs->pc = continue_addr;
}

handle_signal(signr, &ka, &info, regs);
handle_signal(&ksig, regs);
return;
}

Expand Down
14 changes: 7 additions & 7 deletions arch/arm64/kernel/signal32.c
Original file line number Diff line number Diff line change
Expand Up @@ -520,18 +520,18 @@ static int compat_setup_sigframe(struct compat_sigframe __user *sf,
/*
* 32-bit signal handling routines called from signal.c
*/
int compat_setup_rt_frame(int usig, struct k_sigaction *ka, siginfo_t *info,
int compat_setup_rt_frame(int usig, struct ksignal *ksig,
sigset_t *set, struct pt_regs *regs)
{
struct compat_rt_sigframe __user *frame;
int err = 0;

frame = compat_get_sigframe(ka, regs, sizeof(*frame));
frame = compat_get_sigframe(&ksig->ka, regs, sizeof(*frame));

if (!frame)
return 1;

err |= copy_siginfo_to_user32(&frame->info, info);
err |= copy_siginfo_to_user32(&frame->info, &ksig->info);

__put_user_error(0, &frame->sig.uc.uc_flags, err);
__put_user_error(0, &frame->sig.uc.uc_link, err);
Expand All @@ -541,21 +541,21 @@ int compat_setup_rt_frame(int usig, struct k_sigaction *ka, siginfo_t *info,
err |= compat_setup_sigframe(&frame->sig, regs, set);

if (err == 0) {
compat_setup_return(regs, ka, frame->sig.retcode, frame, usig);
compat_setup_return(regs, &ksig->ka, frame->sig.retcode, frame, usig);
regs->regs[1] = (compat_ulong_t)(unsigned long)&frame->info;
regs->regs[2] = (compat_ulong_t)(unsigned long)&frame->sig.uc;
}

return err;
}

int compat_setup_frame(int usig, struct k_sigaction *ka, sigset_t *set,
int compat_setup_frame(int usig, struct ksignal *ksig, sigset_t *set,
struct pt_regs *regs)
{
struct compat_sigframe __user *frame;
int err = 0;

frame = compat_get_sigframe(ka, regs, sizeof(*frame));
frame = compat_get_sigframe(&ksig->ka, regs, sizeof(*frame));

if (!frame)
return 1;
Expand All @@ -564,7 +564,7 @@ int compat_setup_frame(int usig, struct k_sigaction *ka, sigset_t *set,

err |= compat_setup_sigframe(frame, regs, set);
if (err == 0)
compat_setup_return(regs, ka, frame->retcode, frame, usig);
compat_setup_return(regs, &ksig->ka, frame->retcode, frame, usig);

return err;
}
Expand Down

0 comments on commit 00554fa

Please sign in to comment.