Re: [PATCH v2] usb: devio: Add ioctl to disallow detaching kernel USB drivers.

2 messages, 2 authors, 2016-01-25 · open the first message on its own page

Re: [PATCH v2] usb: devio: Add ioctl to disallow detaching kernel USB drivers.

From: Bjørn Mork <bjorn@mork.no>
Date: 2016-01-25 08:40:22

Emilio López [off-list ref] writes:
quoted
quoted
diff --git a/include/uapi/linux/usbdevice_fs.h b/include/uapi/linux/usbdevice_fs.h
index 019ba1e..9abcb34 100644
--- a/include/uapi/linux/usbdevice_fs.h
+++ b/include/uapi/linux/usbdevice_fs.h
@@ -154,6 +154,10 @@ struct usbdevfs_streams {
  	unsigned char eps[0];
  };

+struct usbdevfs_drop_privs {
+	unsigned long interface_allowed_mask;
+};
+
"unsigned long" isn't a very good choice here, is it?
I went with a type matching ifclaimed on struct usb_dev_state to keep
the limit the same, but I guess it's not the best idea for an ioctl. I
can switch it to __u32, keeping the runtime check above as is, or use
__u64. Which one would you prefer?
I don't feel much like an expert here, but I can certainly make up an
opinion anyway :)

Since 64bits kernels allow usb devio with interface numbers up to 63, I
guess you need __u64 to avoid limiting the range?  Limiting will create
all sorts of followup problems, so it's definitely easiest to just go
with __u64.



Bjørn

Re: [PATCH v2] usb: devio: Add ioctl to disallow detaching kernel USB drivers.

From: Alan Stern <stern@rowland.harvard.edu>
Date: 2016-01-25 15:21:26

On Mon, 25 Jan 2016, Bjørn Mork wrote:
I don't feel much like an expert here, but I can certainly make up an
opinion anyway :)

Since 64bits kernels allow usb devio with interface numbers up to 63, I
guess you need __u64 to avoid limiting the range?  Limiting will create
all sorts of followup problems, so it's definitely easiest to just go
with __u64.
But the Linux USB stack only allows up to 32 interfaces (see
include/linux/usb.h):

/* this maximum is arbitrary */
#define USB_MAXINTERFACES	32

So there's no point using a 64-bit value.

On the other hand, this value is supposed to be the same size as 
ps->ifclaimed, which is used as an argument to clear_bit(), set_bit(), 
and test_bit().  Those routines require unsigned long.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help