lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.LFD.2.00.1004251021520.3739@i5.linux-foundation.org>
Date:	Sun, 25 Apr 2010 10:27:35 -0700 (PDT)
From:	Linus Torvalds <torvalds@...ux-foundation.org>
To:	Pavel Machek <pavel@....cz>
cc:	Alan Cox <alan@...rguk.ukuu.org.uk>, Greg KH <gregkh@...e.de>,
	Rik van Riel <riel@...hat.com>,
	John Stoffel <john@...ffel.org>, Hedi Berriche <hedi@....com>,
	Mike Travis <travis@....com>, Ingo Molnar <mingo@...e.hu>,
	Jack Steiner <steiner@....com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Robin Holt <holt@....com>, LKML <linux-kernel@...r.kernel.org>
Subject: Re: [Patch 1/1] init: Provide a kernel start parameter to increase
 pid_max v2


On Sun, 25 Apr 2010, Linus Torvalds wrote:
> 
> Iirc, some _really_ old code used 'short' for pid_t, and we wanted to be 
> really safe when we raised the limits. 

.. I dug into the history, and this is from August 2002..

We used to limit it to sixteen bits, but that was too tight even then for 
some people, so first we did this:

    Author: Linus Torvalds <torvalds@...e.transmeta.com>
    Date:   Thu Aug 8 03:57:42 2002 -0700
    
        Make pid allocation use 30 of the 32 bits, instead of 15.
    
    diff --git a/include/linux/threads.h b/include/linux/threads.h
    index 880b990..6804ee7 100644
    --- a/include/linux/threads.h
    +++ b/include/linux/threads.h
    @@ -19,6 +19,7 @@
     /*
      * This controls the maximum pid allocated to a process
      */
    -#define PID_MAX 0x8000
    +#define PID_MASK 0x3fffffff
    +#define PID_MAX (PID_MASK+1)
     
     #endif
    diff --git a/kernel/fork.c b/kernel/fork.c
    index d40d246..017740d 100644
    --- a/kernel/fork.c
    +++ b/kernel/fork.c
    @@ -142,7 +142,7 @@ static int get_pid(unsigned long flags)
                    return 0;
     
            spin_lock(&lastpid_lock);
    -       if((++last_pid) & 0xffff8000) {
    +       if((++last_pid) & ~PID_MASK) {
                    last_pid = 300;         /* Skip daemons etc. */
                    goto inside;
            }
    @@ -157,7 +157,7 @@ inside:
                               p->tgid == last_pid  ||
                               p->session == last_pid) {
                                    if(++last_pid >= next_safe) {
    -                                       if(last_pid & 0xffff8000)
    +                                       if(last_pid & ~PID_MASK)
                                                    last_pid = 300;
                                            next_safe = PID_MAX;
                                    }

which just upped the limits.  That, in turn, _did_ end up breaking some
silly old binaries, so then a month later Ingo did a "pid-max" patch
that made the maximum dynamic, with a default of the old 15-bit limit,
and a sysctl to raise it. 

And then a couple of weeks later, Ingo did another patch to fix the
scalability problems we had with lots of pids (avoiding the whole
"for_each_task()" crud to figure out which pids were ok, and using a
'struct pid' instead).

So the whole worry about > 15-bit pids goes back to 2002.  I think we're
pretty safe now. 

			Linus

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