Red Hat Bugzilla – Bug 885730
libselinux-devel: [gs]et*con manual pages should document threading behavior
Last modified: 2014-02-14 12:19:35 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):
Eric, do you want to take a stab at this?
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.
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.
Still present in libselinux-devel-2.1.13-15.fc19.x86_64.
(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.
Wow, I've ignored this a long time. set*con are per thread. Dan, feel free to update the man page...
Fixed in libselinux-2.2.2-4.fc21