Skip to contentSkip to conversation

libsepol.context_from_record: MLS is disabled, but MLS context "s0" found

DISCUSSION Vikram Ambrose 4 participants 10 messages Jul 24, 2008 – Jul 28, 2008 2 messages not in the archive SELinux security module

lore
Share & tools
lore
#0 lore raw

I keep getting this error with audit2why.

root@localhost:/root> cat msg
type=1400 audit(1216736766.147:35): avc: denied { read write } for pid=1829 comm="modprobe" name="console" dev=sda ino=344069 scontext=system_u:system_r:insmod_t tcontext=unconfined_u:object_r:default_t tclass=chr_file

root@localhost:/root> audit2allow < msg
#============= insmod_t ==============
allow insmod_t default_t:chr_file { read write };

root@localhost:/root> audit2why < msg
libsepol.context_from_record: MLS is disabled, but MLS context "s0" found libsepol.context_from_record: could not create context structure libsepol.context_from_string: could not create context structure libsepol.sepol_context_to_sid: could not convert system_u:system_r:insmod_t:s0 to sid Invalid Source Context system_u:system_r:insmod_t:s0

root@localhost:/root>

Using selinux-svn2928 and refpolicy-2744 (standard)

Vikram

--
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 12 lines · Vikram Ambrose

I keep getting this error with audit2why.

root@localhost:/root> cat msg
type=1400 audit(1216736766.147:35): avc: denied { read write } for pid=1829 comm="modprobe" name="console" dev=sda ino=344069 scontext=system_u:system_r:insmod_t tcontext=unconfined_u:object_r:default_t tclass=chr_file

root@localhost:/root> audit2allow < msg
#============= insmod_t ==============
allow insmod_t default_t:chr_file { read write };

Quoted 7 lines

root@localhost:/root> audit2why < msg libsepol.context_from_record: MLS is disabled, but MLS context "s0" found libsepol.context_from_record: could not create context structure libsepol.context_from_string: could not create context structure libsepol.sepol_context_to_sid: could not convert system_u:system_r:insmod_t:s0 to sid
Invalid Source Context system_u:system_r:insmod_t:s0

I ran into this last week. Sepolgen incorrectly adds the MLS portion of the context regardless if MLS is enabled or not. Then when the tool uses the context, libsepol throws the above errors when MLS is disabled. I haven't had a chance to really look at what would be the right way to fix it, since I'm no python expert. Karl?

Signature · 7 lines
Chris PeBenito
<[email protected]>
Developer,
Hardened Gentoo Linux
 
Public Key: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0xE6AF9243
Key fingerprint = B0E6 877A 883F A57A 8E6A  CB00 BC8E E42D E6AF 9243
#3 lore raw

RE: libsepol.context_from_record: MLS is disabled, but MLS context"s0" found

In reply to a message not in the archive
Quoted 38 lines · Karl MacMillan
Quoted 30 lines

-----Original Message-----
From: Chris PeBenito [mailto:[email protected]]
Sent: Thursday, July 24, 2008 8:07 PM
To: Vikram Ambrose
Cc: [email protected]; Karl MacMillan
Subject: Re: libsepol.context_from_record: MLS is disabled, but MLS context"s0" found

Quoted 4 lines · Vikram Ambrose

I keep getting this error with audit2why.

root@localhost:/root> cat msg
type=1400 audit(1216736766.147:35): avc: denied { read write }

for

Quoted 7 lines

pid=1829 comm="modprobe" name="console" dev=sda ino=344069 scontext=system_u:system_r:insmod_t tcontext=unconfined_u:object_r:default_t tclass=chr_file

root@localhost:/root> audit2allow < msg #============= insmod_t ============== allow insmod_t default_t:chr_file { read write };

Quoted 8 lines

root@localhost:/root> audit2why < msg libsepol.context_from_record: MLS is disabled, but MLS context "s0" found
libsepol.context_from_record: could not create context structure libsepol.context_from_string: could not create context structure libsepol.sepol_context_to_sid: could not convert system_u:system_r:insmod_t:s0 to sid Invalid Source Context system_u:system_r:insmod_t:s0

