]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] fix current->user->__count leak
authorAndrew Morton <akpm@osdl.org>
Sat, 5 Jul 2003 02:38:06 +0000 (19:38 -0700)
committerLinus Torvalds <torvalds@home.osdl.org>
Sat, 5 Jul 2003 02:38:06 +0000 (19:38 -0700)
From: Arvind Kandhare <arvind.kan@wipro.com>

When switch_uid is called, the reference count of the new user is
incremented twice.  I think the increment in the switch_uid is done because
of the reparent_to_init() function which does not increase the __count for
root user.

But if switch_uid is called from any other function, the reference count is
already incremented by the caller by calling alloc_uid for the new user.
Hence the count is incremented twice.  The user struct will not be deleted
even when there are no processes holding a reference count for it.  This
does not cause any problem currently because nothing is dependent on timely
deletion of the user struct.

kernel/exit.c
kernel/user.c

index ebc839b645a73f1dcd68b9822c0c4cb7968caa8d..c52fc310cb16e48cd0d0879fd58a687183d59ef9 100644 (file)
@@ -230,6 +230,7 @@ void reparent_to_init(void)
        /* signals? */
        security_task_reparent_to_init(current);
        memcpy(current->rlim, init_task.rlim, sizeof(*(current->rlim)));
+       atomic_inc(&(INIT_USER->__count));
        switch_uid(INIT_USER);
 
        write_unlock_irq(&tasklist_lock);
index 592680d8cc68cbf7a6e64cb08409b594bf225e0b..86bd412b85dafebcf7ea4a5c80d07b08c0c22f80 100644 (file)
@@ -126,7 +126,6 @@ void switch_uid(struct user_struct *new_user)
         * we should be checking for it.  -DaveM
         */
        old_user = current->user;
-       atomic_inc(&new_user->__count);
        atomic_inc(&new_user->processes);
        atomic_dec(&old_user->processes);
        current->user = new_user;