From: Stefan Richter Date: Thu, 21 May 2009 19:43:33 +0000 Subject: Re: [PATCH udev] rules: set group ownership of new firewire driver Message-Id: <4A15AEE5.7080401@s5r6.in-berlin.de> List-Id: References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To: linux-hotplug@vger.kernel.org Kay Sievers wrote: > On Thu, May 21, 2009 at 20:08, Stefan Richter = wrote: >=20 >> With some effort, we could add some fw_device attributes which reflect >> fw_unit properties. We would have to encode a little bit of higher-level >> knowledge into the fw_device handling part; but why not if it makes life= for >> userland considerably simpler. >=20 > Sounds ok to me, if we will end up with that solution. >=20 >>> Or maybe delay all uevents until the childs are all created, and send >>> the events only after that, so the child devices can be seen at the >>> time the event is sent out. ... [thanks for the tips how to go about that] ... >> And then, how would an udev rule look like to match attributes in the >> fw_device's subdirectories instead of direct attributes? >> >> SUBSYSTEM=3D"firewire", \ >> ATTR{*/specifier_id}=3D"0x00a02d", \ >> ATTR{*/version}=3D"0x00010?", \ >> GROUP=3D"video" >=20 > This is always numeric, and the unit directory names are not > predictable, right? Then we would need something like the "*/..." > magic to udev. Yes; the "dev" (character device file) sits in devices like /sys/devices/pci0000:00/0000:00:05.0/0000:04:00.0/fw3 while the protocol-specific attributes sit in children like /sys/devices/pci0000:00/0000:00:05.0/0000:04:00.0/fw3/fw3.0 i.e. "%s.%d", parent_name, number; with the number monotonously=20 increasing from 0 to n-1. There may be none to many of such children. If there is no child at all, no problem, then the device won't be=20 interesting to typical application software anyway. In many cases, there will be just one child, named like the parent with=20 .0 appended. However, we also need to cover the case that there is more than one=20 child. Then the attributes of all children need to be evaluated. BTW, the possible (but luckily highly improbable) case of devices with=20 several units of different type poses the question which policy to=20 follow: Paranoid =3D deny access unless all units are of a known good=20 type? Or comfortable =3D grant access if at least one unit is of known=20 good type? (My PROGRAM based patch actually implements the comfortable=20 policy, in case that wasn't obvious.) The paranoid case may have the=20 serious drawback that unknown types would prevent access to known types=20 even if the unknown ones are actually harmless to expose. If we keep it that way that udev has to look at children attributes (if=20 this is feasible at all), then the policy for this mixed type case would=20 remain entirely in userspace. But if we go the route of the 1st=20 variant, i.e. copy children properties into parent's attributes, then we=20 need to be either very careful to solve it without hard-wiring policy=20 into the kernel, or end up with a bias of the kernel part towards one or=20 the other policy. In practice, mixed unit types is a vitually non-existing case though. >>> We fixed almost all these know issues in other subsystems now and I >>> would really like to see that solved properly, without chrgrp hacks >>> like in the rules above. It would hit us back badly, when generic >>> infrastructure which will expect proper event timing regarding device >>> properties. >> Hmm, or maybe we should associate character device files with the fw_uni= ts >> instead? Could break Fedora's userland though. Alas I don't know in de= tail >> what Fedora does to set ACLs on /dev/fw*. >=20 > Maybe it would be nice anyway, if some units-types can be excluded > from access by normal users. Sometimes it would be nice to have > something like this for USB, so we could grant access to the 3G modem > of mobile phone, but not to the firmware update interface :) This is not possible with FireWire because the actual I/O, if not even=20 broadcast to the entire bus, can only be addressed to the FireWire node=20 in its entirety, not to particular units on the node. The node itself=20 (IOW the protocols which the node implements) needs to bring the=20 necessary separation between/ security of the units which reside=20 together on a node.=B9 However, on second thought, providing character device files per fw_unit=20 won't work with current libraw1394 and libdc1394. They expect /dev/fw*=20 to represent one FireWire node (i.e. fw_device) each. ------------ =B9) FireWire is not just a bus after all, it's also a network. Hence=20 device security is more like host-side security in the sense that the=20 device is a host. So, another not too far-fetched way to deal with=20 firewire-cdev permissions is this one: SUBSYSTEM=3D"firewire", GROUP=3D"video" Still, doing it finer grained than this would be good. For example,=20 access to SBP-2 targets should remain a privilege, even though it would=20 require a non-trivial effort to do anything "interesting" to an SBP-2=20 target from userspace. --=20 Stefan Richter -=3D=3D=3D-=3D-=3D=3D -=3D-=3D -=3D-http://arcgraph.de/sr/