Quoted 7 lines

I ran into this last week. Sepolgen incorrectly adds the MLS portion of the context regardless if MLS is enabled or not. Then when the tool uses the context, libsepol throws the above errors when MLS is disabled.
I haven't had a chance to really look at what would be the right way to fix it, since I'm no python expert. Karl?

Quoted 2 lines

Maybe I'm missing something, but from above this looks like an audit2why bug not an sepolgen bug.

Perhaps. I didn't have a change to analyze the problem fully, so I don't know if sepolgen is supposed to be informed if this is an MLS policy or not, or if sepolgen itself is supposed to figure it out. In the end the offending function is in the SecurityContext class in sepolgen:

def to_string(self, default_level="s0"):

        fields = [self.user, self.role, self.type]
        if self.level == "":
            if default_level != "":
                fields.append(default_level)
        else:
            fields.append(self.level)
        return ":".join(fields)
Signature · 7 lines
Chris PeBenito
<[email protected]>
Developer,
Hardened Gentoo Linux
 
Public Key: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0xE6AF9243
Key fingerprint = B0E6 877A 883F A57A 8E6A  CB00 BC8E E42D E6AF 9243
#4 lore raw

RE: libsepol.context_from_record: MLS is disabled, but MLS context"s0" found

Quoted 48 lines · Chris PeBenito
Quoted 38 lines · Karl MacMillan
Quoted 30 lines

-----Original Message-----
From: Chris PeBenito [mailto:[email protected]]
Sent: Thursday, July 24, 2008 8:07 PM
To: Vikram Ambrose
Cc: [email protected]; Karl MacMillan
Subject: Re: libsepol.context_from_record: MLS is disabled, but MLS context"s0" found

Quoted 4 lines · Vikram Ambrose

I keep getting this error with audit2why.

root@localhost:/root> cat msg
type=1400 audit(1216736766.147:35): avc: denied { read write }

for

Quoted 7 lines

pid=1829 comm="modprobe" name="console" dev=sda ino=344069 scontext=system_u:system_r:insmod_t tcontext=unconfined_u:object_r:default_t tclass=chr_file

root@localhost:/root> audit2allow < msg #============= insmod_t ============== allow insmod_t default_t:chr_file { read write };

Quoted 8 lines

root@localhost:/root> audit2why < msg libsepol.context_from_record: MLS is disabled, but MLS context "s0" found
libsepol.context_from_record: could not create context structure libsepol.context_from_string: could not create context structure libsepol.sepol_context_to_sid: could not convert system_u:system_r:insmod_t:s0 to sid Invalid Source Context system_u:system_r:insmod_t:s0

Quoted 7 lines

I ran into this last week. Sepolgen incorrectly adds the MLS portion of the context regardless if MLS is enabled or not. Then when the tool uses the context, libsepol throws the above errors when MLS is disabled.
I haven't had a chance to really look at what would be the right way to fix it, since I'm no python expert. Karl?

Quoted 2 lines

Maybe I'm missing something, but from above this looks like an audit2why bug not an sepolgen bug.

Perhaps. I didn't have a change to analyze the problem fully, so I don't know if sepolgen is supposed to be informed if this is an MLS policy or not, or if sepolgen itself is supposed to figure it out. In the end the offending function is in the SecurityContext class in sepolgen:

Quoted 8 lines

def to_string(self, default_level="s0"):

        fields = [self.user, self.role, self.type]
        if self.level == "":
            if default_level != "":
                fields.append(default_level)
        else:
            fields.append(self.level)
        return ":".join(fields)

To be clear, I couldn't find any example of default_level being set to anything when to_string() is called, so in the end it gets a level no matter what.

Signature · 7 lines
Chris PeBenito
<[email protected]>
Developer,
Hardened Gentoo Linux
 
