Skip to contentSkip to conversation

Do we need a new domain for /usr/share/misc/magic.mgc?

refpolicy New Luis Ressel 3 participants 6 messages Sep 19, 2017

lore
Share & tools
lore
#0 lore raw

Hello,

libmagic (better known by its CLI frontend 'file') needs to mmap() its signature database, which is currently labeled usr_t. If any of refpolicy's application domains need to call 'file' (or use libmagic) directly, we may want to create a new domain for this signature db so that the map permission can be granted only on this domain instead of the much bigger usr_t.

However, the only domains I've found so far which need this access are sysadm_t/staff_t/user_t and portage_t. The user domains already have the neccessary permission, leaving only portage_t. Given that portage_t can access *all* files in any case, I've decided to keep the policy simple by just allowing it to map usr_t.

Is anyone aware of other file/libmagic users which would warrant the creation of a new domain for the signature db?

Regards,
Luis Ressel

#1 lore raw
Quoted 9 lines · Luis Ressel via refpolicy

Hello,

libmagic (better known by its CLI frontend 'file') needs to mmap() its signature database, which is currently labeled usr_t. If any of refpolicy's application domains need to call 'file' (or use libmagic) directly, we may want to create a new domain for this signature db so that the map permission can be granted only on this domain instead of the much bigger usr_t.

Quoted 8 lines

However, the only domains I've found so far which need this access are sysadm_t/staff_t/user_t and portage_t. The user domains already have the neccessary permission, leaving only portage_t. Given that portage_t can access *all* files in any case, I've decided to keep the policy simple by just allowing it to map usr_t.

Is anyone aware of other file/libmagic users which would warrant the creation of a new domain for the signature db?

Stuff like icons probably also need to be mapped and are also usr_t, so i don't think that confining that by itself will solve all the issues

Quoted 8 lines

Regards,
Luis Ressel

_______________________________________________
refpolicy mailing list
refpolicy at oss.tresys.com
http://oss.tresys.com/mailman/listinfo/refpolicy

Signature · 10 lines
Key fingerprint = 5F4D 3CDB D3F8 3652 FBD8  02D5 3B6C 5F1D 2C7B 6B02
https://sks-keyservers.net/pks/lookup?op=get&search=0x3B6C5F1D2C7B6B02
Dominick Grift
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
Url : http://oss.tresys.com/pipermail/refpolicy/attachments/20170919/2aca0e1d/attachment.bin 
#2 lore raw
Quoted 17 lines · On Tue, 19 Sep 2017 18:38:22 +0200 Dominick Grift via refpolicy…
Quoted 15 lines · Luis Ressel via refpolicy

Hello,

libmagic (better known by its CLI frontend 'file') needs to mmap() its signature database, which is currently labeled usr_t. If any of refpolicy's application domains need to call 'file' (or use libmagic) directly, we may want to create a new domain for this signature db so that the map permission can be granted only on this domain instead of the much bigger usr_t.

However, the only domains I've found so far which need this access are sysadm_t/staff_t/user_t and portage_t. The user domains already have the neccessary permission, leaving only portage_t. Given that portage_t can access *all* files in any case, I've decided to keep the policy simple by just allowing it to map usr_t.

Quoted 6 lines
Quoted 2 lines

Is anyone aware of other file/libmagic users which would warrant the creation of a new domain for the signature db?

Stuff like icons probably also need to be mapped and are also usr_t, so i don't think that confining that by itself will solve all the issues

Yes, the GTK icon cache is also labeled usr_t and needs to be mappable. However, compared to magic.mgc there are more domains which will need this access, so I'm planning to create a new domain.

If I don't run into any problems, I'll submit a patch after dinner.

Cheers,
Luis Ressel

#3 lore raw
Quoted 27 lines · Luis Ressel via refpolicy
Quoted 17 lines · On Tue, 19 Sep 2017 18:38:22 +0200 Dominick Grift via refpolicy…
Quoted 15 lines · Luis Ressel via refpolicy

Hello,

libmagic (better known by its CLI frontend 'file') needs to mmap() its signature database, which is currently labeled usr_t. If any of refpolicy's application domains need to call 'file' (or use libmagic) directly, we may want to create a new domain for this signature db so that the map permission can be granted only on this domain instead of the much bigger usr_t.

However, the only domains I've found so far which need this access are sysadm_t/staff_t/user_t and portage_t. The user domains already have the neccessary permission, leaving only portage_t. Given that portage_t can access *all* files in any case, I've decided to keep the policy simple by just allowing it to map usr_t.

Quoted 6 lines
Quoted 2 lines

Is anyone aware of other file/libmagic users which would warrant the creation of a new domain for the signature db?

Stuff like icons probably also need to be mapped and are also usr_t, so i don't think that confining that by itself will solve all the issues

Quoted 5 lines

Yes, the GTK icon cache is also labeled usr_t and needs to be mappable. However, compared to magic.mgc there are more domains which will need this access, so I'm planning to create a new domain.

If I don't run into any problems, I'll submit a patch after dinner.

I'm not really concerned about mapping usr_t, as it is generally not writeable.

Signature · 1 line
Chris PeBenito
#4 lore raw

PATCH 1/1 portage: Grant portage the map permission on usr_t

In reply to Luis Ressel

This is needed for eselect, which portage automatically invokes in some situations.

---
 portage.te | 2 ++
 1 file changed, 2 insertions(+)
portage.te +2 -0
index 3b28f81..269329b 100644
@@ -186,6 +186,8 @@ domain_dontaudit_read_all_domains_state(portage_t)
 
 # modify any files in the system
 files_manage_all_files(portage_t)
+# eselect uses file, which mmap()s its db
+files_map_usr(portage_t)
 
 selinux_get_fs_mount(portage_t)
 
Signature · 1 line
2.14.1
#5 lore raw

PATCH 1/1 portage: Grant portage the map permission on usr_t

Quoted 11 lines · Luis Ressel via refpolicy

This is needed for eselect, which portage automatically invokes in some situations.

---
  portage.te | 2 ++
  1 file changed, 2 insertions(+)
portage.te +0 -0
index 3b28f81..269329b 100644

portage.te domain_dontaudit_read_all_domains_state(portage_t) · line 192

Quoted 7 lines
portage.te +2 -0
@@ -186,6 +186,8 @@ domain_dontaudit_read_all_domains_state(portage_t)
 
  # modify any files in the system
  files_manage_all_files(portage_t)
+# eselect uses file, which mmap()s its db
+files_map_usr(portage_t)
 
  selinux_get_fs_mount(portage_t)

Merged, though it needed to be fixed to use the existing interface.

Signature · 1 line
Chris PeBenito