Skip to contentSkip to conversation

Strange file context issues

DISCUSSION Bradley Chapman 3 participants 6 messages Nov 16, 2006 SELinux security module

lore
Share & tools
lore
#0 lore raw

After tearing my hair out for the past two weeks trying to understand the error messages I've been seeing in my Debian system, I've finally twigged onto why I've been getting so many - there appears to be a mislabeling of file contexts within my filesystems.

Take for example this error message in the dmesg:

audit(1163682174.716:3): avc: denied { read write } for pid=1 comm="init" name="console" dev=sda6 ino=77743 scontext=system_u:system_r:init_t tcontext=system_u:object_r:file_t tclass=chr_file

Clearly, the problem would seem to be that the file /dev/console has the wrong context, preventing init from reading it.

Yet this is what I get when I do ls -l --context /dev/console:

crw------- root root system_u:object_r:console_device_t /dev/console

The majority of early errors in dmesg appear to be similar, with system_u:object_r:file_t popping up all over the place in /dev instead of the correct contexts. I have a feeling that many of the remaining errors I'm seeing are linked to this problem as well.

Can anyone offer any advice as to how this may have happened? I've already tried a filesystem relabel but it doesn't seem to have had any effect.

Brad

Signature · 6 lines
CONTROL YOUR TABS: https://addons.mozilla.org/extensions/158

--
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 19 lines · Bradley Chapman

After tearing my hair out for the past two weeks trying to understand the error messages I've been seeing in my Debian system, I've finally twigged onto why I've been getting so many - there appears to be a mislabeling of file contexts within my filesystems.

Take for example this error message in the dmesg:

audit(1163682174.716:3): avc: denied { read write } for pid=1 comm="init" name="console" dev=sda6 ino=77743 scontext=system_u:system_r:init_t tcontext=system_u:object_r:file_t tclass=chr_file

Clearly, the problem would seem to be that the file /dev/console has the wrong context, preventing init from reading it.

Yet this is what I get when I do ls -l --context /dev/console:

crw------- root root system_u:object_r:console_device_t /dev/console

Quoted 8 lines

The majority of early errors in dmesg appear to be similar, with system_u:object_r:file_t popping up all over the place in /dev instead of the correct contexts. I have a feeling that many of the remaining errors I'm seeing are linked to this problem as well.

Can anyone offer any advice as to how this may have happened? I've already tried a filesystem relabel but it doesn't seem to have had any effect.

Are you using udev? If you have udev and static device nodes under them on the regular fs, those are probably mislabeled. Anything trying to use them early in the boot process before udev is started would hit denials like this. Relabeling wouldn't get them since they're covered up by udev's tmpfs. You'd have to unmount the tmpfs to relabel them.

Signature · 9 lines
Chris PeBenito
Tresys Technology, LLC
(410) 290-1411 x150


--
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

Mr. PeBenito,

Quoted 5 lines · Christopher J. PeBenito

Are you using udev? If you have udev and static device nodes under them on the regular fs, those are probably mislabeled. Anything trying to use them early in the boot process before udev is started would hit denials like this. Relabeling wouldn't get them since they're covered up by udev's tmpfs. You'd have to unmount the tmpfs to relabel them.

Ahhhh. All is made clear now. I am indeed using udev on this machine. Would it be best to turn it off, or easier to simply switch to runlevel 1 and do a relabel of the root filesystem?

Brad

Signature · 6 lines
CONTROL YOUR TABS: https://addons.mozilla.org/extensions/158

--
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 10 lines · Bradley Chapman
Quoted 5 lines · Christopher J. PeBenito

Are you using udev? If you have udev and static device nodes under them on the regular fs, those are probably mislabeled. Anything trying to use them early in the boot process before udev is started would hit denials like this. Relabeling wouldn't get them since they're covered up by udev's tmpfs. You'd have to unmount the tmpfs to relabel them.

Ahhhh. All is made clear now. I am indeed using udev on this machine. Would it be best to turn it off, or easier to simply switch to runlevel 1 and do a relabel of the root filesystem?

I would just do the latter.

Signature · 9 lines
Chris PeBenito
Tresys Technology, LLC
(410) 290-1411 x150


--
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.
#4 lore raw

Mr. PeBenito,

Quoted 8 lines · Christopher J. PeBenito
Quoted 7 lines · Bradley Chapman
Quoted 5 lines · Christopher J. PeBenito

Are you using udev? If you have udev and static device nodes under them on the regular fs, those are probably mislabeled. Anything trying to use them early in the boot process before udev is started would hit denials like this. Relabeling wouldn't get them since they're covered up by udev's tmpfs. You'd have to unmount the tmpfs to relabel them.

Quoted 5 lines
Quoted 3 lines

Ahhhh. All is made clear now. I am indeed using udev on this machine. Would it be best to turn it off, or easier to simply switch to runlevel 1 and do a relabel of the root filesystem?

I would just do the latter.

Which is what I did. Thanks!

Brad

Signature · 6 lines
CONTROL YOUR TABS: https://addons.mozilla.org/extensions/158

--
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.
#5 lore raw
In reply to Bradley Chapman

Hi,
Using an initrd can also cause similar error messages.

I haven't had time to work on SELinux the last few months. I don't know if anyone has worked on making SELinux and init ramdisks play together nicely...

best regards,
Erich Schubert

Signature · 11 lines
    erich@(vitavonni.de|debian.org)    --    GPG Key ID: 4B3A135C    (o_
   It's not denial. I'm just selective about the reality I accept.   //\
     Mit seiner Zeit gehen wollen, heißt, schon überholt zu sein.    V_/_
                          --- Eugène Ionesco



--
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.