Re: [PATCH v2] usb: devio: Add ioctl to disallow detaching kernel USB drivers.
From: BjÃrn Mork
Date: Mon Jan 25 2016 - 03:40:25 EST
Emilio LÃpez <emilio.lopez@xxxxxxxxxxxxxxx> writes:
>>> 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