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>] [day] [month] [year] [list]
Message-ID: <CAJgzZoqz2Ev0WEDYR_etKKf7q61Jfw8SiMJ_1DFxNaEHM=DPhA@mail.gmail.com>
Date: Fri, 7 Mar 2025 17:31:23 -0500
From: enh <enh@...gle.com>
To: Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: PID_MAX_LIMIT

i was clarifying the clock_getcpuclockid() and pthread_getcpuclockid()
code in Android's libc because the bit-twiddling always confuses
people (and the kernel header macros aren't in uapi), and noticed that
neither the libc nor the kernel side of the code checks that (pid <<
3) fits in the clockid_t.

it looks like we're fine because the limit is 4 million thanks to the
code below, but the warning in the comment about the FUTEX_TID_MASK
should probably also warn about this even-lower CPUCLOCK_PID()-induced
limit? (which is one bit less than 32-3 bits unless a cast to unsigned
gets added so we don't accidentally sign-extend the highest pids to
negative values when extracting them from clockid_t values...)

/*
 * This controls the default maximum pid allocated to a process
 */
#define PID_MAX_DEFAULT (IS_ENABLED(CONFIG_BASE_SMALL) ? 0x1000 : 0x8000)

/*
 * 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.]
 */
#define PID_MAX_LIMIT (IS_ENABLED(CONFIG_BASE_SMALL) ? PAGE_SIZE * 8 : \
    (sizeof(long) > 4 ? 4 * 1024 * 1024 : PID_MAX_DEFAULT))

i can send a patch if you'd like but (a) i assume gmail will mangle it
and (b) one-line comments seem like the kind of thing the file's
maintainers would have strong opinions on anyway.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