pam_namespace is broken from an SELinux perspective.
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 10 lines · Daniel J Walsh
I am trying to fix the problems with polyinstatiation and SELinux Policy in MLS.
I have found that the way
pam_namespaceworks is broken from an SELinux point of view.If I setup the /tmp directory to polyinstatiate and I log in as a
staff_t, I end up with /tmp mounted asstaff_tmp_tinstead oftmp_t. This is wrong, since confined apps that I run as a user expecttmp_t.
Quoted 7 lines
Similarly
/home/dwalshgets mounted asstaff_home_tinstead ofstaff_home_dir_t. This causes all of the transitions to fail.The problem is the
pam_namespaceis asking the system ifstaff_tcreates a directory intmp_thow should it be created. The system respondsstaff_tmp_t. Whatpam_namespaceshould be doing is taking the directorytmp_tand replacing it's MLS level with the level of the user. That is all.
security_compute_member() and the type_member rules in the policy configuration are supposed to provide the policy decision for polyinstantiation rather than a hardcoded policy in pam_namespace. Depending on your goal, you might want per-role instantiation of a directory as well and take away the ability to directly write to e.g. tmp_t from all user domains, only letting them write to their own xxx_tmp_t type.
Part of the problem is that type_member rules currently only trigger level instantiation if the new type differs from the old, so you can't just say type_member staff_t tmp_t:dir tmp_t; That could be changed, but requires a (trivial) kernel patch.
You could work around it by labeling the top-level directories like /tmp and /home/dwalsh with other types (e.g. poly_tmp_t, poly_home_t) distinct for polyinstantiated directories, and then define type_member rules on those, e.g. type_member staff_t poly_tmp_t:dir tmp_t; type_member staff_t poly_home_t:dir staff_home_dir_t;
Quoted 11 lines
So
staff_tloging in as s0:c1
will end up with /tmp being
system_u:object_r:tmp_t:s0:c1
And/home/dwalsh
system_u:object_r:staff_home_dir_t:s0:c1I am trying out a patched version of
pam_namespaceto see if this fixes the problem.Am I makeing the correct assumption.
If I read it correctly, the patch completely removes the use of security_compute_member, and hardcodes per-level instantiation. So that limits its usefulness to MLS.
Other comments:
- Need to check return codes from context_new, context_range_set, context_str, strdup and handle appropriately,
- I don't think you want the full range from scontext - just the low level (aka current/sensitivity level).
Signature · 8 lines
Stephen Smalley National Security Agency -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 54 lines · Stephen Smalley
Quoted 10 lines · Daniel J Walsh
I am trying to fix the problems with polyinstatiation and SELinux Policy in MLS.
I have found that the way
pam_namespaceworks is broken from an SELinux point of view.If I setup the /tmp directory to polyinstatiate and I log in as a
staff_t, I end up with /tmp mounted asstaff_tmp_tinstead oftmp_t. This is wrong, since confined apps that I run as a user expecttmp_t.Quoted 7 lines
Similarly
/home/dwalshgets mounted asstaff_home_tinstead ofstaff_home_dir_t. This causes all of the transitions to fail.The problem is the
pam_namespaceis asking the system ifstaff_tcreates a directory intmp_thow should it be created. The system respondsstaff_tmp_t. Whatpam_namespaceshould be doing is taking the directorytmp_tand replacing it's MLS level with the level of the user. That is all.
security_compute_member()and thetype_memberrules in the policy configuration are supposed to provide the policy decision for polyinstantiation rather than a hardcoded policy inpam_namespace. Depending on your goal, you might want per-role instantiation of a directory as well and take away the ability to directly write to e.g.tmp_tfrom all user domains, only letting them write to their ownxxx_tmp_ttype.Part of the problem is that
type_memberrules currently only trigger level instantiation if the new type differs from the old, so you can't just saytype_memberstaff_ttmp_t:dirtmp_t; That could be changed, but requires a (trivial) kernel patch.You could work around it by labeling the top-level directories like /tmp and
/home/dwalshwith other types (e.g.poly_tmp_t,poly_home_t) distinct for polyinstantiated directories, and then definetype_memberrules on those, e.g.type_memberstaff_tpoly_tmp_t:dirtmp_t;type_memberstaff_tpoly_home_t:dirstaff_home_dir_t;Quoted 11 lines
So
staff_tloging in as s0:c1
will end up with /tmp being
system_u:object_r:tmp_t:s0:c1
And/home/dwalsh
system_u:object_r:staff_home_dir_t:s0:c1I am trying out a patched version of
pam_namespaceto see if this fixes the problem.Am I makeing the correct assumption.
If I read it correctly, the patch completely removes the use of
security_compute_member, and hardcodes per-level instantiation. So that limits its usefulness to MLS.
Quoted 5 lines
Other comments:
- Need to check return codes fromcontext_new,context_range_set,context_str, strdup and handle appropriately,
- I don't think you want the full range from scontext - just the low level (aka current/sensitivity level).
Oh, and you either need to check whether MLS is enabled or gracefully handle a NULL result from context_range_get in case MLS is disabled.
Signature · 8 lines
Stephen Smalley National Security Agency -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 5 lines · Stephen Smalley
You could work around it by labeling the top-level directories like /tmp and
/home/dwalshwith other types (e.g.poly_tmp_t,poly_home_t) distinct for polyinstantiated directories, and then definetype_memberrules on those, e.g.type_memberstaff_tpoly_tmp_t:dirtmp_t;type_memberstaff_tpoly_home_t:dirstaff_home_dir_t;
The problem with this is that it makes installation of poly-instantiated directories more difficult.
I would like to see the installation process be as easy as possible to encourage people who aren't the most capable sys-admins to do it.
Signature · 9 lines
[email protected] http://etbe.blogspot.com/ My Blog http://www.coker.com.au/sponsorship.html Sponsoring Free Software development -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 7 lines · Russell Coker
Quoted 5 lines · Stephen Smalley
You could work around it by labeling the top-level directories like /tmp and
/home/dwalshwith other types (e.g.poly_tmp_t,poly_home_t) distinct for polyinstantiated directories, and then definetype_memberrules on those, e.g.type_memberstaff_tpoly_tmp_t:dirtmp_t;type_memberstaff_tpoly_home_t:dirstaff_home_dir_t;
Quoted 5 lines
The problem with this is that it makes installation of poly-instantiated directories more difficult.
I would like to see the installation process be as easy as possible to encourage people who aren't the most capable sys-admins to do it.
The alternative, as I said, is a simple kernel patch to trigger level instantiations even if the new type is the same as the old in the type_member rule. Then you can have type_member staff_t tmp_t:dir tmp_t; if you don't want per-role instantiation of /tmp or type_member staff_t tmp_t:dir staff_tmp_t; plus additional policy to enable applications expecting /tmp to be tmp_t to continue working if you want per-role instantiation. And you would be able to have type_member staff_t staff_home_dir_t:dir staff_home_dir_t;.
Such a patch has been floated previously but it never reached a conclusion. Re-basing, it looks something like this (un-tested, may not even compile):
security/selinux/ss/mls.c +3 -2
@@ -529,6 +529,7 @@ int mls_compute_sid(struct context *sconstruct context *tcontext, u16 tclass, u32 specified, + unsigned int type_rule, struct context *newcontext) { struct range_trans *rtr;
@@ -558,8 +559,8 @@ int mls_compute_sid(struct context *sconreturn mls_scopy_context (newcontext, scontext);case AVTAB_MEMBER :/* Only polyinstantiate the MLS attributes if -the type is being polyinstantiated */ -if (newcontext->type != tcontext->type) { +a type_member rule was specified for the type. */ +if (type_rule) {/* Use the process effective MLS attributes. */ return mls_scopy_context (newcontext, scontext); }else {
security/selinux/ss/mls.h +1 -0
@@ -64,6 +64,7 @@ int mls_compute_sid(struct context *sconstruct context *tcontext, u16 tclass, u32 specified, + unsigned int type_rule, struct context *newcontext); int mls_setup_user_range(struct context *fromcon, struct user_datum *user,
security/selinux/ss/services.c +1 -1
@@ -945,7 +945,7 @@ static int security_compute_sid(u32 ssid/* Set the MLS attributes. This is done last because it may allocate memory. */ - rc =mls_compute_sid (scontext, tcontext, tclass, specified, &newcontext); + rc =mls_compute_sid (scontext, tcontext, tclass, specified, (avdatum!=NULL ), &newcontext);if (rc) goto out_unlock;
Signature · 8 lines
Stephen Smalley National Security Agency -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 14 lines · Stephen Smalley
Quoted 7 lines · Russell Coker
Quoted 5 lines · Stephen Smalley
You could work around it by labeling the top-level directories like /tmp and
/home/dwalshwith other types (e.g.poly_tmp_t,poly_home_t) distinct for polyinstantiated directories, and then definetype_memberrules on those, e.g.type_memberstaff_tpoly_tmp_t:dirtmp_t;type_memberstaff_tpoly_home_t:dirstaff_home_dir_t;Quoted 5 lines
The problem with this is that it makes installation of poly-instantiated directories more difficult.
I would like to see the installation process be as easy as possible to encourage people who aren't the most capable sys-admins to do it.
Quoted 8 lines
The alternative, as I said, is a simple kernel patch to trigger level instantiations even if the new type is the same as the old in the
type_memberrule. Then you can havetype_memberstaff_ttmp_t:dirtmp_t; if you don't want per-role instantiation of /tmp ortype_memberstaff_ttmp_t:dirstaff_tmp_t; plus additional policy to enable applications expecting /tmp to betmp_tto continue working if you want per-role instantiation. And you would be able to havetype_memberstaff_tstaff_home_dir_t:dirstaff_home_dir_t;.
Note however that the parallel thread on redhat-lspp has proposed using Dan's patch (with fixes) for now to get the desired behavior for MLS, renaming the current "context" option in namespace.conf to "level" to be specific to level instantiation, and later introduce "role" or "context" for role-based and/or full context instantiation when/if such support exists in the kernel and/or policy.
Signature · 8 lines
Stephen Smalley National Security Agency -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 6 lines · Stephen Smalley
Note however that the parallel thread on redhat-lspp has proposed using Dan's patch (with fixes) for now to get the desired behavior for MLS, renaming the current "context" option in namespace.conf to "level" to be specific to level instantiation, and later introduce "role" or "context" for role-based and/or full context instantiation when/if such support exists in the kernel and/or policy.
Having the choice of instantiating by level, role, or by full context seems like a useful feature to me.
Signature · 9 lines
[email protected] http://etbe.blogspot.com/ My Blog http://www.coker.com.au/sponsorship.html Sponsoring Free Software development -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 10 lines · Russell Coker
Quoted 6 lines · Stephen Smalley
Note however that the parallel thread on redhat-lspp has proposed using Dan's patch (with fixes) for now to get the desired behavior for MLS, renaming the current "context" option in namespace.conf to "level" to be specific to level instantiation, and later introduce "role" or "context" for role-based and/or full context instantiation when/if such support exists in the kernel and/or policy.
Having the choice of instantiating by level, role, or by full context seems like a useful feature to me.
Yes, although it somewhat breaks the intended encapsulation of the context and security_compute_member interface. At that point the level returned by security_compute_member becomes rather irrelevant - it would always be overridden by the logic in pam_namespace itself based on whether "level" was specified.
Signature · 8 lines
Stephen Smalley National Security Agency -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.