login
Header Space

 
 

[PATCH 3/4] posix timers: timer_delete: remove the bogus "->it_process != NULL" check

Previous thread: [PATCH 0/4] posix timers: misc fixes by Oleg Nesterov on Saturday, May 3, 2008 - 1:35 pm. (1 message)

Next thread: s390 kvm_virtio.c build error by Adrian Bunk on Saturday, May 3, 2008 - 1:47 pm. (8 messages)
To: Andrew Morton <akpm@...>
Cc: Austin Clements <amdragon+kernelbugzilla@...>, Ingo Molnar <mingo@...>, john stultz <johnstul@...>, Linus Torvalds <torvalds@...>, Michael Kerrisk <mtk.manpages@...>, Roland McGrath <roland@...>, Thomas Gleixner <tglx@...>, <linux-kernel@...>
Date: Saturday, May 3, 2008 - 1:35 pm

sys_timer_delete() and itimer_delete() check "timer-&gt;it_process != NULL", this
looks completely bogus. -&gt;it_process == NULL means that this timer is already
under destruction or it is not fully initialized, this must not happen.

	sys_timer_delete: the timer is locked, and lock_timer() can't succeed
	if -&gt;it_process == NULL.

	itimer_delete: it is called by exit_itimers() when there are no other
	threads which can play with signal_struct-&gt;posix_timers.

Signed-off-by: Oleg Nesterov &lt;oleg@tv-sign.ru&gt;

--- 25/kernel/posix-timers.c~3_TDEL_NO_CHECK	2008-04-24 16:52:11.000000000 +0400
+++ 25/kernel/posix-timers.c	2008-05-03 19:55:27.000000000 +0400
@@ -855,11 +855,10 @@ retry_delete:
 	 * This keeps any tasks waiting on the spin lock from thinking
 	 * they got something (see the lock code above).
 	 */
-	if (timer-&gt;it_process) {
-		if (timer-&gt;it_sigev_notify == (SIGEV_SIGNAL|SIGEV_THREAD_ID))
-			put_task_struct(timer-&gt;it_process);
-		timer-&gt;it_process = NULL;
-	}
+	if (timer-&gt;it_sigev_notify == (SIGEV_SIGNAL|SIGEV_THREAD_ID))
+		put_task_struct(timer-&gt;it_process);
+	timer-&gt;it_process = NULL;
+
 	unlock_timer(timer, flags);
 	release_posix_timer(timer, IT_ID_SET);
 	return 0;
@@ -884,11 +883,10 @@ retry_delete:
 	 * This keeps any tasks waiting on the spin lock from thinking
 	 * they got something (see the lock code above).
 	 */
-	if (timer-&gt;it_process) {
-		if (timer-&gt;it_sigev_notify == (SIGEV_SIGNAL|SIGEV_THREAD_ID))
-			put_task_struct(timer-&gt;it_process);
-		timer-&gt;it_process = NULL;
-	}
+	if (timer-&gt;it_sigev_notify == (SIGEV_SIGNAL|SIGEV_THREAD_ID))
+		put_task_struct(timer-&gt;it_process);
+	timer-&gt;it_process = NULL;
+
 	unlock_timer(timer, flags);
 	release_posix_timer(timer, IT_ID_SET);
 }

--
To: Oleg Nesterov <oleg@...>
Cc: Andrew Morton <akpm@...>, Austin Clements <amdragon+kernelbugzilla@...>, Ingo Molnar <mingo@...>, john stultz <johnstul@...>, Linus Torvalds <torvalds@...>, Michael Kerrisk <mtk.manpages@...>, Thomas Gleixner <tglx@...>, <linux-kernel@...>
Date: Monday, May 5, 2008 - 10:33 pm

Signed-off-by: Roland McGrath &lt;roland@redhat.com&gt;
--
Previous thread: [PATCH 0/4] posix timers: misc fixes by Oleg Nesterov on Saturday, May 3, 2008 - 1:35 pm. (1 message)

Next thread: s390 kvm_virtio.c build error by Adrian Bunk on Saturday, May 3, 2008 - 1:47 pm. (8 messages)
speck-geostationary