The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH 1/3] signals: sigqueue_free: don't free sigqueue if it is queued
@ 2008-05-17 15:14 Oleg Nesterov
  2008-05-21  2:20 ` Roland McGrath
  0 siblings, 1 reply; 13+ messages in thread
From: Oleg Nesterov @ 2008-05-17 15:14 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Austin Clements, Ingo Molnar, john stultz, Linus Torvalds,
	Michael Kerrisk, Roland McGrath, Thomas Gleixner, linux-kernel

Currently sigqueue_free() removes sigqueue from list, but doesn't cancel the
pending signal. This is not consistent, the task should either receive the
"full" signal along with siginfo_t, or it shouldn't receive the signal at all.

Change sigqueue_free() to clear SIGQUEUE_PREALLOC but leave sigqueue on list
if it is queued.

This patch doesn't change the behaviour of sys_timer_delete() and friends,
just makes it more correct and allows us to introduce other SIGQUEUE_ flags
passed to the receiver.

Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>

--- 25/kernel/signal.c~4_SF_DONT_REMOVE	2008-05-17 16:22:07.000000000 +0400
+++ 25/kernel/signal.c	2008-05-17 17:14:04.000000000 +0400
@@ -1240,18 +1240,22 @@ void sigqueue_free(struct sigqueue *q)
 
 	BUG_ON(!(q->flags & SIGQUEUE_PREALLOC));
 	/*
-	 * If the signal is still pending remove it from the
-	 * pending queue. We must hold ->siglock while testing
-	 * q->list to serialize with collect_signal() or with
+	 * We must hold ->siglock while testing q->list
+	 * to serialize with collect_signal() or with
 	 * __exit_signal()->flush_sigqueue().
 	 */
 	spin_lock_irqsave(lock, flags);
+	q->flags &= ~SIGQUEUE_PREALLOC;
+	/*
+	 * If it is queued it will be freed when dequeued,
+	 * like the "regular" sigqueue.
+	 */
 	if (!list_empty(&q->list))
-		list_del_init(&q->list);
+		q = NULL;
 	spin_unlock_irqrestore(lock, flags);
 
-	q->flags &= ~SIGQUEUE_PREALLOC;
-	__sigqueue_free(q);
+	if (q)
+		__sigqueue_free(q);
 }
 
 int send_sigqueue(struct sigqueue *q, struct task_struct *t, int group)


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2008-05-23  1:42 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-17 15:14 [PATCH 1/3] signals: sigqueue_free: don't free sigqueue if it is queued Oleg Nesterov
2008-05-21  2:20 ` Roland McGrath
2008-05-21 11:54   ` Oleg Nesterov
2008-05-21 18:42     ` Roland McGrath
2008-05-21 18:49       ` Linus Torvalds
2008-05-21 19:33         ` Roland McGrath
2008-05-21 20:07           ` Linus Torvalds
2008-05-21 23:01             ` Roland McGrath
2008-05-22 11:12               ` Oleg Nesterov
2008-05-22 11:55                 ` Oleg Nesterov
2008-05-22 21:50                 ` Roland McGrath
2008-05-22 21:18                   ` Oleg Nesterov
2008-05-23  1:41                     ` Roland McGrath

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox