Re: [PATCH v2 16/29] nios2: Signal handling support

Ley Foon Tan
2014-08-08T07:21:42Z

On Fri, Jul 18, 2014 at 4:04 PM, Richard Weinberger
<richard.weinberger@gmail.com> wrote:

>> +
>> +#include <asm/ucontext.h>
>> +#include <asm/cacheflush.h>
>> +
>> +#define _BLOCKABLE (~(sigmask(SIGKILL) | sigmask(SIGSTOP)))
>> +
>> +static int do_signal(struct pt_regs *regs, int in_syscall);
>
> Do you really need this prototype?
Yes, we don't need this. Will remove this.

>> +
>> +asmlinkage int do_rt_sigreturn(struct switch_stack *sw)
>> +{
>> + struct pt_regs *regs = (struct pt_regs *)(sw + 1);
>> + /* Verify, can we follow the stack back */
>> + struct rt_sigframe *frame = (struct rt_sigframe *) regs->sp;
>> + sigset_t set;
>> + int rval;
>> +
>> + if (!access_ok(VERIFY_READ, frame, sizeof(*frame)))
>> + goto badframe;
>> +
>> + if (__copy_from_user(&set, &frame->uc.uc_sigmask, sizeof(set)))
>> + goto badframe;
>> +
>> + sigdelsetmask(&set, ~_BLOCKABLE);
>> + spin_lock_irq(&current->sighand->siglock);
>> + current->blocked = set;
>> + recalc_sigpending();
>> + spin_unlock_irq(&current->sighand->siglock);
>
> Why aren't you using set_current_blocked() here?
Okay, will change to use set_current_blocked().

>> +static int setup_rt_frame(struct ksignal *ksig, sigset_t *set,
>> + struct pt_regs *regs)
>> +{
>> + struct rt_sigframe *frame;
>> + int err = 0;
>> +
>> + frame = get_sigframe(ksig, regs, sizeof(*frame));
>> +
>> + if (ksig->ka.sa.sa_flags & SA_SIGINFO)
>> + err |= copy_siginfo_to_user(&frame->info, &ksig->info);
>> +
>> + /* Create the ucontext. */
>> + err |= __put_user(0, &frame->uc.uc_flags);
>> + err |= __put_user(0, &frame->uc.uc_link);
>> + err |= __save_altstack(&frame->uc.uc_stack, regs->sp);
>> + err |= rt_setup_ucontext(&frame->uc, regs);
>> + err |= copy_to_user(&frame->uc.uc_sigmask, set, sizeof(*set));
>
> You neither check nor propagate this error code.
Okay, will add error handling here.

Thanks.

Regards
Ley Foon