<feed xmlns='http://www.w3.org/2005/Atom'>
<title>linux/security/commoncap.c, branch v2.6.28</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/
</subtitle>
<id>https://git.shady.money/linux/atom?h=v2.6.28</id>
<link rel='self' href='https://git.shady.money/linux/atom?h=v2.6.28'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/'/>
<updated>2008-11-01T16:49:45Z</updated>
<entry>
<title>file caps: always start with clear bprm-&gt;caps_*</title>
<updated>2008-11-01T16:49:45Z</updated>
<author>
<name>Serge Hallyn</name>
<email>serue@us.ibm.com</email>
</author>
<published>2008-10-30T16:52:23Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=3318a386e4ca68c76e0294363d29bdc46fcad670'/>
<id>urn:sha1:3318a386e4ca68c76e0294363d29bdc46fcad670</id>
<content type='text'>
While Linux doesn't honor setuid on scripts.  However, it mistakenly
behaves differently for file capabilities.

This patch fixes that behavior by making sure that get_file_caps()
begins with empty bprm-&gt;caps_*.  That way when a script is loaded,
its bprm-&gt;caps_* may be filled when binfmt_misc calls prepare_binprm(),
but they will be cleared again when binfmt_elf calls prepare_binprm()
next to read the interpreter's file capabilities.

Signed-off-by: Serge Hallyn &lt;serue@us.ibm.com&gt;
Acked-by: David Howells &lt;dhowells@redhat.com&gt;
Acked-by: Andrew G. Morgan &lt;morgan@kernel.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>file capabilities: uninline cap_safe_nice</title>
<updated>2008-09-27T05:07:56Z</updated>
<author>
<name>Serge E. Hallyn</name>
<email>serue@us.ibm.com</email>
</author>
<published>2008-09-27T02:27:47Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=de45e806a84909648623119dfe6fc1d31e71ceba'/>
<id>urn:sha1:de45e806a84909648623119dfe6fc1d31e71ceba</id>
<content type='text'>
This reduces the kernel size by 289 bytes.

Signed-off-by: Serge E. Hallyn &lt;serue@us.ibm.com&gt;
Acked-by: Andrew G. Morgan &lt;morgan@kernel.org&gt;
Signed-off-by: James Morris &lt;jmorris@namei.org&gt;
</content>
</entry>
<entry>
<title>security: Fix setting of PF_SUPERPRIV by __capable()</title>
<updated>2008-08-14T12:59:43Z</updated>
<author>
<name>David Howells</name>
<email>dhowells@redhat.com</email>
</author>
<published>2008-08-14T10:37:28Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=5cd9c58fbe9ec92b45b27e131719af4f2bd9eb40'/>
<id>urn:sha1:5cd9c58fbe9ec92b45b27e131719af4f2bd9eb40</id>
<content type='text'>
Fix the setting of PF_SUPERPRIV by __capable() as it could corrupt the flags
the target process if that is not the current process and it is trying to
change its own flags in a different way at the same time.

__capable() is using neither atomic ops nor locking to protect t-&gt;flags.  This
patch removes __capable() and introduces has_capability() that doesn't set
PF_SUPERPRIV on the process being queried.

This patch further splits security_ptrace() in two:

 (1) security_ptrace_may_access().  This passes judgement on whether one
     process may access another only (PTRACE_MODE_ATTACH for ptrace() and
     PTRACE_MODE_READ for /proc), and takes a pointer to the child process.
     current is the parent.

 (2) security_ptrace_traceme().  This passes judgement on PTRACE_TRACEME only,
     and takes only a pointer to the parent process.  current is the child.

     In Smack and commoncap, this uses has_capability() to determine whether
     the parent will be permitted to use PTRACE_ATTACH if normal checks fail.
     This does not set PF_SUPERPRIV.

Two of the instances of __capable() actually only act on current, and so have
been changed to calls to capable().

