linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Suspending access to opened/active /dev/nodes during application runtime
@ 2014-03-07 18:45 Lukasz Pawelczyk
  2014-03-07 19:24 ` Lennart Poettering
  2014-03-11 12:33 ` David Herrmann
  0 siblings, 2 replies; 8+ messages in thread
From: Lukasz Pawelczyk @ 2014-03-07 18:45 UTC (permalink / raw)
  To: linux-input-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	libvir-list-H+wXaHxf7aLQT0dZR+AlfA,
	lxc-devel-cunTk1MwBs9qMoObBWhMNEqPaTDuhLve2LY78lusg7I,
	systemd-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, David Herrmann


[-- Attachment #1.1: Type: text/plain, Size: 2346 bytes --]

Problem:
Has anyone thought about a mechanism to limit/remove an access to a
device during an application runtime? Meaning we have an application
that has an open file descriptor to some /dev/node and depending on
*something* it gains or looses the access to it gracefully (with or
without a notification, but without any fatal consequences).

Example:
LXC. Imagine we have 2 separate containers. Both running full operating
systems. Specifically with 2 X servers. Both running concurrently of
course. Both need the same input devices (e.g. we have just one mouse).
This creates a security problem when we want to have completely separate
environments. One container is active (being displayed on a monitor and
controlled with a mouse) while the other container runs evtest
/dev/input/something and grabs the secret password user typed in the
other.

Solutions:
The complete solution would comprise of 2 parts:
- a mechanism that would allow to temporally "hide" a device from an
open file descriptor.
- a mechanism for deciding whether application/process/namespace should
have an access to a specific device at a specific moment

Let's focus on the first problem only, as it would need to be solved
first anyway.  I haven't found anything that would allow me to do
it. There are a lot mechanisms that make it possible to restrict an
access during open():
- DAC
- ACL (controlled by hand or with uaccess)
- LSM (in general)
- device cgroups
But all of those can't do a thing when the device is already opened and
an application has a file descriptor.  I don't see such mechanism in
kernel sources either.

I do imagine that it would not be possible for every device to handle
such a thing (dri comes to mind) without breaking something (graphics
card state in dri example). But there is class of simple input/output
devices that would handle this without problems.

I did implement some proof-of-concept solution for an evdev driver by
allowing or disallowing events that go to evdev_client structure using
some arbitrary condition. But this is far from a generic solution.

My proof-of-concept is somewhat similar to this (I just found it):
http://www.spinics.net/lists/linux-input/msg25547.html
Though a little bit wider in scope. But neither is flawless nor
generic.

Has anyone had any thoughts about a similar problem?


-- 
Regards
Havner

[-- Attachment #1.2: Type: text/html, Size: 3239 bytes --]

[-- Attachment #2: Type: text/plain, Size: 194 bytes --]

_______________________________________________
lxc-devel mailing list
lxc-devel-cunTk1MwBs9qMoObBWhMNEqPaTDuhLve2LY78lusg7I@public.gmane.org
http://lists.linuxcontainers.org/listinfo/lxc-devel

^ permalink raw reply	[flat|nested] 8+ messages in thread
* Suspending access to opened/active /dev/nodes during application runtime
@ 2014-03-07 18:46 Lukasz Pawelczyk
  2014-03-07 19:09 ` [systemd-devel] " Greg KH
  0 siblings, 1 reply; 8+ messages in thread
From: Lukasz Pawelczyk @ 2014-03-07 18:46 UTC (permalink / raw)
  To: linux-input, linux-kernel, libvir-list, lxc-devel, systemd-devel,
	David Herrmann

Problem:
Has anyone thought about a mechanism to limit/remove an access to a
device during an application runtime? Meaning we have an application
that has an open file descriptor to some /dev/node and depending on
*something* it gains or looses the access to it gracefully (with or
without a notification, but without any fatal consequences).

Example:
LXC. Imagine we have 2 separate containers. Both running full operating
systems. Specifically with 2 X servers. Both running concurrently of
course. Both need the same input devices (e.g. we have just one mouse).
This creates a security problem when we want to have completely separate
environments. One container is active (being displayed on a monitor and
controlled with a mouse) while the other container runs evtest
/dev/input/something and grabs the secret password user typed in the
other.

Solutions:
The complete solution would comprise of 2 parts:
- a mechanism that would allow to temporally "hide" a device from an
open file descriptor.
- a mechanism for deciding whether application/process/namespace should
have an access to a specific device at a specific moment

Let's focus on the first problem only, as it would need to be solved
first anyway.  I haven't found anything that would allow me to do
it. There are a lot mechanisms that make it possible to restrict an
access during open():
- DAC
- ACL (controlled by hand or with uaccess)
- LSM (in general)
- device cgroups
But all of those can't do a thing when the device is already opened and
an application has a file descriptor.  I don't see such mechanism in
kernel sources either.

I do imagine that it would not be possible for every device to handle
such a thing (dri comes to mind) without breaking something (graphics
card state in dri example). But there is class of simple input/output
devices that would handle this without problems.

I did implement some proof-of-concept solution for an evdev driver by
allowing or disallowing events that go to evdev_client structure using
some arbitrary condition. But this is far from a generic solution.

My proof-of-concept is somewhat similar to this (I just found it):
http://www.spinics.net/lists/linux-input/msg25547.html
Though a little bit wider in scope. But neither is flawless nor
generic.

Has anyone had any thoughts about a similar problem?


-- 
Regards
Havner

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

end of thread, other threads:[~2014-03-11 16:02 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-07 18:45 Suspending access to opened/active /dev/nodes during application runtime Lukasz Pawelczyk
2014-03-07 19:24 ` Lennart Poettering
2014-03-07 20:51   ` [systemd-devel] " Lukasz Pawelczyk
2014-03-08  2:39     ` Lennart Poettering
     [not found]     ` <9E972401-6FA3-439B-9531-49D1FCC8D61D-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-03-11 16:02       ` [lxc-devel] [systemd-devel] " Oren Laadan
2014-03-11 12:33 ` David Herrmann
  -- strict thread matches above, loose matches on Subject: below --
2014-03-07 18:46 Lukasz Pawelczyk
2014-03-07 19:09 ` [systemd-devel] " Greg KH
2014-03-07 20:45   ` Lukasz Pawelczyk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).