All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael C Thompson <thompsmc@us.ibm.com>
To: "Serge E. Hallyn" <serue@us.ibm.com>
Cc: SE Linux <selinux@tycho.nsa.gov>, Stephen Smalley <sds@tycho.nsa.gov>
Subject: Re: [PATCH 4/8] make newrole suid (take 3)
Date: Tue, 07 Nov 2006 14:09:08 -0600	[thread overview]
Message-ID: <4550E7E4.4000505@us.ibm.com> (raw)
In-Reply-To: <20061107052338.GB11273@sergelap.austin.ibm.com>

Serge E. Hallyn wrote:
> Quoting Michael C Thompson (thompsmc@us.ibm.com):
>> Michael C Thompson wrote:
>>> The 8 patches are as follows:
>>> 1) Modifications to Makefile to support future patch needs
>>>   Add newrole-lspp.pamd
>>> 2) New extract_pw_data function and use in main()
>>> 3) Add signal handler function
>>> 4) Update drop_capabilities() and use in main()
>> This is the 4th of 8 patches.
>> This patch applies against policycoreutils-1.30.30-1.
>>
>> This patch adds expands the drop_capabilities functionality
>> to support various compile-time options (with audit, with
>> namespace, or neither).
>>
>> Changes:
>>  * Splits drop_capabilities into three versions (compile time option):
>>    - 'No-cap' version, returns true
>>    - 'audit-only' version, retains only CAP_AUDIT_WRITE
>>       Enable with AUDIT_LOG_PRIV=y
>>    - 'namespace+' version, retains CAP_AUDIT_WRITE, CAP_SYS_ADMIN and
>>       more to allow namespace actions
>>       Enable with NAMESPACE_PRIV = y
>>  * main() calls drop_capabilities unconditionally
> 
> It looks like your two later versions of drop_capabilities() don't call
> setresuid?  Your comment doesn't explain why, and a very quick scan of
> your later patches didn't show you adding them.

OK, thanks for pointing this out, its a clear deficiency in the code's 
documentation. Here is my explanation of the code:

There are 4 versions of compiling this code:
1. No auditing or namespace support
2. Auditing but not namespace
3. Namespace but not auditing
4. Both

For the 3rd version of drop_capabilities, that is the return 0; inline, 
it is used when compiled without auditing or namespace capabilities. 
Therefore, there is no need to make newrole suid in this case, and 
drop_capabilities is a 'no-op'.

In the case where you compile with only auditing support the original 
version of drop_capabilities (which does do setresuid) is sufficient 
because as long as we maintain the CAP_AUDIT_WRITE, we can get rid of 
the other capabilities and switch to the user's uid.

However, in order to support namespaces, we need to retain more 
capabilities and Stephen Smalley suggested that the euid of the process 
not be changed to the caller's uid until after the pam_open_session() 
call, so that any actions taken by the pam_namespace module are done as 
euid 0. The reasoning was that the calling user would not be able to 
take advantage of the directories that get created by the pam_namespace 
module before it could set their correct permissions and security 
contexts. The transition_to_caller_uid() function is what handles this 
setresuid() change when compiled to support namespaces, and is called 
after the pam_open_session() call returns.

So, in summary, the 1st version of drop_capabilities() does setresuid 
immediately because we don't need to retain euid 0, the 2nd version of 
drop_capabilities() defers the setresuid to transition_to_call_uid() 
function in order to have a more secure pam_open_session() call, and the 
3rd version is for when newrole is not suid, and therefore doesn't need 
to make that call.

Let me know if any of the above explanations are not sufficient because 
I plan on adding this to the code.

Mike


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

  reply	other threads:[~2006-11-07 20:09 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-03  0:37 [PATCH 0/8] make newrole suid (take 3) Michael C Thompson
2006-11-03  1:02 ` [PATCH 1/8] " Michael C Thompson
2006-11-03  1:03 ` [PATCH 2/8] " Michael C Thompson
2006-11-07  4:54   ` Serge E. Hallyn
2006-11-07 19:41     ` Michael C Thompson
2006-11-03  1:04 ` [PATCH 3/8] " Michael C Thompson
2006-11-03  1:05 ` [PATCH 4/8] " Michael C Thompson
2006-11-07  5:23   ` Serge E. Hallyn
2006-11-07 20:09     ` Michael C Thompson [this message]
2006-11-08 17:32       ` Serge E. Hallyn
2006-11-08 19:35         ` Michael C Thompson
2006-11-09  5:15           ` Serge E. Hallyn
2006-11-09 13:57             ` Stephen Smalley
2006-11-09 16:37               ` Serge E. Hallyn
2006-11-09 20:06                 ` Stephen Smalley
2006-11-09 21:21                   ` Serge E. Hallyn
2006-11-09 20:22                 ` Michael C Thompson
2006-11-09 20:27                   ` Stephen Smalley
2006-11-03  1:05 ` [PATCH 5/8] " Michael C Thompson
2006-11-03  1:06 ` [PATCH 6/8] " Michael C Thompson
2006-11-03  1:06 ` [PATCH 7/8] " Michael C Thompson
2006-11-03  1:07 ` [PATCH 8/8] " Michael C Thompson
2006-11-14  0:08 ` [PATCH 0/8] " Stephen Smalley

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=4550E7E4.4000505@us.ibm.com \
    --to=thompsmc@us.ibm.com \
    --cc=sds@tycho.nsa.gov \
    --cc=selinux@tycho.nsa.gov \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.