public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Willy Tarreau <w@1wt.eu>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Solar Designer <solar@openwall.com>,
	Alex Riesen <fork0@users.sourceforge.net>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] set*uid() must not fail-and-return on OOM/rlimits
Date: Sun, 20 Aug 2006 20:10:25 +0200	[thread overview]
Message-ID: <20060820181025.GN602@1wt.eu> (raw)
In-Reply-To: <1156097013.4051.14.camel@localhost.localdomain>

On Sun, Aug 20, 2006 at 07:03:33PM +0100, Alan Cox wrote:
> Ar Sul, 2006-08-20 am 19:30 +0400, ysgrifennodd Solar Designer:
> > The problem is that there are lots of privileged userspace programs that
> > do not bother to check the return value from set*uid() calls (or
> > otherwise check that the calls succeeded) before proceeding with work
> > that is only safe to do with the *uid switched as intended.
> 
> People keep saying this but we seem short of current, commonly shipped
> examples. And quite frankly any code that doesn't check setuid returns
> is unlikely to be fit for purpose in any other way and presumably has
> never been adequately audited.

This is a beginner's bug. It is a common misconception to believe that
because your program is started as root, it will be allowed to switch
to any other uid. People do not always realize that the syscall might
fail (and not on all OSes it seems), resulting in their program still
running with all privileges. I remember having stuffed some
'setuid(getuid())' in some of my programs a long time ago, I don't see
why others would not do the same. I'm not the only dumb person on this
planet :-)

There's an interesting paper about uid transitions here :

  http://seclab.cs.ucdavis.edu/papers/Hao-Chen-papers/usenix02.pdf

Also, for examples of programs affected till recently, look at the
date on this patch (few weeks ago) :

  http://ftp.x.org/pub/X11R7.1/patches/xf86dga-1.0.1-setuid.diff

and this one now (few days ago) :

  http://www.linuxfromscratch.org/patches/downloads/xorg-server/xorg-server-1.1.0-setuid-2.patch

Scary, both X servers are affected...

Now it's not hard to find programs still working like this. Googling
"setuid(getuid())" returns several ones like this :

  http://devel.squid-cache.org/hno/setfilelimit.c

Here, someone proposing to make tcpdump drop privileges :

  http://www.mail-archive.com/tcpdump-workers@sandelman.ottawa.on.ca/msg03170.html

> Alan

So I think that while it's bad code in userland, a misunderstood kernel
semantic caught the developpers. We can at least make the kernel help them.

Regards,
Willy


  reply	other threads:[~2006-08-20 18:11 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-20  0:38 [PATCH] set*uid() must not fail-and-return on OOM/rlimits Solar Designer
2006-08-20  7:52 ` Kari Hurtta
2006-08-20 18:10   ` Alan Cox
2006-08-21  5:05     ` Kari Hurtta
2006-08-20  8:26 ` Willy Tarreau
2006-08-20 15:25   ` Solar Designer
2006-08-20 10:07 ` Alex Riesen
2006-08-20 15:30   ` Solar Designer
2006-08-20 15:53     ` Arjan van de Ven
2006-08-20 16:17       ` Willy Tarreau
2006-08-20 16:28       ` Ulrich Drepper
2006-08-20 16:45         ` Arjan van de Ven
2006-08-20 16:47         ` Michael Buesch
2006-08-20 16:48         ` Solar Designer
2006-08-20 18:03     ` Alan Cox
2006-08-20 18:10       ` Willy Tarreau [this message]
2006-08-20 18:36         ` Alan Cox
2006-08-20 18:21           ` Willy Tarreau
2006-08-20 18:52             ` Alan Cox
2006-08-20 19:01               ` Willy Tarreau
2006-08-20 19:33                 ` Alan Cox
2006-08-20 19:17                   ` Willy Tarreau
2006-08-20 16:04 ` Florian Weimer
2006-08-20 16:25   ` Solar Designer
2006-08-20 18:14 ` Alan Cox
2006-08-20 22:12   ` Solar Designer
2006-08-20 22:51     ` Alan Cox
2006-08-20 22:58       ` Solar Designer
2006-08-20 23:00       ` Alan Cox
2006-08-21  0:23       ` Peter Williams
2006-08-21  0:45         ` Solar Designer

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=20060820181025.GN602@1wt.eu \
    --to=w@1wt.eu \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=fork0@users.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=solar@openwall.com \
    /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