summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkettenis <kettenis@openbsd.org>2020-09-03 15:30:17 +0000
committerkettenis <kettenis@openbsd.org>2020-09-03 15:30:17 +0000
commitc75bac9bdb6068f5d8019d6df896d092134f10a8 (patch)
tree62ed44e29e91ca03dde6b372b1f6166a748261ac
parentLog OCSP url on connection failure. (diff)
downloadwireguard-openbsd-c75bac9bdb6068f5d8019d6df896d092134f10a8.tar.xz
wireguard-openbsd-c75bac9bdb6068f5d8019d6df896d092134f10a8.zip
The "USL" VT switch and keyboard ioctls are a hack and don't follow the
proper BSD way where the third argument is always a pointer and data is transferred between userland and kernel using copyin(9) and copyout(9). Intead an int is encoded in the thirs argument. This works on 32-bit architectures and little-endian 64-bit architectures. But not on big-endian 64-bit architectures. Deal with this by handling the argument as long (which matches the size of a pointer). Hopefully we can eliminate these ioctls in the near future. ok deraadt@
-rw-r--r--sys/dev/wscons/wsdisplay_compat_usl.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/sys/dev/wscons/wsdisplay_compat_usl.c b/sys/dev/wscons/wsdisplay_compat_usl.c
index 70e3e5416b4..7398e8f399d 100644
--- a/sys/dev/wscons/wsdisplay_compat_usl.c
+++ b/sys/dev/wscons/wsdisplay_compat_usl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wsdisplay_compat_usl.c,v 1.32 2017/01/23 04:43:46 deraadt Exp $ */
+/* $OpenBSD: wsdisplay_compat_usl.c,v 1.33 2020/09/03 15:30:17 kettenis Exp $ */
/* $NetBSD: wsdisplay_compat_usl.c,v 1.12 2000/03/23 07:01:47 thorpej Exp $ */
/*
@@ -303,14 +303,14 @@ wsdisplay_usl_ioctl1(struct wsdisplay_softc *sc, u_long cmd, caddr_t data,
case VT_ACTIVATE:
if ((flag & FWRITE) == 0)
return (EACCES);
- idx = *(int *)data - 1;
+ idx = *(long *)data - 1;
if (idx < 0)
return (EINVAL);
return (wsdisplay_switch((struct device *)sc, idx, 1));
case VT_WAITACTIVE:
if ((flag & FWRITE) == 0)
return (EACCES);
- idx = *(int *)data - 1;
+ idx = *(long *)data - 1;
if (idx < 0)
return (EINVAL);
return (wsscreen_switchwait(sc, idx));
@@ -375,7 +375,7 @@ wsdisplay_usl_ioctl2(struct wsdisplay_softc *sc, struct wsscreen *scr,
case VT_RELDISP:
if ((flag & FWRITE) == 0)
return (EACCES);
-#define d (*(int *)data)
+#define d ((int)(*(long *)data))
sd = usl_sync_get(scr);
if (!sd)
return (EINVAL);
@@ -417,7 +417,7 @@ wsdisplay_usl_ioctl2(struct wsdisplay_softc *sc, struct wsscreen *scr,
if ((flag & FWRITE) == 0)
return (EACCES);
req = WSDISPLAYIO_SMODE;
-#define d (*(int *)data)
+#define d ((int)(*(long *)data))
switch (d) {
case KD_GRAPHICS:
intarg = WSDISPLAYIO_MODE_MAPPED;
@@ -435,7 +435,7 @@ wsdisplay_usl_ioctl2(struct wsdisplay_softc *sc, struct wsscreen *scr,
if ((flag & FWRITE) == 0)
return (EACCES);
req = WSKBDIO_COMPLEXBELL;
-#define d (*(int *)data)
+#define d ((int)(*(long *)data))
if (d) {
#define PCVT_SYSBEEPF 1193182
if (d >> 16) {
@@ -458,7 +458,7 @@ wsdisplay_usl_ioctl2(struct wsdisplay_softc *sc, struct wsscreen *scr,
return (EACCES);
req = WSKBDIO_SETLEDS;
intarg = 0;
-#define d (*(int *)data)
+#define d ((int)(*(long *)data))
if (d & LED_CAP)
intarg |= WSKBD_LED_CAPS;
if (d & LED_NUM)
@@ -477,7 +477,7 @@ wsdisplay_usl_ioctl2(struct wsdisplay_softc *sc, struct wsscreen *scr,
if ((flag & FWRITE) == 0)
return (EACCES);
req = WSKBDIO_SETMODE;
- switch (*(int *)data) {
+ switch ((int)(*(long *)data)) {
case K_RAW:
intarg = WSKBD_RAW;
break;