selinux and thread local storage
Hi all,
I am trying to figure out something about Red Hat Bugzilla – Bug 1195074, where nvidia libGL.so.304.125 hangs in an endless loop when loaded by gnome-shell 3.14.
Sequence is: gnome-shell loads libGL.so which for some reason calls is_selinux_enabled in libselinux.so at library load time, which runs into a spinlock within init_thread_destructor when accessing the thread-local variable destructor_initialized.
gdb print of destructor_initialized reports:
The inferior has not yet allocated storage for thread-local variables in the shared library `/lib64/libselinux.so.1'
gdb backtrace is:
#0 0x0000003f12412495 in tls_get_addr_tail (ti=0x3509221f58, dtv=0x7ffff7f83390, the_map=0x7ffff7f9c000)
at dl-tls.c:751
#1 0x00003�����������́�������ɽ����ɍ��}Ʌ܀����Ё�ɽ����ȹ����(�Ȁ������������������́�������ɽ����ɍ��}Ʌ�(����ѕ������ѕ����������ݙ��������������������������)������������������������݈�����ɕ�Ј���Ё�ɽ����ȹ�����(�̀�����������������є������э��}Ʌ�}��ѕɹ���������������ݙ�������������)�ɽ����ȹ�����(�Ѐ����������������ٍ�������}͕�����}�������}��ѕɹ�������Ё������������(�Ԁ���������������Ռ���������Ѐ�����н���0�ͼ��(����������������ь݈���������Ѐ�����н���0�ͼ��(�܀���������͘����������������}���Ѐ�����ݙ���ݘ���ఁ�ɝ���ɝ�������Ȱ)�ɝ���ɝ���������ݙ���������ఁ���������������ݙ�������������Ё������й����(������������͘������͈����}��}���Ѐ�������ѥ��镐��������ɝ����ѥ��镐)�������ɝ����ѥ��镐�����������ѥ��צVB�WC�BF�֖�B�3�3@�3��6c#C6"���F����B��������6c#c#3C��&v3�"��&wc��vfffffffF3��V�c��vfffffffF33�BF�֖�B�3�#@�3�6c#CC&���F��7F'E�W6W"��B�Ɩ#cB��B�Ɩ�W�׃�b�cB�6�� �3�"�����3"�vfffffffFfFB�����32�vfffffffFfc"�����3B�������F��2�67W'2BƖ'&'���BF��R�6�&Vf�&RvWGF��rF���ₒ�FF�F������FR�2F�B��fRF��2&�&�V�v�F�v���R�6�V���'WB���F�W �W�V7WF&�W2���6�VF��rv���R�6W76����vdž��f��vdžvV'2���@�Ɩ$t��6��3B�#R�B'V��W7Bf��RࠥF��2&�&�V��26�֖�"F�F�R��RFW67&�&VB�ইGG����&2��f���C�C##S#c�s2g#�gs� ��F��Vv���ג66Rv�BV���6�2F�R7����6��2F�F��E�$T��Bf�"Ɩ$t��6�ऒF��wBF����E�$T��B�2&V�ǒ������][ۋ�[�H�Y��\�[ۜ���]XZ�\�]Y��X�[\�H\�]��YXHX����ˌ� �L�H\����Y���\��K[�][���Y���YHX���YXK]��X���[���\�X��]���[\��Y��\���YH�[�]X[^�][ۈ�؛[H�[H[�[ZX��Y[��ق�X��[[�^
Quoted 15 lines · On 04/14/2015 02:45 PM, mm19827 wrote:
Hi all,
I am trying to figure out something about Red Hat Bugzilla – Bug 1195074, where nvidia libGL.so.304.125 hangs in an endless loop when loaded by gnome-shell 3.14.
Sequence is: gnome-shell loads libGL.so which for some reason calls
is_selinux_enabledin libselinux.so at library load time, which runs into a spinlock withininit_thread_destructorwhen accessing the thread-local variabledestructor_initialized.gdb print of
destructor_initializedreports:
The inferior has not yet allocated storage for thread-local variables in the shared library `/lib64/libselinux.so.1'
Quoted 5 lines
gdb backtrace is:
#0
0x0000003f12412495intls_get_addr_tail(ti=0x3509221f58, dtv=0x7ffff7f83390, the_map=0x7ffff7f9c000)at dl-tls.c:751
Perhaps we could address this simply by changing is_selinux_enabled() to use a private or inlined version of getcon_raw() that does not try to cache the result and therefore does not rely on tls?
Quoted 25 lines · Stephen Smalley
Quoted 15 lines · On 04/14/2015 02:45 PM, mm19827 wrote:
Hi all,
I am trying to figure out something about Red Hat Bugzilla – Bug 1195074, where nvidia libGL.so.304.125 hangs in an endless loop when loaded by gnome-shell 3.14.
Sequence is: gnome-shell loads libGL.so which for some reason calls
is_selinux_enabledin libselinux.so at library load time, which runs into a spinlock withininit_thread_destructorwhen accessing the thread-local variabledestructor_initialized.gdb print of
destructor_initializedreports:
The inferior has not yet allocated storage for thread-local variables in the shared library `/lib64/libselinux.so.1'Quoted 5 lines
gdb backtrace is:
#0
0x0000003f12412495intls_get_addr_tail(ti=0x3509221f58, dtv=0x7ffff7f83390, the_map=0x7ffff7f9c000)at dl-tls.c:751Perhaps we could address this simply by changing
is_selinux_enabled()to use a private or inlined version ofgetcon_raw()that does not try to cache the result and therefore does not rely on tls?
Quoted 7 lines
_______________________________________________
Selinux mailing list
[email protected]
To unsubscribe, send email to [email protected].
To get help, send an email containing "help" to [email protected].
I would be fine with that.
Quoted 23 lines · Daniel J Walsh
Quoted 21 lines · Stephen Smalley
Quoted 20 lines · On 04/14/2015 02:45 PM, mm19827 wrote:
Hi all,
I am trying to figure out something about Red Hat Bugzilla – Bug 1195074, where nvidia libGL.so.304.125 hangs in an endless loop when loaded by gnome-shell 3.14.
Sequence is: gnome-shell loads libGL.so which for some reason calls
is_selinux_enabledin libselinux.so at library load time, which runs into a spinlock withininit_thread_destructorwhen accessing the thread-local variabledestructor_initialized.gdb print of
destructor_initializedreports:
The inferior has not yet allocated storage for thread-local variables in the shared library `/lib64/libselinux.so.1'gdb backtrace is:
#0
0x0000003f12412495intls_get_addr_tail(ti=0x3509221f58, dtv=0x7ffff7f83390, the_map=0x7ffff7f9c000)at dl-tls.c:751
Quoted 6 lines
Quoted 5 lines
Perhaps we could address this simply by changing
is_selinux_enabled()to use a private or inlined version ofgetcon_raw()that does not try to cache the result and therefore does not rely on tls?I would be fine with that.
Actually, could we just drop the test altogether of whether getcon() returns "kernel", i.e. no-policy-loaded? IIRC, this is a leftover of Fedora Core 2 days, before we had support for SELinux runtime disable, so that we could emulate SELinux disabled by just not loading a policy.
But these days SELinux can be disabled either via SELINUX=disabled in/etc/selinux/config or selinux=0 and either way selinuxfs is unregistered and /sys/fs/selinux is unmounted, so we should not need this test anymore AFAICS.
Reposting with correct backtrace (hopefully)
Quoted 11 lines · On 04/14/2015 08:45 PM, mm19827 wrote:
Hi all,
I am trying to figure out something about Red Hat Bugzilla – Bug 1195074, where nvidia libGL.so.304.125 hangs in an endless loop when loaded by gnome-shell 3.14.
Sequence is: gnome-shell loads libGL.so which for some reason calls
is_selinux_enabledin libselinux.so at library load time, which runs into a spinlock withininit_thread_destructorwhen accessing the thread-local variabledestructor_initialized.
Quoted 6 lines
gdb print of
destructor_initializedreports:
The inferior has not yet allocated storage for thread-local variables in the shared library `/lib64/libselinux.so.1'gdb backtrace is:
#0 0x0000003f12412495 in tls_get_addr_tail (ti=0x3509221f58, dtv=0x7ffff7f83390, the_map=0x7ffff7f9c000) at dl-tls.c:751 #1 0x000000350900af63 in getprocattrcon_raw () at procattr.c:73 #2 0x000000350900af63 in getprocattrcon_raw (context=context@entry=0x7fffffffd9f0, pid=pid@entry=0, attr=attr@entry=0x3509019e7b "current") at procattr.c:121 #3 0x000000350900b24e in getcon_raw_internal (c=c@entry=0x7fffffffd9f0) at procattr.c:334 #4 0x000000350900a6ce in is_selinux_enabled_internal () at enabled.c:26 #5 0x000000350d0a5c06 in () at /lib64/libGL.so.1 #6 0x000000350d084c7b in () at /lib64/libGL.so.1 #7 0x0000003f1240feed in call_init (l=0x7ffff7f999a8, argc=argc@entry=2, argv=argv@entry=0x7fffffffdc18, env=env@entry=0x7fffffffdc30) at dl-init.c:62 #8 0x0000003f1241003b in _dl_init (env=<optimized out>, argv=<optimized out>, argc=<optimized out>, l=<optimized out>) at dl-init.c:34 #9 0x0000003f1241003b in _dl_init (main_map=0x3f12623148, argc=2, argv=0x7fffffffdc18, env=0x7fffffffdc30) at dl-init.c:124 #10 0x0000003f12400d2a in _dl_start_user () at /lib64/ld-linux-x86-64.so.2 #11 0x0000000000000002 in () #12 0x00007fffffffdfdd in () #13 0x00007fffffffdff2 in () #14 0x0000000000000000 in ()
This occurs at library load time, so before getting to main().
Additional note is that I have this problem with gnome-shell, but many other executables (including gnome-session, glxinfo, glxgears) load libGL.so.304.125 and run just fine.
This problem is similar to the one described in
http://marc.info/?t=142252697100003&r=1&w=2
although in my case what unlocks the spinlock is to do LD_PRELOAD for libGL.so.
What makes it difficult here is that nvidia libGL.so.304.125 is closed source, and that also loads some libnvidia-tls.so which sounds like being involved with tls (no response from nvidia yet), so not much really clear, but I posted this in case it may suggest anything between selinux and tls.