1. 10 10月, 2008 7 次提交
    • P
      netlabel: Replace protocol/NetLabel linking with refrerence counts · b1edeb10
      Paul Moore 提交于
      NetLabel has always had a list of backpointers in the CIPSO DOI definition
      structure which pointed to the NetLabel LSM domain mapping structures which
      referenced the CIPSO DOI struct.  The rationale for this was that when an
      administrator removed a CIPSO DOI from the system all of the associated
      NetLabel LSM domain mappings should be removed as well; a list of
      backpointers made this a simple operation.
      
      Unfortunately, while the backpointers did make the removal easier they were
      a bit of a mess from an implementation point of view which was making
      further development difficult.  Since the removal of a CIPSO DOI is a
      realtively rare event it seems to make sense to remove this backpointer
      list as the optimization was hurting us more then it was helping.  However,
      we still need to be able to track when a CIPSO DOI definition is being used
      so replace the backpointer list with a reference count.  In order to
      preserve the current functionality of removing the associated LSM domain
      mappings when a CIPSO DOI is removed we walk the LSM domain mapping table,
      removing the relevant entries.
      Signed-off-by: NPaul Moore <paul.moore@hp.com>
      Reviewed-by: NJames Morris <jmorris@namei.org>
      b1edeb10
    • P
      smack: Fix missing calls to netlbl_skbuff_err() · a8134296
      Paul Moore 提交于
      Smack needs to call netlbl_skbuff_err() to let NetLabel do the necessary
      protocol specific error handling.
      Signed-off-by: NPaul Moore <paul.moore@hp.com>
      Acked-by: NCasey Schaufler <casey@schaufler-ca.com>
      a8134296
    • P
      selinux: Fix missing calls to netlbl_skbuff_err() · dfaebe98
      Paul Moore 提交于
      At some point I think I messed up and dropped the calls to netlbl_skbuff_err()
      which are necessary for CIPSO to send error notifications to remote systems.
      This patch re-introduces the error handling calls into the SELinux code.
      Signed-off-by: NPaul Moore <paul.moore@hp.com>
      Acked-by: NJames Morris <jmorris@namei.org>
      dfaebe98
    • P
      selinux: Fix a problem in security_netlbl_sid_to_secattr() · 99d854d2
      Paul Moore 提交于
      Currently when SELinux fails to allocate memory in
      security_netlbl_sid_to_secattr() the NetLabel LSM domain field is set to
      NULL which triggers the default NetLabel LSM domain mapping which may not
      always be the desired mapping.  This patch fixes this by returning an error
      when the kernel is unable to allocate memory.  This could result in more
      failures on a system with heavy memory pressure but it is the "correct"
      thing to do.
      Signed-off-by: NPaul Moore <paul.moore@hp.com>
      Acked-by: NJames Morris <jmorris@namei.org>
      99d854d2
    • P
      selinux: Better local/forward check in selinux_ip_postroute() · d8395c87
      Paul Moore 提交于
      It turns out that checking to see if skb->sk is NULL is not a very good
      indicator of a forwarded packet as some locally generated packets also have
      skb->sk set to NULL.  Fix this by not only checking the skb->sk field but also
      the IP[6]CB(skb)->flags field for the IP[6]SKB_FORWARDED flag.  While we are
      at it, we are calling selinux_parse_skb() much earlier than we really should
      resulting in potentially wasted cycles parsing packets for information we
      might no use; so shuffle the code around a bit to fix this.
      Signed-off-by: NPaul Moore <paul.moore@hp.com>
      Acked-by: NJames Morris <jmorris@namei.org>
      d8395c87
    • P
      selinux: Correctly handle IPv4 packets on IPv6 sockets in all cases · aa862900
      Paul Moore 提交于
      We did the right thing in a few cases but there were several areas where we
      determined a packet's address family based on the socket's address family which
      is not the right thing to do since we can get IPv4 packets on IPv6 sockets.
      This patch fixes these problems by either taking the address family directly
      from the packet.
      Signed-off-by: NPaul Moore <paul.moore@hp.com>
      Acked-by: NJames Morris <jmorris@namei.org>
      aa862900
    • P
      selinux: Cleanup the NetLabel glue code · accc6093
      Paul Moore 提交于
      We were doing a lot of extra work in selinux_netlbl_sock_graft() what wasn't
      necessary so this patch removes that code.  It also removes the redundant
      second argument to selinux_netlbl_sock_setsid() which allows us to simplify a
      few other functions.
      Signed-off-by: NPaul Moore <paul.moore@hp.com>
      Acked-by: NJames Morris <jmorris@namei.org>
      accc6093
  2. 04 10月, 2008 1 次提交
    • P
      selinux: Fix an uninitialized variable BUG/panic in selinux_secattr_to_sid() · 3040a6d5
      Paul Moore 提交于
      At some point during the 2.6.27 development cycle two new fields were added
      to the SELinux context structure, a string pointer and a length field.  The
      code in selinux_secattr_to_sid() was not modified and as a result these two
      fields were left uninitialized which could result in erratic behavior,
      including kernel panics, when NetLabel is used.  This patch fixes the
      problem by fully initializing the context in selinux_secattr_to_sid() before
      use and reducing the level of direct context manipulation done to help
      prevent future problems.
      
      Please apply this to the 2.6.27-rcX release stream.
      Signed-off-by: NPaul Moore <paul.moore@hp.com>
      Signed-off-by: NJames Morris <jmorris@namei.org>
      3040a6d5
  3. 04 9月, 2008 1 次提交
  4. 03 9月, 2008 1 次提交
  5. 14 8月, 2008 1 次提交
    • D
      security: Fix setting of PF_SUPERPRIV by __capable() · 5cd9c58f
      David Howells 提交于
      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->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: NDavid Howells <dhowells@redhat.com>
      Acked-by: NSerge Hallyn <serue@us.ibm.com>
      Acked-by: NCasey Schaufler <casey@schaufler-ca.com>
      Acked-by: NAndrew G. Morgan <morgan@kernel.org>
      Acked-by: NAl Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: NJames Morris <jmorris@namei.org>
      5cd9c58f
  6. 30 7月, 2008 1 次提交
    • E
      SELinux: /proc/mounts should show what it can · 383795c2
      Eric Paris 提交于
      Given a hosed SELinux config in which a system never loads policy or
      disables SELinux we currently just return -EINVAL for anyone trying to
      read /proc/mounts.  This is a configuration problem but we can certainly
      be more graceful.  This patch just ignores -EINVAL when displaying LSM
      options and causes /proc/mounts display everything else it can.  If
      policy isn't loaded the obviously there are no options, so we aren't
      really loosing any information here.
      
      This is safe as the only other return of EINVAL comes from
      security_sid_to_context_core() in the case of an invalid sid.  Even if a
      FS was mounted with a now invalidated context that sid should have been
      remapped to unlabeled and so we won't hit the EINVAL and will work like
      we should.  (yes, I tested to make sure it worked like I thought)
      Signed-off-by: NEric Paris <eparis@redhat.com>
      Tested-by: NMarc Dionne <marc.c.dionne@gmail.com>
      Signed-off-by: NJames Morris <jmorris@namei.org>
      383795c2
  7. 27 7月, 2008 4 次提交
  8. 26 7月, 2008 3 次提交
  9. 25 7月, 2008 2 次提交
  10. 15 7月, 2008 1 次提交
  11. 14 7月, 2008 18 次提交