git: 10191b85ee5d - stable/15 - cdevsw: add D_NONPASSABLE flag
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 12 Oct 2026 02:21:30 UTC
The branch stable/15 has been updated by kib:
URL: https://cgit.FreeBSD.org/src/commit/?id=10191b85ee5d0aa034d1b51b63bd4b7d7af57992
commit 10191b85ee5d0aa034d1b51b63bd4b7d7af57992
Author: Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2026-10-04 00:50:23 +0000
Commit: Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2026-10-12 02:20:49 +0000
cdevsw: add D_NONPASSABLE flag
(cherry picked from commit 850d4562928ea9308dd9188d5014bcabe7049938)
---
sys/fs/devfs/devfs_vnops.c | 27 +++++++++++++++++++++++++--
sys/sys/conf.h | 2 ++
2 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/sys/fs/devfs/devfs_vnops.c b/sys/fs/devfs/devfs_vnops.c
index 8c188e768de8..038dfb34166e 100644
--- a/sys/fs/devfs/devfs_vnops.c
+++ b/sys/fs/devfs/devfs_vnops.c
@@ -67,6 +67,7 @@
static struct vop_vector devfs_vnodeops;
static struct vop_vector devfs_specops;
static const struct fileops devfs_ops_f;
+static const struct fileops devfs_ops_nonpassable_f;
#include <fs/devfs/devfs.h>
#include <fs/devfs/devfs_int.h>
@@ -1344,8 +1345,11 @@ devfs_open(struct vop_open_args *ap)
if (fp == NULL)
return (error);
#endif
- if (fp->f_ops == &badfileops)
- finit(fp, fp->f_flag, DTYPE_VNODE, dev, &devfs_ops_f);
+ if (fp->f_ops == &badfileops) {
+ finit(fp, fp->f_flag, DTYPE_VNODE, dev,
+ (dsw->d_flags & D_NONPASSABLE) == 0 ? &devfs_ops_f :
+ &devfs_ops_nonpassable_f);
+ }
return (error);
}
@@ -2096,6 +2100,25 @@ static const struct fileops devfs_ops_f = {
.fo_flags = DFLAG_PASSABLE | DFLAG_SEEKABLE
};
+static const struct fileops devfs_ops_nonpassable_f = {
+ .fo_read = devfs_read_f,
+ .fo_write = devfs_write_f,
+ .fo_truncate = devfs_truncate_f,
+ .fo_ioctl = devfs_ioctl_f,
+ .fo_poll = devfs_poll_f,
+ .fo_kqfilter = devfs_kqfilter_f,
+ .fo_stat = devfs_stat_f,
+ .fo_close = devfs_close_f,
+ .fo_chmod = vn_chmod,
+ .fo_chown = vn_chown,
+ .fo_sendfile = vn_sendfile,
+ .fo_seek = vn_seek,
+ .fo_fill_kinfo = vn_fill_kinfo,
+ .fo_mmap = devfs_mmap_f,
+ .fo_cmp = devfs_cmp_f,
+ .fo_flags = DFLAG_SEEKABLE
+};
+
/* Vops for non-CHR vnodes in /dev. */
static struct vop_vector devfs_vnodeops = {
.vop_default = &default_vnodeops,
diff --git a/sys/sys/conf.h b/sys/sys/conf.h
index 5496133ab6d8..b55da6cc5714 100644
--- a/sys/sys/conf.h
+++ b/sys/sys/conf.h
@@ -176,6 +176,8 @@ typedef int dumper_hdr_t(struct dumperinfo *di, struct kerneldumpheader *kdh);
#define D_GIANTOK 0x00200000 /* suppress warning about using Giant */
#define D_NEEDGIANT 0x00400000 /* driver want Giant */
#define D_NEEDMINOR 0x00800000 /* driver uses clone_create() */
+#define D_NONPASSABLE 0x01000000 /* file is not passable with
+ SCM_RIGHTS or fork(2) */
/*
* Version numbers.