Mark Schulte firstname.lastname@example.org [nuttx]
2018-01-29 20:50:34 UTC
Signal handlers maybe run with interrupts enabled or disabled,
depending on how the task the received the signal was blocked. (i.e.:
If sem_wait() is called, then we disable interrupts, then block the
currently running task). I've noticed this on armv7-m, although I
believe it also is true on armv7-a, armv6-m, and potentially other
platforms. I think this could be dangerous, because we're running user
code with interrupts disabled. I think this is especially true if a
page fault may occur in the signal handler (although I'm not too
familiar with the armv7-a architecture, so I think this is okay.)
My proposed solution is to force enable interrupts in up_sigdeliver(),
calling up_irq_enable() instead of
leave_critical_section(regs[REG_PRIMASK]). I believe this is safe
because, when we return to normal execution, interrupts will be
restored to their previous state when the signal handler returns.
However, I'm not too familiar with the synchronization primatives in
NuttX, and want to make sure that I'm not violating some critical
section by doing so. Any thoughts on this?
I'm happy to provide the patch if this seems like a good solution.
Just want to make sure it makes sense.