Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

itimers: Fix racy writes to cpu_itimer fields

incr_error and error fields of struct cpu_itimer are used when calculating
next timer tick in check_cpu_itimers() and should not be modified without
tsk->sighand->siglock taken.

Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
LKML-Reference: <1253802903-979-1-git-send-email-sgruszka@redhat.com> 
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
  • Loading branch information...
commit 8747d793fc5c4d3e4decd41d55f6dc24498dd5f5 1 parent 0696b71
Stanislaw Gruszka authored November 17, 2009 Thomas Gleixner committed November 18, 2009

Showing 1 changed file with 5 additions and 2 deletions. Show diff stats Hide diff stats

  1. 7  kernel/itimer.c
7  kernel/itimer.c
@@ -146,6 +146,7 @@ static void set_cpu_itimer(struct task_struct *tsk, unsigned int clock_id,
146 146
 {
147 147
 	cputime_t cval, nval, cinterval, ninterval;
148 148
 	s64 ns_ninterval, ns_nval;
  149
+	u32 error, incr_error;
149 150
 	struct cpu_itimer *it = &tsk->signal->it[clock_id];
150 151
 
151 152
 	nval = timeval_to_cputime(&value->it_value);
@@ -153,8 +154,8 @@ static void set_cpu_itimer(struct task_struct *tsk, unsigned int clock_id,
153 154
 	ninterval = timeval_to_cputime(&value->it_interval);
154 155
 	ns_ninterval = timeval_to_ns(&value->it_interval);
155 156
 
156  
-	it->incr_error = cputime_sub_ns(ninterval, ns_ninterval);
157  
-	it->error = cputime_sub_ns(nval, ns_nval);
  157
+	error = cputime_sub_ns(nval, ns_nval);
  158
+	incr_error = cputime_sub_ns(ninterval, ns_ninterval);
158 159
 
159 160
 	spin_lock_irq(&tsk->sighand->siglock);
160 161
 
@@ -168,6 +169,8 @@ static void set_cpu_itimer(struct task_struct *tsk, unsigned int clock_id,
168 169
 	}
169 170
 	it->expires = nval;
170 171
 	it->incr = ninterval;
  172
+	it->error = error;
  173
+	it->incr_error = incr_error;
171 174
 	trace_itimer_state(clock_id == CPUCLOCK_VIRT ?
172 175
 			   ITIMER_VIRTUAL : ITIMER_PROF, value, nval);
173 176
 

0 notes on commit 8747d79

Please sign in to comment.
Something went wrong with that request. Please try again.