aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/vfs_syscalls.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/kern/vfs_syscalls.c')
-rw-r--r--sys/kern/vfs_syscalls.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
index 9704e9c160a8..aeb5657452dc 100644
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -2571,6 +2571,8 @@ kern_statat(struct thread *td, int flag, int fd, const char *path,
}
error = VOP_STAT(nd.ni_vp, sbp, td->td_ucred, NOCRED);
NDFREE_PNBUF(&nd);
+ KASSERT(error != 0 || VN_ISDEV(nd.ni_vp) || sbp->st_rdev == NODEV,
+ ("st_rdev should be NODEV unless the file is a device node"));
vput(nd.ni_vp);
#ifdef __STAT_TIME_T_EXT
sbp->st_atim_ext = 0;
@@ -2839,7 +2841,7 @@ setfflags(struct thread *td, struct vnode *vp, u_long flags)
* if they are allowed to set flags and programs assume that
* chown can't fail when done as root.
*/
- if (vp->v_type == VCHR || vp->v_type == VBLK) {
+ if (VN_ISDEV(vp)) {
error = priv_check(td, PRIV_VFS_CHFLAGS_DEV);
if (error != 0)
return (error);
@@ -5050,15 +5052,16 @@ kern_copy_file_range(struct thread *td, int infd, off_t *inoffp, int outfd,
size_t retlen;
void *rl_rcookie, *rl_wcookie;
off_t inoff, outoff, savinoff, savoutoff;
- bool foffsets_locked;
+ bool foffsets_locked, foffsets_set;
infp = outfp = NULL;
rl_rcookie = rl_wcookie = NULL;
foffsets_locked = false;
+ foffsets_set = false;
error = 0;
retlen = 0;
- if (flags != 0) {
+ if ((flags & ~COPY_FILE_RANGE_USERFLAGS) != 0) {
error = EINVAL;
goto out;
}
@@ -5122,6 +5125,8 @@ kern_copy_file_range(struct thread *td, int infd, off_t *inoffp, int outfd,
}
foffset_lock_pair(infp1, &inoff, outfp1, &outoff, 0);
foffsets_locked = true;
+ } else {
+ foffsets_set = true;
}
savinoff = inoff;
savoutoff = outoff;
@@ -5180,11 +5185,12 @@ out:
vn_rangelock_unlock(invp, rl_rcookie);
if (rl_wcookie != NULL)
vn_rangelock_unlock(outvp, rl_wcookie);
+ if ((foffsets_locked || foffsets_set) &&
+ (error == EINTR || error == ERESTART)) {
+ inoff = savinoff;
+ outoff = savoutoff;
+ }
if (foffsets_locked) {
- if (error == EINTR || error == ERESTART) {
- inoff = savinoff;
- outoff = savoutoff;
- }
if (inoffp == NULL)
foffset_unlock(infp, inoff, 0);
else
@@ -5193,6 +5199,9 @@ out:
foffset_unlock(outfp, outoff, 0);
else
*outoffp = outoff;
+ } else if (foffsets_set) {
+ *inoffp = inoff;
+ *outoffp = outoff;
}
if (outfp != NULL)
fdrop(outfp, td);