Skip to contentSkip to conversation

On Fedora 24 I am seeing something strange with CIL

DISCUSSION Daniel J Walsh 3 participants 8 messages Mar 29, 2016 – Apr 4, 2016 SELinux security module

lore
Share & tools
lore
#0 lore raw

When I compile and install this policy

---------------------------------------------------------------

# cat /tmp/container.te
policy_module(container, 1.0)

virt_sandbox_domain_template(container)

----------------------------------------------------------------
I end up with mknod capability.

sesearch -A -s container_t -t container_t -c capability Found 1 semantic av rules:
allow container_t container_t : capability mknod ;

But I didn't add mknod to the policy.

grep mknod tmp/container.tmp
class capability { chown dac_override dac_read_search fowner fsetid
kill setgid setuid setpcap linux_immutable net_bind_service net_broadcast net_admin net_raw ipc_lock ipc_owner sys_module sys_rawio sys_chroot sys_ptrace sys_pacct sys_admin sys_boot sys_nice sys_resource sys_time sys_tty_config mknod lease audit_write audit_control setfcap };

Any ideas?

#1 lore raw

I investigated this a little further.

If I write a policy file like

===============================================
policy_module(container, 1.0)
gen_require(`

    attribute svirt_sandbox_domain;

')

type foobar_t;
domain_type(foobar_t)
typeattribute foobar_t svirt_sandbox_domain;
===============================================

I get

sesearch -A -s foobar_t | grep capa
allow foobar_t foobar_t : capability mknod ;

If I remove the typeattribute line foobar_t no longer has mknod.

I think this is a compiler problem.

Quoted 22 lines · Daniel J Walsh

When I compile and install this policy

---------------------------------------------------------------

# cat /tmp/container.te
policy_module(container, 1.0)

virt_sandbox_domain_template(container)

----------------------------------------------------------------
I end up with mknod capability.

sesearch -A -s container_t -t container_t -c capability Found 1 semantic av rules:

   allow container_t container_t : capability mknod ;

But I didn't add mknod to the policy.

grep mknod tmp/container.tmp
class capability { chown dac_override dac_read_search fowner
fsetid kill setgid setuid setpcap linux_immutable net_bind_service net_broadcast net_admin net_raw ipc_lock ipc_owner sys_module sys_rawio sys_chroot sys_ptrace sys_pacct sys_admin sys_boot sys_nice sys_resource sys_time sys_tty_config mknod lease audit_write audit_control setfcap };

Any ideas?

#2 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Quoted 2 lines · Daniel J Walsh

I investigated this a little further.

manage_chr_files_pattern(svirt_sandbox_domain, svirt_sandbox_file_t, svirt_sandbox_file_t)

define(manage_chr_files_pattern',

	allow $1 self:capability mknod;
	allow $1 $2:dir rw_dir_perms;
	allow $1 $3:chr_file manage_chr_file_perms;

')

Quoted 45 lines

If I write a policy file like

===============================================
policy_module(container, 1.0) gen_require(` attribute svirt_sandbox_domain; ')

type foobar_t; domain_type(foobar_t) typeattribute foobar_t svirt_sandbox_domain;
===============================================

I get

sesearch -A -s foobar_t | grep capa allow foobar_t foobar_t :
capability mknod ;

If I remove the typeattribute line foobar_t no longer has mknod.

I think this is a compiler problem.

Quoted 24 lines · Daniel J Walsh

When I compile and install this policy

--------------------------------------------------------------- # cat /tmp/container.te policy_module(container, 1.0)

virt_sandbox_domain_template(container)

----------------------------------------------------------------
I end up with mknod capability.

sesearch -A -s container_t -t container_t -c capability Found 1 semantic av rules: allow container_t container_t : capability mknod ;

But I didn't add mknod to the policy.

grep mknod tmp/container.tmp class capability { chown dac_override dac_read_search fowner fsetid kill setgid setuid setpcap linux_immutable net_bind_service net_broadcast net_admin net_raw ipc_lock ipc_owner sys_module sys_rawio sys_chroot sys_ptrace sys_pacct sys_admin sys_boot sys_nice sys_resource sys_time sys_tty_config mknod lease audit_write audit_control setfcap };

Quoted 6 lines
Quoted 1 line

Any ideas?

_______________________________________________ Selinux mailing list [email protected] To unsubscribe, send email to [email protected]. To get help, send an email containing "help" to [email protected].

- --
Key fingerprint = 5F4D 3CDB D3F8 3652 FBD8 02D5 3B6C 5F1D 2C7B 6B02
https://sks-keyservers.net/pks/lookup?op=get&search=0x3B6C5F1D2C7B6B02
Dominick Grift
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQGcBAEBCAAGBQJXAr1YAAoJECV0jlU3+Udp15kL/igUkHF8kUkSzGaEVnFbArtR l63tgknNlnzoRF+s0bjSFYuYBRTefQpa/G23j/sIEQmKvVkRz8DlGQERqtSpPLZ2 sRNRlA3UA3vLqhk+RhGwxoEjdm8/MA/weU9VGhSHWsd0XrhYtOnI3metotgm422Q YuQEtib+YQ/ldnEZ/2987DJy6Pg3leOBMn1JE+e7v3mFZDyzEfYI6IGR6VR+WEau MooO6slYI7ftac4YnqzvUdTeANhYG4h2wfNA0qVxNVty4jS4mT3uCOhu/UmssnX/ fMviLYA2YJAkg0g6rvUnJJqFe0uCHMiVsMDwmR03I324BakxWCDpqnRhj5vxmYfx ZW8gh3Xg+ZPyVoC5njgm9KkD0/6pgzwGEB3ayBIVgIVi8sVsNvzhJM2dILphT46K OhFcSWX98xQY4G5P3/vOXx86nN4leP+Uw25eyZbStOFNscBK2LnZArQq65y4i6he Qqv4V6xwCBRT+3u8VbjtgGzByeKEvkWvk7GMC17tgA==
=28BA
-----END PGP SIGNATURE-----

#3 lore raw
Quoted 6 lines · Dominick Grift

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Quoted 2 lines · Daniel J Walsh

I investigated this a little further.

Quoted 9 lines

manage_chr_files_pattern(svirt_sandbox_domain, svirt_sandbox_file_t, svirt_sandbox_file_t)

define(manage_chr_files_pattern',

	allow $1 self:capability mknod;
	allow $1 $2:dir rw_dir_perms;
	allow $1 $3:chr_file manage_chr_file_perms;

')

Ok Makes sense but why didn't this come up with the svirt_sandbox_domain attribute as opposed to container_t? Maybe this is a change in cil.

I guess I should not make this the default for svirt_sandbox_domain, and only add it for specific domains.

Thanks Dominick.

Quoted 77 lines
Quoted 48 lines

If I write a policy file like

===============================================
policy_module(container, 1.0) gen_require(` attribute svirt_sandbox_domain; ')

type foobar_t; domain_type(foobar_t) typeattribute foobar_t svirt_sandbox_domain;
===============================================

I get

sesearch -A -s foobar_t | grep capa allow foobar_t foobar_t :
capability mknod ;

If I remove the typeattribute line foobar_t no longer has mknod.

I think this is a compiler problem.

Quoted 24 lines · Daniel J Walsh

When I compile and install this policy

--------------------------------------------------------------- # cat /tmp/container.te policy_module(container, 1.0)

virt_sandbox_domain_template(container)

----------------------------------------------------------------
I end up with mknod capability.

sesearch -A -s container_t -t container_t -c capability Found 1 semantic av rules: allow container_t container_t : capability mknod ;

But I didn't add mknod to the policy.

grep mknod tmp/container.tmp class capability { chown dac_override dac_read_search fowner fsetid kill setgid setuid setpcap linux_immutable net_bind_service net_broadcast net_admin net_raw ipc_lock ipc_owner sys_module sys_rawio sys_chroot sys_ptrace sys_pacct sys_admin sys_boot sys_nice sys_resource sys_time sys_tty_config mknod lease audit_write audit_control setfcap };

Quoted 5 lines
Quoted 1 line

Any ideas?

_______________________________________________ Selinux mailing list [email protected] To unsubscribe, send email to [email protected]. To get help, send an email containing "help" to [email protected].

- --
Key fingerprint = 5F4D 3CDB D3F8 3652 FBD8 02D5 3B6C 5F1D 2C7B 6B02
https://sks-keyservers.net/pks/lookup?op=get&search=0x3B6C5F1D2C7B6B02
Dominick Grift
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQGcBAEBCAAGBQJXAr1YAAoJECV0jlU3+Udp15kL/igUkHF8kUkSzGaEVnFbArtR l63tgknNlnzoRF+s0bjSFYuYBRTefQpa/G23j/sIEQmKvVkRz8DlGQERqtSpPLZ2 sRNRlA3UA3vLqhk+RhGwxoEjdm8/MA/weU9VGhSHWsd0XrhYtOnI3metotgm422Q YuQEtib+YQ/ldnEZ/2987DJy6Pg3leOBMn1JE+e7v3mFZDyzEfYI6IGR6VR+WEau MooO6slYI7ftac4YnqzvUdTeANhYG4h2wfNA0qVxNVty4jS4mT3uCOhu/UmssnX/ fMviLYA2YJAkg0g6rvUnJJqFe0uCHMiVsMDwmR03I324BakxWCDpqnRhj5vxmYfx ZW8gh3Xg+ZPyVoC5njgm9KkD0/6pgzwGEB3ayBIVgIVi8sVsNvzhJM2dILphT46K OhFcSWX98xQY4G5P3/vOXx86nN4leP+Uw25eyZbStOFNscBK2LnZArQq65y4i6he Qqv4V6xwCBRT+3u8VbjtgGzByeKEvkWvk7GMC17tgA==
=28BA
-----END PGP SIGNATURE-----
_______________________________________________
Selinux mailing list
[email protected]
To unsubscribe, send email to [email protected].
To get help, send an email containing "help" to [email protected].

#4 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Quoted 4 lines · Daniel J Walsh

On 04/04/2016 03:15 PM, Dominick Grift wrote: On 03/29/2016 08:00 PM, Daniel J Walsh wrote:

Quoted 17 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

I investigated this a little further.

manage_chr_files_pattern(svirt_sandbox_domain,
svirt_sandbox_file_t, svirt_sandbox_file_t)

define(manage_chr_files_pattern', allow $1 self:capability mknod; allow $1 $2:dir rw_dir_perms; allow $1 $3:chr_file manage_chr_file_perms; ')

Quoted 8 lines

Ok Makes sense but why didn't this come up with the svirt_sandbox_domain attribute as opposed to container_t? Maybe this is a change in cil.

I guess I should not make this the default for svirt_sandbox_domain, and only add it for specific domains.

Thanks Dominick.

Yes that may indeed well be a CIL thing. CIL does optimization, and this may make policy analysis a bit different. So yes, be careful when using type attributes to query the policy. Because CIL may have "moved rules around" for the sake of efficiency. Best to alway's, atleast also check the rules associated with the type.

Quoted 27 lines
Quoted 27 lines
Quoted 27 lines
Quoted 27 lines

If I write a policy file like

===============================================
policy_module(container, 1.0) gen_require(` attribute svirt_sandbox_domain; ')

type foobar_t; domain_type(foobar_t) typeattribute foobar_t svirt_sandbox_domain;
===============================================

I get

sesearch -A -s foobar_t | grep capa allow foobar_t foobar_t : capability mknod ;

If I remove the typeattribute line foobar_t no longer has mknod.

I think this is a compiler problem.

Quoted 2 lines · Daniel J Walsh

When I compile and install this policy

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

---------------------------------------------------------------

# cat /tmp/container.te policy_module(container, 1.0)

virt_sandbox_domain_template(container)

----------------------------------------------------------------

I end up with mknod capability.

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines

sesearch -A -s container_t -t container_t -c capability Found 1 semantic av rules: allow container_t container_t :
capability mknod ;

But I didn't add mknod to the policy.

grep mknod tmp/container.tmp class capability { chown dac_override dac_read_search fowner fsetid kill setgid setuid setpcap linux_immutable net_bind_service net_broadcast net_admin net_raw ipc_lock ipc_owner sys_module sys_rawio sys_chroot sys_ptrace sys_pacct sys_admin sys_boot sys_nice sys_resource sys_time sys_tty_config mknod lease audit_write audit_control setfcap };

Any ideas?

Quoted 10 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

_______________________________________________ Selinux mailing list [email protected] To unsubscribe, send email to [email protected]. To get help, send an email containing "help" to [email protected].

-- Key fingerprint = 5F4D 3CDB D3F8 3652 FBD8 02D5 3B6C 5F1D 2C7B 6B02
https://sks-keyservers.net/pks/lookup?op=get&search=0x3B6C5F1D2C7B6B02

Dominick Grift

Quoted 5 lines
Quoted 4 lines

_______________________________________________ Selinux mailing list [email protected] To unsubscribe, send email to [email protected]. To get help, send an email containing "help" to [email protected].

- --
Key fingerprint = 5F4D 3CDB D3F8 3652 FBD8 02D5 3B6C 5F1D 2C7B 6B02
https://sks-keyservers.net/pks/lookup?op=get&search=0x3B6C5F1D2C7B6B02
Dominick Grift
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iQGcBAEBCAAGBQJXAsW9AAoJECV0jlU3+Udp+7MMAIsBvo/FLOkUY0/099TmY/bU x/97Td+N+ebHciTa/r69j2A7823s9tIJ3HwSPkLfO4ujMfTaG+7+RjjGKH7Sof2U ZTboko964kqfdJnXmrcpkpXwDdfTzpCQ3M0h3T7r23WuZr8LfWoExHnNFv6C+6aq Z1ZavApkd7eS69+rhn9sP9jqf8cdILlTax0EyR9GIdh41uSjVUjuw2LlH42SPdGU xx8KUWJrG0CnGYDFkRpubOTARPoo/kmMLet1bZZnIRIeYslGFhU0QR4PazNE7ffh nfYm+tT4mQTMf3d29oIlYVC+EH4xNxyKhxyUCBUXMNo9HyHiz/oPwxYdxsC5+AUm Iuzc03ic4P6SDPdedyKlLyGHe3k/xfotyDZFKw20SuAA+axkKRe5q+9ZJdT8zLj4 OxJu9+E92zk3T8ZVCSGfdUhnDIwYKn8goP/4MX19MDTco3TCQETbk2Zvdx0GLw1W pRs72qC9/gtB3dBwIX51p32b+zg+HX1eyqHGYwK73g==
=B09e
-----END PGP SIGNATURE-----

#5 lore raw
Quoted 21 lines · Dominick Grift
Quoted 17 lines · Daniel J Walsh
Quoted 2 lines · Daniel J Walsh
Quoted 2 lines
Quoted 2 lines

I investigated this a little further.

manage_chr_files_pattern(svirt_sandbox_domain,
svirt_sandbox_file_t, svirt_sandbox_file_t)

define(manage_chr_files_pattern', allow $1 self:capability mknod; allow $1 $2:dir rw_dir_perms; allow $1 $3:chr_file manage_chr_file_perms; ')

Quoted 6 lines

Ok Makes sense but why didn't this come up with the svirt_sandbox_domain attribute as opposed to container_t? Maybe this is a change in cil.

I guess I should not make this the default for svirt_sandbox_domain, and only add it for specific domains.

Quoted 8 lines
Quoted 1 line
Quoted 1 line

Thanks Dominick.

Yes that may indeed well be a CIL thing. CIL does optimization, and this may make policy analysis a bit different. So yes, be careful when using type attributes to query the policy. Because CIL may have "moved rules around" for the sake of efficiency. Best to alway's, atleast also check the rules associated with the type.

I think this is actually the expected behavior. The issue here is that a typeattribute is used with the 'self' keyword. When this happens, the avrule is expanded to the individual rules. For example:

allow attr self : file read;

becomes:

allow type1 type1 : file read;
allow type2 type2 : file read;

The original avrule never makes it into the policy. Using the -d flag with sesearch will show this is the case. I don't know if 'self' with typeattributes is a kernel limitation or not, but both CIL and checkpolicy have the same behavior.

- Steve

Quoted 74 lines
Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
Quoted 25 lines

If I write a policy file like

===============================================
policy_module(container, 1.0) gen_require(` attribute svirt_sandbox_domain; ')

type foobar_t; domain_type(foobar_t) typeattribute foobar_t svirt_sandbox_domain;
===============================================

I get

sesearch -A -s foobar_t | grep capa allow foobar_t foobar_t : capability mknod ;

If I remove the typeattribute line foobar_t no longer has mknod.

I think this is a compiler problem.

Quoted 2 lines · Daniel J Walsh

When I compile and install this policy

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

---------------------------------------------------------------

# cat /tmp/container.te policy_module(container, 1.0)

virt_sandbox_domain_template(container)

----------------------------------------------------------------

I end up with mknod capability.

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines

sesearch -A -s container_t -t container_t -c capability Found 1 semantic av rules: allow container_t container_t :
capability mknod ;

But I didn't add mknod to the policy.

grep mknod tmp/container.tmp class capability { chown dac_override dac_read_search fowner fsetid kill setgid setuid setpcap linux_immutable net_bind_service net_broadcast net_admin net_raw ipc_lock ipc_owner sys_module sys_rawio sys_chroot sys_ptrace sys_pacct sys_admin sys_boot sys_nice sys_resource sys_time sys_tty_config mknod lease audit_write audit_control setfcap };

Any ideas?

Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

_______________________________________________ Selinux mailing list [email protected] To unsubscribe, send email to [email protected]. To get help, send an email containing "help" to [email protected].

-- Key fingerprint = 5F4D 3CDB D3F8 3652 FBD8 02D5 3B6C 5F1D 2C7B 6B02
https://sks-keyservers.net/pks/lookup?op=get&search=0x3B6C5F1D2C7B6B02

Dominick Grift

Quoted 4 lines
Quoted 4 lines

_______________________________________________ Selinux mailing list [email protected] To unsubscribe, send email to [email protected]. To get help, send an email containing "help" to [email protected].

_______________________________________________
Selinux mailing list
[email protected]
To unsubscribe, send email to [email protected].
To get help, send an email containing "help" to [email protected].

#6 lore raw
Quoted 39 lines · Steve Lawrence
Quoted 21 lines · Dominick Grift
Quoted 17 lines · Daniel J Walsh
Quoted 2 lines · Daniel J Walsh
Quoted 2 lines
Quoted 2 lines

I investigated this a little further.

manage_chr_files_pattern(svirt_sandbox_domain,
svirt_sandbox_file_t, svirt_sandbox_file_t)

define(manage_chr_files_pattern', allow $1 self:capability mknod; allow $1 $2:dir rw_dir_perms; allow $1 $3:chr_file manage_chr_file_perms; ')

Quoted 6 lines

Ok Makes sense but why didn't this come up with the svirt_sandbox_domain attribute as opposed to container_t? Maybe this is a change in cil.

I guess I should not make this the default for svirt_sandbox_domain, and only add it for specific domains.

Quoted 8 lines
Quoted 1 line
Quoted 1 line

Thanks Dominick.

Yes that may indeed well be a CIL thing. CIL does optimization, and this may make policy analysis a bit different. So yes, be careful when using type attributes to query the policy. Because CIL may have "moved rules around" for the sake of efficiency. Best to alway's, atleast also check the rules associated with the type.

I think this is actually the expected behavior. The issue here is that a typeattribute is used with the 'self' keyword. When this happens, the avrule is expanded to the individual rules. For example:

allow attr self : file read;

becomes:

Quoted 8 lines

allow type1 type1 : file read;
allow type2 type2 : file read;

The original avrule never makes it into the policy. Using the -d flag with sesearch will show this is the case. I don't know if 'self' with typeattributes is a kernel limitation or not, but both CIL and checkpolicy have the same behavior.

Ah, actually, I think the binary policy/kernel does not have a concept of 'self' at all. Once put in the binary, this

allow type1 self : file read;

becomes

allow type1 type1 : file read;

So 'self' is essentially replaced with the source type. However, you cannot do this replacement when source is an attribute because this

allow attr self : file read;

and this

allow attr attr : file read;

have very different meanings. So since the kernel has no concept of self, attributes with self must be expanded.

Quoted 81 lines
Quoted 68 lines
Quoted 25 lines
Quoted 25 lines
Quoted 25 lines
Quoted 25 lines

If I write a policy file like

===============================================
policy_module(container, 1.0) gen_require(` attribute svirt_sandbox_domain; ')

type foobar_t; domain_type(foobar_t) typeattribute foobar_t svirt_sandbox_domain;
===============================================

I get

sesearch -A -s foobar_t | grep capa allow foobar_t foobar_t : capability mknod ;

If I remove the typeattribute line foobar_t no longer has mknod.

I think this is a compiler problem.

Quoted 2 lines · Daniel J Walsh

When I compile and install this policy

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

---------------------------------------------------------------

# cat /tmp/container.te policy_module(container, 1.0)

virt_sandbox_domain_template(container)

----------------------------------------------------------------

I end up with mknod capability.

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
Quoted 17 lines

sesearch -A -s container_t -t container_t -c capability Found 1 semantic av rules: allow container_t container_t :
capability mknod ;

But I didn't add mknod to the policy.

grep mknod tmp/container.tmp class capability { chown dac_override dac_read_search fowner fsetid kill setgid setuid setpcap linux_immutable net_bind_service net_broadcast net_admin net_raw ipc_lock ipc_owner sys_module sys_rawio sys_chroot sys_ptrace sys_pacct sys_admin sys_boot sys_nice sys_resource sys_time sys_tty_config mknod lease audit_write audit_control setfcap };

Any ideas?

Quoted 8 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

_______________________________________________ Selinux mailing list [email protected] To unsubscribe, send email to [email protected]. To get help, send an email containing "help" to [email protected].

-- Key fingerprint = 5F4D 3CDB D3F8 3652 FBD8 02D5 3B6C 5F1D 2C7B 6B02
https://sks-keyservers.net/pks/lookup?op=get&search=0x3B6C5F1D2C7B6B02

Dominick Grift

Quoted 4 lines
Quoted 4 lines

_______________________________________________ Selinux mailing list [email protected] To unsubscribe, send email to [email protected]. To get help, send an email containing "help" to [email protected].

Quoted 6 lines

_______________________________________________
Selinux mailing list
[email protected]
To unsubscribe, send email to [email protected].
To get help, send an email containing "help" to [email protected].

_______________________________________________
Selinux mailing list
[email protected]
To unsubscribe, send email to [email protected].
To get help, send an email containing "help" to [email protected].

#7 lore raw
Quoted 54 lines · Steve Lawrence
Quoted 33 lines · Steve Lawrence
Quoted 18 lines · Dominick Grift
Quoted 15 lines · Daniel J Walsh
Quoted 2 lines · Daniel J Walsh
Quoted 2 lines
Quoted 2 lines

I investigated this a little further.

manage_chr_files_pattern(svirt_sandbox_domain, svirt_sandbox_file_t, svirt_sandbox_file_t) define(manage_chr_files_pattern', allow $1 self:capability mknod; allow $1 $2:dir rw_dir_perms; allow $1 $3:chr_file manage_chr_file_perms; ')

Quoted 6 lines

Ok Makes sense but why didn't this come up with the svirt_sandbox_domain attribute as opposed to container_t? Maybe this is a change in cil.
I guess I should not make this the default for svirt_sandbox_domain, and only add it for specific domains. Thanks Dominick.

Quoted 6 lines

Yes that may indeed well be a CIL thing. CIL does optimization, and this may make policy analysis a bit different. So yes, be careful when using type attributes to query the policy. Because CIL may have "moved rules around" for the sake of efficiency. Best to alway's, atleast also check the rules associated with the type.

I think this is actually the expected behavior. The issue here is that a typeattribute is used with the 'self' keyword. When this happens, the avrule is expanded to the individual rules. For example:

   allow attr self : file read;

becomes:

Quoted 8 lines
   allow type1 type1 : file read;
   allow type2 type2 : file read;

The original avrule never makes it into the policy. Using the -d flag with sesearch will show this is the case. I don't know if 'self' with typeattributes is a kernel limitation or not, but both CIL and checkpolicy have the same behavior.

Ah, actually, I think the binary policy/kernel does not have a concept of 'self' at all. Once put in the binary, this

   allow type1 self : file read;

becomes

   allow type1 type1 : file read;

So 'self' is essentially replaced with the source type. However, you cannot do this replacement when source is an attribute because this

Quoted 9 lines
   allow attr self : file read;

and this

   allow attr attr : file read;

have very different meanings. So since the kernel has no concept of self, attributes with self must be expanded.

That makes sense, so it probably worked the same was as before, anyways I was confused, and now I have a fix to get what I want which is a container process with no caps.

Quoted 82 lines
Quoted 69 lines
Quoted 63 lines
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
Quoted 24 lines

If I write a policy file like

===============================================
policy_module(container, 1.0) gen_require(` attribute svirt_sandbox_domain; ')

type foobar_t; domain_type(foobar_t) typeattribute foobar_t svirt_sandbox_domain;
===============================================

I get

sesearch -A -s foobar_t | grep capa allow foobar_t foobar_t : capability mknod ;

If I remove the typeattribute line foobar_t no longer has mknod.

I think this is a compiler problem.

Quoted 2 lines · Daniel J Walsh

When I compile and install this policy

Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

---------------------------------------------------------------

# cat /tmp/container.te policy_module(container, 1.0)

virt_sandbox_domain_template(container)

----------------------------------------------------------------

I end up with mknod capability.

Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
Quoted 15 lines

sesearch -A -s container_t -t container_t -c capability Found 1 semantic av rules: allow container_t container_t :
capability mknod ;

But I didn't add mknod to the policy.

grep mknod tmp/container.tmp class capability { chown dac_override dac_read_search fowner fsetid kill setgid setuid setpcap linux_immutable net_bind_service net_broadcast net_admin net_raw ipc_lock ipc_owner sys_module sys_rawio sys_chroot sys_ptrace sys_pacct sys_admin sys_boot sys_nice sys_resource sys_time sys_tty_config mknod lease audit_write audit_control setfcap };

Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line

Any ideas?

_______________________________________________ Selinux mailing list [email protected] To unsubscribe, send email to [email protected]. To get help, send an email containing "help" to [email protected].

-- Key fingerprint = 5F4D 3CDB D3F8 3652 FBD8 02D5 3B6C 5F1D 2C7B 6B02
https://sks-keyservers.net/pks/lookup?op=get&search=0x3B6C5F1D2C7B6B02

Dominick Grift

Quoted 4 lines
Quoted 4 lines

_______________________________________________ Selinux mailing list [email protected] To unsubscribe, send email to [email protected]. To get help, send an email containing "help" to [email protected].

Quoted 6 lines

_______________________________________________
Selinux mailing list
[email protected]
To unsubscribe, send email to [email protected].
To get help, send an email containing "help" to [email protected].

Quoted 6 lines

_______________________________________________
Selinux mailing list
[email protected]
To unsubscribe, send email to [email protected].
To get help, send an email containing "help" to [email protected].

_______________________________________________
Selinux mailing list
[email protected]
To unsubscribe, send email to [email protected].
To get help, send an email containing "help" to [email protected].