public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: David Madore <david.madore@ens.fr>
To: Linux Kernel mailing-list <linux-kernel@vger.kernel.org>
Cc: "Serge E. Hallyn" <serue@us.ibm.com>
Subject: Re: patch to make Linux capabilities into something useful (v 0.3.1)
Date: Fri, 8 Sep 2006 03:08:02 +0200	[thread overview]
Message-ID: <20060908010802.GA14770@clipper.ens.fr> (raw)
In-Reply-To: <20060907230245.GB21124@sergelap.austin.ibm.com>

On Thu, Sep 07, 2006 at 06:02:45PM -0500, Serge E. Hallyn wrote:
> Ok, so to be clear, in terms of inheritability of capabilities, your
> three main changes are:

Yes, this is a fair description:

> 	1. When creating a bprm, it's inheritable and effective
> 	capability sets are set full on, whereas they used to be
> 	cleared.  The permitted set is treated as before (always
> 	cleared)

- This is to make capabilities inheritable but don't add any others
except when executing suid root.

> 	2. When computing a process' new capabilities, the new
> 	inheritable come from the new permitted, rather than the old
> 	inheritable.

- The reason for that is the necessity to preserve Unix semantics (see
below).

> 	3. You change half the computation of p'E to replace fE by
> 	pE in one half.

- Again, to preserve Unix semantics (if a process with {r,s}uid=0 and
euid!=0 does an exec(), the resulting process also has euid!=0, that
is, no effective capabilities).

> Here is one apparent change in behavior:
> 
> If I currently do
> 
> 	cp /bin/sh /bin/shsetuid
> 	chmod u+s /bin/shsetuid
> 
> then log in as uid 1000 and run
> 
> 	/bin/shsetuid
> 	# whoami
> 	hallyn
> 	# ls /root
> 	ls: /root: Permission denied

What does "currently" mean"?  On an unpatched Linux, I believe (and
observe) the following:

* if your /bin/sh is bash, it purposely drops privileges (by doing
something like setresuid(getuid(),getuid(),getuid()), I haven't
checked the source), and this is the reason you get "Permission
denied",

* if your /bin/sh is something else, it keeps euid==0 and you have
root privileges all the way, including in children processes - this is
traditional Unix behavior.

My patch doesn't change any of this (I've checked), since it uses
inheritance rules for capabilities which are closely modeled upon
those of {r,s,e}uid (in fact, that's my very reason for "changing"
things), and since the bash method of dropping privileges is also kept
woring.

(I don't know *why* bash tries to drop privileges.  It's probably an
attempt at avoiding certain security problems, but I think it's a
rather bad one.)

> With your patch I believe it will succeed, since the sh process'
> inheritable set will be set to it's permitted set.

My patch doesn't change this behavior.  Evidently, if it did, it would
be very bad...

> Put another way:

I'm not sure why what follows is a restatement of what precedes, so
I'll answer differently.

> 	cap_set_proc("=i");
> 	execve("/bin/shsetuid");
> 
> I obviously wanted my inheritable set to be cleared, but running the
> setuid binary will end up resetting my inheritable set to a larger
> set.  Your goal of allowing the inheritable caps to be truly
> inheritable may make sense, but this part of it feels wrong, and
> changes current setuid behavior.

In the current (unpatched) Linux kernel, the inheritable set is
completely ignored anyway. :-( So certainly any attempt to make
something of it must change the behavior.

I agree that the above code snippet exhibits a difference of my patch
w.r.t. the capabilities(7)-documented behavior (or at least, might,
according to the way suid programs are interpreted), but this
difference is

(a) necessary in order not to break traditional Unix semantics
(children of a program with euid==0 also have euid==0, and the father
process can't avoid that), and

(b) necessary for security reasons (it is imperative that the parent
of a suid root process cannot prevent that process from keeping
privileges, otherwise we get the sendmail bug again).


To summarize my answer: as far as I know, my patch does not change
suid behavior: I've taken great care not to let that happen.  It does
change the documented inheritance behavior of capabilities, but that
is unavoidable.

PS: I should be releasing a new version of my patch, along with a
merged version of yours, very shortly.

-- 
     David A. Madore
    (david.madore@ens.fr,
     http://www.madore.org/~david/ )

  reply	other threads:[~2006-09-08  1:08 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-05 21:26 patch to make Linux capabilities into something useful (v 0.3.1) David Madore
2006-09-06  0:27 ` Casey Schaufler
2006-09-06 10:06   ` David Madore
2006-09-06 13:26     ` David Madore
2006-09-07  0:11       ` Casey Schaufler
2006-09-07  0:32         ` David Madore
2006-09-07  1:01           ` Casey Schaufler
2006-09-07  1:29             ` David Wagner
2006-09-07 16:00               ` Casey Schaufler
2006-09-07 18:33                 ` David Wagner
2006-09-07 17:34             ` David Madore
2006-09-07 19:38               ` Bernd Eckenfels
2006-09-07 23:00                 ` Pavel Machek
2006-09-08  1:22                   ` Bernd Eckenfels
2006-09-08 10:45                     ` Pavel Machek
2006-09-08 16:08                       ` Casey Schaufler
2006-09-08 14:39                     ` Pavel Machek
2006-09-08 19:10                       ` Bernd Eckenfels
2006-09-07 22:54               ` Pavel Machek
2006-09-08  4:10                 ` David Madore
2006-09-08 10:52                   ` Pavel Machek
2006-09-08 22:51                     ` David Madore
2006-09-09  0:11                       ` Casey Schaufler
2006-09-09 11:59                         ` Pavel Machek
2006-09-09 11:40                       ` Pavel Machek
2006-09-10 10:41                         ` David Madore
2006-09-10 13:06                           ` Pavel Machek
2006-09-10 14:25                             ` capability inheritance (was: Re: patch to make Linux capabilities into something useful (v 0.3.1)) David Madore
2006-09-10 22:42                               ` Pavel Machek
2006-09-11 16:00                               ` Casey Schaufler
2006-09-11 17:39                                 ` David Madore
2006-09-09  0:59                   ` patch to make Linux capabilities into something useful (v 0.3.1) David Wagner
2006-09-09 12:49                     ` David Madore
2006-09-09 23:18       ` Theodore Tso
2006-09-10 10:13         ` David Madore
2006-09-10 12:36         ` Pavel Machek
2006-09-10 23:24           ` Theodore Tso
2006-09-11  8:09             ` Pavel Machek
2006-09-06 18:25 ` Serge E. Hallyn
2006-09-06 22:27   ` David Madore
2006-09-07  0:04     ` David Madore
2006-09-07 23:06       ` Serge E. Hallyn
2006-09-08  4:16         ` David Madore
2006-09-07  6:43     ` Jan Engelhardt
2006-09-07 23:02     ` Serge E. Hallyn
2006-09-08  1:08       ` David Madore [this message]
2006-09-08  1:31         ` Serge E. Hallyn
2006-09-08 21:45           ` David Madore
2006-09-07 18:21 ` James Antill
2006-09-07 18:33   ` Kyle Moffett
2006-09-07 20:05     ` James Antill
2006-09-08  4:00   ` David Madore

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=20060908010802.GA14770@clipper.ens.fr \
    --to=david.madore@ens.fr \
    --cc=linux-kernel@vger.kernel.org \
    --cc=serue@us.ibm.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