Public Key: http://pgp.mit.edu:11371/pks/lookup?op=get&search=0xE6AF9243
Key fingerprint = B0E6 877A 883F A57A 8E6A  CB00 BC8E E42D E6AF 9243
#5 lore raw

Re: libsepol.context_from_record: MLS is disabled, but MLS context"s0" found

Quoted 64 lines · Chris PeBenito
Quoted 52 lines · Chris PeBenito
Quoted 41 lines · Karl MacMillan
Quoted 33 lines

-----Original Message-----
From: Chris PeBenito [mailto:[email protected]]
Sent: Thursday, July 24, 2008 8:07 PM
To: Vikram Ambrose
Cc: [email protected]; Karl MacMillan
Subject: Re: libsepol.context_from_record: MLS is disabled, but MLS context"s0" found

Quoted 5 lines · Vikram Ambrose

I keep getting this error with audit2why.

root@localhost:/root> cat msg
type=1400 audit(1216736766.147:35): avc: denied { read write }

for

Quoted 7 lines

pid=1829 comm="modprobe" name="console" dev=sda ino=344069 scontext=system_u:system_r:insmod_t tcontext=unconfined_u:object_r:default_t tclass=chr_file

root@localhost:/root> audit2allow < msg #============= insmod_t ============== allow insmod_t default_t:chr_file { read write };

Quoted 9 lines

root@localhost:/root> audit2why < msg libsepol.context_from_record: MLS is disabled, but MLS context "s0" found
libsepol.context_from_record: could not create context structure libsepol.context_from_string: could not create context structure libsepol.sepol_context_to_sid: could not convert system_u:system_r:insmod_t:s0 to sid Invalid Source Context system_u:system_r:insmod_t:s0

Quoted 8 lines

I ran into this last week. Sepolgen incorrectly adds the MLS portion of the context regardless if MLS is enabled or not. Then when the tool uses the context, libsepol throws the above errors when MLS is disabled.
I haven't had a chance to really look at what would be the right way to fix it, since I'm no python expert. Karl?

Quoted 3 lines

Maybe I'm missing something, but from above this looks like an audit2why bug not an sepolgen bug.

Perhaps. I didn't have a change to analyze the problem fully, so I don't know if sepolgen is supposed to be informed if this is an MLS policy or not, or if sepolgen itself is supposed to figure it out. In the end the offending function is in the SecurityContext class in sepolgen:

Quoted 9 lines

def to_string(self, default_level="s0"):

        fields = [self.user, self.role, self.type]
        if self.level == "":
            if default_level != "":
                fields.append(default_level)
        else:
            fields.append(self.level)
        return ":".join(fields)
Quoted 5 lines

To be clear, I couldn't find any example of default_level being set to anything when to_string() is called, so in the end it gets a level no matter what.

I can confirm this problem does not exist with an MLS enabled policy and filesystem.

Vikram

Signature · 7 lines
Vikram Ambrose | Linux Products Division | WindRiver Corporation


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

RE: libsepol.context_from_record: MLS is disabled, but MLS context"s0" found

In reply to Chris PeBenito
Quoted 58 lines · Chris PeBenito
Quoted 48 lines · Chris PeBenito
Quoted 38 lines · Karl MacMillan
Quoted 30 lines

-----Original Message-----
From: Chris PeBenito [mailto:[email protected]]
Sent: Thursday, July 24, 2008 8:07 PM
To: Vikram Ambrose
Cc: [email protected]; Karl MacMillan
Subject: Re: libsepol.context_from_record: MLS is disabled, but MLS context"s0" found

Quoted 4 lines · Vikram Ambrose

I keep getting this error with audit2why.

root@localhost:/root> cat msg
type=1400 audit(1216736766.147:35): avc: denied { read write }

for

Quoted 7 lines

pid=1829 comm="modprobe" name="console" dev=sda ino=344069 scontext=system_u:system_r:insmod_t tcontext=unconfined_u:object_r:default_t tclass=chr_file

