linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: linux-hotplug@vger.kernel.org
Subject: Re: [security] Race condition in udev
Date: Tue, 25 Aug 2009 18:20:55 +0000	[thread overview]
Message-ID: <20090825182055.GA13957@kroah.com> (raw)
In-Reply-To: <20090821102407.GA29609@florz.florz.dyndns.org>

On Tue, Aug 25, 2009 at 08:11:37PM +0200, Florian Zumbiehl wrote:
> Hi,
> 
> > On Tue, Aug 25, 2009 at 07:31:30PM +0200, Florian Zumbiehl wrote:
> > > Assumption:
> > > 
> > >  /dev/foo is configured to be owned by user root, group users, mode 0646.
> > >  The attacker tries to open /dev/foo for writing as a user that's not
> > >  root, not a member of the group root, but a member of the group users.
> > > 
> > > The Trace:
> > > 
> > >   action                     | owner | group | mode    | open(O_WRONLY)?
> > >  ----------------------------+-------+-------+---------+-----------------
> > >   mknod(/dev/foo)            | root  | root  | 0644(?) | no
> > >   chmod(/dev/foo,0646)       | root  | root  | 0646    | yes
> > >   chown(/dev/foo,root,users) | root  | users | 0646    | no
> > 
> > Are there any current device nodes that get set to this kind of "odd"
> > permissions with the current udev ruleset?
> 
> None that I am aware of - I haven't really looked, though :-)
> 
> But I have encountered such "odd" permissions in the wild for other
> purposes - so, it's probably not a thing that has to be fixed in all
> distributions by yesterday morning, but as a matter of reliability,
> I think it still ought to be fixed.

And again, specifically how do you think this should be fixed?

And see Scott's responses as to why this type of configuration is
invalid.

> > > Could we now take care of the bug?
> > 
> > Do you have a proposed patch?
> 
> Nope, not yet - it was part of my intention behind this thread to gain
> some understanding of the code so as to possibly be able to provide a
> patch that doesn't break the code in some other way. In particular, as
> mentioned, the purpose of the special case codepath for a pre-existing
> device node isn't all that clear to me.
> 
> I guess the general ideas I have in mind are roughly:
> 
> a) mknod() it under some temporary name with appropriate euid/egid and
>    umask, then rename it into place.
> 
>    This one seems to have some issues that I can't really judge yet
>    (changing inode number, ACLs being dropped).

That will not work for the case of an existing device node, correct?

> b) (optionally mknod() with mode&0600), chmod() to mode&0600,
>    chown() to configured owner/group, chmod() to configured mode.
> 
>    This one potentially temporarily reduces permissions to a proper
>    subset of both the permissions before and after the change -
>    I guess that that's not desirable?

See Scott's response as to why this isn't ok.

thanks,

greg k-h

  parent reply	other threads:[~2009-08-25 18:20 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-21 10:24 [security] Race condition in udev Florian Zumbiehl
2009-08-21 11:14 ` Kay Sievers
2009-08-21 11:25 ` Florian Zumbiehl
2009-08-21 11:59 ` Kay Sievers
2009-08-22  0:19 ` Florian Zumbiehl
2009-08-22  2:25 ` Bryan Kadzban
2009-08-22  3:11 ` Florian Zumbiehl
2009-08-25 11:32 ` Florian Zumbiehl
2009-08-25 11:58 ` Scott James Remnant
2009-08-25 12:03 ` Kay Sievers
2009-08-25 12:21 ` Florian Zumbiehl
2009-08-25 12:43 ` Scott James Remnant
2009-08-25 12:55 ` Florian Zumbiehl
2009-08-25 13:11 ` Florian Zumbiehl
2009-08-25 13:31 ` Scott James Remnant
2009-08-25 14:22 ` Florian Zumbiehl
2009-08-25 16:08 ` Scott James Remnant
2009-08-25 16:27 ` Florian Zumbiehl
2009-08-25 16:49 ` Scott James Remnant
2009-08-25 17:31 ` Florian Zumbiehl
2009-08-25 17:42 ` Greg KH
2009-08-25 18:04 ` Robby Workman
2009-08-25 18:05 ` Scott James Remnant
2009-08-25 18:11 ` Florian Zumbiehl
2009-08-25 18:17 ` Kay Sievers
2009-08-25 18:20 ` Greg KH [this message]
2009-08-25 18:21 ` Greg KH
2009-08-25 18:38 ` Florian Zumbiehl
2009-08-25 18:53 ` Florian Zumbiehl
2009-08-25 19:10 ` Greg KH
2009-08-25 19:28 ` Mr POSIX
2009-08-25 21:55 ` Florian Zumbiehl
2009-08-26 11:22 ` Scott James Remnant
2009-08-26 17:41 ` Florian Zumbiehl
2009-08-26 21:00 ` Greg KH
2009-08-27  6:54 ` Matthias Schwarzott
2009-08-27 15:09 ` Florian Zumbiehl
2009-08-27 15:13 ` Florian Zumbiehl
2009-08-27 15:22 ` Greg KH
2009-08-27 15:52 ` Florian Zumbiehl
2009-08-27 16:03 ` Florian Zumbiehl
2009-08-28 17:34 ` Florian Zumbiehl
2009-08-29 14:15 ` Kay Sievers
2009-08-29 14:20 ` Florian Zumbiehl
2009-08-29 14:32 ` Kay Sievers
2009-08-29 14:41 ` Florian Zumbiehl
2009-08-29 14:47 ` Kay Sievers
2009-08-29 14:58 ` Florian Zumbiehl
2009-09-04 19:12 ` Florian Zumbiehl
2009-09-04 19:16 ` Florian Zumbiehl

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=20090825182055.GA13957@kroah.com \
    --to=greg@kroah.com \
    --cc=linux-hotplug@vger.kernel.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).