Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1314857

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

From Bjørn Mork <bjorn@mork.no>
Newsgroups linux.kernel
Subject Re: [PATCH v2] usb: devio: Add ioctl to disallow detaching kernel USB drivers.
Date 2016-01-22 10:50 +0100
Message-ID <qTGvV-2d2-31@gated-at.bofh.it> (permalink)
References <qSIT9-33H-27@gated-at.bofh.it> <qTxiV-3Zo-3@gated-at.bofh.it>
Organization m

Show all headers | View raw


Emilio López <emilio.lopez@collabora.co.uk> writes:

> diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
> index 38ae877c..bf40aa6 100644
> --- a/drivers/usb/core/devio.c
> +++ b/drivers/usb/core/devio.c
> @@ -77,6 +77,8 @@ struct usb_dev_state {
>  	unsigned long ifclaimed;
>  	u32 secid;
>  	u32 disabled_bulk_eps;
> +	bool privileges_dropped;
> +	unsigned long interface_allowed_mask;
>  };
>  
>  struct async {
> @@ -641,6 +643,14 @@ static int claimintf(struct usb_dev_state *ps, unsigned int ifnum)
>  	if (test_bit(ifnum, &ps->ifclaimed))
>  		return 0;
>  
> +	if (ps->privileges_dropped) {
> +		if (ifnum >= 8*sizeof(ps->interface_allowed_mask))
> +			return -EINVAL;


I don't think you need this runtime test. You can just make sure that
sizeof(ps->interface_allowed_mask) == sizeof(ps->ifclaimed) at build
time.

I do find this variable and arbitrary limit a bit confusing, but that's
not your fault - I guess it is an indication that ifnums > 31 are rare
:)


> 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?



Bjørn

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [PATCH v1 0/1] ioctl to disallow detaching kernel USB drivers Emilio López <emilio.lopez@collabora.co.uk> - 2016-01-19 17:50 +0100
  Re: [PATCH v1 0/1] ioctl to disallow detaching kernel USB drivers Greg KH <gregkh@linuxfoundation.org> - 2016-01-19 19:10 +0100
    [PATCH v2] usb: devio: Add ioctl to disallow detaching kernel USB drivers. Emilio López <emilio.lopez@collabora.co.uk> - 2016-01-22 01:00 +0100
      Re: [PATCH v2] usb: devio: Add ioctl to disallow detaching kernel USB drivers. Bjørn Mork <bjorn@mork.no> - 2016-01-22 10:50 +0100
        Re: [PATCH v2] usb: devio: Add ioctl to disallow detaching kernel USB  drivers. Emilio López <emilio.lopez@collabora.co.uk> - 2016-01-25 03:10 +0100
          Re: [PATCH v2] usb: devio: Add ioctl to disallow detaching kernel USB drivers. Bjørn Mork <bjorn@mork.no> - 2016-01-25 09:50 +0100
            Re: [PATCH v2] usb: devio: Add ioctl to disallow detaching kernel  USB drivers. Alan Stern <stern@rowland.harvard.edu> - 2016-01-25 16:30 +0100
              Re: [PATCH v2] usb: devio: Add ioctl to disallow detaching kernel USB drivers. Bjørn Mork <bjorn@mork.no> - 2016-01-25 16:40 +0100
                Re: [PATCH v2] usb: devio: Add ioctl to disallow detaching kernel  USB drivers. Alan Stern <stern@rowland.harvard.edu> - 2016-01-25 16:50 +0100
      Re: [PATCH v2] usb: devio: Add ioctl to disallow detaching kernel  USB drivers. Alan Stern <stern@rowland.harvard.edu> - 2016-01-22 17:20 +0100
        Re: [PATCH v2] usb: devio: Add ioctl to disallow detaching kernel USB  drivers. Emilio López <emilio.lopez@collabora.co.uk> - 2016-01-25 03:10 +0100

csiph-web