Skip to contentSkip to conversation

segfault in semodule

DISCUSSION Eric Paris 3 participants 5 messages Feb 22, 2008 SELinux security module

lore
Share & tools
lore

Eric Paris

author
#0 lore raw

I added "allow-unknown = deny" in semanage.conf and ran semodule -R

[root@dhcp231-146 ~]# semodule -R
error parsing semanage configuration file: syntax error
semodule: Could not create semanage handle
semodule: handle.c:123: semanage_is_connected: Assertion `sh != ((void *)0)' failed. Segmentation fault

It was supposed to bail (allow-unknown is not a valid entry, it should be handle-unknown) but it wasn't supposed to segfault. Maybe someone who knows this code can find/fix it really quickly, if not I'm sure I'll get to look at it when it gets to the top of my list in 10 or 12 months :)

policycoreutils-2.0.43-2.fc9.x86_64

-Eric

--
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 8 lines · Eric Paris

I added "allow-unknown = deny" in semanage.conf and ran semodule -R

[root@dhcp231-146 ~]# semodule -R
error parsing semanage configuration file: syntax error
semodule: Could not create semanage handle
semodule: handle.c:123: semanage_is_connected: Assertion `sh != ((void *)0)' failed. Segmentation fault

Quoted 8 lines

It was supposed to bail (allow-unknown is not a valid entry, it should be handle-unknown) but it wasn't supposed to segfault. Maybe someone who knows this code can find/fix it really quickly, if not I'm sure I'll get to look at it when it gets to the top of my list in 10 or 12 months :)

policycoreutils-2.0.43-2.fc9.x86_64

This is totally untested but should fix it:

policycoreutils/semodule/semodule.c (working copy) renamed from policycoreutils/semodule/semodule.c (revision 2808) +3 -1
Index: trunk/policycoreutils/semodule/semodule.c
===================================================================
@@ -285,7 +285,7 @@
       if (!sh) {
               fprintf(stderr, "%s:  Could not create semanage handle\n",
                       argv[0]);
-               goto cleanup;
+               goto cleanup_nohandle;
       }
 
       if (store) {
@@ -473,6 +473,8 @@
               }
       }
       semanage_handle_destroy(sh);
+
+      cleanup_nohandle:
       cleanup();
       exit(status);

}

--
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 15 lines · Joshua Brindle
Quoted 14 lines · Eric Paris

I added "allow-unknown = deny" in semanage.conf and ran semodule -R

[root@dhcp231-146 ~]# semodule -R
error parsing semanage configuration file: syntax error
semodule: Could not create semanage handle
semodule: handle.c:123: semanage_is_connected: Assertion `sh != ((void *)0)' failed. Segmentation fault

It was supposed to bail (allow-unknown is not a valid entry, it should be handle-unknown) but it wasn't supposed to segfault. Maybe someone who knows this code can find/fix it really quickly, if not I'm sure I'll get to look at it when it gets to the top of my list in 10 or 12 months :)

Quoted 4 lines
Quoted 2 lines

policycoreutils-2.0.43-2.fc9.x86_64

This is totally untested but should fix it:

Whitespace damaged, but applied with -l and it fixed the problem.

Merge at will.

Quoted 30 lines

Index: trunk/policycoreutils/semodule/semodule.c
===================================================================

policycoreutils/semodule/semodule.c (working copy) renamed from policycoreutils/semodule/semodule.c (revision 2808) +3 -2
@@ -285,7 +285,7 @@
        if (!sh) {
                fprintf(stderr, "%s:  Could not create semanage handle\n",
                        argv[0]);
-               goto cleanup;
+               goto cleanup_nohandle;
        }
 
        if (store) {
@@ -473,6 +473,8 @@
                }
        }
        semanage_handle_destroy(sh);
+
+      cleanup_nohandle:
        cleanup();
        exit(status);
 }
 
 
 
--

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.

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.
#3 lore raw
In reply to Joshua Brindle
Quoted 15 lines · Joshua Brindle
Quoted 14 lines · Eric Paris

I added "allow-unknown = deny" in semanage.conf and ran semodule -R

[root@dhcp231-146 ~]# semodule -R
error parsing semanage configuration file: syntax error
semodule: Could not create semanage handle
semodule: handle.c:123: semanage_is_connected: Assertion `sh != ((void *)0)' failed. Segmentation fault

It was supposed to bail (allow-unknown is not a valid entry, it should be handle-unknown) but it wasn't supposed to segfault. Maybe someone who knows this code can find/fix it really quickly, if not I'm sure I'll get to look at it when it gets to the top of my list in 10 or 12 months :)

Quoted 4 lines
Quoted 2 lines

policycoreutils-2.0.43-2.fc9.x86_64

This is totally untested but should fix it:

I suppose the other option would be to make semanage_is_connected() return 0 if sh == NULL rather than assert'ing that sh is non-NULL. Then the same error path could be used.

Quoted 30 lines

Index: trunk/policycoreutils/semodule/semodule.c
===================================================================

policycoreutils/semodule/semodule.c (working copy) renamed from policycoreutils/semodule/semodule.c (revision 2808) +3 -2
@@ -285,7 +285,7 @@
        if (!sh) {
                fprintf(stderr, "%s:  Could not create semanage handle\n",
                        argv[0]);
-               goto cleanup;
+               goto cleanup_nohandle;
        }
 
        if (store) {
@@ -473,6 +473,8 @@
                }
        }
        semanage_handle_destroy(sh);
+
+      cleanup_nohandle:
        cleanup();
        exit(status);
 }
 
 
 
--

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.

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.
#4 lore raw
Quoted 21 lines · Stephen Smalley
Quoted 19 lines · Joshua Brindle
Quoted 17 lines · Eric Paris

I added "allow-unknown = deny" in semanage.conf and ran semodule -R

[root@dhcp231-146 ~]# semodule -R
error parsing semanage configuration file: syntax error
semodule: Could not create semanage handle
semodule: handle.c:123: semanage_is_connected: Assertion `sh != ((void *)0)' failed. Segmentation fault

It was supposed to bail (allow-unknown is not a valid entry, it should be handle-unknown) but it wasn't supposed to segfault. Maybe someone who knows this code can find/fix it really quickly, if not I'm sure I'll get to look at it when it gets to the top of my list in 10 or 12 months :)

policycoreutils-2.0.43-2.fc9.x86_64

Quoted 8 lines
Quoted 2 lines

This is totally untested but should fix it:

I suppose the other option would be to make semanage_is_connected() return 0 if sh == NULL rather than assert'ing that sh is non-NULL. Then the same error path could be used.

I suppose, I think the basic philosophy in this library was that passing a null handle to any function that requires a handle is a bug and should be fixed. I'd hate to fix it in semanage_is_connected() and leave the asserts every where else.

Quoted 25 lines
Quoted 25 lines

Index: trunk/policycoreutils/semodule/semodule.c
===================================================================

policycoreutils/semodule/semodule.c (working copy) renamed from policycoreutils/semodule/semodule.c (revision 2808) +3 -1
@@ -285,7 +285,7 @@
        if (!sh) {
                fprintf(stderr, "%s:  Could not create semanage handle\n",
                        argv[0]);
-               goto cleanup;
+               goto cleanup_nohandle;
        }
 
        if (store) {
@@ -473,6 +473,8 @@
                }
        }
        semanage_handle_destroy(sh);
+
+      cleanup_nohandle:
        cleanup();
        exit(status);
 }
Quoted 5 lines
Quoted 5 lines

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

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