Skip to contentSkip to conversation

semodule dumps core

DISCUSSION Thomas Bleher 3 participants 6 messages Mar 16, 2006 – Mar 20, 2006 SELinux security module

lore
Share & tools
lore
#0 lore raw

Seems like semodule doesn't like me. I just recompiled my policy with the new versions of the tools and now semodule dumps core when I do a "semodule -b base.pp".

The backtrace from gdb looks like this:
(gdb) backtrace

#0  0x37ec2f5c in fclose@plt () from /lib/libsemanage.so.1
#1  0x37ec8950 in semanage_direct_commit (sh=0x804c4a8) at direct_api.c:401
#2  0x37eca3fe in semanage_commit (sh=0x804c4a8) at handle.c:227
#3  0x08049507 in main (argc=3, argv=0x3fc5db44) at semodule.c:361

I'm not experienced in debugging this so I put up semodule, the corefile and the base.pp at
http://www.cip.ifi.lmu.de/~bleher/selinux/ubuntu/semodule-coredump.tar.bz2
(1.5MB)

In this directory you will also find the Debian packages I used (libsemanage, libsepol, ...).

Please let me know if you need more information.

Thanks,
Thomas

#1 lore raw
Quoted 11 lines · Thomas Bleher

Seems like semodule doesn't like me. I just recompiled my policy with
the new versions of the tools and now semodule dumps core when I do a "semodule -b base.pp".

The backtrace from gdb looks like this:
(gdb) backtrace

#0  0x37ec2f5c in fclose@plt () from /lib/libsemanage.so.1
#1  0x37ec8950 in semanage_direct_commit (sh=0x804c4a8) at direct_api.c:401
#2  0x37eca3fe in semanage_commit (sh=0x804c4a8) at handle.c:227
#3  0x08049507 in main (argc=3, argv=0x3fc5db44) at semodule.c:361

Hmm? line 401 in direct_api.c is not in semanage_direct_commit() in the version of libsemanage you specified (1.6?)...

--
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
In reply to Thomas Bleher
Quoted 16 lines · Thomas Bleher

Seems like semodule doesn't like me. I just recompiled my policy with the new versions of the tools and now semodule dumps core when I do a "semodule -b base.pp".

The backtrace from gdb looks like this:
(gdb) backtrace

#0  0x37ec2f5c in fclose@plt () from /lib/libsemanage.so.1
#1  0x37ec8950 in semanage_direct_commit (sh=0x804c4a8) at direct_api.c:401
#2  0x37eca3fe in semanage_commit (sh=0x804c4a8) at handle.c:227
#3  0x08049507 in main (argc=3, argv=0x3fc5db44) at semodule.c:361

I'm not experienced in debugging this so I put up semodule, the corefile and the base.pp at
http://www.cip.ifi.lmu.de/~bleher/selinux/ubuntu/semodule-coredump.tar.bz2
(1.5MB)

Quoted 4 lines

In this directory you will also find the Debian packages I used (libsemanage, libsepol, ...).

Please let me know if you need more information.

Hmmm...I can successfully run that semodule binary (with my own libsemanage and libsepol) on that base.pp file, ala:
mkdir -p /etc/selinux/bleher/policy
mkdir -p /etc/selinux/bleher/contexts/files
valgrind ./semodule -v -s bleher -b base.pp

The -s option is to install it to an alternate "store" so that it doesn't clobber my own active policy or try to load it.

Pardon my ignorance, but how does one unpack a binary deb file on a rpm-based system like Fedora (so that I can extract your libse*
binaries)? Any equivalent to rpm2cpio for extracting deb files?

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
Quoted 28 lines · Stephen Smalley
Quoted 16 lines · Thomas Bleher

Seems like semodule doesn't like me. I just recompiled my policy with the new versions of the tools and now semodule dumps core when I do a "semodule -b base.pp".

The backtrace from gdb looks like this:
(gdb) backtrace

