From owner-freebsd-current Fri Nov 10 18:12:27 1995 Return-Path: owner-current Received: (from root@localhost) by freefall.freebsd.org (8.6.12/8.6.6) id SAA24179 for current-outgoing; Fri, 10 Nov 1995 18:12:27 -0800 Received: from godzilla.zeta.org.au (godzilla.zeta.org.au [203.2.228.19]) by freefall.freebsd.org (8.6.12/8.6.6) with ESMTP id SAA24174 for ; Fri, 10 Nov 1995 18:12:22 -0800 Received: (from bde@localhost) by godzilla.zeta.org.au (8.6.9/8.6.9) id NAA01399 for current@freebsd.org; Sat, 11 Nov 1995 13:09:59 +1100 Date: Sat, 11 Nov 1995 13:09:59 +1100 From: Bruce Evans Message-Id: <199511110209.NAA01399@godzilla.zeta.org.au> To: current@freebsd.org Subject: old bugs in vfs_lookup.c Sender: owner-current@freebsd.org Precedence: bulk I've reported these bugs and fixes before but there wasn't enough discussion. 1. The empty pathname is allowed as an alias for ".". This breaks POSIX conformance for every syscall that involves a pathname. 2. lstat() depletes the namei cache. Thus file system traversals often blow away the cache entries for everything they look at. Bruce *** vfs_lookup.c~ Mon Oct 23 01:47:39 1995 --- vfs_lookup.c Mon Oct 23 01:47:40 1995 *************** *** 51,54 **** --- 51,55 ---- #include #include + #include #ifdef KTRACE *************** *** 111,114 **** --- 112,127 ---- error = copyinstr(ndp->ni_dirp, cnp->cn_pnbuf, MAXPATHLEN, (u_int *)&ndp->ni_pathlen); + + /* + * Don't allow empty pathname. + * Log the error until we find the standard utilities that cause it. + */ + if (!error && *cnp->cn_pnbuf == '\0') { + log(LOG_ERR, + "pid %d (%s) called namei with an empty pathname\n", + cnp->cn_proc->p_pid, cnp->cn_proc->p_comm); + error = ENOENT; + } + if (error) { free(cnp->cn_pnbuf, M_NAMEI); *************** *** 267,272 **** wantparent = cnp->cn_flags & (LOCKPARENT | WANTPARENT); docache = (cnp->cn_flags & NOCACHE) ^ NOCACHE; if (cnp->cn_nameiop == DELETE || ! (wantparent && cnp->cn_nameiop != CREATE)) docache = 0; rdonly = cnp->cn_flags & RDONLY; --- 280,297 ---- wantparent = cnp->cn_flags & (LOCKPARENT | WANTPARENT); docache = (cnp->cn_flags & NOCACHE) ^ NOCACHE; + /* + * XXX the following seems to be just to recover from not setting + * NOCACHE for the DELETE cases (unlink, rmdir and the rename + * source). In BSD4.4lite[2], docache was also cleared for the + * (wantparent && cnp->cn_nameiop == LOOKUP) case. This case + * seems to only occur for lstat and olstat, when it is wrong + * to clear docache. This case probably didn't occur before + * BSD4.4lite. LOCKPARENT was introduced for lstat to support + * the new behaviour of symlinks (attributes inherited from the + * parent. + */ if (cnp->cn_nameiop == DELETE || ! (wantparent && cnp->cn_nameiop != CREATE && ! cnp->cn_nameiop != LOOKUP)) docache = 0; rdonly = cnp->cn_flags & RDONLY;