Date: Thu, 21 Jun 2007 11:28:29 GMT From: Roman Divacky <rdivacky@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 122088 for review Message-ID: <200706211128.l5LBSTgO042587@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=122088 Change 122088 by rdivacky@rdivacky_witten on 2007/06/21 11:27:47 Check for absolute path in namei() when startdir is NULL when called from *at context. Affected files ... .. //depot/projects/soc2007/rdivacky/linux_at/sys/kern/vfs_lookup.c#6 edit .. //depot/projects/soc2007/rdivacky/linux_at/sys/kern/vfs_syscalls.c#24 edit .. //depot/projects/soc2007/rdivacky/linux_at/sys/sys/namei.h#5 edit Differences ... ==== //depot/projects/soc2007/rdivacky/linux_at/sys/kern/vfs_lookup.c#6 (text+ko) ==== @@ -195,8 +195,12 @@ if (ndp->ni_startdir) dp = ndp->ni_startdir; - else + else { dp = fdp->fd_cdir; + /* we might have raced so check it */ + if ((cnp->cn_flags & AT) && (cnp->cn_pnbuf[0] != '/')) + return (EBADF); + } vfslocked = VFS_LOCK_GIANT(dp->v_mount); VREF(dp); FILEDESC_SUNLOCK(fdp); ==== //depot/projects/soc2007/rdivacky/linux_at/sys/kern/vfs_syscalls.c#24 (text+ko) ==== @@ -1027,7 +1027,7 @@ if (error && !kern_absolute_path(path, pathseg)) return (error); - NDINIT_AT(&nd, LOOKUP, FOLLOW | AUDITVNODE1 | MPSAFE, pathseg, path, td, dir_vn); + NDINIT_AT(&nd, LOOKUP, AT | FOLLOW | AUDITVNODE1 | MPSAFE, pathseg, path, td, dir_vn); if ((flags & O_ACCMODE) == O_ACCMODE) { error = EINVAL; @@ -1244,7 +1244,7 @@ if (error && !kern_absolute_path(path, pathseg)) return (error); bwillwrite(); - NDINIT_AT(&nd, CREATE, LOCKPARENT | SAVENAME | MPSAFE | AUDITVNODE1, + NDINIT_AT(&nd, CREATE, AT | LOCKPARENT | SAVENAME | MPSAFE | AUDITVNODE1, pathseg, path, td, dir_vn); if ((error = namei(&nd)) != 0) { if (dir_vn) @@ -1371,7 +1371,7 @@ if (error && !kern_absolute_path(path, pathseg)) return (error); bwillwrite(); - NDINIT_AT(&nd, CREATE, LOCKPARENT | SAVENAME | MPSAFE | AUDITVNODE1, + NDINIT_AT(&nd, CREATE, AT | LOCKPARENT | SAVENAME | MPSAFE | AUDITVNODE1, pathseg, path, td, dir_vn); if ((error = namei(&nd)) != 0) { if (dir_vn) @@ -1513,13 +1513,13 @@ if (error && !kern_absolute_path(path, segflg)) return (error); - NDINIT_AT(&ndp, LOOKUP, FOLLOW | MPSAFE | AUDITVNODE1, segflg, path, td, pdir_vn); + NDINIT_AT(&ndp, LOOKUP, AT | FOLLOW | MPSAFE | AUDITVNODE1, segflg, path, td, pdir_vn); error = kern_get_at(td, newdirfd, &ldir_vn); if (error && !kern_absolute_path(link, segflg)) return (error); - NDINIT_AT(&ndl, CREATE, LOCKPARENT | SAVENAME| MPSAFE | AUDITVNODE1, segflg, + NDINIT_AT(&ndl, CREATE, AT | LOCKPARENT | SAVENAME| MPSAFE | AUDITVNODE1, segflg, link, td, ldir_vn); bwillwrite(); @@ -1632,7 +1632,7 @@ if (error && !kern_absolute_path(link, segflg)) return (error); bwillwrite(); - NDINIT_AT(&nd, CREATE, LOCKPARENT | SAVENAME | MPSAFE | AUDITVNODE1, + NDINIT_AT(&nd, CREATE, AT | LOCKPARENT | SAVENAME | MPSAFE | AUDITVNODE1, segflg, link, td, dir_vn); if ((error = namei(&nd)) != 0) goto out; @@ -1781,7 +1781,7 @@ if (error && !kern_absolute_path(path, pathseg)) return (error); bwillwrite(); - NDINIT_AT(&nd, DELETE, LOCKPARENT | LOCKLEAF | MPSAFE | AUDITVNODE1, + NDINIT_AT(&nd, DELETE, AT | LOCKPARENT | LOCKLEAF | MPSAFE | AUDITVNODE1, pathseg, path, td, dir_vn); if ((error = namei(&nd)) != 0) { if (dir_vn) @@ -2055,7 +2055,7 @@ if (error && !kern_absolute_path(path, pathseg)) return (error); - NDINIT_AT(&nd, LOOKUP, FOLLOW | LOCKLEAF | MPSAFE | AUDITVNODE1, + NDINIT_AT(&nd, LOOKUP, AT | FOLLOW | LOCKLEAF | MPSAFE | AUDITVNODE1, pathseg, path, td, dir_vn); /* @@ -2265,7 +2265,7 @@ if (error && !kern_absolute_path(path, pathseg)) return (error); - NDINIT_AT(&nd, LOOKUP, FOLLOW | LOCKSHARED | LOCKLEAF | AUDITVNODE1 | + NDINIT_AT(&nd, LOOKUP, AT | FOLLOW | LOCKSHARED | LOCKLEAF | AUDITVNODE1 | MPSAFE, pathseg, path, td, dir_vn); if ((error = namei(&nd)) != 0) @@ -2334,7 +2334,7 @@ if (error && !kern_absolute_path(path, pathseg)) return (error); - NDINIT_AT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | LOCKSHARED | AUDITVNODE1 | + NDINIT_AT(&nd, LOOKUP, AT | NOFOLLOW | LOCKLEAF | LOCKSHARED | AUDITVNODE1 | MPSAFE, pathseg, path, td, dir_vn); if ((error = namei(&nd)) != 0) @@ -2527,7 +2527,7 @@ if (error && !kern_absolute_path(path, pathseg)) return (error); - NDINIT_AT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | MPSAFE | AUDITVNODE1, pathseg, + NDINIT_AT(&nd, LOOKUP, AT | NOFOLLOW | LOCKLEAF | MPSAFE | AUDITVNODE1, pathseg, path, td, dir_vn); if ((error = namei(&nd)) != 0) @@ -2774,7 +2774,7 @@ if (error && !kern_absolute_path(path, pathseg)) return (error); - NDINIT_AT(&nd, LOOKUP, FOLLOW | MPSAFE | AUDITVNODE1, pathseg, path, td, dir_vn); + NDINIT_AT(&nd, LOOKUP, AT | FOLLOW | MPSAFE | AUDITVNODE1, pathseg, path, td, dir_vn); if ((error = namei(&nd)) != 0) goto out; @@ -2934,7 +2934,7 @@ if (error && !kern_absolute_path(path, pathseg)) return (error); - NDINIT_AT(&nd, LOOKUP, FOLLOW | MPSAFE | AUDITVNODE1, pathseg, path, td, dir_vn); + NDINIT_AT(&nd, LOOKUP, AT | FOLLOW | MPSAFE | AUDITVNODE1, pathseg, path, td, dir_vn); if ((error = namei(&nd)) != 0) goto out; @@ -2991,7 +2991,7 @@ if (error && !kern_absolute_path(path, pathseg)) return (error); - NDINIT_AT(&nd, LOOKUP, NOFOLLOW | MPSAFE | AUDITVNODE1, pathseg, path, td, dir_vn); + NDINIT_AT(&nd, LOOKUP, AT | NOFOLLOW | MPSAFE | AUDITVNODE1, pathseg, path, td, dir_vn); if ((error = namei(&nd)) != 0) goto out; @@ -3165,7 +3165,7 @@ if (error && !kern_absolute_path(path, pathseg)) return (error); - NDINIT_AT(&nd, LOOKUP, FOLLOW | AUDITVNODE1 | MPSAFE, pathseg, path, td, dir_vn); + NDINIT_AT(&nd, LOOKUP, AT |FOLLOW | AUDITVNODE1 | MPSAFE, pathseg, path, td, dir_vn); if ((error = getutimes(tptr, tptrseg, ts)) != 0) goto out; @@ -3551,13 +3551,13 @@ return (error); #ifdef MAC - NDINIT_AT(&fromnd, DELETE, LOCKPARENT | LOCKLEAF | SAVESTART | MPSAFE | + NDINIT_AT(&fromnd, DELETE, AT | LOCKPARENT | LOCKLEAF | SAVESTART | MPSAFE | AUDITVNODE1, pathseg, from, td, fdir_vn); #else - NDINIT_AT(&fromnd, DELETE, WANTPARENT | SAVESTART | MPSAFE | + NDINIT_AT(&fromnd, DELETE, AT | WANTPARENT | SAVESTART | MPSAFE | AUDITVNODE1, pathseg, from, td, fdir_vn); #endif - NDINIT_AT(&tond, RENAME, LOCKPARENT | LOCKLEAF | NOCACHE | SAVESTART | + NDINIT_AT(&tond, RENAME, AT | LOCKPARENT | LOCKLEAF | NOCACHE | SAVESTART | MPSAFE | AUDITVNODE2, pathseg, to, td, tdir_vn); bwillwrite(); @@ -3706,7 +3706,7 @@ if (error && !kern_absolute_path(path, segflg)) return (error); bwillwrite(); - NDINIT_AT(&nd, CREATE, LOCKPARENT | SAVENAME | MPSAFE | AUDITVNODE1, + NDINIT_AT(&nd, CREATE, AT | LOCKPARENT | SAVENAME | MPSAFE | AUDITVNODE1, segflg, path, td, dir_vn); nd.ni_cnd.cn_flags |= WILLBEDIR; if ((error = namei(&nd)) != 0) { @@ -3810,7 +3810,7 @@ if (error && !kern_absolute_path(path, pathseg)) return (error); bwillwrite(); - NDINIT_AT(&nd, DELETE, LOCKPARENT | LOCKLEAF | MPSAFE | AUDITVNODE1, + NDINIT_AT(&nd, DELETE, AT | LOCKPARENT | LOCKLEAF | MPSAFE | AUDITVNODE1, pathseg, path, td, dir_vn); if ((error = namei(&nd)) != 0) return (error); ==== //depot/projects/soc2007/rdivacky/linux_at/sys/sys/namei.h#5 (text+ko) ==== @@ -109,8 +109,9 @@ #define NOCACHE 0x0020 /* name must not be left in cache */ #define FOLLOW 0x0040 /* follow symbolic links */ #define LOCKSHARED 0x0100 /* Shared lock leaf */ +#define AT 0x0200 /* called from *at context */ #define NOFOLLOW 0x0000 /* do not follow symbolic links (pseudo) */ -#define MODMASK 0x01fc /* mask of operational modifiers */ +#define MODMASK 0x03fc /* mask of operational modifiers */ /* * Namei parameter descriptors. *
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200706211128.l5LBSTgO042587>