Skip to contentSkip to conversation

strange labelling error

DISCUSSION Russell Coker 2 participants 4 messages Jun 26, 2012 – Jun 27, 2012 SELinux security module

lore
Share & tools
lore
#0 lore raw

I was relabelling one of my systems that I've been using for development and saw the below messages. I've got no idea how "SystemLow" apparently got into the contexts of lots of files. Any ideas?

I can't reproduce it so I'm not particularly worried, presumably later versions of the code in question fixed it. Given the files that were affected I suspect a bug in dpkg or in the SE Linux libraries it uses. But it's a fairly strange one.

restorecon reset /usr/share/doc/xserver-xorg-video-intel/changelog.gz context system_u:object_r:usr_t:SystemLow->system_u:object_r:usr_t:s0 restorecon reset /usr/share/doc/xserver-xorg-video-intel/NEWS.gz context system_u:object_r:usr_t:SystemLow->system_u:object_r:usr_t:s0 restorecon reset /usr/share/doc/xserver-xorg-video-intel/README.Debian context system_u:object_r:usr_t:SystemLow->system_u:object_r:usr_t:s0 restorecon reset /usr/share/doc/xserver-xorg-video-intel/changelog.Debian.gz context system_u:object_r:usr_t:SystemLow->system_u:object_r:usr_t:s0 restorecon reset /usr/share/doc/xserver-xorg-video-intel/README context system_u:object_r:usr_t:SystemLow->system_u:object_r:usr_t:s0 restorecon reset /usr/share/doc/xserver-xorg-video-intel/copyright context system_u:object_r:usr_t:SystemLow->system_u:object_r:usr_t:s0

Signature · 7 lines
My Main Blog         http://etbe.coker.com.au/
My Documents Blog    http://doc.coker.com.au/

--
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.
#1 lore raw
Quoted 3 lines · Russell Coker

I was relabelling one of my systems that I've been using for development and saw the below messages. I've got no idea how "SystemLow" apparently got into the contexts of lots of files. Any ideas?

A domain with :capability2 mac_admin permission could set any arbitrary value as a file security context, so it would just require a program in such a domain (or perhaps any root program in permissive mode) to accidentally pass the translated security context to setxattr or possibly even to setfilecon if mcstrans wasn't running.

Quoted 18 lines

I can't reproduce it so I'm not particularly worried, presumably later versions of the code in question fixed it. Given the files that were affected I suspect a bug in dpkg or in the SE Linux libraries it uses. But it's a fairly strange one.

restorecon reset /usr/share/doc/xserver-xorg-video-intel/changelog.gz context system_u:object_r:usr_t:SystemLow->system_u:object_r:usr_t:s0 restorecon reset /usr/share/doc/xserver-xorg-video-intel/NEWS.gz context system_u:object_r:usr_t:SystemLow->system_u:object_r:usr_t:s0 restorecon reset /usr/share/doc/xserver-xorg-video-intel/README.Debian context system_u:object_r:usr_t:SystemLow->system_u:object_r:usr_t:s0 restorecon reset /usr/share/doc/xserver-xorg-video-intel/changelog.Debian.gz context system_u:object_r:usr_t:SystemLow->system_u:object_r:usr_t:s0 restorecon reset /usr/share/doc/xserver-xorg-video-intel/README context system_u:object_r:usr_t:SystemLow->system_u:object_r:usr_t:s0 restorecon reset /usr/share/doc/xserver-xorg-video-intel/copyright context system_u:object_r:usr_t:SystemLow->system_u:object_r:usr_t:s0

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.
#2 lore raw
Quoted 5 lines · Stephen Smalley

A domain with :capability2 mac_admin permission could set any arbitrary value as a file security context, so it would just require a program in such a domain (or perhaps any root program in permissive mode) to accidentally pass the translated security context to setxattr or possibly even to setfilecon if mcstrans wasn't running.

Thanks for that tip, I've just seen it happen when upgrading a system. It seems that dpkg converted "s0" to "SystemLow" when mcstransd was running, then stopped mcstransd (as part of an upgrade process) and couldn't convert it back to s0. Now I have to work out why it did such a conversion. The file_contexts file uses the computer-friendly version of the range so there shouldn't be a need for any conversion.

I don't like my chances of getting a dpkg patch in Wheezy, changing the most important package in a distribution 3 days before a freeze is asking a lot. I will probably have to maintain a forked package in my own repository and hope that I can get a change in the first update for Wheezy.

Below is one of the audit messages that were generated.

type=AVC msg=audit(1340784425.654:1271): avc: denied { mac_admin } for pid=6276 comm="dpkg" capability=33 scontext=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 tcontext=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 tclass=capability2

Hopefully I will have solved this in a few hours and posted the answer to the list.

Signature · 7 lines
My Main Blog         http://etbe.coker.com.au/
My Documents Blog    http://doc.coker.com.au/

--
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.
#3 lore raw
Quoted 21 lines · Russell Coker
Quoted 5 lines · Stephen Smalley

A domain with :capability2 mac_admin permission could set any arbitrary value as a file security context, so it would just require a program in such a domain (or perhaps any root program in permissive mode) to accidentally pass the translated security context to setxattr or possibly even to setfilecon if mcstrans wasn't running.

Thanks for that tip, I've just seen it happen when upgrading a system. It seems that dpkg converted "s0" to "SystemLow" when mcstransd was running, then stopped mcstransd (as part of an upgrade process) and couldn't convert it back to s0. Now I have to work out why it did such a conversion. The file_contexts file uses the computer-friendly version of the range so there shouldn't be a need for any conversion.

I don't like my chances of getting a dpkg patch in Wheezy, changing the most important package in a distribution 3 days before a freeze is asking a lot. I will probably have to maintain a forked package in my own repository and hope that I can get a change in the first update for Wheezy.

Below is one of the audit messages that were generated.

Quoted 8 lines

type=AVC msg=audit(1340784425.654:1271): avc: denied { mac_admin } for pid=6276 comm="dpkg" capability=33 scontext=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 tcontext=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 tclass=capability2

Hopefully I will have solved this in a few hours and posted the answer to the list.

If dpkg uses the regular libselinux interfaces rather than the _raw() interfaces, it will get the translated context as long as mcstrans is running. rpm and setfiles use selabel_lookup_raw() and lgetfilecon_raw() to avoid such issues.

If dpkg was denied mac_admin, then the setfilecon/setxattr should have failed unless the system was in permissive mode.

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.