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: <87mt2bc9wz.ffs@tglx>
Date:   Thu, 11 May 2023 14:47:08 +0200
From:   Thomas Gleixner <tglx@...utronix.de>
To:     Peter Zijlstra <peterz@...radead.org>, Jann Horn <jannh@...gle.com>
Cc:     Ingo Molnar <mingo@...hat.com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Darren Hart <dvhart@...radead.org>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] threads: Update PID limit comment according to futex
 UAPI change


Reviving this old thread.

On Tue, Mar 03 2020 at 15:12, Thomas Gleixner wrote:
> Peter Zijlstra <peterz@...radead.org> writes:
>> On Mon, Mar 02, 2020 at 12:29:39PM +0100, Jann Horn wrote:
>>>  /*
>>>   * A maximum of 4 million PIDs should be enough for a while.
>>> - * [NOTE: PID/TIDs are limited to 2^29 ~= 500+ million, see futex.h.]
>>> + * [NOTE: PID/TIDs are limited to 2^30 ~= 1 billion, see FUTEX_TID_MASK.]
>>>   */
>>>  #define PID_MAX_LIMIT (CONFIG_BASE_SMALL ? PAGE_SIZE * 8 : \
>>>  	(sizeof(long) > 4 ? 4 * 1024 * 1024 : PID_MAX_DEFAULT))
>>
>> I just noticed another mention of this in Documentation/robust-futex-ABI.txt
>> There it states that bit-29 is reserved for future use.
>>
>> Thomas, do we want to release that bit and update all this?
>
> In fact we've released it long ago:
>
> include/uapi/linux/futex.h:
>
> #define FUTEX_TID_MASK          0x3fffffff

That futex mask is irrelevant because there is another limitiation for
the PID space namely posix CPU timers:

static inline clockid_t make_process_cpuclock(const unsigned int pid,
		                              const clockid_t clock)
{
	return ((~pid) << 3) | clock;
}

That existed even before we fiddled with robust futexes and puts a hard
limit of 29 bits on the PID space.

So we want something like the below.

Thanks,

        tglx
---       
--- a/include/linux/threads.h
+++ b/include/linux/threads.h
@@ -29,7 +29,9 @@
 
 /*
  * A maximum of 4 million PIDs should be enough for a while.
- * [NOTE: PID/TIDs are limited to 2^30 ~= 1 billion, see FUTEX_TID_MASK.]
+ *
+ * PID/TIDs are limited to 2^29 due to POSIX CPU timers. See
+ * make_process_cpuclock().
  */
 #define PID_MAX_LIMIT (CONFIG_BASE_SMALL ? PAGE_SIZE * 8 : \
 	(sizeof(long) > 4 ? 4 * 1024 * 1024 : PID_MAX_DEFAULT))

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