linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dave Airlie <airlied@gmail.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Matthew Wilcox <matthew@wil.cx>,
	peter.hutterer@who-t.net, linux-input@vger.kernel.org,
	xorg@freedesktop.org
Subject: Re: Securing non-root X input
Date: Sun, 31 Jan 2010 18:38:51 +1000	[thread overview]
Message-ID: <21d7e9971001310038y11a936f2g778f4a3119652692@mail.gmail.com> (raw)
In-Reply-To: <20100131071307.GB12320@core.coreip.homeip.net>

On Sun, Jan 31, 2010 at 5:13 PM, Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
> On Sat, Jan 30, 2010 at 06:35:47PM -0700, Matthew Wilcox wrote:
>> On Fri, Jan 29, 2010 at 11:45:46PM -0800, Dmitry Torokhov wrote:
>> > Hi Matthew,
>> >
>> > On Fri, Jan 29, 2010 at 04:24:38PM -0700, Matthew Wilcox wrote:
>> > > This tiny patch allows the X server to ask how many times the device has
>> > > been opened.  If it's more than one, the X server can ask the user what
>> > > they want to do about it.  For bonus points, the X server can also run
>> > > programs like lsof or fuser to find out which other processes have the
>> > > device open, and tell the user that information too.  At that point,
>> > > the sysadmin can call in the ICBM strike on the offending user.
>> > >
>> > > Does this approach work for everyone?
>> >
>> > I do not think so. What about the cases when event devices are
>> > legitimately opened by several processes, like this:
>> >
>> > [dtor@dtor-d630 work]$ ps aux | grep hald-addon-input
>> > root      1132  0.0  0.0  22200   824 ?        S    Jan22   0:29
>> > hald-addon-input: Listening on /dev/input/event7 /dev/input/event2 /dev/input/event1 /dev/input/event6 /dev/input/event0 /dev/input/event12 /dev/input/event4
>> > dtor     30424  0.0  0.0 102736   808 pts/3    S+   23:23   0:00 grep hald-addon-input
>> > [dtor@dtor-d630 work]$
>> >
>> > It might not be hald but some other daemon monitoring key presses
>> > (sleep, hibernate, wifi keys and switches, etc).
>> >
>> > If it was just about ensuring that only oneprocess accesses the device
>> > then we could just use EVIOCGRAB but as experience shows it is not a
>> > workable solution.
>>
>> Yes, that's right.  I didn't quite go far enough in my explanation
>> above ...  the X server can look around the system to see what trusted
>> daemons (running as either root or the same user as the one running X)
>> currently have the device open, and notify the user if there's additional
>> openers that it isn't expecting.
>>
>
> Then it will be constant race between X and the rest of the world with X
> pretty much always behind. Kind of like SELinux - as soon as try moving
> left or right the thing starts screaming at you...
>
>> Maybe we don't need a kernel patch to make this work after all, just
>> a suid helper for X that uses the code from lsof/fuser to list all the
>> current openers of /dev/input/eventN.
>>
>
> But what about the case where malicious user opens the devices after the
> X done its scan?

That can't happen since we remove privs from the previous users of the
node before starting the new X server via ConsoleKit or at least thats the plan,

The problem is only a user holding open the evdev device after they've lost
perms on the device.

Dave.

> mknod is a privileged operation, requiring CAP_MKNOD. Otherwise evcen
> current setup would be completely insecure if any user could just mknod
> in his home directory and snoop root's keypresses at console.

Its more the other devices the kernel might make, or udev. Not sure if
that ever happens though.

Dave.
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2010-01-31  8:38 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-29 23:24 Securing non-root X input Matthew Wilcox
2010-01-30  7:45 ` Dmitry Torokhov
2010-01-31  1:35   ` Matthew Wilcox
2010-01-31  7:13     ` Dmitry Torokhov
2010-01-31  8:38       ` Dave Airlie [this message]
2010-01-31  8:50         ` Dmitry Torokhov
2010-01-31 17:08       ` Matthew Wilcox
2010-02-01  2:03         ` Dmitry Torokhov

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=21d7e9971001310038y11a936f2g778f4a3119652692@mail.gmail.com \
    --to=airlied@gmail.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=matthew@wil.cx \
    --cc=peter.hutterer@who-t.net \
    --cc=xorg@freedesktop.org \
    /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;
as well as URLs for NNTP newsgroup(s).