root@localhost:/root> audit2allow < msg #============= insmod_t ============== allow insmod_t default_t:chr_file { read write };

Quoted 8 lines

root@localhost:/root> audit2why < msg libsepol.context_from_record: MLS is disabled, but MLS context "s0" found
libsepol.context_from_record: could not create context structure libsepol.context_from_string: could not create context structure libsepol.sepol_context_to_sid: could not convert system_u:system_r:insmod_t:s0 to sid Invalid Source Context system_u:system_r:insmod_t:s0

Quoted 7 lines

I ran into this last week. Sepolgen incorrectly adds the MLS portion of the context regardless if MLS is enabled or not. Then when the tool uses the context, libsepol throws the above errors when MLS is disabled.
I haven't had a chance to really look at what would be the right way to fix it, since I'm no python expert. Karl?

Quoted 2 lines

Maybe I'm missing something, but from above this looks like an audit2why bug not an sepolgen bug.

Perhaps. I didn't have a change to analyze the problem fully, so I don't know if sepolgen is supposed to be informed if this is an MLS policy or not, or if sepolgen itself is supposed to figure it out. In the end the offending function is in the SecurityContext class in sepolgen:

Quoted 8 lines

def to_string(self, default_level="s0"):

        fields = [self.user, self.role, self.type]
        if self.level == "":
            if default_level != "":
                fields.append(default_level)
        else:
            fields.append(self.level)
        return ":".join(fields)
Quoted 3 lines

To be clear, I couldn't find any example of default_level being set to anything when to_string() is called, so in the end it gets a level no matter what.

Right - it shouldn't do that if is_selinux_mls_enabled() <= 0. I think this is a result of the audit2allow / audit2why integration; previously, audit2why was directly consuming audit messages but now it is leveraging sepolgen.

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

#7 lore raw

Re: libsepol.context_from_record: MLS is disabled, but MLS context"s0" found

Quoted 70 lines · Stephen Smalley
Quoted 63 lines · Chris PeBenito
Quoted 52 lines · Chris PeBenito
Quoted 41 lines · Karl MacMillan
Quoted 33 lines

-----Original Message-----
From: Chris PeBenito [mailto:[email protected]]
Sent: Thursday, July 24, 2008 8:07 PM
To: Vikram Ambrose
Cc: [email protected]; Karl MacMillan
Subject: Re: libsepol.context_from_record: MLS is disabled, but MLS context"s0" found

Quoted 5 lines · Vikram Ambrose

I keep getting this error with audit2why.

root@localhost:/root> cat msg
type=1400 audit(1216736766.147:35): avc: denied { read write }

for

Quoted 7 lines

pid=1829 comm="modprobe" name="console" dev=sda ino=344069 scontext=system_u:system_r:insmod_t tcontext=unconfined_u:object_r:default_t tclass=chr_file

root@localhost:/root> audit2allow < msg #============= insmod_t ============== allow insmod_t default_t:chr_file { read write };

Quoted 9 lines

root@localhost:/root> audit2why < msg libsepol.context_from_record: MLS is disabled, but MLS context "s0" found
libsepol.context_from_record: could not create context structure libsepol.context_from_string: could not create context structure libsepol.sepol_context_to_sid: could not convert system_u:system_r:insmod_t:s0 to sid Invalid Source Context system_u:system_r:insmod_t:s0

Quoted 8 lines

I ran into this last week. Sepolgen incorrectly adds the MLS portion of the context regardless if MLS is enabled or not. Then when the tool uses the context, libsepol throws the above errors when MLS is disabled.
I haven't had a chance to really look at what would be the right way to fix it, since I'm no python expert. Karl?

Quoted 3 lines

Maybe I'm missing something, but from above this looks like an audit2why bug not an sepolgen bug.

Perhaps. I didn't have a change to analyze the problem fully, so I don't know if sepolgen is supposed to be informed if this is an MLS policy or not, or if sepolgen itself is supposed to figure it out. In the end the offending function is in the SecurityContext class in sepolgen:

