* Handling unknown permissions in userspace object managers
@ 2013-11-01 15:18 Eric Paris
2013-11-01 15:48 ` Stephen Smalley
0 siblings, 1 reply; 7+ messages in thread
From: Eric Paris @ 2013-11-01 15:18 UTC (permalink / raw)
To: selinux, sds; +Cc: codonell
glibc/nscd is acting as a userspace object manager. Today what they are
doing is:
static const access_vector_t perms[LASTREQ] =
{
[GETPWBYNAME] = NSCD__GETPWD,
[GETPWBYUID] = NSCD__GETPWD,
...
[INNETGR] = NSCD__GETNETGRP,
[GETFDNETGR] = NSCD__SHMEMNETGRP,
};
...
rc = avc_has_perm (ssid, tsid, SECCLASS_NSCD, perms[req], &aeref, NULL) < 0;
...
They recently ran into problems where they defined NSCD__GETNETGRP in
their application but the selinux policy was never updated to support
the new permission. They found that such checks were being denied.
(which surprises me actually but I haven't dug into that and probably
should)
I suggested glibc replace SECCLASS_NSCD with string_to_security_class()
and to replace the hard coded perm values with string_to_av_perm(). It
has a couple of obvious benefits. one: they know if policy supports the
class/perm in question. two: if things change in policy glibc still
works (we know that WE won't change the policy such that they would
break, but that doesn't mean that someone couldn't/wouldn't)
Carlos and I had a question come out of this. How do we recommend he
handle the perms[] array? Before the switch to string_to_av_perm() it
was on a read only data page. Now since it has to be updated at run
time he has an array of strings on a read only data page but the AV
values are on a rw page. Do we have a suggestion how this could be
improved? Is it worth map-ing a page for this tiny array so it can be
marked RO after it is filled in?
-Eric
--
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.
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: Handling unknown permissions in userspace object managers
2013-11-01 15:18 Handling unknown permissions in userspace object managers Eric Paris
@ 2013-11-01 15:48 ` Stephen Smalley
2013-11-01 15:54 ` Eric Paris
0 siblings, 1 reply; 7+ messages in thread
From: Stephen Smalley @ 2013-11-01 15:48 UTC (permalink / raw)
To: Eric Paris; +Cc: selinux, codonell
On 11/01/2013 11:18 AM, Eric Paris wrote:
> glibc/nscd is acting as a userspace object manager. Today what they are
> doing is:
>
> static const access_vector_t perms[LASTREQ] =
> {
> [GETPWBYNAME] = NSCD__GETPWD,
> [GETPWBYUID] = NSCD__GETPWD,
> ...
> [INNETGR] = NSCD__GETNETGRP,
> [GETFDNETGR] = NSCD__SHMEMNETGRP,
> };
> ...
> rc = avc_has_perm (ssid, tsid, SECCLASS_NSCD, perms[req], &aeref, NULL) < 0;
> ...
>
> They recently ran into problems where they defined NSCD__GETNETGRP in
> their application but the selinux policy was never updated to support
> the new permission. They found that such checks were being denied.
> (which surprises me actually but I haven't dug into that and probably
> should)
>
> I suggested glibc replace SECCLASS_NSCD with string_to_security_class()
> and to replace the hard coded perm values with string_to_av_perm(). It
> has a couple of obvious benefits. one: they know if policy supports the
> class/perm in question. two: if things change in policy glibc still
> works (we know that WE won't change the policy such that they would
> break, but that doesn't mean that someone couldn't/wouldn't)
Use selinux_set_mapping() if you want to create a mapping of your own
class/perm indices to the policy values without needing to keep them
identical. See XSELinux for an example.
Use selinux_check_access() instead if you want to push all the handling
of the AVC, class/perm string mapping, etc to libselinux and not deal
with it inside your application. That's by far the easiest interface.
It does however impose the overhead of looking up the SIDs, class, and
perm value on each check, but I doubt this path is performance-critical.
It also handles security_deny_unknown() checking so handle_unknown is
dealt with properly.
>
> Carlos and I had a question come out of this. How do we recommend he
> handle the perms[] array? Before the switch to string_to_av_perm() it
> was on a read only data page. Now since it has to be updated at run
> time he has an array of strings on a read only data page but the AV
> values are on a rw page. Do we have a suggestion how this could be
> improved? Is it worth map-ing a page for this tiny array so it can be
> marked RO after it is filled in?
>
> -Eric
>
>
> --
> 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.
>
>
--
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.
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: Handling unknown permissions in userspace object managers
2013-11-01 15:48 ` Stephen Smalley
@ 2013-11-01 15:54 ` Eric Paris
2013-11-01 16:00 ` Stephen Smalley
0 siblings, 1 reply; 7+ messages in thread
From: Eric Paris @ 2013-11-01 15:54 UTC (permalink / raw)
To: Stephen Smalley; +Cc: selinux, codonell
On Fri, 2013-11-01 at 11:48 -0400, Stephen Smalley wrote:
> On 11/01/2013 11:18 AM, Eric Paris wrote:
> > glibc/nscd is acting as a userspace object manager. Today what they are
> > doing is:
> >
> > static const access_vector_t perms[LASTREQ] =
> > {
> > [GETPWBYNAME] = NSCD__GETPWD,
> > [GETPWBYUID] = NSCD__GETPWD,
> > ...
> > [INNETGR] = NSCD__GETNETGRP,
> > [GETFDNETGR] = NSCD__SHMEMNETGRP,
> > };
> > ...
> > rc = avc_has_perm (ssid, tsid, SECCLASS_NSCD, perms[req], &aeref, NULL) < 0;
> > ...
> >
> > They recently ran into problems where they defined NSCD__GETNETGRP in
> > their application but the selinux policy was never updated to support
> > the new permission. They found that such checks were being denied.
> > (which surprises me actually but I haven't dug into that and probably
> > should)
> >
> > I suggested glibc replace SECCLASS_NSCD with string_to_security_class()
> > and to replace the hard coded perm values with string_to_av_perm(). It
> > has a couple of obvious benefits. one: they know if policy supports the
> > class/perm in question. two: if things change in policy glibc still
> > works (we know that WE won't change the policy such that they would
> > break, but that doesn't mean that someone couldn't/wouldn't)
>
> Use selinux_set_mapping() if you want to create a mapping of your own
> class/perm indices to the policy values without needing to keep them
> identical. See XSELinux for an example.
I completely forget about that interface. It does simplify things a
bit, but it seems to make things worse as well. When dealing with
unknown perms selinux_set_mapping() is going to return EINVAL and the
userspace object manager will be just screwed...
Any thoughts how we could better that interface for the case where
security_deny_unknown() == 0?
--
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.
^ permalink raw reply [flat|nested] 7+ messages in thread* Re: Handling unknown permissions in userspace object managers
2013-11-01 15:54 ` Eric Paris
@ 2013-11-01 16:00 ` Stephen Smalley
[not found] ` <5273DE3D.4070402@redhat.com>
0 siblings, 1 reply; 7+ messages in thread
From: Stephen Smalley @ 2013-11-01 16:00 UTC (permalink / raw)
To: Eric Paris; +Cc: selinux, codonell
On 11/01/2013 11:54 AM, Eric Paris wrote:
> On Fri, 2013-11-01 at 11:48 -0400, Stephen Smalley wrote:
>> On 11/01/2013 11:18 AM, Eric Paris wrote:
>>> glibc/nscd is acting as a userspace object manager. Today what they are
>>> doing is:
>>>
>>> static const access_vector_t perms[LASTREQ] =
>>> {
>>> [GETPWBYNAME] = NSCD__GETPWD,
>>> [GETPWBYUID] = NSCD__GETPWD,
>>> ...
>>> [INNETGR] = NSCD__GETNETGRP,
>>> [GETFDNETGR] = NSCD__SHMEMNETGRP,
>>> };
>>> ...
>>> rc = avc_has_perm (ssid, tsid, SECCLASS_NSCD, perms[req], &aeref, NULL) < 0;
>>> ...
>>>
>>> They recently ran into problems where they defined NSCD__GETNETGRP in
>>> their application but the selinux policy was never updated to support
>>> the new permission. They found that such checks were being denied.
>>> (which surprises me actually but I haven't dug into that and probably
>>> should)
>>>
>>> I suggested glibc replace SECCLASS_NSCD with string_to_security_class()
>>> and to replace the hard coded perm values with string_to_av_perm(). It
>>> has a couple of obvious benefits. one: they know if policy supports the
>>> class/perm in question. two: if things change in policy glibc still
>>> works (we know that WE won't change the policy such that they would
>>> break, but that doesn't mean that someone couldn't/wouldn't)
>>
>> Use selinux_set_mapping() if you want to create a mapping of your own
>> class/perm indices to the policy values without needing to keep them
>> identical. See XSELinux for an example.
>
> I completely forget about that interface. It does simplify things a
> bit, but it seems to make things worse as well. When dealing with
> unknown perms selinux_set_mapping() is going to return EINVAL and the
> userspace object manager will be just screwed...
>
> Any thoughts how we could better that interface for the case where
> security_deny_unknown() == 0?
Just do what I did in the kernel code (security/selinux/ss/services.c,
changes to selinux_set_mapping, map_decision based on handle_unknown).
But selinux_check_access() is IMHO a better way to go for any new code
unless it is so performance-critical that the context, class, and perm
lookups per check are prohibitive.
--
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.
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2013-11-01 21:21 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-01 15:18 Handling unknown permissions in userspace object managers Eric Paris
2013-11-01 15:48 ` Stephen Smalley
2013-11-01 15:54 ` Eric Paris
2013-11-01 16:00 ` Stephen Smalley
[not found] ` <5273DE3D.4070402@redhat.com>
2013-11-01 17:02 ` Stephen Smalley
[not found] ` <5273E261.3050100@redhat.com>
2013-11-01 17:20 ` Stephen Smalley
2013-11-01 21:21 ` Daniel J Walsh
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.