This service will be undergoing maintenance at 00:00 UTC, 2016-08-01. It is expected to last about 1 hours
Bug 885730 - libselinux-devel: [gs]et*con manual pages should document threading behavior
libselinux-devel: [gs]et*con manual pages should document threading behavior
Status: CLOSED RAWHIDE
Product: Fedora
Classification: Fedora
Component: libselinux (Show other bugs)
rawhide
Unspecified Unspecified
unspecified Severity low
: ---
: ---
Assigned To: Daniel Walsh
Fedora Extras Quality Assurance
: FutureFeature
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-12-10 08:49 EST by Florian Weimer
Modified: 2014-02-14 12:19 EST (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2014-02-14 12:19:35 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:


Attachments (Terms of Use)

  None (edit)
Description Florian Weimer 2012-12-10 08:49:03 EST
Description of problem:

The manual pages getfscon(3), getexeccon(3) (and maybe others) should document the threading behavior, that is, if the context is a thread-specific or process-wide attribute.

Version-Release number of selected component (if applicable):

libselinux-devel-2.1.10-3.fc17.x86_64
Comment 1 Daniel Walsh 2012-12-10 11:08:40 EST
Eric, do you want to take a stab at this?
Comment 2 Miloslav Trmač 2012-12-11 08:51:44 EST
This might be wrong, take it with a grain of salt:

AFAICS the contexts are thread-scoped in the kernel
http://oss.tresys.com/projects/refpolicy/browser/libselinux/src/setfscreatecon.c?rev=2192d4baa1a47137427ea5f22edb825c915657ce is handled in the kernel by fs/proc/base.c:proc_pid_attr_write => security/selinux/hooks.c:selinux_setprocattr => kernel/cred.c:commit_creds, which manipulates a per-task == per-thread "creds" pointer.

OTOH setfscreatecon.c uses /proc/self, which seems to link to the process, not to the thread - so perhaps the setfscreatecon() ando ther functions that use /proc/self/attr don't actually work in multi-threaded programs?

In any case, selinux_setprocattr fails if a thread attempts to modify the value of another thread, and this error seems to be correctly propagated through libselinux, so in the worst case using these functions in a multi-threaded program will "only" fail to work.
Comment 3 Fedora End Of Life 2013-07-03 18:20:43 EDT
This message is a reminder that Fedora 17 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 17. 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 '17'.

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 17'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 17 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, you are encouraged  change the 
'version' to a later Fedora version prior to Fedora 17's end of life.

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.
Comment 4 Florian Weimer 2013-07-04 04:19:12 EDT
Still present in libselinux-devel-2.1.13-15.fc19.x86_64.
Comment 5 Florian Weimer 2014-01-27 08:01:08 EST
(In reply to Miloslav Trmač from comment #2)

> OTOH setfscreatecon.c uses /proc/self, which seems to link to the process,
> not to the thread - so perhaps the setfscreatecon() ando ther functions that
> use /proc/self/attr don't actually work in multi-threaded programs?

I have verified empircally that /proc/self/attr/fscreate reflects the process (or the process with the original PID), but /proc/self/task/%d/attr/fscreate on a separate thread does not change when the main thread calls setfscreatecon (and getfscreatecon on the thread reflects that as well).

So fscreate at least is thread-specific.
Comment 6 Eric Paris 2014-01-31 12:50:12 EST
Wow, I've ignored this a long time.  set*con are per thread.  Dan, feel free to update the man page...
Comment 7 Daniel Walsh 2014-02-14 12:19:35 EST
Fixed in libselinux-2.2.2-4.fc21

Note You need to log in before you can comment on or make changes to this bug.