Quoted 9 lines

def to_string(self, default_level="s0"):

        fields = [self.user, self.role, self.type]
        if self.level == "":
            if default_level != "":
                fields.append(default_level)
        else:
            fields.append(self.level)
        return ":".join(fields)
Quoted 4 lines

To be clear, I couldn't find any example of default_level being set to anything when to_string() is called, so in the end it gets a level no matter what.

Quoted 6 lines

Right - it shouldn't do that if is_selinux_mls_enabled() <= 0. I think this is a result of the audit2allow / audit2why integration; previously, audit2why was directly consuming audit messages but now it is leveraging sepolgen.

Is there a temporary work around for this? audit2* is basically the only debug tools available for selinux n00bs.

Vikram

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

#8 lore raw

Re: libsepol.context_from_record: MLS is disabled, but MLS context"s0" found

Quoted 71 lines · Vikram Ambrose
Quoted 70 lines · Stephen Smalley
Quoted 67 lines · Chris PeBenito
Quoted 52 lines · Chris PeBenito
Quoted 41 lines · Karl MacMillan
Quoted 33 lines

-----Original Message-----
From: Chris PeBenito [mailto:[email protected]]
Sent: Thursday, July 24, 2008 8:07 PM
To: Vikram Ambrose
Cc: [email protected]; Karl MacMillan
Subject: Re: libsepol.context_from_record: MLS is disabled, but MLS context"s0" found

Quoted 5 lines · Vikram Ambrose

I keep getting this error with audit2why.

root@localhost:/root> cat msg
type=1400 audit(1216736766.147:35): avc: denied { read write }

for

Quoted 7 lines

pid=1829 comm="modprobe" name="console" dev=sda ino=344069 scontext=system_u:system_r:insmod_t tcontext=unconfined_u:object_r:default_t tclass=chr_file

root@localhost:/root> audit2allow < msg #============= insmod_t ============== allow insmod_t default_t:chr_file { read write };

Quoted 9 lines

root@localhost:/root> audit2why < msg libsepol.context_from_record: MLS is disabled, but MLS context "s0" found
libsepol.context_from_record: could not create context structure libsepol.context_from_string: could not create context structure libsepol.sepol_context_to_sid: could not convert system_u:system_r:insmod_t:s0 to sid Invalid Source Context system_u:system_r:insmod_t:s0

Quoted 8 lines

I ran into this last week. Sepolgen incorrectly adds the MLS portion of the context regardless if MLS is enabled or not. Then when the tool uses the context, libsepol throws the above errors when MLS is disabled.
I haven't had a chance to really look at what would be the right way to fix it, since I'm no python expert. Karl?

Quoted 3 lines

Maybe I'm missing something, but from above this looks like an audit2why bug not an sepolgen bug.

Perhaps. I didn't have a change to analyze the problem fully, so I don't know if sepolgen is supposed to be informed if this is an MLS policy or not, or if sepolgen itself is supposed to figure it out. In the end the offending function is in the SecurityContext class in sepolgen:

Quoted 9 lines

def to_string(self, default_level="s0"):

        fields = [self.user, self.role, self.type]
        if self.level == "":
            if default_level != "":
                fields.append(default_level)
        else:
            fields.append(self.level)
        return ":".join(fields)

To be clear, I couldn't find any example of default_level being set to anything when to_string() is called, so in the end it gets a level no matter what.

Quoted 8 lines
Quoted 6 lines

Right - it shouldn't do that if is_selinux_mls_enabled() <= 0. I think this is a result of the audit2allow / audit2why integration; previously, audit2why was directly consuming audit messages but now it is leveraging sepolgen.

Is there a temporary work around for this? audit2* is basically the only debug tools available for selinux n00bs.

I would think that you could just change default_level="" in the to_string definition in class SecurityContext in refpolicy.py. Or make it dynamically determine it based on is_selinux_mls_enabled().

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

Re: libsepol.context_from_record: MLS is disabled, but MLS context"s0" found

