Now that MPSAFE flag is gone, we can arrange code a bit better.
This commit is contained in:
parent
b108953c6f
commit
4bbe7b0c20
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=246177
@ -187,8 +187,8 @@ sys_quotactl(td, uap)
|
||||
AUDIT_ARG_UID(uap->uid);
|
||||
if (!prison_allow(td->td_ucred, PR_ALLOW_QUOTAS))
|
||||
return (EPERM);
|
||||
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | AUDITVNODE1,
|
||||
UIO_USERSPACE, uap->path, td);
|
||||
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | AUDITVNODE1, UIO_USERSPACE,
|
||||
uap->path, td);
|
||||
if ((error = namei(&nd)) != 0)
|
||||
return (error);
|
||||
NDFREE(&nd, NDF_ONLY_PNBUF);
|
||||
@ -293,8 +293,8 @@ kern_statfs(struct thread *td, char *path, enum uio_seg pathseg,
|
||||
int error;
|
||||
struct nameidata nd;
|
||||
|
||||
NDINIT(&nd, LOOKUP, FOLLOW | LOCKSHARED | LOCKLEAF |
|
||||
AUDITVNODE1, pathseg, path, td);
|
||||
NDINIT(&nd, LOOKUP, FOLLOW | LOCKSHARED | LOCKLEAF | AUDITVNODE1,
|
||||
pathseg, path, td);
|
||||
error = namei(&nd);
|
||||
if (error)
|
||||
return (error);
|
||||
@ -871,8 +871,8 @@ sys_chroot(td, uap)
|
||||
error = priv_check(td, PRIV_VFS_CHROOT);
|
||||
if (error)
|
||||
return (error);
|
||||
NDINIT(&nd, LOOKUP, FOLLOW | LOCKSHARED | LOCKLEAF |
|
||||
AUDITVNODE1, UIO_USERSPACE, uap->path, td);
|
||||
NDINIT(&nd, LOOKUP, FOLLOW | LOCKSHARED | LOCKLEAF | AUDITVNODE1,
|
||||
UIO_USERSPACE, uap->path, td);
|
||||
error = namei(&nd);
|
||||
if (error)
|
||||
goto error;
|
||||
@ -1077,8 +1077,8 @@ kern_openat(struct thread *td, int fd, char *path, enum uio_seg pathseg,
|
||||
/* Set the flags early so the finit in devfs can pick them up. */
|
||||
fp->f_flag = flags & FMASK;
|
||||
cmode = ((mode &~ fdp->fd_cmask) & ALLPERMS) &~ S_ISTXT;
|
||||
NDINIT_ATRIGHTS(&nd, LOOKUP, FOLLOW | AUDITVNODE1, pathseg,
|
||||
path, fd, rights_needed, td);
|
||||
NDINIT_ATRIGHTS(&nd, LOOKUP, FOLLOW | AUDITVNODE1, pathseg, path, fd,
|
||||
rights_needed, td);
|
||||
td->td_dupfd = -1; /* XXX check for fdopen */
|
||||
error = vn_open(&nd, &flags, cmode, fp);
|
||||
if (error) {
|
||||
@ -1277,9 +1277,8 @@ kern_mknodat(struct thread *td, int fd, char *path, enum uio_seg pathseg,
|
||||
return (error);
|
||||
restart:
|
||||
bwillwrite();
|
||||
NDINIT_ATRIGHTS(&nd, CREATE,
|
||||
LOCKPARENT | SAVENAME | AUDITVNODE1, pathseg, path, fd,
|
||||
CAP_MKNOD, td);
|
||||
NDINIT_ATRIGHTS(&nd, CREATE, LOCKPARENT | SAVENAME | AUDITVNODE1,
|
||||
pathseg, path, fd, CAP_MKNOD, td);
|
||||
if ((error = namei(&nd)) != 0)
|
||||
return (error);
|
||||
vp = nd.ni_vp;
|
||||
@ -1398,9 +1397,8 @@ kern_mkfifoat(struct thread *td, int fd, char *path, enum uio_seg pathseg,
|
||||
AUDIT_ARG_MODE(mode);
|
||||
restart:
|
||||
bwillwrite();
|
||||
NDINIT_ATRIGHTS(&nd, CREATE,
|
||||
LOCKPARENT | SAVENAME | AUDITVNODE1, pathseg, path, fd,
|
||||
CAP_MKFIFO, td);
|
||||
NDINIT_ATRIGHTS(&nd, CREATE, LOCKPARENT | SAVENAME | AUDITVNODE1,
|
||||
pathseg, path, fd, CAP_MKFIFO, td);
|
||||
if ((error = namei(&nd)) != 0)
|
||||
return (error);
|
||||
if (nd.ni_vp != NULL) {
|
||||
@ -1539,8 +1537,7 @@ kern_linkat(struct thread *td, int fd1, int fd2, char *path1, char *path2,
|
||||
int error;
|
||||
|
||||
bwillwrite();
|
||||
NDINIT_AT(&nd, LOOKUP, follow | AUDITVNODE1, segflg, path1,
|
||||
fd1, td);
|
||||
NDINIT_AT(&nd, LOOKUP, follow | AUDITVNODE1, segflg, path1, fd1, td);
|
||||
|
||||
if ((error = namei(&nd)) != 0)
|
||||
return (error);
|
||||
@ -1554,8 +1551,8 @@ kern_linkat(struct thread *td, int fd1, int fd2, char *path1, char *path2,
|
||||
vrele(vp);
|
||||
return (error);
|
||||
}
|
||||
NDINIT_ATRIGHTS(&nd, CREATE, LOCKPARENT | SAVENAME |
|
||||
AUDITVNODE2, segflg, path2, fd2, CAP_CREATE, td);
|
||||
NDINIT_ATRIGHTS(&nd, CREATE, LOCKPARENT | SAVENAME | AUDITVNODE2,
|
||||
segflg, path2, fd2, CAP_CREATE, td);
|
||||
if ((error = namei(&nd)) == 0) {
|
||||
if (nd.ni_vp != NULL) {
|
||||
if (nd.ni_dvp == nd.ni_vp)
|
||||
@ -1647,8 +1644,8 @@ kern_symlinkat(struct thread *td, char *path1, int fd, char *path2,
|
||||
AUDIT_ARG_TEXT(syspath);
|
||||
restart:
|
||||
bwillwrite();
|
||||
NDINIT_ATRIGHTS(&nd, CREATE, LOCKPARENT | SAVENAME |
|
||||
AUDITVNODE1, segflg, path2, fd, CAP_CREATE, td);
|
||||
NDINIT_ATRIGHTS(&nd, CREATE, LOCKPARENT | SAVENAME | AUDITVNODE1,
|
||||
segflg, path2, fd, CAP_CREATE, td);
|
||||
if ((error = namei(&nd)) != 0)
|
||||
goto out;
|
||||
if (nd.ni_vp) {
|
||||
@ -1799,8 +1796,8 @@ kern_unlinkat(struct thread *td, int fd, char *path, enum uio_seg pathseg,
|
||||
|
||||
restart:
|
||||
bwillwrite();
|
||||
NDINIT_ATRIGHTS(&nd, DELETE, LOCKPARENT | LOCKLEAF |
|
||||
AUDITVNODE1, pathseg, path, fd, CAP_DELETE, td);
|
||||
NDINIT_ATRIGHTS(&nd, DELETE, LOCKPARENT | LOCKLEAF | AUDITVNODE1,
|
||||
pathseg, path, fd, CAP_DELETE, td);
|
||||
if ((error = namei(&nd)) != 0)
|
||||
return (error == EINVAL ? EPERM : error);
|
||||
vp = nd.ni_vp;
|
||||
@ -2307,8 +2304,8 @@ kern_statat_vnhook(struct thread *td, int flag, int fd, char *path,
|
||||
return (EINVAL);
|
||||
|
||||
NDINIT_ATRIGHTS(&nd, LOOKUP, ((flag & AT_SYMLINK_NOFOLLOW) ? NOFOLLOW :
|
||||
FOLLOW) | LOCKSHARED | LOCKLEAF | AUDITVNODE1, pathseg,
|
||||
path, fd, CAP_FSTAT, td);
|
||||
FOLLOW) | LOCKSHARED | LOCKLEAF | AUDITVNODE1, pathseg, path, fd,
|
||||
CAP_FSTAT, td);
|
||||
|
||||
if ((error = namei(&nd)) != 0)
|
||||
return (error);
|
||||
@ -2484,7 +2481,8 @@ sys_lpathconf(td, uap)
|
||||
} */ *uap;
|
||||
{
|
||||
|
||||
return (kern_pathconf(td, uap->path, UIO_USERSPACE, uap->name, NOFOLLOW));
|
||||
return (kern_pathconf(td, uap->path, UIO_USERSPACE, uap->name,
|
||||
NOFOLLOW));
|
||||
}
|
||||
|
||||
int
|
||||
@ -2570,8 +2568,8 @@ kern_readlinkat(struct thread *td, int fd, char *path, enum uio_seg pathseg,
|
||||
if (count > IOSIZE_MAX)
|
||||
return (EINVAL);
|
||||
|
||||
NDINIT_AT(&nd, LOOKUP, NOFOLLOW | LOCKSHARED | LOCKLEAF |
|
||||
AUDITVNODE1, pathseg, path, fd, td);
|
||||
NDINIT_AT(&nd, LOOKUP, NOFOLLOW | LOCKSHARED | LOCKLEAF | AUDITVNODE1,
|
||||
pathseg, path, fd, td);
|
||||
|
||||
if ((error = namei(&nd)) != 0)
|
||||
return (error);
|
||||
@ -2668,8 +2666,7 @@ sys_chflags(td, uap)
|
||||
struct nameidata nd;
|
||||
|
||||
AUDIT_ARG_FFLAGS(uap->flags);
|
||||
NDINIT(&nd, LOOKUP, FOLLOW | AUDITVNODE1, UIO_USERSPACE,
|
||||
uap->path, td);
|
||||
NDINIT(&nd, LOOKUP, FOLLOW | AUDITVNODE1, UIO_USERSPACE, uap->path, td);
|
||||
if ((error = namei(&nd)) != 0)
|
||||
return (error);
|
||||
NDFREE(&nd, NDF_ONLY_PNBUF);
|
||||
@ -2693,8 +2690,8 @@ sys_lchflags(td, uap)
|
||||
struct nameidata nd;
|
||||
|
||||
AUDIT_ARG_FFLAGS(uap->flags);
|
||||
NDINIT(&nd, LOOKUP, NOFOLLOW | AUDITVNODE1, UIO_USERSPACE,
|
||||
uap->path, td);
|
||||
NDINIT(&nd, LOOKUP, NOFOLLOW | AUDITVNODE1, UIO_USERSPACE, uap->path,
|
||||
td);
|
||||
if ((error = namei(&nd)) != 0)
|
||||
return (error);
|
||||
NDFREE(&nd, NDF_ONLY_PNBUF);
|
||||
@ -2850,8 +2847,8 @@ kern_fchmodat(struct thread *td, int fd, char *path, enum uio_seg pathseg,
|
||||
|
||||
AUDIT_ARG_MODE(mode);
|
||||
follow = (flag & AT_SYMLINK_NOFOLLOW) ? NOFOLLOW : FOLLOW;
|
||||
NDINIT_ATRIGHTS(&nd, LOOKUP, follow | AUDITVNODE1, pathseg,
|
||||
path, fd, CAP_FCHMOD, td);
|
||||
NDINIT_ATRIGHTS(&nd, LOOKUP, follow | AUDITVNODE1, pathseg, path, fd,
|
||||
CAP_FCHMOD, td);
|
||||
if ((error = namei(&nd)) != 0)
|
||||
return (error);
|
||||
NDFREE(&nd, NDF_ONLY_PNBUF);
|
||||
@ -2980,8 +2977,8 @@ kern_fchownat(struct thread *td, int fd, char *path, enum uio_seg pathseg,
|
||||
|
||||
AUDIT_ARG_OWNER(uid, gid);
|
||||
follow = (flag & AT_SYMLINK_NOFOLLOW) ? NOFOLLOW : FOLLOW;
|
||||
NDINIT_ATRIGHTS(&nd, LOOKUP, follow | AUDITVNODE1, pathseg,
|
||||
path, fd, CAP_FCHOWN, td);
|
||||
NDINIT_ATRIGHTS(&nd, LOOKUP, follow | AUDITVNODE1, pathseg, path, fd,
|
||||
CAP_FCHOWN, td);
|
||||
|
||||
if ((error = namei(&nd)) != 0)
|
||||
return (error);
|
||||
@ -3186,8 +3183,8 @@ kern_utimesat(struct thread *td, int fd, char *path, enum uio_seg pathseg,
|
||||
|
||||
if ((error = getutimes(tptr, tptrseg, ts)) != 0)
|
||||
return (error);
|
||||
NDINIT_ATRIGHTS(&nd, LOOKUP, FOLLOW | AUDITVNODE1, pathseg,
|
||||
path, fd, CAP_FUTIMES, td);
|
||||
NDINIT_ATRIGHTS(&nd, LOOKUP, FOLLOW | AUDITVNODE1, pathseg, path, fd,
|
||||
CAP_FUTIMES, td);
|
||||
|
||||
if ((error = namei(&nd)) != 0)
|
||||
return (error);
|
||||
@ -3508,8 +3505,8 @@ kern_renameat(struct thread *td, int oldfd, char *old, int newfd, char *new,
|
||||
NDINIT_ATRIGHTS(&fromnd, DELETE, LOCKPARENT | LOCKLEAF | SAVESTART |
|
||||
AUDITVNODE1, pathseg, old, oldfd, CAP_DELETE, td);
|
||||
#else
|
||||
NDINIT_ATRIGHTS(&fromnd, DELETE, WANTPARENT | SAVESTART |
|
||||
AUDITVNODE1, pathseg, old, oldfd, CAP_DELETE, td);
|
||||
NDINIT_ATRIGHTS(&fromnd, DELETE, WANTPARENT | SAVESTART | AUDITVNODE1,
|
||||
pathseg, old, oldfd, CAP_DELETE, td);
|
||||
#endif
|
||||
|
||||
if ((error = namei(&fromnd)) != 0)
|
||||
@ -3654,8 +3651,8 @@ kern_mkdirat(struct thread *td, int fd, char *path, enum uio_seg segflg,
|
||||
AUDIT_ARG_MODE(mode);
|
||||
restart:
|
||||
bwillwrite();
|
||||
NDINIT_ATRIGHTS(&nd, CREATE, LOCKPARENT | SAVENAME |
|
||||
AUDITVNODE1, segflg, path, fd, CAP_MKDIR, td);
|
||||
NDINIT_ATRIGHTS(&nd, CREATE, LOCKPARENT | SAVENAME | AUDITVNODE1,
|
||||
segflg, path, fd, CAP_MKDIR, td);
|
||||
nd.ni_cnd.cn_flags |= WILLBEDIR;
|
||||
if ((error = namei(&nd)) != 0)
|
||||
return (error);
|
||||
@ -3738,8 +3735,8 @@ kern_rmdirat(struct thread *td, int fd, char *path, enum uio_seg pathseg)
|
||||
|
||||
restart:
|
||||
bwillwrite();
|
||||
NDINIT_ATRIGHTS(&nd, DELETE, LOCKPARENT | LOCKLEAF |
|
||||
AUDITVNODE1, pathseg, path, fd, CAP_RMDIR, td);
|
||||
NDINIT_ATRIGHTS(&nd, DELETE, LOCKPARENT | LOCKLEAF | AUDITVNODE1,
|
||||
pathseg, path, fd, CAP_RMDIR, td);
|
||||
if ((error = namei(&nd)) != 0)
|
||||
return (error);
|
||||
vp = nd.ni_vp;
|
||||
@ -4121,8 +4118,8 @@ sys_revoke(td, uap)
|
||||
int error;
|
||||
struct nameidata nd;
|
||||
|
||||
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | AUDITVNODE1,
|
||||
UIO_USERSPACE, uap->path, td);
|
||||
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | AUDITVNODE1, UIO_USERSPACE,
|
||||
uap->path, td);
|
||||
if ((error = namei(&nd)) != 0)
|
||||
return (error);
|
||||
vp = nd.ni_vp;
|
||||
@ -4228,8 +4225,8 @@ sys_lgetfh(td, uap)
|
||||
error = priv_check(td, PRIV_VFS_GETFH);
|
||||
if (error)
|
||||
return (error);
|
||||
NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | AUDITVNODE1,
|
||||
UIO_USERSPACE, uap->fname, td);
|
||||
NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | AUDITVNODE1, UIO_USERSPACE,
|
||||
uap->fname, td);
|
||||
error = namei(&nd);
|
||||
if (error)
|
||||
return (error);
|
||||
@ -4264,8 +4261,8 @@ sys_getfh(td, uap)
|
||||
error = priv_check(td, PRIV_VFS_GETFH);
|
||||
if (error)
|
||||
return (error);
|
||||
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | AUDITVNODE1,
|
||||
UIO_USERSPACE, uap->fname, td);
|
||||
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | AUDITVNODE1, UIO_USERSPACE,
|
||||
uap->fname, td);
|
||||
error = namei(&nd);
|
||||
if (error)
|
||||
return (error);
|
||||
|
Loading…
Reference in New Issue
Block a user