From: Casey Schaufler <casey@schaufler-ca.com>
To: Stephen Smalley <sds@tycho.nsa.gov>,
"Roberts, William C" <william.c.roberts@intel.com>,
Paul Moore <paul@paul-moore.com>
Cc: Daniel Cashman <dcashman@android.com>,
"selinux@tycho.nsa.gov" <selinux@tycho.nsa.gov>,
Eric Paris <eparis@parisplace.org>,
James Morris <james.l.morris@oracle.com>,
"serge@hallyn.com" <serge@hallyn.com>,
"linux-security-module@vger.kernel.org"
<linux-security-module@vger.kernel.org>,
"jeffv@google.com" <jeffv@google.com>,
"nnk@google.com" <nnk@google.com>,
"arve@google.com" <arve@google.com>,
Casey Schaufler <casey@schaufler-ca.com>
Subject: Re: Exposing secid to secctx mapping to user-space
Date: Tue, 15 Dec 2015 08:06:54 -0800 [thread overview]
Message-ID: <56703A9E.7000507@schaufler-ca.com> (raw)
In-Reply-To: <56702B25.9010205@tycho.nsa.gov>
On 12/15/2015 7:00 AM, Stephen Smalley wrote:
> On 12/14/2015 05:57 PM, Roberts, William C wrote:
>> <snip>
>>>>
>>>> If I understand correctly, the goal here is to avoid the lookup from
>>>> pid to context. If we somehow Had the context or a token to a context
>>>> during the ipc transaction to userspace, we could just use that In
>>>> computing the access decision. If that is correct, then since we have
>>>> PID, why not just extend the SE Linux compute av decision interface to support
>>> passing of PID and then it can do the lookup in the Kernel?
>>>
>>> That's no less racy than getpidcon().
>>>
>>
>> I got a bounce from when I sent this from gmail, resending.
>>
>> True, but in this case the binder transaction would be dead...
>>
>> Why not just pass ctx? It's less than ideal, but it might be good enough for now until contexts get unwieldy big.
>>
>> grep -rn '^type ' * | grep domain | cut -d' ' -f 2-2 | sed s/','//g | awk ' { thislen=length($0); printf("%-5s %dn", NR, thislen); totlen+=thislen}
>> END { printf("average: %dn", totlen/NR); } '
>>
>> The avg type length for domain types in external/sepolicy is 7. Add the full ctx:
>>
>> u:r:xxxxxxx:s0(cat)
>>
>> 1. We're looking at like 18 or so bytes, how do we know this won't be "fast enough"?
>> 2. What's the current perf numbers, and what's agreed upon on what you need to hit to be fast enough?
>> 3. I'm assuming the use case is in service manager, but would a userspace cache of AVD's help? Then you can (possibly) avoid both kernel trips, and you can invalidate the cache on policy reload and on PID deaths? In the case of service manager would it always be a miss based on usage pattern? I'm assuming things would say hey resolve this once, and be done. However, you could only do the ctx lookup and do the avd based on the policy in user space, thus avoiding 1 of two trips.
>
> 1. I don't think it is the size of the context that is the concern but rather the fact that it is a variable-length string, whereas current binder commands use fixed-size arguments and encode the size in the command value (common for ioctls). Supporting passing a variable-length string would be a change to the protocol and would complicate the code. On the performance side, it means generating a context string from the secid and then copying it to userspace on each IPC (versus just getting the secid and putting that in the existing binder_transaction_data that is already copied to userspace).
I have long wondered why SELinux generates the context string
of the secid more than once. Audit performance alone would
justify keeping it around. The variable length issue isn't
so difficult as you make it out. As William pointed out earlier,
most SELinux contexts are short. Two protocols, one with a
fixed length of 16 chars (typical is 7) and one with a fixed
length of 256 (for abnormal contexts) solve the problem without
complicating the code hardly at all.
If it's such a problem, why do we have SO_PEERSEC return a
variable length string? That's been around forever and seems
to work just fine.
>
> 2. Don't know; deferring to Daniel to run whatever binder IPC benchmarks might exist with and without the current patch that copies the context string.
>
> 3. It is for any binder-based service that wants to apply SELinux access checks, which presently includes servicemanager and keystore.
> We already have a userspace AVC (in libselinux) that gets used automatically when you use selinux_check_access(), but you still need to get the sender security context in some manner.
>
>
next prev parent reply other threads:[~2015-12-15 16:07 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-11 18:37 Exposing secid to secctx mapping to user-space Daniel Cashman
2015-12-11 19:55 ` Paul Moore
2015-12-11 20:41 ` Roberts, William C
2015-12-11 22:14 ` Stephen Smalley
2015-12-12 0:24 ` Casey Schaufler
2015-12-13 22:06 ` Paul Moore
2015-12-14 17:03 ` Mike Palmiotto
2015-12-14 17:31 ` Casey Schaufler
2015-12-14 17:42 ` Stephen Smalley
2015-12-14 17:50 ` Casey Schaufler
2015-12-14 21:29 ` Roberts, William C
2015-12-14 22:11 ` Stephen Smalley
2015-12-14 22:52 ` William Roberts
2015-12-14 22:57 ` Roberts, William C
2015-12-15 15:00 ` Stephen Smalley
2015-12-15 16:06 ` Casey Schaufler [this message]
2015-12-15 16:55 ` Stephen Smalley
2015-12-15 17:36 ` Casey Schaufler
2015-12-15 17:19 ` Joe Nall
2015-12-15 18:03 ` Stephen Smalley
2015-12-15 19:09 ` Joe Nall
2015-12-18 23:55 ` Paul Moore
2015-12-15 20:58 ` Daniel Cashman
2015-12-15 22:41 ` William Roberts
2015-12-18 23:54 ` Paul Moore
2015-12-11 20:36 ` Casey Schaufler
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=56703A9E.7000507@schaufler-ca.com \
--to=casey@schaufler-ca.com \
--cc=arve@google.com \
--cc=dcashman@android.com \
--cc=eparis@parisplace.org \
--cc=james.l.morris@oracle.com \
--cc=jeffv@google.com \
--cc=linux-security-module@vger.kernel.org \
--cc=nnk@google.com \
--cc=paul@paul-moore.com \
--cc=sds@tycho.nsa.gov \
--cc=selinux@tycho.nsa.gov \
--cc=serge@hallyn.com \
--cc=william.c.roberts@intel.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.