All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Smalley <sds@tycho.nsa.gov>
To: Stefano Borini <stefano.borini@quantumwise.com>, selinux@tycho.nsa.gov
Subject: Re: spinlock in centos 6.4 and redhat enterprise 6 using chcon
Date: Fri, 30 Jan 2015 11:15:44 -0500	[thread overview]
Message-ID: <54CBAE30.5060402@tycho.nsa.gov> (raw)
In-Reply-To: <54CA07EC.5090403@quantumwise.com>

On 01/29/2015 05:14 AM, Stefano Borini wrote:
> Good morning,
> 
> I am encountering what seems to be a spinlock with the chcon utility
> trying the following operation
> 
> chcon -t texrel_shlib_t /tmp/subdir/withheldpath
> 
> where withheld path is a .so that is going to be accessed with dlopen.
> I am not invoking the chcon command directly nor performing the dlopen,
> a closed-source library does that, apparently to prepare the .so for
> dlopening.

While this obviously shouldn't hang, it is definitely wrong for this
library to be invoking chcon on the .so file.  The label should be set
when the .so file is first installed, preferably by rpm itself by adding
a file_contexts entry via semanage fcontext -a followed by a restorecon
call in the %post scriptlet.  Can you bug the author of the
closed-source library to fix their package?

> 
> Note that if I try the same operation from the command line, even while
> the spinlock is in progress, no lock occurs.
> 
> I am unable to understand the details of what may cause this spinlock.
> This is the backtrace of chcon, apparently involving some thread local
> storage
> 
> #0  0x0000003e3ea00b64 in rtld_lock_default_lock_recursive () from
> /lib64/ld-linux-x86-64.so.2
> #1  0x0000003e3ea11257 in tls_get_addr_tail () from
> /lib64/ld-linux-x86-64.so.2
> #2  0x0000003e3ea11660 in __tls_get_addr () from
> /lib64/ld-linux-x86-64.so.2
> #3  0x0000003e40a14334 in selinux_raw_to_trans_context () from
> /lib64/libselinux.so.1
> #4  0x0000003e40a0ca7a in getfilecon () from /lib64/libselinux.so.1
> 
> Checking the tls_get_addr_tail function, it is apparently stuck in the
> again: loop
> 
> http://code.woboq.org/userspace/glibc/elf/dl-tls.c.html#742
> 
> I have only access to the centos 6.4 and can run additional
> non-destructive tests if needed. It's a customer machine so I am unable
> to say if modifications have been done to it when it comes to security,
> although I suspect it's a standard centos6.4 installation with selinux
> enabled.
> 
> The current ls -Z of /tmp gives
> 
> system_u:object_r:tmp_t:s0
> 
> of subdir and of the so file is
> 
> unconfined_u:object_r:user_tmp_t:s0
> 
> Thank you for your help.
> 
> 

  parent reply	other threads:[~2015-01-30 16:15 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-29 10:14 spinlock in centos 6.4 and redhat enterprise 6 using chcon Stefano Borini
2015-01-30 16:08 ` Stephen Smalley
2015-01-30 16:15 ` Stephen Smalley [this message]
2015-01-30 21:25   ` Stefano Borini
2015-01-30 21:36     ` Stephen Smalley
2015-02-01 11:17       ` Stefano Borini
2015-02-02 11:09         ` Stefano Borini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54CBAE30.5060402@tycho.nsa.gov \
    --to=sds@tycho.nsa.gov \
    --cc=selinux@tycho.nsa.gov \
    --cc=stefano.borini@quantumwise.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.