Date: Thu, 21 Jun 2007 10:01:06 GMT From: Roman Divacky <rdivacky@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 122077 for review Message-ID: <200706211001.l5LA16H4021185@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=122077 Change 122077 by rdivacky@rdivacky_witten on 2007/06/21 10:00:59 Introduce kern_absolute_path which checks whether a given path is absolute or not by checking first char for being '/'. Use this function to implement BADF semantic of *at syscalls. Affected files ... .. //depot/projects/soc2007/rdivacky/linux_at/sys/kern/vfs_syscalls.c#21 edit Differences ... ==== //depot/projects/soc2007/rdivacky/linux_at/sys/kern/vfs_syscalls.c#21 (text+ko) ==== @@ -88,6 +88,7 @@ static int kern_get_at(struct thread *td, int dirfd, struct vnode **dir_vn); static int vn_access(struct vnode *vp, int user_flags, struct ucred *cred, struct thread *td); +static int kern_absolute_path(char *path, enum uio_seg pathseg); /* * The module initialization routine for POSIX asynchronous I/O will @@ -981,6 +982,22 @@ return (0); } +/* Check whether a path is an absolute path. */ +static int kern_absolute_path(char *path, enum uio_seg pathseg) +{ + int error, len; + char buf[PATH_MAX]; + + if (pathseg == UIO_SYSSPACE) { + return (path[0] == '/'); + } else { + error = copyinstr(path, buf, PATH_MAX, &len); + if (error) + return 1; /* we want to fail */ + return (buf[0] == '/'); + } +} + int kern_openat(struct thread *td, char *path, enum uio_seg pathseg, int flags, int mode, int dirfd) @@ -1004,7 +1021,7 @@ /* XXX: audit dirfd */ error = kern_get_at(td, dirfd, &dir_vn); - if (error) + if (error && !kern_absolute_path(path, pathseg)) return (error); NDINIT_AT(&nd, LOOKUP, FOLLOW | AUDITVNODE1 | MPSAFE, pathseg, path, td, dir_vn); @@ -1221,7 +1238,7 @@ if (dir_vn) vrele(dir_vn); error = kern_get_at(td, dirfd, &dir_vn); - if (error) + if (error && !kern_absolute_path(path, pathseg)) return (error); bwillwrite(); NDINIT_AT(&nd, CREATE, LOCKPARENT | SAVENAME | MPSAFE | AUDITVNODE1, @@ -1348,7 +1365,7 @@ if (dir_vn) vrele(dir_vn); error = kern_get_at(td, dirfd, &dir_vn); - if (error) + if (error && !kern_absolute_path(path, pathseg)) return (error); bwillwrite(); NDINIT_AT(&nd, CREATE, LOCKPARENT | SAVENAME | MPSAFE | AUDITVNODE1, @@ -1490,13 +1507,13 @@ int lvfslocked; error = kern_get_at(td, olddirfd, &pdir_vn); - if (error) + if (error && !kern_absolute_path(path, segflg)) return (error); NDINIT_AT(&ndp, LOOKUP, FOLLOW | MPSAFE | AUDITVNODE1, segflg, path, td, pdir_vn); error = kern_get_at(td, newdirfd, &ldir_vn); - if (error) + if (error && !kern_absolute_path(link, segflg)) return (error); NDINIT_AT(&ndl, CREATE, LOCKPARENT | SAVENAME| MPSAFE | AUDITVNODE1, segflg, @@ -1609,7 +1626,7 @@ if (dir_vn) vrele(dir_vn); error = kern_get_at(td, dirfd, &dir_vn); - if (error) + if (error && !kern_absolute_path(link, segflg)) return (error); bwillwrite(); NDINIT_AT(&nd, CREATE, LOCKPARENT | SAVENAME | MPSAFE | AUDITVNODE1, @@ -1758,7 +1775,7 @@ if (dir_vn) vrele(dir_vn); error = kern_get_at(td, dirfd, &dir_vn); - if (error) + if (error && !kern_absolute_path(path, pathseg)) return (error); bwillwrite(); NDINIT_AT(&nd, DELETE, LOCKPARENT | LOCKLEAF | MPSAFE | AUDITVNODE1, @@ -2032,7 +2049,7 @@ int vfslocked; error = kern_get_at(td, dirfd, &dir_vn); - if (error) + if (error && !kern_absolute_path(path, pathseg)) return (error); NDINIT_AT(&nd, LOOKUP, FOLLOW | LOCKLEAF | MPSAFE | AUDITVNODE1, @@ -2242,7 +2259,7 @@ int error, vfslocked; error = kern_get_at(td, dirfd, &dir_vn); - if (error) + if (error && !kern_absolute_path(path, pathseg)) return (error); NDINIT_AT(&nd, LOOKUP, FOLLOW | LOCKSHARED | LOCKLEAF | AUDITVNODE1 | @@ -2311,7 +2328,7 @@ int error, vfslocked; error = kern_get_at(td, dirfd, &dir_vn); - if (error) + if (error && !kern_absolute_path(path, pathseg)) return (error); NDINIT_AT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | LOCKSHARED | AUDITVNODE1 | @@ -2504,7 +2521,7 @@ int error, vfslocked; error = kern_get_at(td, dirfd, &dir_vn); - if (error) + if (error && !kern_absolute_path(path, pathseg)) return (error); NDINIT_AT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | MPSAFE | AUDITVNODE1, pathseg, @@ -2751,7 +2768,7 @@ int error, vfslocked; error = kern_get_at(td, dirfd, &dir_vn); - if (error) + if (error && !kern_absolute_path(path, pathseg)) return (error); NDINIT_AT(&nd, LOOKUP, FOLLOW | MPSAFE | AUDITVNODE1, pathseg, path, td, dir_vn); @@ -2911,7 +2928,7 @@ int error, vfslocked; error = kern_get_at(td, dirfd, &dir_vn); - if (error) + if (error && !kern_absolute_path(path, pathseg)) return (error); NDINIT_AT(&nd, LOOKUP, FOLLOW | MPSAFE | AUDITVNODE1, pathseg, path, td, dir_vn); @@ -2968,7 +2985,7 @@ int error, vfslocked; error = kern_get_at(td, dirfd, &dir_vn); - if (error) + if (error && !kern_absolute_path(path, pathseg)) return (error); NDINIT_AT(&nd, LOOKUP, NOFOLLOW | MPSAFE | AUDITVNODE1, pathseg, path, td, dir_vn); @@ -3142,7 +3159,7 @@ int error, vfslocked; error = kern_get_at(td, dirfd, &dir_vn); - if (error) + if (error && !kern_absolute_path(path, pathseg)) return (error); NDINIT_AT(&nd, LOOKUP, FOLLOW | AUDITVNODE1 | MPSAFE, pathseg, path, td, dir_vn); @@ -3524,10 +3541,10 @@ int error; error = kern_get_at(td, fdirfd, &fdir_vn); - if (error) + if (error && !kern_absolute_path(from, pathseg)) return (error); error = kern_get_at(td, tdirfd, &tdir_vn); - if (error) + if (error && !kern_absolute_path(to, pathseg)) return (error); #ifdef MAC @@ -3683,7 +3700,7 @@ if (dir_vn) vrele(dir_vn); error = kern_get_at(td, dirfd, &dir_vn); - if (error) + if (error && !kern_absolute_path(path, segflg)) return (error); bwillwrite(); NDINIT_AT(&nd, CREATE, LOCKPARENT | SAVENAME | MPSAFE | AUDITVNODE1, @@ -3787,7 +3804,7 @@ restart: error = kern_get_at(td, dirfd, &dir_vn); - if (error) + if (error && !kern_absolute_path(path, pathseg)) return (error); bwillwrite(); NDINIT_AT(&nd, DELETE, LOCKPARENT | LOCKLEAF | MPSAFE | AUDITVNODE1,
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200706211001.l5LA16H4021185>