All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Feist <cfeist@redhat.com>
To: jmoyer@redhat.com, autofs@linux.kernel.org
Subject: Re: Race in expire code
Date: Mon, 31 Jan 2005 10:47:47 -0600	[thread overview]
Message-ID: <41FE6133.3070802@redhat.com> (raw)
In-Reply-To: <16894.20494.352068.720924@segfault.boston.redhat.com>

Jeff Moyer wrote:
> ==> Regarding Re: [autofs] Race in expire code; raven@themaw.net adds:
> 
> raven> On Sat, 29 Jan 2005, Steinar H. Gunderson wrote:
> 
>>>On Sat, Jan 29, 2005 at 09:36:31PM +0800, raven@themaw.net wrote:
>>>
>>>>Can everyone who is maintaining downstream packages please chaeck that
>>>>the code in their package ends up looking like what the patch below
>>>>acheives.
>>>>
>>>>[...]
>>>>
>>>>case EXP_STARTED: - sigprocmask(SIG_SETMASK, &ready_sigs, NULL);
>>>>ap.state = ST_EXPIRE; + sigprocmask(SIG_SETMASK, &ready_sigs, NULL);
>>>>return 0; } return 1;
>>>
>>>The Debian packages are close, but not quite:
>>>
>>>case EXP_STARTED: sigprocmask(SIG_SETMASK, &lock_sigs, NULL); ap.state =
>>>ST_EXPIRE; sigprocmask(SIG_SETMASK, &ready_sigs, NULL); return 0;
>>>
>>>I have no idea what lock_sigs does, but this should be OK, no?
> 
> 
> raven> It's just the list of signals that are blocked while we do "stuff"
> raven> that we don`t want interrupted by something else.
> 
> raven> Similarly ready_sigs contains the signals we expect to be received
> raven> in normal operation.
> 
> raven> The first sigprocmask call above does nothing as signals are already
> raven> blocked at that point.
> 
> The Red Hat package also has the two calls to sigprocmask.  When "fixing"
> signal races, I definitely managed to introduce a similar bug.  Chris Feist
> fixed it.  Chris, do you agree with Ian on this matter, that the first
> sigprocmask is superfluous?

Yes, I think I just included it to be safe, but it should be able to be 
safely removed.

The reason that we needed to make the 'ap.state = ST_EXPIRE' run before 
enabling ready_sigs, is as soon as we enable sigprocmask the kernel 
sends down a queued up SIGCHLD which then runs the sigchld event handler 
which doesn't realize that we're in ST_EXPIRE (because it hasn't been 
set yet).

Thanks,
Chris

      reply	other threads:[~2005-01-31 16:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-29 13:36 Race in expire code raven
2005-01-29 13:51 ` Steinar H. Gunderson
2005-01-29 14:13   ` raven
2005-01-31 15:34     ` Jeff Moyer
2005-01-31 16:47       ` Chris Feist [this message]

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=41FE6133.3070802@redhat.com \
    --to=cfeist@redhat.com \
    --cc=autofs@linux.kernel.org \
    --cc=jmoyer@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.