]> rtime.felk.cvut.cz Git - zynq/linux.git/commit
signal/x86: Delay calling signals in atomic
authorOleg Nesterov <oleg@redhat.com>
Sun, 13 Sep 2015 07:47:03 +0000 (09:47 +0200)
committerMichal Sojka <sojka@merica.cz>
Sun, 13 Sep 2015 07:47:03 +0000 (09:47 +0200)
commit6f81f36c5bd3a0f6bf96e19a0a9582d1a16338bd
tree924c7f46b5801c737ca024b44ceb3e291a3764ed
parent83e70a14203f79fd1239ee303d2ab59956b0d03d
signal/x86: Delay calling signals in atomic

On x86_64 we must disable preemption before we enable interrupts
for stack faults, int3 and debugging, because the current task is using
a per CPU debug stack defined by the IST. If we schedule out, another task
can come in and use the same stack and cause the stack to be corrupted
and crash the kernel on return.

When CONFIG_PREEMPT_RT_FULL is enabled, spin_locks become mutexes, and
one of these is the spin lock used in signal handling.

Some of the debug code (int3) causes do_trap() to send a signal.
This function calls a spin lock that has been converted to a mutex
and has the possibility to sleep. If this happens, the above issues with
the corrupted stack is possible.

Instead of calling the signal right away, for PREEMPT_RT and x86_64,
the signal information is stored on the stacks task_struct and
TIF_NOTIFY_RESUME is set. Then on exit of the trap, the signal resume
code will send the signal when preemption is enabled.

[ rostedt: Switched from #ifdef CONFIG_PREEMPT_RT_FULL to
  ARCH_RT_DELAYS_SIGNAL_SEND and added comments to the code. ]

Cc: stable-rt@vger.kernel.org
Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
arch/x86/include/asm/signal.h
arch/x86/kernel/signal.c
include/linux/sched.h
kernel/signal.c