From: Bastien Nocera <hadess@hadess.net>
To: linux-usb@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Alan Stern <stern@rowland.harvard.edu>,
Benjamin Tissoires <benjamin.tissoires@redhat.com>,
Peter Hutterer <peter.hutterer@who-t.net>,
Bastien Nocera <hadess@hadess.net>
Subject: [RFC v2] USB: core: add a way to revoke access to open USB devices
Date: Thu, 4 Aug 2022 18:03:04 +0200 [thread overview]
Message-ID: <20220804160306.134014-1-hadess@hadess.net> (raw)
Hey,
This is a follow-up to "[RFC v1] USB: core: add USBDEVFS_REVOKE ioctl" from April.
The end-goal is being able to cut-off access to USB devices for
applications/programs that open raw USB devices using, in most cases,
libusb.
I've implemented this using BPF, so we don't need to add new ioctls.
The presence or absence of that feature can be evaluated at runtime,
and can be used to implement revoke support on session switching,
in logind for example:
https://github.com/hadess/usb-revoke-userspace/
I have some notes and questions on the API as it is exposed.
- I didn't see a point in having multiple kernel functions as entry
points as I was going to use a single BPF program as an entry point,
which can check the arguments. Can I rely on the BPF program checking
those arguments, or should I re-check them again in the kernel
implementation?
- Are my UID checks correct if I expect revoking to be called outside
namespaces, on the effective UID of the user. Is there a way to assert
that?
- Is there a good "errno" error for ENOSUCHUSER for using in the
usb_revoke() loop if we couldn't find any USB device matching the
requested user?
Cheers
Bastien Nocera (2):
USB: core: add a way to revoke access to open USB devices
usb: Implement usb_revoke() BPF function
drivers/usb/core/devio.c | 105 ++++++++++++++++++++++++++++++++++++---
drivers/usb/core/usb.c | 51 +++++++++++++++++++
drivers/usb/core/usb.h | 8 +++
3 files changed, 158 insertions(+), 6 deletions(-)
--
2.36.1
next reply other threads:[~2022-08-04 16:03 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-08-04 16:03 Bastien Nocera [this message]
2022-08-04 16:03 ` [RFC v2 1/2] USB: core: add a way to revoke access to open USB devices Bastien Nocera
2022-08-04 19:25 ` Alan Stern
2022-08-05 12:38 ` Bastien Nocera
2022-08-05 14:42 ` Alan Stern
2022-08-09 9:10 ` Bastien Nocera
2022-08-04 16:03 ` [RFC v2 2/2] usb: Implement usb_revoke() BPF function Bastien Nocera
2022-08-04 19:12 ` [RFC v2] USB: core: add a way to revoke access to open USB devices Alan Stern
2022-08-05 12:38 ` Bastien Nocera
2022-08-05 14:31 ` Alan Stern
2022-08-09 9:10 ` Bastien Nocera
2022-08-09 12:09 ` Bastien Nocera
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=20220804160306.134014-1-hadess@hadess.net \
--to=hadess@hadess.net \
--cc=benjamin.tissoires@redhat.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-usb@vger.kernel.org \
--cc=peter.hutterer@who-t.net \
--cc=stern@rowland.harvard.edu \
/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