aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/kern/kern_descrip.c5
-rw-r--r--sys/kern/vfs_syscalls.c3
-rw-r--r--sys/kern/vfs_vnops.c2
-rw-r--r--sys/sys/vnode.h1
4 files changed, 10 insertions, 1 deletions
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c
index dd510cfd23f9..d88263ddeedb 100644
--- a/sys/kern/kern_descrip.c
+++ b/sys/kern/kern_descrip.c
@@ -1852,9 +1852,14 @@ filecaps_validate(const struct filecaps *fcaps, const char *func)
KASSERT(fcaps->fc_fcntls == 0 ||
cap_rights_is_set(&fcaps->fc_rights, CAP_FCNTL),
("%s: fcntls without CAP_FCNTL", func));
+ /*
+ * open calls without WANTIOCTLCAPS free caps but leave the counter
+ */
+#if 0
KASSERT(fcaps->fc_ioctls != NULL ? fcaps->fc_nioctls > 0 :
(fcaps->fc_nioctls == -1 || fcaps->fc_nioctls == 0),
("%s: invalid ioctls", func));
+#endif
KASSERT(fcaps->fc_nioctls == 0 ||
cap_rights_is_set(&fcaps->fc_rights, CAP_IOCTL),
("%s: ioctls without CAP_IOCTL", func));
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c
index dec7fdca92f2..87bf0a9d866b 100644
--- a/sys/kern/vfs_syscalls.c
+++ b/sys/kern/vfs_syscalls.c
@@ -1167,7 +1167,8 @@ kern_openat(struct thread *td, int fd, const char *path, enum uio_seg pathseg,
NDINIT_ATRIGHTS(&nd, LOOKUP, FOLLOW | AUDITVNODE1 | WANTIOCTLCAPS,
pathseg, path, fd, &rights);
td->td_dupfd = -1; /* XXX check for fdopen */
- error = vn_open(&nd, &flags, cmode, fp);
+ error = vn_open_cred(&nd, &flags, cmode, VN_OPEN_WANTIOCTLCAPS,
+ td->td_ucred, fp);
if (error != 0) {
/*
* If the vn_open replaced the method vector, something
diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c
index 4d75c53a701b..d5234b44e5eb 100644
--- a/sys/kern/vfs_vnops.c
+++ b/sys/kern/vfs_vnops.c
@@ -213,6 +213,8 @@ open2nameif(int fmode, u_int vn_open_flags)
res |= AUDITVNODE1;
if ((vn_open_flags & VN_OPEN_NOCAPCHECK) != 0)
res |= NOCAPCHECK;
+ if ((vn_open_flags & VN_OPEN_WANTIOCTLCAPS) != 0)
+ res |= WANTIOCTLCAPS;
return (res);
}
diff --git a/sys/sys/vnode.h b/sys/sys/vnode.h
index 7bd483d2e17c..0ff7501837c7 100644
--- a/sys/sys/vnode.h
+++ b/sys/sys/vnode.h
@@ -616,6 +616,7 @@ typedef void vop_getpages_iodone_t(void *, vm_page_t *, int, int);
#define VN_OPEN_NOCAPCHECK 0x00000002
#define VN_OPEN_NAMECACHE 0x00000004
#define VN_OPEN_INVFS 0x00000008
+#define VN_OPEN_WANTIOCTLCAPS 0x00000010
/* copy_file_range kernel flags */
#define COPY_FILE_RANGE_KFLAGS 0xff000000