linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Resource leak in reparent_to_init
@ 2003-09-02 10:37 Vladimir Kondratiev
  0 siblings, 0 replies; only message in thread
From: Vladimir Kondratiev @ 2003-09-02 10:37 UTC (permalink / raw)
  To: Linux Kernel Mailing List, Marcelo Tosatti

In reparent_to_init, it is clear bug that causes resource leak. It is 
pretty easy to test that this bug causes problems: if your module allows 
to create thread for non-root user (using daemonize() and 
reparent_to_init()), it will mis-count number of processes running for 
that user.
Patch follows.
P.S. I do not subscribed to the list, thus please in your reply CC me 
(vladimir.kondratiev@intel.com)

--- kernel/sched.c.orig    2003-08-17 20:12:14.000000000 +0300
+++ kernel/sched.c    2003-08-17 21:21:08.000000000 +0300
@@ -1274,8 +1274,16 @@
    this_task->cap_permitted = CAP_FULL_SET;
    this_task->keep_capabilities = 0;
    memcpy(this_task->rlim, init_task.rlim, sizeof(*(this_task->rlim)));
-    this_task->user = INIT_USER;
-
+    if (this_task->uid) { /* not root? switch user */
+        struct user_struct *old_user = this_task->user,
+            *new_user = INIT_USER;
+        this_task->uid = 0;
+        this_task->user = new_user;
+        atomic_inc(&new_user->__count);
+        atomic_inc(&new_user->processes);
+        atomic_dec(&old_user->processes);
+        free_uid(old_user);
+    }
    spin_unlock(&runqueue_lock);
    write_unlock_irq(&tasklist_lock);
}




^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-09-02 10:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-09-02 10:37 [PATCH] Resource leak in reparent_to_init Vladimir Kondratiev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).