Bug 484595

Summary: segfault in libselinux cleanup functions
Product: [Fedora] Fedora Reporter: DaveT <davetickem>
Component: libselinuxAssignee: Miroslav Grepl <mgrepl>
Status: CLOSED WONTFIX QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: low    
Version: 11CC: drepper, dwalsh, mgrepl, sct
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: All   
OS: Linux   
URL: https://bugs.launchpad.net/ubuntu/+source/libselinux/+bug/237156
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2010-06-28 11:12:57 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description DaveT 2009-02-08 20:28:29 UTC
Description of problem:

When running certain binaries (tcmodinfo from transcode is one example) an issue within libselinux.so.1 is exposed. This appears to be an issue for a number of distributions, around tls. Sorry, thread local storage, not transport layer... blah.

Version-Release number of selected component (if applicable):
- up to date Fedora 10 install on x86_64, full patches/updates.
- selinux permissive, enforce or disabled - all the same issue
- transcode-1.0.7-2.fc10.x86_64 (not Fedora I know, rpmfusion - but demonstrates issue)

How reproducible:

Very - every time

Steps to Reproduce:

1. Fed 10 install of x86_64 + all current patches
2. rpmfusion install transcode
3. run "tcmodinfo -i resample"

Actual results:

[davet@dolphin ~]$ /usr/bin/tcmodinfo -i resample
[filter_resample.so] v0.1.4 (2003-08-22) audio resampling filter plugin
[filter_resample.so] options=help
START
"filter_resample.so", "audio resampling filter plugin", "v0.1.4 (2003-08-22)", "Thomas Oestreich", "AE", "1"
END
Segmentation fault
[davet@dolphin ~]$ 

Expected results:

[davet@dolphin ~]$ /usr/bin/tcmodinfo -i resample
[filter_resample.so] v0.1.4 (2003-08-22) audio resampling filter plugin
[filter_resample.so] options=help
START
"filter_resample.so", "audio resampling filter plugin", "v0.1.4 (2003-08-22)", "Thomas Oestreich", "AE", "1"
END
[davet@dolphin ~]$ 

Additional info:

1. see "https://bugs.launchpad.net/ubuntu/+source/libselinux/+bug/237156"
2. libs :
[davet@dolphin ~]$ ldd /usr/bin/tcmodinfo
	linux-vdso.so.1 =>  (0x00007fffd6dfe000)
	libm.so.6 => /lib64/libm.so.6 (0x0000003fa4400000)
	libz.so.1 => /lib64/libz.so.1 (0x0000003fa5000000)
	libdl.so.2 => /lib64/libdl.so.2 (0x0000003fa4800000)
	libc.so.6 => /lib64/libc.so.6 (0x0000003fa4000000)
	/lib64/ld-linux-x86-64.so.2 (0x0000003fa3c00000)
[davet@dolphin ~]$ rpm -q -f /lib64/libm.so.6 
glibc-2.9-3.x86_64
[davet@dolphin ~]$ rpm -q -f /lib64/libz.so.1
zlib-1.2.3-18.fc9.x86_64
[davet@dolphin ~]$ rpm -q -f /lib64/libdl.so.2 
glibc-2.9-3.x86_64
[davet@dolphin ~]$ rpm -q -f /lib64/libc.so.6 
glibc-2.9-3.x86_64
[davet@dolphin ~]$ rpm -q -f /lib64/ld-linux-x86-64.so.2 
glibc-2.9-3.x86_64
[davet@dolphin ~]$ 

3. backtrace:
[davet@dolphin ~]$ gdb tcmodinfo
GNU gdb Fedora (6.8-29.fc10)
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu"...
(gdb) run -i resample
Starting program: /usr/bin/tcmodinfo -i resample
[Thread debugging using libthread_db enabled]
[filter_resample.so] v0.1.4 (2003-08-22) audio resampling filter plugin
[filter_resample.so] options=help
START
"filter_resample.so", "audio resampling filter plugin", "v0.1.4 (2003-08-22)", "Thomas Oestreich", "AE", "1"
END
[New Thread 0x7ffff7fd66f0 (LWP 5788)]