Of the places that were using __capable():

 (1) The OOM killer calls __capable() thrice when weighing the killability of a
     process.  All of these now use has_capability().

 (2) cap_ptrace() and smack_ptrace() were using __capable() to check to see
     whether the parent was allowed to trace any process.  As mentioned above,
     these have been split.  For PTRACE_ATTACH and /proc, capable() is now
     used, and for PTRACE_TRACEME, has_capability() is used.

 (3) cap_safe_nice() only ever saw current, so now uses capable().

 (4) smack_setprocattr() rejected accesses to tasks other than current just
     after calling __capable(), so the order of these two tests have been
     switched and capable() is used instead.

 (5) In smack_file_send_sigiotask(), we need to allow privileged processes to
     receive SIGIO on files they're manipulating.

 (6) In smack_task_wait(), we let a process wait for a privileged process,
     whether or not the process doing the waiting is privileged.

I've tested this with the LTP SELinux and syscalls testscripts.

Signed-off-by: David Howells &lt;dhowells@redhat.com&gt;
Acked-by: Serge Hallyn &lt;serue@us.ibm.com&gt;
Acked-by: Casey Schaufler &lt;casey@schaufler-ca.com&gt;
Acked-by: Andrew G. Morgan &lt;morgan@kernel.org&gt;
Acked-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
Signed-off-by: James Morris &lt;jmorris@namei.org&gt;
</content>
</entry>
<entry>
<title>security: protect legacy applications from executing with insufficient privilege</title>
<updated>2008-07-24T17:47:22Z</updated>
<author>
<name>Andrew G. Morgan</name>
<email>morgan@kernel.org</email>
</author>
<published>2008-07-24T04:28:24Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=5459c164f0591ee75ed0203bb8f3817f25948e2f'/>
<id>urn:sha1:5459c164f0591ee75ed0203bb8f3817f25948e2f</id>
<content type='text'>
When cap_bset suppresses some of the forced (fP) capabilities of a file,
it is generally only safe to execute the program if it understands how to
recognize it doesn't have enough privilege to work correctly.  For legacy
applications (fE!=0), which have no non-destructive way to determine that
they are missing privilege, we fail to execute (EPERM) any executable that
requires fP capabilities, but would otherwise get pP' &lt; fP.  This is a
fail-safe permission check.

For some discussion of why it is problematic for (legacy) privileged
applications to run with less than the set of capabilities requested for
them, see:

 http://userweb.kernel.org/~morgan/sendmail-capabilities-war-story.html

With this iteration of this support, we do not include setuid-0 based
privilege protection from the bounding set.  That is, the admin can still
(ab)use the bounding set to suppress the privileges of a setuid-0 program.

[akpm@linux-foundation.org: coding-style fixes]
[akpm@linux-foundation.org: cleanup]
Signed-off-by: Andrew G. Morgan &lt;morgan@kernel.org&gt;
Acked-by: Serge Hallyn &lt;serue@us.ibm.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>Security: split proc ptrace checking into read vs. attach</title>
<updated>2008-07-14T05:01:47Z</updated>
<author>
<name>Stephen Smalley</name>
<email>sds@tycho.nsa.gov</email>
</author>
<published>2008-05-19T12:32:49Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=006ebb40d3d65338bd74abb03b945f8d60e362bd'/>
<id>urn:sha1:006ebb40d3d65338bd74abb03b945f8d60e362bd</id>
<content type='text'>
Enable security modules to distinguish reading of process state via
proc from full ptrace access by renaming ptrace_may_attach to
ptrace_may_access and adding a mode argument indicating whether only
read access or full attach access is requested.  This allows security
modules to permit access to reading process state without granting
full ptrace access.  The base DAC/capability checking remains unchanged.

Read access to /proc/pid/mem continues to apply a full ptrace attach
check since check_mem_permission() already requires the current task
to already be ptracing the target.  The other ptrace checks within
proc for elements like environ, maps, and fds are changed to pass the
read mode instead of attach.

