1. 20 5月, 2011 2 次提交
    • L
      selinux: avoid unnecessary avc cache stat hit count · 257313b2
      Linus Torvalds 提交于
      There is no point in counting hits - we can calculate it from the number
      of lookups and misses.
      
      This makes the avc statistics a bit smaller, and makes the code
      generation better too.
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      257313b2
    • L
      selinux: de-crapify avc cache stat code generation · 044aea9b
      Linus Torvalds 提交于
      You can turn off the avc cache stats, but distributions seem to not do
      that (perhaps because several performance tuning how-to's talk about the
      avc cache statistics).
      
      Which is sad, because the code it generates is truly horrendous, with
      the statistics update being sandwitched between get_cpu/put_cpu which in
      turn causes preemption disables etc.  We're talking ten+ instructions
      just to increment a per-cpu variable in some pretty hot code.
      
      Fix the craziness by just using 'this_cpu_inc()' instead.  Suddenly we
      only need a single 'inc' instruction to increment the statistics.  This
      is quite noticeable in the incredibly hot avc_has_perm_noaudit()
      function (which triggers all the statistics by virtue of doing an
      avc_lookup() call).
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      044aea9b
  2. 13 5月, 2011 1 次提交
  3. 12 5月, 2011 1 次提交
  4. 08 5月, 2011 2 次提交
  5. 29 4月, 2011 2 次提交
    • E
      flex_array: flex_array_prealloc takes a number of elements, not an end · 5d30b10b
      Eric Paris 提交于
      Change flex_array_prealloc to take the number of elements for which space
      should be allocated instead of the last (inclusive) element. Users
      and documentation are updated accordingly.  flex_arrays got introduced before
      they had users.  When folks started using it, they ended up needing a
      different API than was coded up originally.  This swaps over to the API that
      folks apparently need.
      Based-on-patch-by: NSteffen Klassert <steffen.klassert@secunet.com>
      Signed-off-by: NEric Paris <eparis@redhat.com>
      Tested-by: NChris Richards <gizmo@giz-works.com>
      Acked-by: NDave Hansen <dave@linux.vnet.ibm.com>
      Cc: stable@kernel.org [2.6.38+]
      5d30b10b
    • E
      SELinux: pass last path component in may_create · cb1e922f
      Eric Paris 提交于
      New inodes are created in a two stage process.  We first will compute the
      label on a new inode in security_inode_create() and check if the
      operation is allowed.  We will then actually re-compute that same label and
      apply it in security_inode_init_security().  The change to do new label
      calculations based in part on the last component of the path name only
      passed the path component information all the way down the
      security_inode_init_security hook.  Down the security_inode_create hook the
      path information did not make it past may_create.  Thus the two calculations
      came up differently and the permissions check might not actually be against
      the label that is created.  Pass and use the same information in both places
      to harmonize the calculations and checks.
      Reported-by: NDominick Grift <domg472@gmail.com>
      Signed-off-by: NEric Paris <eparis@redhat.com>
      cb1e922f
  6. 26 4月, 2011 1 次提交
    • E
      SELINUX: Make selinux cache VFS RCU walks safe · 9ade0cf4
      Eric Paris 提交于
      Now that the security modules can decide whether they support the
      dcache RCU walk or not it's possible to make selinux a bit more
      RCU friendly.  The SELinux AVC and security server access decision
      code is RCU safe.  A specific piece of the LSM audit code may not
      be RCU safe.
      
      This patch makes the VFS RCU walk retry if it would hit the non RCU
      safe chunk of code.  It will normally just work under RCU.  This is
      done simply by passing the VFS RCU state as a flag down into the
      avc_audit() code and returning ECHILD there if it would have an issue.
      Based-on-patch-by: NAndi Kleen <ak@linux.intel.com>
      Signed-off-by: NEric Paris <eparis@redhat.com>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      9ade0cf4
  7. 23 4月, 2011 1 次提交
  8. 20 4月, 2011 1 次提交
  9. 19 4月, 2011 3 次提交
  10. 10 4月, 2011 1 次提交
  11. 04 4月, 2011 1 次提交
  12. 31 3月, 2011 2 次提交
  13. 29 3月, 2011 1 次提交
  14. 24 3月, 2011 3 次提交
    • S
      userns: rename is_owner_or_cap to inode_owner_or_capable · 2e149670
      Serge E. Hallyn 提交于
      And give it a kernel-doc comment.
      
      [akpm@linux-foundation.org: btrfs changed in linux-next]
      Signed-off-by: NSerge E. Hallyn <serge.hallyn@canonical.com>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Cc: Daniel Lezcano <daniel.lezcano@free.fr>
      Acked-by: NDavid Howells <dhowells@redhat.com>
      Cc: James Morris <jmorris@namei.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      2e149670
    • S
      userns: allow ptrace from non-init user namespaces · 8409cca7
      Serge E. Hallyn 提交于
      ptrace is allowed to tasks in the same user namespace according to the
      usual rules (i.e.  the same rules as for two tasks in the init user
      namespace).  ptrace is also allowed to a user namespace to which the
      current task the has CAP_SYS_PTRACE capability.
      
      Changelog:
      	Dec 31: Address feedback by Eric:
      		. Correct ptrace uid check
      		. Rename may_ptrace_ns to ptrace_capable
      		. Also fix the cap_ptrace checks.
      	Jan  1: Use const cred struct
      	Jan 11: use task_ns_capable() in place of ptrace_capable().
      	Feb 23: same_or_ancestore_user_ns() was not an appropriate
      		check to constrain cap_issubset.  Rather, cap_issubset()
      		only is meaningful when both capsets are in the same
      		user_ns.
      Signed-off-by: NSerge E. Hallyn <serge.hallyn@canonical.com>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Acked-by: NDaniel Lezcano <daniel.lezcano@free.fr>
      Acked-by: NDavid Howells <dhowells@redhat.com>
      Cc: James Morris <jmorris@namei.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      8409cca7
    • S
      userns: security: make capabilities relative to the user namespace · 3486740a
      Serge E. Hallyn 提交于
      - Introduce ns_capable to test for a capability in a non-default
        user namespace.
      - Teach cap_capable to handle capabilities in a non-default
        user namespace.
      
      The motivation is to get to the unprivileged creation of new
      namespaces.  It looks like this gets us 90% of the way there, with
      only potential uid confusion issues left.
      
      I still need to handle getting all caps after creation but otherwise I
      think I have a good starter patch that achieves all of your goals.
      
      Changelog:
      	11/05/2010: [serge] add apparmor
      	12/14/2010: [serge] fix capabilities to created user namespaces
      	Without this, if user serge creates a user_ns, he won't have
      	capabilities to the user_ns he created.  THis is because we
      	were first checking whether his effective caps had the caps
      	he needed and returning -EPERM if not, and THEN checking whether
      	he was the creator.  Reverse those checks.
      	12/16/2010: [serge] security_real_capable needs ns argument in !security case
      	01/11/2011: [serge] add task_ns_capable helper
      	01/11/2011: [serge] add nsown_capable() helper per Bastian Blank suggestion
      	02/16/2011: [serge] fix a logic bug: the root user is always creator of
      		    init_user_ns, but should not always have capabilities to
      		    it!  Fix the check in cap_capable().
      	02/21/2011: Add the required user_ns parameter to security_capable,
      		    fixing a compile failure.
      	02/23/2011: Convert some macros to functions as per akpm comments.  Some
      		    couldn't be converted because we can't easily forward-declare
      		    them (they are inline if !SECURITY, extern if SECURITY).  Add
      		    a current_user_ns function so we can use it in capability.h
      		    without #including cred.h.  Move all forward declarations
      		    together to the top of the #ifdef __KERNEL__ section, and use
      		    kernel-doc format.
      	02/23/2011: Per dhowells, clean up comment in cap_capable().
      	02/23/2011: Per akpm, remove unreachable 'return -EPERM' in cap_capable.
      
      (Original written and signed off by Eric;  latest, modified version
      acked by him)
      
      [akpm@linux-foundation.org: fix build]
      [akpm@linux-foundation.org: export current_user_ns() for ecryptfs]
      [serge.hallyn@canonical.com: remove unneeded extra argument in selinux's task_has_capability]
      Signed-off-by: NEric W. Biederman <ebiederm@xmission.com>
      Signed-off-by: NSerge E. Hallyn <serge.hallyn@canonical.com>
      Acked-by: N"Eric W. Biederman" <ebiederm@xmission.com>
      Acked-by: NDaniel Lezcano <daniel.lezcano@free.fr>
      Acked-by: NDavid Howells <dhowells@redhat.com>
      Cc: James Morris <jmorris@namei.org>
      Signed-off-by: NSerge E. Hallyn <serge.hallyn@canonical.com>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      3486740a
  15. 22 3月, 2011 1 次提交
  16. 17 3月, 2011 2 次提交
    • D
      KEYS: Make request_key() and co. return an error for a negative key · 4aab1e89
      David Howells 提交于
      Make request_key() and co. return an error for a negative or rejected key.  If
      the key was simply negated, then return ENOKEY, otherwise return the error
      with which it was rejected.
      
      Without this patch, the following command returns a key number (with the latest
      keyutils):
      
      	[root@andromeda ~]# keyctl request2 user debug:foo rejected @s
      	586569904
      
      Trying to print the key merely gets you a permission denied error:
      
      	[root@andromeda ~]# keyctl print 586569904
      	keyctl_read_alloc: Permission denied
      
      Doing another request_key() call does get you the error, as long as it hasn't
      expired yet:
      
      	[root@andromeda ~]# keyctl request user debug:foo
      	request_key: Key was rejected by service
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Signed-off-by: NJames Morris <jmorris@namei.org>
      4aab1e89
    • D
      KEYS: Improve /proc/keys · 78b7280c
      David Howells 提交于
      Improve /proc/keys by:
      
       (1) Don't attempt to summarise the payload of a negated key.  It won't have
           one.  To this end, a helper function - key_is_instantiated() has been
           added that allows the caller to find out whether the key is positively
           instantiated (as opposed to being uninstantiated or negatively
           instantiated).
      
       (2) Do show keys that are negative, expired or revoked rather than hiding
           them.  This requires an override flag (no_state_check) to be passed to
           search_my_process_keyrings() and keyring_search_aux() to suppress this
           check.
      
           Without this, keys that are possessed by the caller, but only grant
           permissions to the caller if possessed are skipped as the possession check
           fails.
      
           Keys that are visible due to user, group or other checks are visible with
           or without this patch.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Signed-off-by: NJames Morris <jmorris@namei.org>
      78b7280c
  17. 13 3月, 2011 1 次提交
  18. 09 3月, 2011 2 次提交
  19. 08 3月, 2011 4 次提交
  20. 05 3月, 2011 1 次提交
  21. 04 3月, 2011 7 次提交