summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoranton <anton@openbsd.org>2019-05-21 20:57:10 +0000
committeranton <anton@openbsd.org>2019-05-21 20:57:10 +0000
commit78fe050fe5498542e041db8ba20c87dd2ee41af0 (patch)
treecf6c2da9aa7b875c2ac353f373e1cb0c261b46b9
parentAvoid rm(1) prompt and show out in clean target (diff)
downloadwireguard-openbsd-78fe050fe5498542e041db8ba20c87dd2ee41af0.tar.xz
wireguard-openbsd-78fe050fe5498542e041db8ba20c87dd2ee41af0.zip
A problem fixed in wskbd is also present in wsmux. Repeating the
previous commit message: In wsmuxclose(), use the same logic as in wsmuxopen() to determine if the device was opened in write-only mode. Relying on me_evar being NULL does not work if the wsmux device was opened first followed attaching it to another wsmux. Closing the wsmux device first at this stage would cause the wscons_event queue inherited from the parent wsmux to be freed. This in turn could cause a panic if an ioctl(WSMUXIO_INJECTEVENT) command is issued on parent wsmux device. ok mpi@ visa@ Reported-by: syzbot+f6c2ed7901eb4b970720@syzkaller.appspotmail.com
-rw-r--r--sys/dev/wscons/wsmux.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sys/dev/wscons/wsmux.c b/sys/dev/wscons/wsmux.c
index ebdd09a018f..28f6815d91f 100644
--- a/sys/dev/wscons/wsmux.c
+++ b/sys/dev/wscons/wsmux.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wsmux.c,v 1.45 2019/03/30 08:04:35 anton Exp $ */
+/* $OpenBSD: wsmux.c,v 1.46 2019/05/21 20:57:10 anton Exp $ */
/* $NetBSD: wsmux.c,v 1.37 2005/04/30 03:47:12 augustss Exp $ */
/*
@@ -290,7 +290,7 @@ wsmuxclose(dev_t dev, int flags, int mode, struct proc *p)
(struct wsmux_softc *)wsmuxdevs[minor(dev)];
struct wseventvar *evar = sc->sc_base.me_evp;
- if (evar == NULL)
+ if ((flags & (FREAD | FWRITE)) == FWRITE)
/* Not open for read */
return (0);