Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern clear p->p_cwdi of exiting processes and



details:   https://anonhg.NetBSD.org/src/rev/d3baa1a84dbd
branches:  trunk
changeset: 573286:d3baa1a84dbd
user:      dbj <dbj%NetBSD.org@localhost>
date:      Mon Jan 24 21:27:02 2005 +0000

description:
clear p->p_cwdi of exiting processes and
avoid dereferencing invalid p_cwdi in checkdirs
this fixes a race condition between exiting processes and mount
see discussion on tech-kern:
 http://mail-index.netbsd.org/tech-kern/2004/10/04/0006.html
 http://mail-index.netbsd.org/tech-kern/2004/10/08/0005.html

diffstat:

 sys/kern/kern_exit.c    |  5 +++--
 sys/kern/vfs_syscalls.c |  6 ++++--
 2 files changed, 7 insertions(+), 4 deletions(-)

diffs (53 lines):

diff -r 38e2287b634c -r d3baa1a84dbd sys/kern/kern_exit.c
--- a/sys/kern/kern_exit.c      Mon Jan 24 21:25:09 2005 +0000
+++ b/sys/kern/kern_exit.c      Mon Jan 24 21:27:02 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_exit.c,v 1.143 2004/10/01 16:30:52 yamt Exp $     */
+/*     $NetBSD: kern_exit.c,v 1.144 2005/01/24 21:27:02 dbj Exp $      */
 
 /*-
  * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
@@ -74,7 +74,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.143 2004/10/01 16:30:52 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.144 2005/01/24 21:27:02 dbj Exp $");
 
 #include "opt_ktrace.h"
 #include "opt_perfctrs.h"
@@ -266,6 +266,7 @@
         */
        fdfree(p);
        cwdfree(p->p_cwdi);
+       p->p_cwdi = 0;
 
        doexithooks(p);
 
diff -r 38e2287b634c -r d3baa1a84dbd sys/kern/vfs_syscalls.c
--- a/sys/kern/vfs_syscalls.c   Mon Jan 24 21:25:09 2005 +0000
+++ b/sys/kern/vfs_syscalls.c   Mon Jan 24 21:27:02 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_syscalls.c,v 1.214 2005/01/02 16:08:29 thorpej Exp $       */
+/*     $NetBSD: vfs_syscalls.c,v 1.215 2005/01/24 21:27:02 dbj Exp $   */
 
 /*
  * Copyright (c) 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.214 2005/01/02 16:08:29 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_syscalls.c,v 1.215 2005/01/24 21:27:02 dbj Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_compat_43.h"
@@ -402,6 +402,8 @@
        proclist_lock_read();
        PROCLIST_FOREACH(p, &allproc) {
                cwdi = p->p_cwdi;
+               if (!cwdi)
+                       continue;
                if (cwdi->cwdi_cdir == olddp) {
                        vrele(cwdi->cwdi_cdir);
                        VREF(newdp);



Home | Main Index | Thread Index | Old Index