From: Kyle Moffett <kyle@moffetthome.net>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Kay Sievers <kay.sievers@vrfy.org>,
Alan Stern <stern@rowland.harvard.edu>,
Al Viro <viro@zeniv.linux.org.uk>,
Kernel development list <linux-kernel@vger.kernel.org>
Subject: Re: How to tell whether a struct file is held by a process?
Date: Thu, 21 May 2009 21:28:36 -0400 [thread overview]
Message-ID: <f73f7ab80905211828te5c49dcx863a18c8e428a59f@mail.gmail.com> (raw)
In-Reply-To: <20090521231452.676d4898@lxorguk.ukuu.org.uk>
On Thu, May 21, 2009 at 6:14 PM, Alan Cox <alan@lxorguk.ukuu.org.uk> wrote:
>> Not sure, if we already discussed that with a conclusion: this
>> "prevent access to a future device" interface needs to work at the pid
>> level, or would a uid/gid check be sufficient?
>
> As I said before neither pid or uid make any sense at all for a kernel
> level check beyond what already exists at user space level (ie chown),
> and what the usual user space gunk provides for device creation policy
> (udev)
>
>> Root can do all that stuff anyway, even with the locking in place.
>> Uid/gid file permissions need to be applied to the "lock file", so
>> specified non-root users can use that interface.
>
> It's actually sometimes important that root can ignore the lock
> files - eg to send a reset to a channel of a jammed device that is owned
> by a user and wedged.
>
>> Maybe it would be good enough, to check that the one that opened the
>> "lock file" has the same uid/gid as the on that tries to open the
>> device when it has shown up?
>
> My feeling too - there simply isn't any need for kernel infrastructure
> here. The only case the kernel must be involved is when you need
> exclusivity including telling the kernel to leave things alone, and even
> that usually only needs to be by specific handle and we normally borrow
> O_EXCL for it as it has no "traditional" meaning on device nodes.
>
> We do tty devices with lock files no reason it won't work for USB stuff
> too.
Hrm, I think this is missing the point. Here's a practical example for you:
My Debian laptop has a Windows VM (using KVM, specifically) on it for
the occasional times when work forces me to use such software. One of
the things I need the Windows VM for is a USB JTAG debug box that (for
stupid Windows driver reasons) shows up as an HID device. The debug
box needs firmware loaded on it as soon as it is attached or it tends
to crash or behave unreliably; the firmware loading software is also
Windows-only. There are also other random USB devices like encrypted
flash drives with windows-only software, software license tokens, etc.
My ideal solution is to be able to prevent Linux from automatically
binding to any devices attached off specific USB ports. There's
simply no point in letting the usb-storage or usb-hid modules try to
scan those devices because I'm just going to immediately "unbind" them
and drive them with libusb *anyways*.
Basically I want one of my USB ports (which I plug into an external
hub) to always go to my Windows KVM, and another USB port (also with a
hub) to always go to my Fedora KVM. There are a couple requirements
for this:
(1) I need to be able to exclude any access *BEFORE* a device is connected.
(2) This exclusion needs to apply to kernel drivers
One possible alternative (although I don't know if this would work for
the OP), is to make there be a global "prevent kernel drivers from
autobinding to devices on his port" flag, and manage the rest with
lockfiles in userspace.
Cheers,
Kyle Moffett
next prev parent reply other threads:[~2009-05-22 1:28 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-19 16:57 Alan Stern
2009-05-21 9:52 ` Al Viro
2009-05-21 14:06 ` Alan Stern
2009-05-21 21:07 ` Kay Sievers
2009-05-21 21:27 ` Alan Stern
2009-05-22 13:30 ` Pantelis Koukousoulas
2009-05-22 13:38 ` Oliver Neukum
2009-05-22 13:43 ` Alan Cox
2009-05-22 13:52 ` Pantelis Koukousoulas
2009-05-22 14:12 ` Alan Cox
2009-05-22 14:29 ` Pantelis Koukousoulas
2009-05-21 22:14 ` Alan Cox
2009-05-22 1:28 ` Kyle Moffett [this message]
2009-05-22 9:53 ` Alan Cox
2009-05-22 15:12 ` Alan Stern
2009-05-22 15:20 ` Alan Cox
2009-05-22 16:04 ` Alan Stern
2009-05-22 16:23 ` Pantelis Koukousoulas
2009-05-22 18:19 ` Alan Stern
2009-05-22 15:21 ` Kay Sievers
2009-05-22 15:54 ` Alan Stern
2009-05-22 18:24 ` Kay Sievers
2009-05-22 18:48 ` Pantelis Koukousoulas
2009-05-22 19:31 ` Alan Stern
2009-05-22 21:54 ` Kay Sievers
2009-05-22 22:07 ` Alan Stern
2009-05-23 22:47 ` Kay Sievers
2009-05-22 8:36 ` Oliver Neukum
2009-05-21 22:22 ` Alan Cox
2009-05-22 12:26 ` Oliver Neukum
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f73f7ab80905211828te5c49dcx863a18c8e428a59f@mail.gmail.com \
--to=kyle@moffetthome.net \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=kay.sievers@vrfy.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stern@rowland.harvard.edu \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®