summaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorVisa Hankala <visa@cvs.openbsd.org>2021-12-13 14:54:23 +0000
committerVisa Hankala <visa@cvs.openbsd.org>2021-12-13 14:54:23 +0000
commita2ed3d0be022b17fa7362efd74f839646949a6a5 (patch)
tree2f4c1b3f9bf5d4ef64e2c9c5eed32b7c971c936f /sys/kern
parenteaf5f4103506feda446d96464aa4609b5543552e (diff)
Prevent kevent(2) use of EVFILT_EXCEPT with FIFOs and pipes
Currently, the only intended direct usage of the EVFILT_EXCEPT filter is with NOTE_OOB to detect out-of-band data in ptys and sockets. NOTE_OOB does not apply to FIFOs or pipes. Prevent the user from registering the filter with these file types. The filter code is for the kernel's internal use. OK mpi@
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/sys_pipe.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c
index 4da474aa257..fa103c6f4d4 100644
--- a/sys/kern/sys_pipe.c
+++ b/sys/kern/sys_pipe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sys_pipe.c,v 1.131 2021/12/08 13:03:52 visa Exp $ */
+/* $OpenBSD: sys_pipe.c,v 1.132 2021/12/13 14:54:22 visa Exp $ */
/*
* Copyright (c) 1996 John S. Dyson
@@ -927,6 +927,11 @@ pipe_kqfilter(struct file *fp, struct knote *kn)
error = EPERM;
break;
}
+ if ((kn->kn_flags & __EV_POLL) == 0) {
+ /* Disallow usage through kevent(2). */
+ error = EINVAL;
+ break;
+ }
kn->kn_fop = &pipe_efiltops;
kn->kn_hook = rpipe;
klist_insert_locked(&rpipe->pipe_sel.si_note, kn);