In the SELinux case, we model such reading of process state as a
reading of a proc file labeled with the target process' label.  This
enables SELinux policy to permit such reading of process state without
permitting control or manipulation of the target process, as there are
a number of cases where programs probe for such information via proc
but do not need to be able to control the target (e.g. procps,
lsof, PolicyKit, ConsoleKit).  At present we have to choose between
allowing full ptrace in policy (more permissive than required/desired)
or breaking functionality (or in some cases just silencing the denials
via dontaudit rules but this can hide genuine attacks).

This version of the patch incorporates comments from Casey Schaufler
(change/replace existing ptrace_may_attach interface, pass access
mode), and Chris Wright (provide greater consistency in the checking).

Note that like their predecessors __ptrace_may_attach and
ptrace_may_attach, the __ptrace_may_access and ptrace_may_access
interfaces use different return value conventions from each other (0
or -errno vs. 1 or 0).  I retained this difference to avoid any
changes to the caller logic but made the difference clearer by
changing the latter interface to return a bool rather than an int and
by adding a comment about it to ptrace.h for any future callers.

Signed-off-by:  Stephen Smalley &lt;sds@tycho.nsa.gov&gt;
Acked-by: Chris Wright &lt;chrisw@sous-sol.org&gt;
Signed-off-by: James Morris &lt;jmorris@namei.org&gt;
</content>
</entry>
<entry>
<title>security: filesystem capabilities: fix CAP_SETPCAP handling</title>
<updated>2008-07-04T17:40:08Z</updated>
<author>
<name>Andrew G. Morgan</name>
<email>morgan@kernel.org</email>
</author>
<published>2008-07-04T16:59:59Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=1209726ce942047c9fefe7cd427dc36f8e9ded53'/>
<id>urn:sha1:1209726ce942047c9fefe7cd427dc36f8e9ded53</id>
<content type='text'>
The filesystem capability support meaning for CAP_SETPCAP is less powerful
than the non-filesystem capability support.  As such, when filesystem
capabilities are configured, we should not permit CAP_SETPCAP to 'enhance'
the current process through strace manipulation of a child process.

Signed-off-by: Andrew G. Morgan &lt;morgan@kernel.org&gt;
Acked-by: Serge Hallyn &lt;serue@us.ibm.com&gt;
Cc: David Howells &lt;dhowells@redhat.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>xattr: add missing consts to function arguments</title>
<updated>2008-04-29T15:06:06Z</updated>
<author>
<name>David Howells</name>
<email>dhowells@redhat.com</email>
</author>
<published>2008-04-29T07:59:41Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=8f0cfa52a1d4ffacd8e7de906d19662f5da58d58'/>
<id>urn:sha1:8f0cfa52a1d4ffacd8e7de906d19662f5da58d58</id>
<content type='text'>
Add missing consts to xattr function arguments.

Signed-off-by: David Howells &lt;dhowells@redhat.com&gt;
Cc: Andreas Gruenbacher &lt;agruen@suse.de&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>capabilities: implement per-process securebits</title>
<updated>2008-04-28T15:58:26Z</updated>
<author>
<name>Andrew G. Morgan</name>
<email>morgan@kernel.org</email>
</author>
<published>2008-04-28T09:13:40Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=3898b1b4ebff8dcfbcf1807e0661585e06c9a91c'/>
<id>urn:sha1:3898b1b4ebff8dcfbcf1807e0661585e06c9a91c</id>
<content type='text'>
Filesystem capability support makes it possible to do away with (set)uid-0
based privilege and use capabilities instead.  That is, with filesystem
support for capabilities but without this present patch, it is (conceptually)
possible to manage a system with capabilities alone and never need to obtain
privilege via (set)uid-0.

Of course, conceptually isn't quite the same as currently possible since few
user applications, certainly not enough to run a viable system, are currently
prepared to leverage capabilities to exercise privilege.  Further, many
applications exist that may never get upgraded in this way, and the kernel
will continue to want to support their setuid-0 base privilege needs.

Where pure-capability applications evolve and replace setuid-0 binaries, it is
desirable that there be a mechanisms by which they can contain their
privilege.  In addition to leveraging the per-process bounding and inheritable
sets, this should include suppressing the privilege of the uid-0 superuser
from the process' tree of children.

