Commit b6d09449 authored by Martin Schwidefsky's avatar Martin Schwidefsky Committed by Linus Torvalds

[PATCH] s390: pfault interrupt race

There is a race in pfault_interrupt.  That function gets called two times for
each pfault notification.  Once with a subcode of 0 to indicate that a real
page is not available and once with a subcode of 0x80 to indicate that the
page is present again.

Since the two external interrupts can be delivered on two different cpus the
order in which the two calls are made is unpredictable.  It is possible that
the subcode 0x80 interrupt is completed before the subcode 0x00 interrupt has
done the wake_up() call.

To avoid calling wake_up() on an already removed task structure proper task
structure reference counting is needed.  Increase the reference counter in the
subcode 0x00 interrupt before setting pfault_wait to zero and return the
reference after the wake_up call.
Signed-off-by: default avatarMartin Schwidefsky <schwidefsky@de.ibm.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 4c24da79
...@@ -563,12 +563,14 @@ pfault_interrupt(struct pt_regs *regs, __u16 error_code) ...@@ -563,12 +563,14 @@ pfault_interrupt(struct pt_regs *regs, __u16 error_code)
* interrupt. pfault_wait is valid. Set pfault_wait * interrupt. pfault_wait is valid. Set pfault_wait
* back to zero and wake up the process. This can * back to zero and wake up the process. This can
* safely be done because the task is still sleeping * safely be done because the task is still sleeping
* and can't procude new pfaults. */ * and can't produce new pfaults. */
tsk->thread.pfault_wait = 0; tsk->thread.pfault_wait = 0;
wake_up_process(tsk); wake_up_process(tsk);
put_task_struct(tsk);
} }
} else { } else {
/* signal bit not set -> a real page is missing. */ /* signal bit not set -> a real page is missing. */
get_task_struct(tsk);
set_task_state(tsk, TASK_UNINTERRUPTIBLE); set_task_state(tsk, TASK_UNINTERRUPTIBLE);
if (xchg(&tsk->thread.pfault_wait, 1) != 0) { if (xchg(&tsk->thread.pfault_wait, 1) != 0) {
/* Completion interrupt was faster than the initial /* Completion interrupt was faster than the initial
...@@ -578,6 +580,7 @@ pfault_interrupt(struct pt_regs *regs, __u16 error_code) ...@@ -578,6 +580,7 @@ pfault_interrupt(struct pt_regs *regs, __u16 error_code)
* mode and can't produce new pfaults. */ * mode and can't produce new pfaults. */
tsk->thread.pfault_wait = 0; tsk->thread.pfault_wait = 0;
set_task_state(tsk, TASK_RUNNING); set_task_state(tsk, TASK_RUNNING);
put_task_struct(tsk);
} else } else
set_tsk_need_resched(tsk); set_tsk_need_resched(tsk);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment