mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Keith Owens <kaos@ocs.com.au>
To: Oliver Neukum <Oliver.Neukum@lrz.uni-muenchen.de>
Cc: Dave Hansen <haveblue@us.ibm.com>,
	Kasper Dupont <kasperd@daimi.au.dk>,
	Linux-Kernel <linux-kernel@vger.kernel.org>
Subject: Re: [RFC] Race condition?
Date: Sat, 03 Aug 2002 21:07:11 +1000	[thread overview]
Message-ID: <2020.1028372831@ocs3.intra.ocs.com.au> (raw)
In-Reply-To: Your message of "Sat, 03 Aug 2002 12:08:28 +0200." <17aw0S-0U7gB7C@fmrl00.sul.t-online.com>

On Sat, 3 Aug 2002 12:08:28 +0200, 
Oliver Neukum <Oliver.Neukum@lrz.uni-muenchen.de> wrote:
>Hi,
>
>> >I don't see any locking in the call chain leading to this function, so
>> >I think you're right.  The attached patch fixes this.  It costs an
>> >extra 2 atomic ops in the failure case, but otherwise just makes the
>> >processes++ operation earlier.
>>
>> Does this race really justify extra locks?  AFAICT the worst case is
>> that a user can go slightly over their RLIMIT_NPROC, and that will only
>> occur if they fork on multiple cpus "at the same time".  Given the
>
>Only if preempt is not enabled.

Preempt is irrelevant here.  To make any difference, there would have
to be an interrupt in the window between reading and updating
p->user->processes _and_ another process would have to be waiting to
enter fork().  Even if that occurred, the result is the user is one
process over their limit, big deal.

>> timing constraints on that small window, I would be surprised if this
>> race could be exploited to gain more than a couple of extra processes.
>> This looks like a case where close enough is good enough.
>
>There's no such thing as a tolerable race :-)

The result is just a slightly elevated process count in rare cases.
Even then it is self correcting.  It is not a significant race, just a
bit of fuzzy counting.

>Anyway this code can corrupt the global variable nr_threads.
>Without the BKL it is buggy, so it has to be fixed anyway and we
>can do it right.

nr_threads is protected by tasklist_lock.  How on earth can fuzzy
counting on user->processes corrupt nr_threads?


       reply	other threads:[~2002-08-03 11:03 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <17aw0S-0U7gB7C@fmrl00.sul.t-online.com>
2002-08-03 11:07 ` Keith Owens [this message]
2002-08-03 11:17   ` Keith Owens
2002-08-02 13:46 Kasper Dupont
2002-08-02 14:48 ` Oliver Neukum
2002-08-02 17:13   ` Kasper Dupont
2002-08-02 18:51     ` Oliver Neukum
2002-08-02 17:37   ` Dave Hansen
2002-08-02 18:45     ` Oliver Neukum
2002-08-02 19:09       ` Dave Hansen
2002-08-02 17:00 ` Dave Hansen
2002-08-02 17:41   ` Oliver Neukum
2002-08-02 18:48     ` Dave Hansen
2002-08-02 18:56     ` Dave Hansen
2002-08-03  0:36   ` Keith Owens

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=2020.1028372831@ocs3.intra.ocs.com.au \
    --to=kaos@ocs.com.au \
    --cc=Oliver.Neukum@lrz.uni-muenchen.de \
    --cc=haveblue@us.ibm.com \
    --cc=kasperd@daimi.au.dk \
    --cc=linux-kernel@vger.kernel.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

all inboxes | Powered by JetHome®