The feature added by this patch can be leveraged to suppress the privilege
associated with (set)uid-0.  This suppression requires CAP_SETPCAP to
initiate, and only immediately affects the 'current' process (it is inherited
through fork()/exec()).  This reimplementation differs significantly from the
historical support for securebits which was system-wide, unwieldy and which
has ultimately withered to a dead relic in the source of the modern kernel.

With this patch applied a process, that is capable(CAP_SETPCAP), can now drop
all legacy privilege (through uid=0) for itself and all subsequently
fork()'d/exec()'d children with:

  prctl(PR_SET_SECUREBITS, 0x2f);

This patch represents a no-op unless CONFIG_SECURITY_FILE_CAPABILITIES is
enabled at configure time.

[akpm@linux-foundation.org: fix uninitialised var warning]
[serue@us.ibm.com: capabilities: use cap_task_prctl when !CONFIG_SECURITY]
Signed-off-by: Andrew G. Morgan &lt;morgan@kernel.org&gt;
Acked-by: Serge Hallyn &lt;serue@us.ibm.com&gt;
Reviewed-by: James Morris &lt;jmorris@namei.org&gt;
Cc: Stephen Smalley &lt;sds@tycho.nsa.gov&gt;
Cc: Paul Moore &lt;paul.moore@hp.com&gt;
Signed-off-by: Serge E. Hallyn &lt;serue@us.ibm.com&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
<entry>
<title>security: replace remaining __FUNCTION__ occurrences</title>
<updated>2008-04-18T10:26:07Z</updated>
<author>
<name>Harvey Harrison</name>
<email>harvey.harrison@gmail.com</email>
</author>
<published>2008-03-05T23:03:59Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=dd6f953adb5c4deb9cd7b6a5054e7d5eafe4ed71'/>
<id>urn:sha1:dd6f953adb5c4deb9cd7b6a5054e7d5eafe4ed71</id>
<content type='text'>
__FUNCTION__ is gcc-specific, use __func__

Signed-off-by: Harvey Harrison &lt;harvey.harrison@gmail.com&gt;
Cc: James Morris &lt;jmorris@namei.org&gt;
Cc: Stephen Smalley &lt;sds@tycho.nsa.gov&gt;
Signed-off-by: Andrew Morton &lt;akpm@linux-foundation.org&gt;
Signed-off-by: James Morris &lt;jmorris@namei.org&gt;
</content>
</entry>
<entry>
<title>file capabilities: remove cap_task_kill()</title>
<updated>2008-03-20T16:46:36Z</updated>
<author>
<name>Serge Hallyn</name>
<email>serge@hallyn.com</email>
</author>
<published>2008-02-29T15:14:57Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/linux/commit/?id=aedb60a67c10a0861af179725d060765262ba0fb'/>
<id>urn:sha1:aedb60a67c10a0861af179725d060765262ba0fb</id>
<content type='text'>
The original justification for cap_task_kill() was as follows:

	check_kill_permission() does appropriate uid equivalence checks.
	However with file capabilities it becomes possible for an
	unprivileged user to execute a file with file capabilities
	resulting in a more privileged task with the same uid.

However now that cap_task_kill() always returns 0 (permission
granted) when p-&gt;uid==current-&gt;uid, the whole hook is worthless,
and only likely to create more subtle problems in the corner cases
where it might still be called but return -EPERM.  Those cases
are basically when uids are different but euid/suid is equivalent
as per the check in check_kill_permission().

One example of a still-broken application is 'at' for non-root users.

This patch removes cap_task_kill().

Signed-off-by: Serge Hallyn &lt;serge@hallyn.com&gt;
Acked-by: Andrew G. Morgan &lt;morgan@kernel.org&gt;
Earlier-version-tested-by: Luiz Fernando N. Capitulino &lt;lcapitulino@mandriva.com.br&gt;
Acked-by: Casey Schaufler &lt;casey@schaufler-ca.com&gt;
Signed-off-by: Linus Torvalds &lt;torvalds@linux-foundation.org&gt;
</content>
</entry>
</feed>
