The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@tv-sign.ru>
To: Roland McGrath <roland@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Austin Clements <amdragon+kernelbugzilla@mit.edu>,
	Ingo Molnar <mingo@elte.hu>, john stultz <johnstul@us.ibm.com>,
	Michael Kerrisk <mtk.manpages@googlemail.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] signals: sigqueue_free: don't free sigqueue if it is queued
Date: Thu, 22 May 2008 15:12:11 +0400	[thread overview]
Message-ID: <20080522111211.GA117@tv-sign.ru> (raw)
In-Reply-To: <20080521230135.BF65A26FA24@magilla.localdomain>

On 05/21, Roland McGrath wrote:
>
> -void flush_sigqueue(struct sigpending *queue)
> +static void __flush_sigqueue(struct sigpending *queue, int timers)
>  {
>  	struct sigqueue *q;
>  
>  	sigemptyset(&queue->signal);
>  	while (!list_empty(&queue->list)) {
>  		q = list_entry(queue->list.next, struct sigqueue , list);
> +		if (timers && q->info.si_code != SI_TIMER)
> +			continue;
>  		list_del_init(&q->list);
>  		__sigqueue_free(q);
>  	}
>  }

This is not enough. Again, we remove and free sigqueue but don't discard
the pending signal. (and we must take into account other rt signals with
the same si_signo if we want to discard the signal).

Oh, this problem is unexpectedly nasty. It is trivial and minor, we can
solve it in may ways, but personally I can't find a simple/clean way.

Let's look at my first attempt,

	http://marc.info/?l=linux-kernel&m=120888210417700

the patch was "almost" correct.
We can add the "bool cancel" parameter to sigqueue_free(), true when
called from exec (or exit_itimers). In that case SIGQUEUE_SHARED_PENDING
is enough: the pending signal was either sent to current, or it is group
wide. Not nice too of course, but afaics a bit simpler. Actually, the
patch exists: http://marc.info/?l=linux-kernel&m=120888210417698

What do you think?

(instead of SIGQUEUE_SHARED_PENDING, we can encode "struct sigpending *"
 in q->flags, but this is really awful and I agree with Linus on the
 EINTR/etc issues).

I'll try to think more on Weekend.

Oleg.


  reply	other threads:[~2008-05-22 12:13 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080522111211.GA117@tv-sign.ru \
    --to=oleg@tv-sign.ru \
    --cc=akpm@linux-foundation.org \
    --cc=amdragon+kernelbugzilla@mit.edu \
    --cc=johnstul@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=mtk.manpages@googlemail.com \
    --cc=roland@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox