public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Restricting CDC-ACM devices
       [not found] ` <20070821171018.C964B5F778@attila.bofh.it>
@ 2007-08-21 22:03   ` Nate
  2007-08-22  5:46     ` Greg KH
  0 siblings, 1 reply; 7+ messages in thread
From: Nate @ 2007-08-21 22:03 UTC (permalink / raw)
  To: linux-kernel

I would like to use the cdc-acm driver in the Linux kernel (2.6.22-rc1),
but restrict the access to only my VID/PID devices.  Is there an easy way
to do with without modifying cdc-acm.c?

In a past prototype I made a simple wrapper driver for usb serial by
adding my VID/PID numbers to the wrapper driver's id_table.  Then when
that usb driver was accessed on connection, the driver just pointed to the
usb_serial_* functions (probe, disconnect, etc).  I tried to do the same
with the cdc-acm driver, but the cdc-acm driver's probe function was
called before my driver's probe.  I noticed that the cdc-amc driver will
attach when it detects the two CDC-ACM interfaces, so I removed the
cdc-acm driver with "make menuconfig".  This didn't work because the
cdc-acm functions I was attempting to call from my driver do not exist.

Thanks for the help,
-Nate



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Restricting CDC-ACM devices
  2007-08-21 22:03   ` Restricting CDC-ACM devices Nate
@ 2007-08-22  5:46     ` Greg KH
  2007-08-22 14:41       ` Nate
  0 siblings, 1 reply; 7+ messages in thread
From: Greg KH @ 2007-08-22  5:46 UTC (permalink / raw)
  To: Nate; +Cc: linux-kernel

On Tue, Aug 21, 2007 at 05:03:54PM -0500, Nate wrote:
> I would like to use the cdc-acm driver in the Linux kernel (2.6.22-rc1),
> but restrict the access to only my VID/PID devices.  Is there an easy way
> to do with without modifying cdc-acm.c?

Why do you not want to modify the driver?

> In a past prototype I made a simple wrapper driver for usb serial by
> adding my VID/PID numbers to the wrapper driver's id_table.  Then when
> that usb driver was accessed on connection, the driver just pointed to the
> usb_serial_* functions (probe, disconnect, etc).  I tried to do the same
> with the cdc-acm driver, but the cdc-acm driver's probe function was
> called before my driver's probe.  I noticed that the cdc-amc driver will
> attach when it detects the two CDC-ACM interfaces, so I removed the
> cdc-acm driver with "make menuconfig".  This didn't work because the
> cdc-acm functions I was attempting to call from my driver do not exist.

You can disconnect the device from the driver from userspace for any
device you just don't want to have connected by using the sysfs
bind/unbind files.  That doesn't require any kernel changes at all.

Why do you want to do this, what are you expecting to achieve with such
a change?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Restricting CDC-ACM devices
  2007-08-22  5:46     ` Greg KH
@ 2007-08-22 14:41       ` Nate
  2007-08-22 18:55         ` Greg KH
  0 siblings, 1 reply; 7+ messages in thread
From: Nate @ 2007-08-22 14:41 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-kernel


> Why do you not want to modify the driver?

Modifying the cdc-acm driver is an alternative; however, I would like to
avoid that when I'm adding my vendor specific restrictions.  My hope is
that when patches are made to that file, I don't need to worry about
someone merging them over the my previous ones.  Is this a bad goal?


> You can disconnect the device from the driver from userspace for any
> device you just don't want to have connected by using the sysfs
> bind/unbind files.  That doesn't require any kernel changes at all.

I don't fully follow you here.  Are you saying that I can disconnect the
CDC-ACM driver from my USB device and allow my driver to get a call probe?


> Why do you want to do this, what are you expecting to achieve with such
> a change?

The main application accesses data from USB devices over the /dev/ttyACMx
files, so using the CDC-ACM driver makes it easy for me to get the USB
device data.  There will be multiple USB devices that will be
communicating using CDC-ACM protocol, and I would like to restrict access
to only devices with the correct product IDs.  I was thinking if my driver
checked the VID/PID before allowing the CDC-ACM driver to process the
probe call, then I can restrict the devices.  The approved devices would
then be connected to ttyACMx by the standard cdc-acm driver code.

I'm still pretty green with regards to USB driver development, so there
might be a better way to achieve this.  If there is please tell me. :)

Thanks,
-Nate


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Restricting CDC-ACM devices
  2007-08-22 14:41       ` Nate
@ 2007-08-22 18:55         ` Greg KH
  2007-08-22 21:52           ` Nate
  0 siblings, 1 reply; 7+ messages in thread
From: Greg KH @ 2007-08-22 18:55 UTC (permalink / raw)
  To: Nate; +Cc: linux-kernel

On Wed, Aug 22, 2007 at 09:41:33AM -0500, Nate wrote:
> 
> > Why do you not want to modify the driver?
> 
> Modifying the cdc-acm driver is an alternative; however, I would like to
> avoid that when I'm adding my vendor specific restrictions.  My hope is
> that when patches are made to that file, I don't need to worry about
> someone merging them over the my previous ones.  Is this a bad goal?

Well, just messing with the device ids is not that tough of a patch to
keep up to date over time, so you might just try that if necessary.

