| 1 |
-*- text -*- |
| 2 |
|
| 3 |
* NOTE: This information predates all of the elfcap stuff in the |
| 4 |
kernel. I have no idea how things will work in combination with it. If |
| 5 |
you do, drop me a note :) |
| 6 |
|
| 7 |
These are capability inheriting rules (ie, what happens across an |
| 8 |
exec). |
| 9 |
|
| 10 |
pI' = pI |
| 11 |
pP' = fP | (fI & pI) |
| 12 |
pE' = pP' & fE |
| 13 |
|
| 14 |
Currently (as of 2.2.3) |
| 15 |
On exec, fI and fE is always 0 to a non-root process, and ~0 to a |
| 16 |
non-root process. |
| 17 |
On setuid away from root, pP and pE are cleared. |
| 18 |
|
| 19 |
The upshot of this is that once you setuid to anything other than |
| 20 |
root, you lose all of your capabilities (pE == 0), can't regain them |
| 21 |
by asking (pP == 0), and can't regain them by exec (fE = 0). |
| 22 |
|
| 23 |
OTOH, if you *are* root, then you can remove capabilities from |
| 24 |
yourself. This is nice, but there doesn't appear to be any way to |
| 25 |
remove things like basic RW access to root owned files. |
| 26 |
|
| 27 |
I've written a patch to play with this a bit (available from |
| 28 |
http://www.eris.rcpt.to/rlinetd). Its effects: |
| 29 |
|
| 30 |
On exec, fI and fE are unconditionally ~0. |
| 31 |
On setuid away from root, pI and pE are cleared. |
| 32 |
|
| 33 |
The upshot - an application may raise capabilities up to it's |
| 34 |
permitted set after a suid. If it does not do so (ie, capability |
| 35 |
unaware), it will permanently lose all capabilities after an exec (pP |
| 36 |
== 0). Playing with capabilities on root processes does not |
| 37 |
necessarily do what you expect. |
| 38 |
|
| 39 |
Security note - this provides a danger window. A capability unaware |
| 40 |
application will assume that a setuid permanently discards all |
| 41 |
privileges. In reality, this is not the case until it performs a |
| 42 |
subsequent exec. |
| 43 |
|
| 44 |
Another note - if a process is not uid 0 but has cap_setuid raised, |
| 45 |
then performing a setuid will NOT clear the inheritable and effective |
| 46 |
sets. The theory is that if a non-root process has any capabilities, |
| 47 |
it should bloody well know what to do with them. |
| 48 |
|
| 49 |
=eip will not work, due to CAP_SETPCAP being disallowed. this is not |
| 50 |
necessarily a bad thing :) |
| 51 |
|