• Oleg Nesterov's avatar
    [PATCH] pidhash: don't use zero pids · c7c64641
    Oleg Nesterov authored
    
    
    daemonize() calls set_special_pids(1,1), while init and kernel threads spawned
    from init/main.c:init() run with 0,0 special pids.  This patch changes
    INIT_SIGNALS() so that that they run with ->pgrp == ->session == 1 also.  This
    patch relies on fact that swapper's pid == 1.
    
    Now we have no hashed zero pids in pid_hash[].
    
    User-space visibible change is that now /sbin/init runs with (1,1) special
    pids and becomes a session leader.
    
    Quoting Eric W. Biederman:
    >
    > daemonize consuming pids (1,1) then consumes pgrp 1.  So that when
    > /sbin/init calls setsid() it thinks /sbin/init is a process group
    > leader and setsid() fails.  So /sbin/init wants pgrp 1 session 1
    > but doesn't get it.  I am pretty certain daemonize did not exist so
    > /sbin/init got pgrp 1 session 1 in 2.4.
    >
    > That is the bug that is being fixed.
    >
    > This patch takes things one step farther and essentially calls
    > setsid() for pid == 1 before init is execed.  That is new behavior
    > but it cleans up the kernel as we now do not need to support the
    > case of a process without a process group or a session.
    >
    > The only process that could have possibly cared was /sbin/init
    > and it already calls setsid() because it doesn't want that.
    >
    > If this was going to break anything noticeable the change in behavior
    > from 2.4 to 2.6 would have already done that.
    Signed-off-by: default avatarOleg Nesterov <oleg@tv-sign.ru>
    Cc: "Eric W. Biederman" <ebiederm@xmission.com>
    Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
    c7c64641
init_task.h 3.69 KB