Quoted 91 lines · Stephen Smalley
Quoted 89 lines · Vikram Ambrose
Quoted 87 lines · Stephen Smalley
Quoted 72 lines · Chris PeBenito
Quoted 59 lines · Chris PeBenito
Quoted 46 lines · Karl MacMillan
Quoted 37 lines

-----Original Message-----
From: Chris PeBenito [mailto:[email protected]]
Sent: Thursday, July 24, 2008 8:07 PM
To: Vikram Ambrose
Cc: [email protected]; Karl MacMillan
Subject: Re: libsepol.context_from_record: MLS is disabled, but MLS context"s0" found

Quoted 6 lines · Vikram Ambrose

I keep getting this error with audit2why.

root@localhost:/root> cat msg
type=1400 audit(1216736766.147:35): avc: denied { read write }

for

Quoted 7 lines

pid=1829 comm="modprobe" name="console" dev=sda ino=344069 scontext=system_u:system_r:insmod_t tcontext=unconfined_u:object_r:default_t tclass=chr_file

root@localhost:/root> audit2allow < msg #============= insmod_t ============== allow insmod_t default_t:chr_file { read write };

Quoted 10 lines

root@localhost:/root> audit2why < msg libsepol.context_from_record: MLS is disabled, but MLS context "s0" found
libsepol.context_from_record: could not create context structure libsepol.context_from_string: could not create context structure libsepol.sepol_context_to_sid: could not convert system_u:system_r:insmod_t:s0 to sid Invalid Source Context system_u:system_r:insmod_t:s0

Quoted 9 lines

I ran into this last week. Sepolgen incorrectly adds the MLS portion of the context regardless if MLS is enabled or not. Then when the tool uses the context, libsepol throws the above errors when MLS is disabled.
I haven't had a chance to really look at what would be the right way to fix it, since I'm no python expert. Karl?

Quoted 4 lines

Maybe I'm missing something, but from above this looks like an audit2why bug not an sepolgen bug.

Perhaps. I didn't have a change to analyze the problem fully, so I don't know if sepolgen is supposed to be informed if this is an MLS policy or not, or if sepolgen itself is supposed to figure it out. In the end the offending function is in the SecurityContext class in sepolgen:

Quoted 10 lines

def to_string(self, default_level="s0"):

        fields = [self.user, self.role, self.type]
        if self.level == "":
            if default_level != "":
                fields.append(default_level)
        else:
            fields.append(self.level)
        return ":".join(fields)
Quoted 5 lines

To be clear, I couldn't find any example of default_level being set to anything when to_string() is called, so in the end it gets a level no matter what.

Right - it shouldn't do that if is_selinux_mls_enabled() <= 0. I think this is a result of the audit2allow / audit2why integration; previously, audit2why was directly consuming audit messages but now it is leveraging sepolgen.

Quoted 8 lines
Quoted 2 lines

Is there a temporary work around for this? audit2* is basically the only debug tools available for selinux n00bs.

I would think that you could just change default_level="" in the to_string definition in class SecurityContext in refpolicy.py. Or make it dynamically determine it based on is_selinux_mls_enabled().

You mean that in a non-MCS/MLS policy level=""?
and its fine for that function to append "" to the context (without the ":" added on) ?

Signature · 7 lines
Vikram Ambrose | Linux Products Division | WindRiver Corporation


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

Re: libsepol.context_from_record: MLS is disabled, but MLS context"s0" found

In reply to a message not in the archive

[snip]

Quoted 4 lines · Karl MacMillan

Here's a patch - I'd appreciate testing on a non-MLS system as I don't have one handy right now.

Quoted 9 lines

Karl

----
Karl MacMillan
Tresys Technology
(410) 290-1411 ext. 173
[email protected]

Patch works. Applied and tested with selinux-svn2928. Thank you Karl.

Vikram

Signature · 7 lines
Vikram Ambrose | Linux Products Division | WindRiver Corporation


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