Source-Changes-HG archive

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

[src/trunk]: src/sys/kern With TRYEMULROOT namei_getstartdir() gets used twic...



details:   https://anonhg.NetBSD.org/src/rev/208cc99921c5
branches:  trunk
changeset: 449709:208cc99921c5
user:      hannken <hannken%NetBSD.org@localhost>
date:      Sun Mar 17 10:14:52 2019 +0000

description:
With TRYEMULROOT namei_getstartdir() gets used twice so have to
vrele() "ni_rootdir" and "ni_erootdir" on entry.

diffstat:

 sys/kern/vfs_lookup.c |  12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diffs (40 lines):

diff -r ad19eb376e5a -r 208cc99921c5 sys/kern/vfs_lookup.c
--- a/sys/kern/vfs_lookup.c     Sun Mar 17 09:54:06 2019 +0000
+++ b/sys/kern/vfs_lookup.c     Sun Mar 17 10:14:52 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_lookup.c,v 1.209 2019/03/12 14:03:35 hannken Exp $ */
+/*     $NetBSD: vfs_lookup.c,v 1.210 2019/03/17 10:14:52 hannken Exp $ */
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.209 2019/03/12 14:03:35 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_lookup.c,v 1.210 2019/03/17 10:14:52 hannken Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_magiclinks.h"
@@ -537,6 +537,13 @@
        struct lwp *self = curlwp;      /* thread doing namei() */
        struct vnode *rootdir, *erootdir, *curdir, *startdir;
 
+       if (state->root_referenced) {
+               vrele(state->ndp->ni_rootdir);
+               if (state->ndp->ni_erootdir != NULL)
+                       vrele(state->ndp->ni_erootdir);
+               state->root_referenced = 0;
+       }
+
        cwdi = self->l_proc->p_cwdi;
        rw_enter(&cwdi->cwdi_lock, RW_READER);
 
@@ -589,7 +596,6 @@
         * A multithreaded process may chroot during namei.
         */
        vref(startdir);
-       KASSERT(! state->root_referenced);
        vref(state->ndp->ni_rootdir);
        if (state->ndp->ni_erootdir != NULL)
                vref(state->ndp->ni_erootdir);



Home | Main Index | Thread Index | Old Index