summaryrefslogtreecommitdiff
path: root/sys/dev/usb
diff options
context:
space:
mode:
authorYojiro Uo <yuo@cvs.openbsd.org>2008-12-09 03:08:08 +0000
committerYojiro Uo <yuo@cvs.openbsd.org>2008-12-09 03:08:08 +0000
commite7c2307b4274de1648f420c4fa841c1da9d5ace4 (patch)
treed89717a9f54b63c3c070def0dc2215c89a8c9dad /sys/dev/usb
parentba69b03849ae5f2fa7946cb06440047b95fd9157 (diff)
assign ehcidebug to USB_DEBUG ioctl argument.
add priv check to the ioctl. only root priv should access these debug flags. ok deraadt@
Diffstat (limited to 'sys/dev/usb')
-rw-r--r--sys/dev/usb/usb.c20
-rw-r--r--sys/dev/usb/usb.h4
2 files changed, 18 insertions, 6 deletions
diff --git a/sys/dev/usb/usb.c b/sys/dev/usb/usb.c
index da11681153d..0167d801046 100644
--- a/sys/dev/usb/usb.c
+++ b/sys/dev/usb/usb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: usb.c,v 1.57 2008/06/26 05:42:19 ray Exp $ */
+/* $OpenBSD: usb.c,v 1.58 2008/12/09 03:08:07 yuo Exp $ */
/* $NetBSD: usb.c,v 1.77 2003/01/01 00:10:26 thorpej Exp $ */
/*
@@ -39,6 +39,7 @@
#include "ohci.h"
#include "uhci.h"
+#include "ehci.h"
#include <sys/param.h>
#include <sys/systm.h>
@@ -75,6 +76,9 @@ extern int uhcidebug;
#if defined(OHCI_DEBUG) && NOHCI > 0
extern int ohcidebug;
#endif
+#if defined(EHCI_DEBUG) && NEHCI > 0
+extern int ehcidebug;
+#endif
/*
* 0 - do usual exploration
* 1 - do not use timeout exploration
@@ -453,6 +457,7 @@ usbioctl(dev_t devt, u_long cmd, caddr_t data, int flag, struct proc *p)
{
struct usb_softc *sc;
int unit = minor(devt);
+ int error;
if (unit == USB_DEV_MINOR) {
switch (cmd) {
@@ -477,17 +482,24 @@ usbioctl(dev_t devt, u_long cmd, caddr_t data, int flag, struct proc *p)
if (sc->sc_dying)
return (EIO);
+ error = 0;
switch (cmd) {
#ifdef USB_DEBUG
case USB_SETDEBUG:
+ /* only root can access to these debug flags */
+ if ((error = suser(curproc, 0)) != 0)
+ return (error);
if (!(flag & FWRITE))
return (EBADF);
- usbdebug = ((*(int *)data) & 0x000000ff);
+ usbdebug = ((*(unsigned int *)data) & 0x000000ff);
#if defined(UHCI_DEBUG) && NUHCI > 0
- uhcidebug = ((*(int *)data) & 0x0000ff00) >> 8;
+ uhcidebug = ((*(unsigned int *)data) & 0x0000ff00) >> 8;
#endif
#if defined(OHCI_DEBUG) && NOHCI > 0
- ohcidebug = ((*(int *)data) & 0x00ff0000) >> 16;
+ ohcidebug = ((*(unsigned int *)data) & 0x00ff0000) >> 16;
+#endif
+#if defined(EHCI_DEBUG) && NEHCI > 0
+ ehcidebug = ((*(unsigned int *)data) & 0xff000000) >> 24;
#endif
break;
#endif /* USB_DEBUG */
diff --git a/sys/dev/usb/usb.h b/sys/dev/usb/usb.h
index 563d9c47e2e..d6207c678ec 100644
--- a/sys/dev/usb/usb.h
+++ b/sys/dev/usb/usb.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: usb.h,v 1.33 2008/08/09 22:59:20 mglocker Exp $ */
+/* $OpenBSD: usb.h,v 1.34 2008/12/09 03:08:07 yuo Exp $ */
/* $NetBSD: usb.h,v 1.69 2002/09/22 23:20:50 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/usb.h,v 1.14 1999/11/17 22:33:46 n_hibma Exp $ */
@@ -653,7 +653,7 @@ struct usb_event {
/* USB controller */
#define USB_REQUEST _IOWR('U', 1, struct usb_ctl_request)
-#define USB_SETDEBUG _IOW ('U', 2, int)
+#define USB_SETDEBUG _IOW ('U', 2, unsigned int)
#define USB_DISCOVER _IO ('U', 3)
#define USB_DEVICEINFO _IOWR('U', 4, struct usb_device_info)
#define USB_DEVICESTATS _IOR ('U', 5, struct usb_device_stats)