#0  0x37ec2f5c in fclose@plt () from /lib/libsemanage.so.1
#1  0x37ec8950 in semanage_direct_commit (sh=0x804c4a8) at direct_api.c:401
#2  0x37eca3fe in semanage_commit (sh=0x804c4a8) at handle.c:227
#3  0x08049507 in main (argc=3, argv=0x3fc5db44) at semodule.c:361

I'm not experienced in debugging this so I put up semodule, the corefile and the base.pp at
http://www.cip.ifi.lmu.de/~bleher/selinux/ubuntu/semodule-coredump.tar.bz2
(1.5MB)

Quoted 4 lines

In this directory you will also find the Debian packages I used (libsemanage, libsepol, ...).

Please let me know if you need more information.

Hmmm...I can successfully run that semodule binary (with my own libsemanage and libsepol) on that base.pp file, ala:
mkdir -p /etc/selinux/bleher/policy
mkdir -p /etc/selinux/bleher/contexts/files
valgrind ./semodule -v -s bleher -b base.pp

Quoted 6 lines

The -s option is to install it to an alternate "store" so that it doesn't clobber my own active policy or try to load it.

Pardon my ignorance, but how does one unpack a binary deb file on a rpm-based system like Fedora (so that I can extract your libse*
binaries)? Any equivalent to rpm2cpio for extracting deb files?

Ah, nevermind. I found some helpful hints over at:
http://lists.debian.org/debian-user/2001/07/msg00645.html

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
In reply to Thomas Bleher
Quoted 3 lines · Thomas Bleher

Seems like semodule doesn't like me. I just recompiled my policy with the new versions of the tools and now semodule dumps core when I do a "semodule -b base.pp".

Stephen gave me many good suggestions, among them to compile without -O2. I tried this and the problem went away! Tracking this down further I narrowed it down to libsepol being miscompiled with -O2, it works fine with -O0 or -O1. So this looks like a compiler bug in gcc (as shipped in current Ubuntu Dapper). Unfortunately I won't have time to track down this problem but if anyone wants to look into this I can provide the sources I used.

Thanks,
Thomas

--
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
Quoted 5 lines · Thomas Bleher
Quoted 3 lines · Thomas Bleher

Seems like semodule doesn't like me. I just recompiled my policy with the new versions of the tools and now semodule dumps core when I do a "semodule -b base.pp".

Quoted 7 lines

Stephen gave me many good suggestions, among them to compile without -O2. I tried this and the problem went away! Tracking this down further I narrowed it down to libsepol being miscompiled with -O2, it works fine with -O0 or -O1. So this looks like a compiler bug in gcc (as shipped in current Ubuntu Dapper). Unfortunately I won't have time to track down this problem but if anyone wants to look into this I can provide the sources I used.

Ok, I reproduced this on Fedora by building libsepol with just -O2 by hand, e.g. make CFLAGS+="-O2" clean install. Looking at what an rpm build of the libsepol package does, it does build with -O2 but also adds several other flags during the build. Trying these flags individually with -O2, it appears that the -fstack-protector option makes the
difference: adding it yields a working libsepol while removing it leaves a broken libsepol. As -fstack-protector adds guard variables and checking code, it seemed likely that it was covering up some bug that would otherwise occur. Looking at sepol_module_package_write() again, since the seg fault occurred immediately after it completed, I noticed that buf[] is too small if you include all optional sections (i.e. users_extra and seusers as well as file_contexts). Patch below.

Index: libsepol/src/module.c
===================================================================
RCS file: /nfshome/pal/CVS/selinux-usr/libsepol/src/module.c,v retrieving revision 1.19

src/module.c +1 -1
diff -u -p -r1.19 module.c
@@ -661,7 +661,7 @@ int sepol_module_package_write(sepol_mod
 {
 	struct policy_file *file = &spf->pf;
 	policy_file_t polfile;
-	uint32_t buf[3], offsets[5], len, nsec = 0;
+	uint32_t buf[5], offsets[5], len, nsec = 0;
 	int i;
 
 	if (p->policy) {
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.