Skip to content

Commit bc1978d

Browse files
KAGA-KOKOLinus Torvalds
authored andcommitted
[PATCH] hrtimers: fixup itimer conversion
The itimer conversion removed the locking which protects the timer and variables in the shared signal structure. Steven Rostedt found the problem in the latest -rt patches. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
1 parent 853609b commit bc1978d

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

‎kernel/itimer.c‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,11 @@ int do_getitimer(int which, struct itimerval *value)
4949

5050
switch (which) {
5151
case ITIMER_REAL:
52+
spin_lock_irq(&tsk->sighand->siglock);
5253
value->it_value = itimer_get_remtime(&tsk->signal->real_timer);
5354
value->it_interval =
5455
ktime_to_timeval(tsk->signal->it_real_incr);
56+
spin_unlock_irq(&tsk->sighand->siglock);
5557
break;
5658
case ITIMER_VIRTUAL:
5759
read_lock(&tasklist_lock);
@@ -150,8 +152,14 @@ int do_setitimer(int which, struct itimerval *value, struct itimerval *ovalue)
150152

151153
switch (which) {
152154
case ITIMER_REAL:
155+
again:
156+
spin_lock_irq(&tsk->sighand->siglock);
153157
timer = &tsk->signal->real_timer;
154-
hrtimer_cancel(timer);
158+
/* We are sharing ->siglock with it_real_fn() */
159+
if (hrtimer_try_to_cancel(timer) < 0) {
160+
spin_unlock_irq(&tsk->sighand->siglock);
161+
goto again;
162+
}
155163
if (ovalue) {
156164
ovalue->it_value = itimer_get_remtime(timer);
157165
ovalue->it_interval
@@ -162,6 +170,7 @@ int do_setitimer(int which, struct itimerval *value, struct itimerval *ovalue)
162170
expires = timeval_to_ktime(value->it_value);
163171
if (expires.tv64 != 0)
164172
hrtimer_start(timer, expires, HRTIMER_REL);
173+
spin_unlock_irq(&tsk->sighand->siglock);
165174
break;
166175
case ITIMER_VIRTUAL:
167176
nval = timeval_to_cputime(&value->it_value);

0 commit comments

Comments
 (0)