> > You can disconnect the device from the driver from userspace for any
> > device you just don't want to have connected by using the sysfs
> > bind/unbind files.  That doesn't require any kernel changes at all.
> 
> I don't fully follow you here.  Are you saying that I can disconnect the
> CDC-ACM driver from my USB device and allow my driver to get a call probe?

Yes.  You can manually bind and unbind all PCI and USB devices from
their drivers from userspace.  So you do have full control over this
already, no kernel changes needed.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Restricting CDC-ACM devices
  2007-08-22 21:52           ` Nate
@ 2007-08-22 21:47             ` Greg KH
  2007-08-27 15:58               ` Nate
  0 siblings, 1 reply; 7+ messages in thread
From: Greg KH @ 2007-08-22 21:47 UTC (permalink / raw)
  To: Nate; +Cc: linux-kernel

On Wed, Aug 22, 2007 at 04:52:06PM -0500, Nate wrote:
> Thank you for your responses.  Please don't take my repeated questioning
> of your answers as me being difficult, I'm just trying to get a better
> understanding.
> 
> 
> > Well, just messing with the device ids is not that tough of a patch to
> > keep up to date over time, so you might just try that if necessary.
> 
> That is a good point.  I may also be adding some extra logic to check
> other fields to confirm compatibility before allowing a usb device to be
> bound to the CDC-ACM driver.  That is still probably pretty small piece of
> code in the probe function, but I'm just concerned that over time more
> logic would be added and other developers will be maintaining the code.

Well, this is of course the easiest way to achive what you are wanting
to do.  Only you can answer the "how I'm going to maintain this in the
future" question :)

> > Yes.  You can manually bind and unbind all PCI and USB devices from
> > their drivers from userspace.  So you do have full control over this
> > already, no kernel changes needed.
> 
> Does this require my userspace applications to poll the USB devices
> (/proc/bus/usb/devices) and then disconnect/connect my driver every time a
> USB device using CDC-ACM is connected?  Is this what is normally done? 
> Does this cause a noticeable performance hit when the driver is cycled
> like this?  If I don't enable CDC-ACM in make menuconfig, can I still bind
> it to a USB device from userspace?

No, you still need the driver to be around :)

Anyway, you can get a notification from udev whenever a device is bound
to the cdc-acm driver, and then trigger your "disconnect/connect" script
on that.

> I don't know if this matters, but I wanted to add some use case details:
> This driver will be running on a <200 MHz processor and there can be a
> number of connects/disconnect of the device in a short time from the
> users.

I don't know how fast the above will all work out, you are going to have
to test it yourself, sorry.

hope this helps,

greg k-h

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Restricting CDC-ACM devices
  2007-08-22 18:55         ` Greg KH
@ 2007-08-22 21:52           ` Nate
  2007-08-22 21:47             ` Greg KH
  0 siblings, 1 reply; 7+ messages in thread
From: Nate @ 2007-08-22 21:52 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-kernel

Thank you for your responses.  Please don't take my repeated questioning
of your answers as me being difficult, I'm just trying to get a better
understanding.


> Well, just messing with the device ids is not that tough of a patch to
> keep up to date over time, so you might just try that if necessary.

That is a good point.  I may also be adding some extra logic to check
other fields to confirm compatibility before allowing a usb device to be
bound to the CDC-ACM driver.  That is still probably pretty small piece of
code in the probe function, but I'm just concerned that over time more
logic would be added and other developers will be maintaining the code.


> Yes.  You can manually bind and unbind all PCI and USB devices from
> their drivers from userspace.  So you do have full control over this
> already, no kernel changes needed.

Does this require my userspace applications to poll the USB devices
(/proc/bus/usb/devices) and then disconnect/connect my driver every time a
USB device using CDC-ACM is connected?  Is this what is normally done? 
Does this cause a noticeable performance hit when the driver is cycled
like this?  If I don't enable CDC-ACM in make menuconfig, can I still bind
it to a USB device from userspace?


I don't know if this matters, but I wanted to add some use case details:
This driver will be running on a <200 MHz processor and there can be a
number of connects/disconnect of the device in a short time from the
users.

Thanks,
-Nate


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Restricting CDC-ACM devices
  2007-08-22 21:47             ` Greg KH
@ 2007-08-27 15:58               ` Nate
  0 siblings, 0 replies; 7+ messages in thread
From: Nate @ 2007-08-27 15:58 UTC (permalink / raw)
  To: linux-kernel


>
> I don't know how fast the above will all work out, you are going to have
> to test it yourself, sorry.
>
> hope this helps,

It has.  Thank you for answering all of my questions.

-Nate




^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2007-08-27 16:20 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <1187716018.731090.165620@j4g2000prf.googlegroups.com>
     [not found] ` <20070821171018.C964B5F778@attila.bofh.it>
2007-08-21 22:03   ` Restricting CDC-ACM devices Nate
2007-08-22  5:46     ` Greg KH
2007-08-22 14:41       ` Nate
2007-08-22 18:55         ` Greg KH
2007-08-22 21:52           ` Nate
2007-08-22 21:47             ` Greg KH
2007-08-27 15:58               ` Nate

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox