public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* /proc/sys/kernel/pid_max issues
@ 2004-09-12  8:56 Anton Blanchard
  2004-09-12  9:36 ` William Lee Irwin III
                   ` (2 more replies)
  0 siblings, 3 replies; 38+ messages in thread
From: Anton Blanchard @ 2004-09-12  8:56 UTC (permalink / raw)
  To: linux-kernel; +Cc: mingo, viro, wli


Hi,

I tried creating 100,000 threads just for the hell of it. I was
surprised that it appears to have worked even with pid_max set at 32k.

It seems if we are above pid_max we wrap back to RESERVED_PIDS at the
start of alloc_pidmap but do not enforce this upper limit. I guess every
call of alloc_pidmap above 32k was wrapping back to RESERVED_PIDS,
walking the allocated space then allocating off the end.

Just as an aside, does it make sense to remove the pidmap allocator and
use the IDR allocator now its there?

Now once I had managed to allocate those 100,000 threads, I noticed
this:

18446744071725383682 dr-xr-xr-x   3 root root   0 Sep 12 08:10 100796

Strange huh. Turns out we allocate inodes in proc via:

#define fake_ino(pid,ino) (((pid)<<16)|(ino))

With 32bit inodes we are screwed once pids go over 64k arent we?

Anton

^ permalink raw reply	[flat|nested] 38+ messages in thread
* Re: /proc/sys/kernel/pid_max issues
@ 2004-09-13  3:20 Albert Cahalan
  2004-09-13  7:42 ` William Lee Irwin III
  2004-09-13  7:57 ` Ingo Molnar
  0 siblings, 2 replies; 38+ messages in thread
From: Albert Cahalan @ 2004-09-13  3:20 UTC (permalink / raw)
  To: linux-kernel mailing list; +Cc: wli, cw, mingo, anton

Ingo Molnar writes:

> it's getting quite spaghetti ... do we really want to handle
> RESERVED_PID? There's no guarantee that any root daemon wont stray out
> of the 1...300 PID range anyway, so if it has an exploitable PID race
> bug then it's probably exploitable even without the RESERVED_PID
> protection.

Purpose:

1. weak security enhancement
2. cosmetic (backwards, IMHO)
3. speed (avoid PIDs likely to be used)

I'd much prefer LRU allocation. There are
lots of system calls that take PID values.
All such calls are hazardous. They're pretty
much broken by design.

Better yet, make a random choice from
the 50% of PID space that has been least
recently used.

Another idea is to associate PIDs with users
to some extent. You keep getting back the same
set of PIDs unless the system runs low in some
global pool and has to steal from one user to
satisfy another.

BTW, since pid_max is now adjustable, reducing
the default to 4 digits would make sense. Try a
"ps j" to see the use. (column width changes if
you change max_pid)



^ permalink raw reply	[flat|nested] 38+ messages in thread

end of thread, other threads:[~2004-09-24 16:02 UTC | newest]

Thread overview: 38+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-09-12  8:56 /proc/sys/kernel/pid_max issues Anton Blanchard
2004-09-12  9:36 ` William Lee Irwin III
2004-09-12  9:51   ` Ingo Molnar
2004-09-12  9:58   ` William Lee Irwin III
2004-09-12 10:10     ` William Lee Irwin III
2004-09-12 10:13     ` Ingo Molnar
2004-09-12 10:43       ` William Lee Irwin III
2004-09-12 10:45         ` William Lee Irwin III
2004-09-12 11:08           ` William Lee Irwin III
2004-09-12 11:20             ` Ingo Molnar
2004-09-12 17:13               ` William Lee Irwin III
2004-09-12 18:02                 ` Chris Wedgwood
2004-09-12 23:06                   ` William Lee Irwin III
2004-09-13  1:46                 ` [pidhashing] rewrite alloc_pidmap() William Lee Irwin III
2004-09-12  9:39 ` /proc/sys/kernel/pid_max issues Ingo Molnar
2004-09-12  9:43   ` William Lee Irwin III
2004-09-12 12:18 ` Arjan van de Ven
2004-09-12 12:30   ` Anton Blanchard
2004-09-12 12:44     ` Arjan van de Ven
2004-09-12 13:34       ` Anton Blanchard
2004-09-12 13:41       ` Ingo Molnar
  -- strict thread matches above, loose matches on Subject: below --
2004-09-13  3:20 Albert Cahalan
2004-09-13  7:42 ` William Lee Irwin III
2004-09-13 14:11   ` Albert Cahalan
2004-09-13 14:27     ` William Lee Irwin III
2004-09-13 14:51       ` Herbert Poetzl
2004-09-14  2:13         ` William Lee Irwin III
2004-09-23 13:13       ` Pavel Machek
2004-09-24 16:02         ` Martin Mares
2004-09-23 13:11   ` Pavel Machek
2004-09-13  7:57 ` Ingo Molnar
2004-09-13 13:54   ` Albert Cahalan
2004-09-13 14:24     ` William Lee Irwin III
2004-09-13 14:54       ` Albert Cahalan
2004-09-14  2:02         ` William Lee Irwin III
2004-09-14 15:32     ` Ingo Molnar
2004-09-18 18:32       ` Pavel Machek
2004-09-23 13:18     ` Pavel Machek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox