git: 947d644c55a7 - stable/14 - fdescfs: add VOP_ACCESS() implementation
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 17 Nov 2026 17:03:02 UTC
The branch stable/14 has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=947d644c55a7a34832e3f7bea90e63173603a1d7
commit 947d644c55a7a34832e3f7bea90e63173603a1d7
Author: Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2026-11-06 00:00:19 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2026-11-17 13:24:11 +0000
fdescfs: add VOP_ACCESS() implementation
kern_truncate() checks VWRITE only through VOP_ACCESS() on the fdescfs
vnode, which always succeeded until now. So a file opened read-only
could be truncated, even if the caller has no write permission for it.
Note that reopen on mounts without nodup already performs the permission
checks in dupfdopen(). For nodup mounts, the VOP_ACCESS() implementation
of the real filesystem is used.
Approved by: so
Security: FreeBSD-SA-26:91.fdescfs
Security: CVE-2026-127745
Reported by: Kevin Day <kevin@your.org>
Sponsored by: The FreeBSD Foundation
---
sys/fs/fdescfs/fdesc_vnops.c | 34 +++++++++++++++++++++++++++++++++-
1 file changed, 33 insertions(+), 1 deletion(-)
diff --git a/sys/fs/fdescfs/fdesc_vnops.c b/sys/fs/fdescfs/fdesc_vnops.c
index 7926395d6954..f1e204d9b2d0 100644
--- a/sys/fs/fdescfs/fdesc_vnops.c
+++ b/sys/fs/fdescfs/fdesc_vnops.c
@@ -75,11 +75,12 @@ static vop_readdir_t fdesc_readdir;
static vop_readlink_t fdesc_readlink;
static vop_reclaim_t fdesc_reclaim;
static vop_setattr_t fdesc_setattr;
+static vop_access_t fdesc_access;
static struct vop_vector fdesc_vnodeops = {
.vop_default = &default_vnodeops,
- .vop_access = VOP_NULL,
+ .vop_access = fdesc_access,
.vop_getattr = fdesc_getattr,
.vop_lookup = fdesc_lookup,
.vop_open = fdesc_open,
@@ -706,3 +707,34 @@ out:
vn_lock(vn, lockflags | LK_RETRY);
return (error);
}
+
+static int
+fdesc_access(struct vop_access_args *va)
+{
+ struct vnode *vp;
+ struct fdescnode *fd;
+ struct file *fp;
+ int error, flags, locked;
+
+ vp = va->a_vp;
+ fd = VTOFDESC(vp);
+ if (fd->fd_type == Froot)
+ return (0);
+ error = fget(va->a_td, fd->fd_fd, &cap_no_rights, &fp);
+ if (error != 0)
+ return (error);
+ flags = 0;
+ if ((va->a_accmode & VREAD) != 0)
+ flags |= FREAD;
+ if ((va->a_accmode & (VWRITE | VAPPEND)) != 0)
+ flags |= FWRITE;
+ if ((va->a_accmode & VEXEC) != 0)
+ flags |= FEXEC;
+ if ((flags & fp->f_flag) != flags)
+ error = EACCES;
+ locked = VOP_ISLOCKED(vp);
+ VOP_UNLOCK(vp);
+ fdrop(fp, va->a_td);
+ vn_lock(vp, locked | LK_RETRY);
+ return (error);
+}