Skip to contentSkip to conversation

Avoid race w/ posix-cpu-timer and exiting tasks

RFC PATCH New john stultz 1 participant 1 message Jun 13, 2006

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 Avoid race w/ posix-cpu-timer and exiting tasks

Hey Ingo,
We've occasionally come across OOPSes in posix-cpu-timer thread (as
well as tripping over the BUG_ON(tsk->exit_state there) where it appears the task we're processing exits out on us while we're using it.

Thus this fix tries to avoid running the posix-cpu-timers on a task that is exiting.

I'm not sure if it is the proper fix, so I wanted some extra eyes to look it over. We're testing it to see if we can still trigger any of the OOPSes (the BUG_ON is removed, so that won't catch us anymore), but if you have any thoughts I'd be interested in them.

thanks
-john

kernel/posix-cpu-timers.c +5 -2
@@ -1290,12 +1290,15 @@
 
 #undef	UNEXPIRED
 
-	BUG_ON(tsk->exit_state);
-
 	/*
 	 * Double-check with locks held.
 	 */
 	read_lock(&tasklist_lock);
+	/* Make sure the task doesn't exit under us. */
+	if(unlikely(tsk->exit_state)) {
+		read_unlock(&tasklist_lock);
+		return;
+	}
 	spin_lock(&tsk->sighand->siglock);
 
 	/*