summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlandry <landry@openbsd.org>2019-01-21 20:09:37 +0000
committerlandry <landry@openbsd.org>2019-01-21 20:09:37 +0000
commit3ec81e34febd88e290e639ca9c70292382f14399 (patch)
treea1750b23cca6925b3ac4ad4a64aa56642874737d
parentIntroduce a dedicated entry point data structure for file locks. This new data (diff)
downloadwireguard-openbsd-3ec81e34febd88e290e639ca9c70292382f14399.tar.xz
wireguard-openbsd-3ec81e34febd88e290e639ca9c70292382f14399.zip
Add "video" promise.
Allows a subset of ioctls on video(4) devices, subset selected from video(1) and firefox webrtc implementation. ok semarie@ deraadt@
-rw-r--r--sys/kern/kern_pledge.c32
-rw-r--r--sys/sys/pledge.h4
2 files changed, 34 insertions, 2 deletions
diff --git a/sys/kern/kern_pledge.c b/sys/kern/kern_pledge.c
index ef4a9934e3a..e0a74a1cbe3 100644
--- a/sys/kern/kern_pledge.c
+++ b/sys/kern/kern_pledge.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_pledge.c,v 1.248 2019/01/18 01:34:50 pd Exp $ */
+/* $OpenBSD: kern_pledge.c,v 1.249 2019/01/21 20:09:37 landry Exp $ */
/*
* Copyright (c) 2015 Nicholas Marriott <nicm@openbsd.org>
@@ -43,6 +43,7 @@
#include <sys/dkio.h>
#include <sys/mtio.h>
#include <sys/audioio.h>
+#include <sys/videoio.h>
#include <net/bpf.h>
#include <net/route.h>
#include <net/if.h>
@@ -396,6 +397,7 @@ static const struct {
{ "tty", PLEDGE_TTY },
{ "unix", PLEDGE_UNIX },
{ "unveil", PLEDGE_UNVEIL },
+ { "video", PLEDGE_VIDEO },
{ "vminfo", PLEDGE_VMINFO },
{ "vmm", PLEDGE_VMM },
{ "wpath", PLEDGE_WPATH },
@@ -1150,6 +1152,34 @@ pledge_ioctl(struct proc *p, long com, struct file *fp)
}
}
+ if ((p->p_p->ps_pledge & PLEDGE_VIDEO)) {
+ switch (com) {
+ case VIDIOC_QUERYCAP:
+ case VIDIOC_TRY_FMT:
+ case VIDIOC_ENUM_FMT:
+ case VIDIOC_S_FMT:
+ case VIDIOC_QUERYCTRL:
+ case VIDIOC_G_CTRL:
+ case VIDIOC_S_CTRL:
+ case VIDIOC_G_PARM:
+ case VIDIOC_S_PARM:
+ case VIDIOC_REQBUFS:
+ case VIDIOC_QBUF:
+ case VIDIOC_DQBUF:
+ case VIDIOC_QUERYBUF:
+ case VIDIOC_STREAMON:
+ case VIDIOC_STREAMOFF:
+ case VIDIOC_ENUM_FRAMESIZES:
+ case VIDIOC_ENUM_FRAMEINTERVALS:
+ if (fp->f_type == DTYPE_VNODE &&
+ vp->v_type == VCHR &&
+ cdevsw[major(vp->v_rdev)].d_open == videoopen)
+ return (0);
+ break;
+ }
+ }
+
+
#if NPF > 0
if ((p->p_p->ps_pledge & PLEDGE_PF)) {
switch (com) {
diff --git a/sys/sys/pledge.h b/sys/sys/pledge.h
index 578efb0615b..d44a575bc5b 100644
--- a/sys/sys/pledge.h
+++ b/sys/sys/pledge.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: pledge.h,v 1.38 2018/08/11 16:16:07 beck Exp $ */
+/* $OpenBSD: pledge.h,v 1.39 2019/01/21 20:09:37 landry Exp $ */
/*
* Copyright (c) 2015 Nicholas Marriott <nicm@openbsd.org>
@@ -62,6 +62,7 @@
#define PLEDGE_ERROR 0x0000000400000000ULL /* ENOSYS instead of kill */
#define PLEDGE_WROUTE 0x0000000800000000ULL /* interface address ioctls */
#define PLEDGE_UNVEIL 0x0000001000000000ULL /* allow unveil() */
+#define PLEDGE_VIDEO 0x0000002000000000ULL /* video ioctls */
/*
* Bits outside PLEDGE_USERSET are used by the kernel itself
@@ -111,6 +112,7 @@ static struct {
{ PLEDGE_ERROR, "error" },
{ PLEDGE_WROUTE, "wroute" },
{ PLEDGE_UNVEIL, "unveil" },
+ { PLEDGE_VIDEO, "video" },
{ 0, NULL },
};
#endif