dynamic context transitions
stephen,
i assume it _is_ necessary to perform dynamic auto transitions?
such that i can track to alternative contexts, yes?
e.g. i am running in sshd_privsep_t [because on a fork(), i deliberately called setcon() to set it that way]
and i now want to be a user-related context, so i do this:
get_default_context(pw->pw_name,NULL,&scontext) setcon(scontext);
and i set up a dynamic_auto_trans(sshd_privsep_t,
sshd_exec_t, sshd_privsep_user_t)
... hang on, that doesn't look right. surely there should be four arguments:
* domain you were in before the setcon
* domain the setcon asked to be in
* executable_t
* domain you want to be in afterwards
so it'd be:
dynamic_auto_trans(sshd_privsep_t, /* where we were */
user_t, /* from get_default_context() */
sshd_exec_t, /* from the sshd binary */
sshd_privsep_user_t) /* what we _really_ want to be */
burblburbl... *gloop* drowning in not-much-understanding...
l.
Signature · 8 lines
-- <a href="http://lkcl.net">http://lkcl.net</a> -- -- 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 · Luke Kenneth Casson Leighton
stephen,
i assume it _is_ necessary to perform dynamic auto transitions?
such that i can track to alternative contexts, yes?
Could you explain what you mean by "dynamic auto transitions"? An auto transition is a policy defined transition upon exec. The dynamic transitions (setcon) are done programatically.
Quoted 28 lines
e.g. i am running in
sshd_privsep_t[because on afork(), i deliberately calledsetcon()to set it that way]and i now want to be a user-related context, so i do this:
get_default_context(pw->pw_name,NULL,&scontext) setcon(scontext);and i set up a dynamic_auto_trans(sshd_privsep_t,
sshd_exec_t,sshd_privsep_user_t)... hang on, that doesn't look right. surely there should be four arguments:
* domain you were in before the setcon
* domain the setcon asked to be in
*executable_t
* domain you want to be in afterwardsso it'd be:
dynamic_auto_trans(sshd_privsep_t, /* where we were */
user_t, /* fromget_default_context()*/
sshd_exec_t, /* from the sshd binary */
sshd_privsep_user_t) /* what we _really_ want to be */
Quoted 4 lines
burblburbl... *gloop* drowning in not-much-understanding...
l.
For the above call to setcon to be successful, you will need the following policy rules where CURRENT_T is the current process domain and NEW_T is the domain that you are trying to transition to:
1) allow CURRENT_T self:process setcurrent;
2) allow CURRENT_T NEW_T:process dyntransition;
The first is necessary for the process to be able to use setcon. The second is necessary for a dynamic transition to take place from CURRENT_T to NEW_T. Those two will allow the transition to happen. The executable type has no bearing on dynamic transitions because there is no exec taking place. Remember that the transition will take place in the same process state - the new domain should most likely be able to access at least some of the resources (such as tty) of the previous domain.
Hope this helps a little...
Signature · 6 lines
Darrel -- 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 11 lines · Darrel Goeddel
Quoted 6 lines · Luke Kenneth Casson Leighton
stephen,
i assume it _is_ necessary to perform dynamic auto transitions?
such that i can track to alternative contexts, yes?
Could you explain what you mean by "dynamic auto transitions"? An auto transition is a policy defined transition upon exec. The dynamic transitions (setcon) are done programatically.
yes, and they're absolutely awful.
as explained in a message which has crossed with this one and outlines some pseudo-code in which a security context is HARD-CODED into the program.
plus a patch which _implements_ "dynamic auto transitions".
so i'm hoping that my other message will cover this question, which you should receive in the next few mins.
l.
--
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 3 lines · Luke Kenneth Casson Leighton
i assume it _is_ necessary to perform dynamic auto transitions?
such that i can track to alternative contexts, yes?
No. Dynamic transitions are always explicitly requested by applications, just like setuid(2) calls. Since you must modify the application anyway to introduce the dynamic context transition (unlike an automatic transition upon an existing execve call), there is no such thing as an automatic dynamic transition. Now, the issue of how to get the right new domain is another matter. For user contexts, we want something akin to get_default_context(). But in this case, you are again dealing with two fixed domains that are not associated with a user, IIUC, so you might as well just create new appconfig files (under policy/appconfig) that are installed to /etc/selinux/$SELINUXTYPE/contexts and read by sshd upon startup to obtain the desired context for the monitor and unprivileged child.
Signature · 8 lines
Stephen Smalley <[email protected]> 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 10 lines · Stephen Smalley
Quoted 3 lines · Luke Kenneth Casson Leighton
i assume it _is_ necessary to perform dynamic auto transitions?
such that i can track to alternative contexts, yes?
No. Dynamic transitions are always explicitly requested by applications, just like setuid(2) calls. Since you must modify the application anyway to introduce the dynamic context transition (unlike an automatic transition upon an existing execve call), there is no such thing as an automatic dynamic transition.
the patch i created last night provides exactly that functionality.
whether it's the right thing to do, and whether it checks appropriate permissions or not is an entirely different matter :)
i picked process:dyntransition and process:setcontext out of thin air, based on observing the use of allow $1 $3:process transition and allow $3 $2:file entrypoint in the domain_trans macro.
heck, maybe it _should_ be process:dyntransition and process:entrypoint.
... i will wait until someone absorbs the impact and implications of the patch i created.
Quoted 3 lines
Now, the issue of how to get
the right new domain is another matter. For user contexts, we want something akin toget_default_context().
yes.
[i understand about get_default_context() only supporting transition not dyntransition]
Quoted 3 lines
But in this case, you are
again dealing with two fixed domains that are not associated with a user,
no, that's wrong.
i _do_ need a domain which is associated with the user, in an easily derivable manner, that can be specified in the SE-Linux policy source.
why?
in order to be able to restrict users from logging in on a per-IP basis.
e.g. so restricted_user1 can ONLY ssh in from 192.168.0.223, because i set up a net_context that said so, and associated sshd_priv_restricted_user1_t with that network context
(instead of using the can_network() macro, i'd use a hacked version
of can_network())
l.
--
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 · Luke Kenneth Casson Leighton
in order to be able to restrict users from logging in on a per-IP basis.
e.g. so
restricted_user1can ONLY ssh in from 192.168.0.223, because i set up anet_contextthat said so, and associatedsshd_priv_restricted_user1_twith that network context
I'm not clear that this is going to work for you, or that this is the right approach (vs. using iptables and multiple sshd instances running in different security contexts and listening on different ports initially). Further, I'm not sure where you are going to perform these dynamic context transitions, as the user isn't authenticated when the monitor and unprivileged child are created.
Signature · 8 lines
Stephen Smalley <[email protected]> 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 4 lines · Stephen Smalley
Quoted 3 lines · Luke Kenneth Casson Leighton
in order to be able to restrict users from logging in on a per-IP basis.
Quoted 8 lines
Quoted 3 lines
e.g. so
restricted_user1can ONLY ssh in from 192.168.0.223, because i set up anet_contextthat said so, and associatedsshd_priv_restricted_user1_twith that network contextI'm not clear that this is going to work for you, or that this is the right approach (vs. using iptables and multiple sshd instances running in different security contexts and listening on different ports initially).
this is the temporary approach that i have in fact taken.
think in terms of maybe having to add a dozen or more different "zones".
eth0 -> iptables -> /usr/sbin/sshd_eth0 -> restricted_user0 eth1 -> iptables -> /usr/sbin/sshd_eth1 -> restricted_user1
....
....
eth100 -> iptables -> /usr/sbin/sshd_eth100-> restricted_user100
and it _very_ quickly becomes unmanageable - some time after the first two users are added.
the requirements are such that there will be several different users with several different ip addresses / zones from which those users need to be restricted.
i can forsee a point where the customer is going to bitch at me to provide a solution.
Quoted 3 lines
Further, I'm not sure where you are going to perform these dynamic context transitions, as the user isn't authenticated when the monitor and unprivileged child are created.
do_authentication2() - just afer the username is determined.
auth2.c's input_userauth_request().
after "user = packet_get_string(NULL)"
i hope :)
l.
Signature · 8 lines
-- <a href="http://lkcl.net">http://lkcl.net</a> -- -- 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.