]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] BSD accounting oops fix
authorAndrew Morton <akpm@osdl.org>
Mon, 12 Apr 2004 08:04:34 +0000 (01:04 -0700)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Mon, 12 Apr 2004 08:04:34 +0000 (01:04 -0700)
oopses have been reported in do_acct_process(), with premption enabled, when
threaded applications are exitting.

It appears that we're racing with another thread which is nulling out
current->tty.  I think this race is still there after we moved current->tty
into current->signal->tty, so let's take the needed lock.

kernel/acct.c

index 8e32413c41f39678712e49f092003e936d70d965..555e1e3c349ffb1639dcc8d9139e2778c27a9425 100644 (file)
@@ -347,7 +347,11 @@ static void do_acct_process(long exitcode, struct file *file)
        /* we really need to bite the bullet and change layout */
        ac.ac_uid = current->uid;
        ac.ac_gid = current->gid;
-       ac.ac_tty = current->signal->tty ? old_encode_dev(tty_devnum(current->signal->tty)) : 0;
+
+       read_lock(&tasklist_lock);      /* pin current->signal */
+       ac.ac_tty = current->signal->tty ?
+               old_encode_dev(tty_devnum(current->signal->tty)) : 0;
+       read_unlock(&tasklist_lock);
 
        ac.ac_flag = 0;
        if (current->flags & PF_FORKNOEXEC)