avr32: handle_signal() bug?

From: Matt Fleming
Date: Wed Aug 03 2011 - 05:04:56 EST


Hey guys,

I was just looking at the code in handle_signal() and I got pretty
confused, specifically about this part...

/*
* Set up the stack frame
*/
ret = setup_rt_frame(sig, ka, info, oldset, regs);

/*
* Check that the resulting registers are sane
*/
ret |= !valid_user_regs(regs);

/*
* Block the signal if we were unsuccessful.
*/
if (ret != 0 || !(ka->sa.sa_flags & SA_NODEFER)) {
spin_lock_irq(&current->sighand->siglock);
sigorsets(&current->blocked, &current->blocked,
&ka->sa.sa_mask);
sigaddset(&current->blocked, sig);
recalc_sigpending();
spin_unlock_irq(&current->sighand->siglock);
}

if (ret == 0)
return;

That doesn't look correct to me. Now, if we were unsuccessful in setting
up a signal frame, say, ret == -EFAULT, do we really want to block the
signal or any of the signals in the handler mask?

Is there some intricacy of the avr32 architecture that I'm missing here?
It looks to me like this code was copied from the arm implementation
from years ago before commit a6c61e9dfdd0 ("[ARM] 3168/1: Update ARM
signal delivery and masking").

How about this?

-------------8<-----------