1. 29 Mar, 2006 12 commits
    • 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
    • Oleg Nesterov's avatar
      [PATCH] pidhash: don't count idle threads · 73b9ebfe
      Oleg Nesterov authored
      fork_idle() does unhash_process() just after copy_process().  Contrary,
      boot_cpu's idle thread explicitely registers itself for each pid_type with nr
      = 0.
      
      copy_process() already checks p->pid != 0 before process_counts++, I think we
      can just skip attach_pid() calls and job control inits for idle threads and
      kill unhash_process().  We don't need to cleanup ->proc_dentry in fork_idle()
      because with this patch idle threads are never hashed in
      kernel/pid.c:pid_hash[].
      
      We don't need to hash pid == 0 in pidmap_init().  free_pidmap() is never
      called with pid == 0 arg, so it will never be reused.  So it is still possible
      to use pid == 0 in any PIDTYPE_xxx namespace from kernel/pid.c's POV.
      
      However with this patch we don't hash pid == 0 for PIDTYPE_PID case.  We still
      have have PIDTYPE_PGID/PIDTYPE_SID entries with pid == 0: /sbin/init and
      kernel threads which don't call daemonize().
      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>
      73b9ebfe
    • Oleg Nesterov's avatar
      [PATCH] kill SET_LINKS/REMOVE_LINKS · c97d9893
      Oleg Nesterov authored
      Both SET_LINKS() and SET_LINKS/REMOVE_LINKS() have exactly one caller, and
      these callers already check thread_group_leader().
      
      This patch kills theese macros, they mix two different things: setting
      process's parent and registering it in init_task.tasks list.  Callers are
      updated to do these actions by hand.
      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>
      c97d9893
    • Oleg Nesterov's avatar
      [PATCH] don't use REMOVE_LINKS/SET_LINKS for reparenting · 9b678ece
      Oleg Nesterov authored
      There are places where kernel uses REMOVE_LINKS/SET_LINKS while changing
      process's ->parent.  Use add_parent/remove_parent instead, they don't abuse
      of global process list.
      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>
      9b678ece
    • Oleg Nesterov's avatar
      [PATCH] remove add_parent()'s parent argument · 8fafabd8
      Oleg Nesterov authored
      add_parent(p, parent) is always called with parent == p->parent, and it makes
      no sense to do it differently.  This patch removes this argument.
      
      No changes in affected .o files.
      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>
      8fafabd8
    • Oleg Nesterov's avatar
      [PATCH] choose_new_parent: remove unused arg, sanitize exit_state check · d799f035
      Oleg Nesterov authored
      'child_reaper' arg is not used in choose_new_parent().
      
      "->exit_state >= EXIT_ZOMBIE" check is a leftover, was
      valid when EXIT_ZOMBIE lived in ->state var.
      Signed-off-by: default avatarOleg Nesterov <oleg@tv-sign.ru>
      Acked-by: default avatarEric Biederman <ebiederm@xmission.com>
      Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
      d799f035
    • Eric W. Biederman's avatar
      [PATCH] pidhash: kill switch_exec_pids · d73d6529
      Eric W. Biederman authored
      switch_exec_pids is only called from de_thread by way of exec, and it is
      only called when we are exec'ing from a non thread group leader.
      
      Currently switch_exec_pids gives the leader the pid of the thread and
      unhashes and rehashes all of the process groups.  The leader is already in
      the EXIT_DEAD state so no one cares about it's pids.  The only concern for
      the leader is that __unhash_process called from release_task will function
      correctly.  If we don't touch the leader at all we know that
      __unhash_process will work fine so there is no need to touch the leader.
      
      For the task becomming the thread group leader, we just need to give it the
      pid of the old thread group leader, add it to the task list, and attach it
      to the session and the process group of the thread group.
      
      Currently de_thread is also adding the task to the task list which is just
      silly.
      
      Currently the only leader of __detach_pid besides detach_pid is
      switch_exec_pids because of the ugly extra work that was being
      performed.
      
      So this patch removes switch_exec_pids because it is doing too much, it is
      creating an unnecessary special case in pid.c, duing work duplicated in
      de_thread, and generally obscuring what it is going on.
      
      The necessary work is added to de_thread, and it seems to be a little
      clearer there what is going on.
      Signed-off-by: default avatarEric W. Biederman <ebiederm@xmission.com>
      Cc: Oleg Nesterov <oleg@tv-sign.ru>
      Cc: Kirill Korotaev <dev@sw.ru>
      Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
      d73d6529
    • Eric W. Biederman's avatar
      [PATCH] do_SAK: don't depend on session ID 0 · 652486fb
      Eric W. Biederman authored
      I'm not really certain what the thinking was but the code obviously wanted to
      walk processes other than just those in it's session, for purposes of do_SAK.
      Just walking those tasks that don't have a session assigned sounds at the very
      least incomplete.
      
      So modify the code to kill everything in the session and anything else that
      might have the tty open.  Hopefully this helps if the do_SAK functionality is
      ever finished.
      Signed-off-by: default avatarEric W. Biederman <ebiederm@xmission.com>
      Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
      652486fb
    • Eric W. Biederman's avatar
      [PATCH] do_tty_hangup: use group_send_sig_info not send_group_sig_info · f96a795d
      Eric W. Biederman authored
      We already have the tasklist_lock so there is no need for us to reacquire it
      with send_group_sig_info.  reader/writer locks allow multiple readers and thus
      recursion so the old code was ok just wastful.
      Signed-off-by: default avatarEric W. Biederman <ebiederm@xmission.com>
      Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
      f96a795d
    • Eric W. Biederman's avatar
      [PATCH] Remove dead kill_sl prototype from sched.h · 6c99c5cb
      Eric W. Biederman authored
      The kill_sl function doesn't exist in the kernel so a prototype is completely
      unnecessary.
      Signed-off-by: default avatarEric W. Biederman <ebiederm@xmission.com>
      Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
      6c99c5cb
    • Oleg Nesterov's avatar
      [PATCH] simplify exec from init's subthread · 1434261c
      Oleg Nesterov authored
      I think it is enough to take tasklist_lock for reading while changing
      child_reaper:
      
      	Reparenting needs write_lock(tasklist_lock)
      
      	Only one thread in a thread group can do exec()
      
      	sighand->siglock garantees that get_signal_to_deliver()
      	will not see a stale value of child_reaper.
      
      This means that we can change child_reaper earlier, without calling
      zap_other_threads() twice.
      
      "child_reaper = current" is a NOOP when init does exec from main thread, we
      don't care.
      Signed-off-by: default avatarOleg Nesterov <oleg@tv-sign.ru>
      Acked-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
      1434261c
    • Eric W. Biederman's avatar
      [PATCH] exec: allow init to exec from any thread. · fef23e7f
      Eric W. Biederman authored
      After looking at the problem of init calling exec some more I figured out
      an easy way to make the code work.
      
      The actual symptom without out this patch is that all threads will die
      except pid == 1, and the thread calling exec.  The thread calling exec will
      wait forever for pid == 1 to die.
      
      Since pid == 1 does not install a handler for SIGKILL it will never die.
      
      This modifies the tests for init from current->pid == 1 to the equivalent
      current == child_reaper.  And then it causes exec in the ugly case to
      modify child_reaper.
      
      The only weird symptom is that you wind up with an init process that
      doesn't have the oldest start time on the box.
      Signed-off-by: default avatarEric W. Biederman <ebiederm@xmission.com>
      Cc: Oleg Nesterov <oleg@tv-sign.ru>
      Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
      fef23e7f
  2. 28 Mar, 2006 28 commits