Program received signal SIGSEGV, Segmentation fault.
0x0000003fa541257d in fini_context_translations () at setrans_client.c:217
217		free(prev_r2t_trans);
(gdb) bt
#0  0x0000003fa541257d in fini_context_translations () at setrans_client.c:217
#1  0x0000003fa5404fef in __do_global_dtors_aux () from /lib64/libselinux.so.1
#2  0x00000000004019b0 in write@plt ()
#3  0x00007fffffffe0c0 in ?? ()
#4  0x0000003fa54140f1 in _fini () from /lib64/libselinux.so.1
#5  0x00007fffffffe0c0 in ?? ()
#6  0x0000003fa3c0f1d4 in _dl_fini () at dl-fini.c:248
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
(gdb)

4. really where? After main has completed, exit function run-through, setrans cleanup: 

">>" indicates segfault marker in setrans_client.c

hidden void fini_context_translations(void)
{
>>	free(prev_r2t_trans);
	free(prev_r2t_raw);
	free(prev_t2r_trans);
	free(prev_t2r_raw);
}

Comment 1 Daniel Walsh 2009-02-09 13:48:12 UTC
This is actually just exposing a bug in the transcode package and should be reported to them.

The libselinux library is just freeing up memory in it's destructor.

We have had a few other packages that this code has tirggered errors.  Uli can explain better then I.

Comment 2 DaveT 2009-03-19 15:50:51 UTC
I'll close until I can prove otherwise, (If I can...).

Comment 3 Stephen Tweedie 2009-08-06 21:34:25 UTC
Reopening, I've just been bitten by this same transcode issue on F10 i386, and it does appear to be a libselinux fault.

gdb shows the problem is occurring in the libselinux destructor:

  static void fini_lib(void) __attribute__ ((destructor))
calls
    hidden void fini_context_translations(void)
calls
      free(prev_r2t_trans);

where this variable is thread-local:

static __thread security_context_t prev_r2t_trans = NULL;

In this particular case, libselinux is being dlopen'ed implicitly by the dlopen'ing of the transcode filter-resample.so DSO.  When that DSO is dlclosed, libselinux is having its destructor called, but I don't think it's legal to access TLS from that context.

I chatted with Eric Paris about this for a bit.  He believes that this has been fixed in rawhide libselinux, and indeed, rebuilding the current libselinux/devel source on F10 fixes the transcode problem for me.  He also pointed me at

http://www.engardelinux.org/modules/index/list_archives.cgi?list=selinux&page=0014.html&month=2009-05
http://www.engardelinux.org/modules/index/list_archives.cgi?list=selinux&page=0039.html&month=2009-07

where this destructor problem is discussed further.

Comment 4 Daniel Walsh 2009-08-10 14:04:06 UTC
Miroslav can you see about back porting the libselinux functionality to F10 and F11.

Comment 5 Bug Zapper 2009-11-18 09:49:10 UTC
This message is a reminder that Fedora 10 is nearing its end of life.
Approximately 30 (thirty) days from now Fedora will stop maintaining
and issuing updates for Fedora 10.  It is Fedora's policy to close all
bug reports from releases that are no longer maintained.  At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '10'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 10's end of life.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 10 is end of life.  If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora please change the 'version' of this 
bug to the applicable version.  If you are unable to change the version, 
please add a comment here and someone will do it for you.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events.  Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 
http://fedoraproject.org/wiki/BugZappers/HouseKeeping

Comment 6 Bug Zapper 2010-04-27 12:53:08 UTC
This message is a reminder that Fedora 11 is nearing its end of life.
Approximately 30 (thirty) days from now Fedora will stop maintaining
and issuing updates for Fedora 11.  It is Fedora's policy to close all
bug reports from releases that are no longer maintained.  At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '11'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 11's end of life.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 11 is end of life.  If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora please change the 'version' of this 
bug to the applicable version.  If you are unable to change the version, 
please add a comment here and someone will do it for you.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events.  Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 
http://fedoraproject.org/wiki/BugZappers/HouseKeeping

Comment 7 Bug Zapper 2010-06-28 11:12:57 UTC
Fedora 11 changed to end-of-life (EOL) status on 2010-06-25. Fedora 11 is 
no longer maintained, which means that it will not receive any further 
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of 
Fedora please feel free to reopen this bug against that version.

Thank you for reporting this bug and we are sorry it could not be fixed.