All of lore.kernel.org
 help / color / mirror / Atom feed
* [refpolicy] RFC: direct_init_entry breaks direct_initrc
@ 2013-12-10 15:57 Dominick Grift
  2013-12-10 16:00 ` Dominick Grift
  2014-01-14 13:56 ` Christopher J. PeBenito
  0 siblings, 2 replies; 18+ messages in thread
From: Dominick Grift @ 2013-12-10 15:57 UTC (permalink / raw)
  To: refpolicy

I have not tested this yet and it is a theory

I was not there when that type attribute was implemented so i do not
know the rationale behind the decision to implement it.

Would be nice if anyone could shed some light on that and would be even
better if this fix is acknowledged

> From fc51afbd178dd6321f51d54939e73b1a94172fb9 Tue, 10 Dec 2013 16:53:08 +0100
> From: Dominick Grift <dominick.grift@gmail.com>
> Date: Tue, 10 Dec 2013 16:51:46 +0100
> Subject: [PATCH] Get rid of direct_init_entry:
> 
> 
> This thing breaks direct_initrc
> 
> This type attribute was associated to domain entry files and used for
> role transitions to system_r
> 
> The transition shouldnt happem on the domain entry file though it should
> happen on the init script executable files
> 
> This was breaking direct_initrc because some executables can be run as
> system service and session service. By using the domain entry file init
> the init_daemon_domain interface and associating direct init entry with
> it and using direct init entry for the role transitions you force
> daemons to use system_r whether they are system or session daemon.
> 
> 
> 
> 
> Signed-off-by: Dominick Grift <dominick.grift@gmail.com>
> diff --git a/policy/modules/system/init.if b/policy/modules/system/init.if
> index 79a45f6..5a7df5e 100644
> --- a/policy/modules/system/init.if
> +++ b/policy/modules/system/init.if
> @@ -191,7 +191,7 @@
>  #
>  interface(`init_daemon_domain',`
>  	gen_require(`
> -		attribute direct_run_init, direct_init, direct_init_entry;
> +		attribute direct_run_init, direct_init;
>  		type initrc_t;
>  		role system_r;
>  		attribute daemon;
> @@ -220,7 +220,6 @@
>  		allow direct_run_init $1:process { noatsecure siginh rlimitinh };
>  
>  		typeattribute $1 direct_init;
> -		typeattribute $2 direct_init_entry;
>  
>  		userdom_dontaudit_use_user_terminals($1)
>  	')
> @@ -982,12 +981,12 @@
>  #
>  interface(`init_run_daemon',`
>  	gen_require(`
> -		attribute direct_run_init, direct_init, direct_init_entry;
> +		attribute direct_run_init, init_script_file_type;
>  		role system_r;
>  	')
>  
>  	typeattribute $1 direct_run_init;
> -	role_transition $2 direct_init_entry system_r;
> +	role_transition $2 init_script_file_type system_r;
>  ')
>  
>  ########################################
> diff --git a/policy/modules/system/init.te b/policy/modules/system/init.te
> index d9d9f5d..116e37a 100644
> --- a/policy/modules/system/init.te
> +++ b/policy/modules/system/init.te
> @@ -27,7 +27,6 @@
>  # by admin domains
>  attribute direct_run_init;
>  attribute direct_init;
> -attribute direct_init_entry;
>  
>  attribute init_script_domain_type;
>  attribute init_script_file_type;

^ permalink raw reply	[flat|nested] 18+ messages in thread
* [refpolicy] RFC: direct_init_entry breaks direct_initrc
@ 2013-12-11  8:33 Sven Vermeulen
  2013-12-11  8:56 ` Dominick Grift
  0 siblings, 1 reply; 18+ messages in thread
From: Sven Vermeulen @ 2013-12-11  8:33 UTC (permalink / raw)
  To: refpolicy

On Tue, 2013-12-10 at 17:00 +0100, Dominick Grift wrote:
> On Tue, 2013-12-10 at 16:57 +0100, Dominick Grift wrote:
> 
> > >  
> > >  		typeattribute $1 direct_init;
> > -		typeattribute $2 direct_init_entry;
> 
> Here its actually associated with the init daemon entry file. That is
> wrong in my view. The role transition should happen on the init script
> not the daemon entry file
> 
> > > -	role_transition $2 direct_init_entry system_r;
> > > +	role_transition $2 init_script_file_type system_r;
>
> Here is that actual role transition. This is causing problems with
> direct_initrc. role transition to system_r should happen on the init
> script and not the init daemon executable file

In Gentoo, we don't use the direct_* attributes so I can't tell you that
they do (or do not) cause problems. 

hpl htdocs # seinfo -adirect_init -x
   direct_init
hpl htdocs # seinfo -adirect_run_init -x
   direct_run_init
hpl htdocs # seinfo -adirect_init_entry -x
   direct_init_entry

What we do is we have the following set:

seutil_init_script_run_runinit(sysadm_t, sysadm_r)
. seutil_init_script_domtrans_runinit(sysadm_t)
. . init_script_file_domtrans(sysadm_t, run_init_t)
. . . domain_auto_trans(sysadm_t, initrc_exec_t, run_init_t)

This ensures that, if sysadm_t executes an initrc_exec_t script, the script
is launched in the run_init_t context. Then, our init system (OpenRC) calls
a shared library we provide (linked with libselinux) which sets the next
execution context to system_u:system_r:initrc_t (using setexeccon) and
re-executes the script.

Wkr,
  Sven Vermeulen

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2014-01-16 21:12 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-10 15:57 [refpolicy] RFC: direct_init_entry breaks direct_initrc Dominick Grift
2013-12-10 16:00 ` Dominick Grift
2014-01-14 13:56 ` Christopher J. PeBenito
2014-01-14 14:02   ` Dominick Grift
2014-01-14 14:10     ` Christopher J. PeBenito
2014-01-14 14:48       ` Daniel J Walsh
2014-01-14 18:30       ` Dominick Grift
2014-01-14 20:44         ` Christopher J. PeBenito
2014-01-14 22:23           ` Dominick Grift
2014-01-15 13:01             ` Dominick Grift
2014-01-15 13:51             ` Christopher J. PeBenito
2014-01-15 15:44               ` Dominick Grift
2014-01-15 17:01                 ` Daniel J Walsh
2014-01-16 21:12                 ` Christopher J. PeBenito
2013-12-11  8:33 Sven Vermeulen
2013-12-11  8:56 ` Dominick Grift
2013-12-11  9:52   ` Sven Vermeulen
2013-12-11 10:31     ` Dominick Grift

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.