Page MenuHomeFreeBSD

D58079.1795829526.diff
No OneTemporary

Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None

D58079.1795829526.diff

diff --git a/sys/fs/fdescfs/fdesc_vnops.c b/sys/fs/fdescfs/fdesc_vnops.c
--- a/sys/fs/fdescfs/fdesc_vnops.c
+++ b/sys/fs/fdescfs/fdesc_vnops.c
@@ -248,6 +248,7 @@
struct file *fp;
struct thread *td;
bool fdropped;
+ uint8_t fd_flags;
};
static int
@@ -263,6 +264,11 @@
fdm = VFSTOFDESC(mp);
if ((fdm->flags & FMNT_NODUP) != 0 && a->fp->f_type == DTYPE_VNODE) {
vp = a->fp->f_vnode;
+ /* f_flag is always between 1 and FMASK and < INT_MAX. */
+ if (a->fd_flags & UF_RESOLVE_BENEATH)
+ a->td->td_dupfd = a->fp->f_flag;
+ else
+ a->td->td_dupfd = 0;
vget(vp, lkflags | LK_RETRY);
*rvp = vp;
error = 0;
@@ -332,7 +338,8 @@
/*
* No rights to check since 'fp' isn't actually used.
*/
- if ((error = fget(td, fd, &cap_no_rights, &fp)) != 0)
+ if ((error = fget_cap(td, fd, &cap_no_rights, &arg.fd_flags,
+ &fp, NULL)) != 0)
goto bad;
/*
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -1295,7 +1295,6 @@
goto bad;
}
- td->td_dupfd = 0;
NDFREE_PNBUF(&nd);
vp = nd.ni_vp;
@@ -1310,6 +1309,7 @@
if (fpp != NULL) {
MPASS(error == 0);
NDFREE_IOCTLCAPS(&nd);
+ td->td_dupfd = -1;
*fpp = fp;
return (0);
}
@@ -1324,10 +1324,12 @@
else
#endif
fcaps = NULL;
- if ((nd.ni_resflags & NIRES_BENEATH) != 0)
+ if ((nd.ni_resflags & NIRES_BENEATH) != 0 ||
+ td->td_dupfd > 0)
flags |= O_RESOLVE_BENEATH;
else
flags &= ~O_RESOLVE_BENEATH;
+ td->td_dupfd = -1;
error = finstall_refed(td, fp, &indx, flags, fcaps);
/* On success finstall_refed() consumes fcaps. */
if (error != 0) {
@@ -1343,6 +1345,7 @@
bad:
KASSERT(indx == -1, ("indx=%d, should be -1", indx));
NDFREE_IOCTLCAPS(&nd);
+ td->td_dupfd = -1;
falloc_abort(td, fp);
return (error);
}

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 28, 1:32 AM (20 h, 16 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
42047766
Default Alt Text
D58079.1795829526.diff (1 KB)

Event Timeline