OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
 
From: Matthias Andree (ma_at_dt.e-technik.uni-dortmund.de)
Date: Thu Jan 16 2003 - 16:28:03 CST

  • Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

    Mate Wierdl has code to show that his tested version of Linux collides
    PIDs within less than a fifth of a second, on a GHz-class machine. See
    his attached mail, forwarded from the qmail list.

    The non-amusing part of his findings is that the PID reuse problem
    suddenly looks pretty threatening even for today's machines, imagine there
    is a runaway process (say something that tried to restart a child
    process) zooming through your PID space.

    -- 
    Matthias Andree
    

    attached mail follows:


    Well, Linux has no 1 second guarantees either. At the suggestion of Matthias, I now have a programm that recycles the same PID in much less than 1 second.

    Here is the run of the program:

    $ ./child Collision after 0.14 secs! child: 32383 PID: 13145

    The hardware is an 1100MHz, 256M RAM Athlon box, running RH Linux 8.0.

    Here is the program

    #include <stdio.h> #include <sys/types.h> #include <sys/wait.h> #include <time.h> #include <unistd.h>

    #define NCHILD 33000

    int main(void) { int i; pid_t pid, pid1 = 0; int status; clock_t start, end; start = clock();

    for(i = 1; i <= NCHILD; i++) { if ((pid = vfork()) < 0) { perror("fork"); _exit(1); } if (pid == 0) _exit(1); if (i == 1) pid1 = pid; if(i != 1 && pid1 == pid) { end = clock(); printf("Collision after\t%.2f secs! ", (double)(end - start)/(double)CLOCKS_PER_SEC); printf("child:\t%d\tPID:\t%d\n", i, pid); _exit(20); } while (wait(&status) != pid); } return 0; }

    Mate