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
This commit is contained in:
dbj 2005-01-24 21:27:02 +00:00
parent 027c11539b
commit 208b0b3a89
2 changed files with 7 additions and 4 deletions

View File

@ -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 @@ exit1(struct lwp *l, int rv)
*/
fdfree(p);
cwdfree(p->p_cwdi);
p->p_cwdi = 0;
doexithooks(p);

View File

@ -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 @@ checkdirs(olddp)
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);