Source-Changes-HG archive

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

[src/trunk]: src/sys/kern Fix obscure bug in namei(), which was the cause of ...



details:   https://anonhg.NetBSD.org/src/rev/7fffcd803209
branches:  trunk
changeset: 471663:7fffcd803209
user:      wrstuden <wrstuden%NetBSD.org@localhost>
date:      Wed Apr 07 05:47:37 1999 +0000

description:
Fix obscure bug in namei(), which was the cause of PR 7306.

The problem is that if "sl" is a symbolic link, a lookup on "sl/"
will be flagged as the last component. Thus VOP_LOOKUP will lock
the parent directory if LOCKPARENT is set. In order for the symbolic
link to be resolved, this lock needs to be released. namei() would
test for this by checking if ni_pathlen == 1, which it wouldn't as
"/" is left in the name, and namei() would not unlock the parent.
The next call to lookup() to resolve the symbolic link would fail
as the parent was still locked.

diffstat:

 sys/kern/vfs_lookup.c |  4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diffs (18 lines):

diff -r ed5ffa578919 -r 7fffcd803209 sys/kern/vfs_lookup.c
--- a/sys/kern/vfs_lookup.c     Wed Apr 07 05:34:32 1999 +0000
+++ b/sys/kern/vfs_lookup.c     Wed Apr 07 05:47:37 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: vfs_lookup.c,v 1.28 1998/08/04 04:03:19 perry Exp $    */
+/*     $NetBSD: vfs_lookup.c,v 1.29 1999/04/07 05:47:37 wrstuden Exp $ */
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -164,7 +164,7 @@
                                cnp->cn_flags |= HASBUF;
                        return (0);
                }
-               if ((cnp->cn_flags & LOCKPARENT) && ndp->ni_pathlen == 1)
+               if ((cnp->cn_flags & LOCKPARENT) && (cnp->cn_flags & ISLASTCN))
                        VOP_UNLOCK(ndp->ni_dvp, 0);
                if (ndp->ni_loopcnt++ >= MAXSYMLINKS) {
                        error = ELOOP;



Home | Main Index | Thread Index | Old Index