1. 04 1月, 2012 5 次提交
  2. 21 12月, 2011 1 次提交
    • D
      SELinux: Fix RCU deref check warning in sel_netport_insert() · 50345f1e
      David Howells 提交于
      Fix the following bug in sel_netport_insert() where rcu_dereference() should
      be rcu_dereference_protected() as sel_netport_lock is held.
      
      ===================================================
      [ INFO: suspicious rcu_dereference_check() usage. ]
      ---------------------------------------------------
      security/selinux/netport.c:127 invoked rcu_dereference_check() without protection!
      
      other info that might help us debug this:
      
      rcu_scheduler_active = 1, debug_locks = 0
      1 lock held by ossec-rootcheck/3323:
       #0:  (sel_netport_lock){+.....}, at: [<ffffffff8117d775>] sel_netport_sid+0xbb/0x226
      
      stack backtrace:
      Pid: 3323, comm: ossec-rootcheck Not tainted 3.1.0-rc8-fsdevel+ #1095
      Call Trace:
       [<ffffffff8105cfb7>] lockdep_rcu_dereference+0xa7/0xb0
       [<ffffffff8117d871>] sel_netport_sid+0x1b7/0x226
       [<ffffffff8117d6ba>] ? sel_netport_avc_callback+0xbc/0xbc
       [<ffffffff8117556c>] selinux_socket_bind+0x115/0x230
       [<ffffffff810a5388>] ? might_fault+0x4e/0x9e
       [<ffffffff810a53d1>] ? might_fault+0x97/0x9e
       [<ffffffff81171cf4>] security_socket_bind+0x11/0x13
       [<ffffffff812ba967>] sys_bind+0x56/0x95
       [<ffffffff81380dac>] ? sysret_check+0x27/0x62
       [<ffffffff8105b767>] ? trace_hardirqs_on_caller+0x11e/0x155
       [<ffffffff81076fcd>] ? audit_syscall_entry+0x17b/0x1ae
       [<ffffffff811b5eae>] ? trace_hardirqs_on_thunk+0x3a/0x3f
       [<ffffffff81380d7b>] system_call_fastpath+0x16/0x1b
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Acked-by: NPaul Moore <paul@paul-moore.com>
      Acked-by: NEric Dumazet <eric.dumazet@gmail.com>
      Cc: stable@kernel.org
      Signed-off-by: NJames Morris <jmorris@namei.org>
      50345f1e
  3. 20 12月, 2011 2 次提交
  4. 09 12月, 2011 1 次提交
  5. 07 12月, 2011 1 次提交
    • A
      fix apparmor dereferencing potentially freed dentry, sanitize __d_path() API · 02125a82
      Al Viro 提交于
      __d_path() API is asking for trouble and in case of apparmor d_namespace_path()
      getting just that.  The root cause is that when __d_path() misses the root
      it had been told to look for, it stores the location of the most remote ancestor
      in *root.  Without grabbing references.  Sure, at the moment of call it had
      been pinned down by what we have in *path.  And if we raced with umount -l, we
      could have very well stopped at vfsmount/dentry that got freed as soon as
      prepend_path() dropped vfsmount_lock.
      
      It is safe to compare these pointers with pre-existing (and known to be still
      alive) vfsmount and dentry, as long as all we are asking is "is it the same
      address?".  Dereferencing is not safe and apparmor ended up stepping into
      that.  d_namespace_path() really wants to examine the place where we stopped,
      even if it's not connected to our namespace.  As the result, it looked
      at ->d_sb->s_magic of a dentry that might've been already freed by that point.
      All other callers had been careful enough to avoid that, but it's really
      a bad interface - it invites that kind of trouble.
      
      The fix is fairly straightforward, even though it's bigger than I'd like:
      	* prepend_path() root argument becomes const.
      	* __d_path() is never called with NULL/NULL root.  It was a kludge
      to start with.  Instead, we have an explicit function - d_absolute_root().
      Same as __d_path(), except that it doesn't get root passed and stops where
      it stops.  apparmor and tomoyo are using it.
      	* __d_path() returns NULL on path outside of root.  The main
      caller is show_mountinfo() and that's precisely what we pass root for - to
      skip those outside chroot jail.  Those who don't want that can (and do)
      use d_path().
      	* __d_path() root argument becomes const.  Everyone agrees, I hope.
      	* apparmor does *NOT* try to use __d_path() or any of its variants
      when it sees that path->mnt is an internal vfsmount.  In that case it's
      definitely not mounted anywhere and dentry_path() is exactly what we want
      there.  Handling of sysctl()-triggered weirdness is moved to that place.
      	* if apparmor is asked to do pathname relative to chroot jail
      and __d_path() tells it we it's not in that jail, the sucker just calls
      d_absolute_path() instead.  That's the other remaining caller of __d_path(),
      BTW.
              * seq_path_root() does _NOT_ return -ENAMETOOLONG (it's stupid anyway -
      the normal seq_file logics will take care of growing the buffer and redoing
      the call of ->show() just fine).  However, if it gets path not reachable
      from root, it returns SEQ_SKIP.  The only caller adjusted (i.e. stopped
      ignoring the return value as it used to do).
      Reviewed-by: NJohn Johansen <john.johansen@canonical.com>
      ACKed-by: NJohn Johansen <john.johansen@canonical.com>
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      Cc: stable@vger.kernel.org
      02125a82
  6. 17 11月, 2011 2 次提交
    • M
      encrypted-keys: module build fixes · 9c698987
      Mimi Zohar 提交于
      Encrypted keys are encrypted/decrypted using either a trusted or
      user-defined key type, which is referred to as the 'master' key.
      The master key may be of type trusted iff the trusted key is
      builtin or both the trusted key and encrypted keys are built as
      modules.  This patch resolves the build dependency problem.
      
      - Use "masterkey-$(CONFIG_TRUSTED_KEYS)-$(CONFIG_ENCRYPTED_KEYS)" construct
      to encapsulate the above logic. (Suggested by Dimtry Kasatkin.)
      - Fixing the encrypted-keys Makefile, results in a module name change
      from encrypted.ko to encrypted-keys.ko.
      - Add module dependency for request_trusted_key() definition
      Signed-off-by: NMimi Zohar <zohar@us.ibm.com>
      9c698987
    • M
      encrypted-keys: fix error return code · f4a0d5ab
      Mimi Zohar 提交于
      Fix request_master_key() error return code.
      Signed-off-by: NMimi Zohar <zohar@us.ibm.com>
      f4a0d5ab
  7. 16 11月, 2011 1 次提交
    • D
      KEYS: Fix a NULL pointer deref in the user-defined key type · 9f35a33b
      David Howells 提交于
      Fix a NULL pointer deref in the user-defined key type whereby updating a
      negative key into a fully instantiated key will cause an oops to occur
      when the code attempts to free the non-existent old payload.
      
      This results in an oops that looks something like the following:
      
        BUG: unable to handle kernel NULL pointer dereference at 0000000000000008
        IP: [<ffffffff81085fa1>] __call_rcu+0x11/0x13e
        PGD 3391d067 PUD 3894a067 PMD 0
        Oops: 0002 [#1] SMP
        CPU 1
        Pid: 4354, comm: keyctl Not tainted 3.1.0-fsdevel+ #1140                  /DG965RY
        RIP: 0010:[<ffffffff81085fa1>]  [<ffffffff81085fa1>] __call_rcu+0x11/0x13e
        RSP: 0018:ffff88003d591df8  EFLAGS: 00010246
        RAX: 0000000000000000 RBX: 0000000000000000 RCX: 000000000000006e
        RDX: ffffffff8161d0c0 RSI: 0000000000000000 RDI: 0000000000000000
        RBP: ffff88003d591e18 R08: 0000000000000000 R09: ffffffff8152fa6c
        R10: 0000000000000000 R11: 0000000000000300 R12: ffff88003b8f9538
        R13: ffffffff8161d0c0 R14: ffff88003b8f9d50 R15: ffff88003c69f908
        FS:  00007f97eb18c720(0000) GS:ffff88003bd00000(0000) knlGS:0000000000000000
        CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
        CR2: 0000000000000008 CR3: 000000003d47a000 CR4: 00000000000006e0
        DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
        DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
        Process keyctl (pid: 4354, threadinfo ffff88003d590000, task ffff88003c78a040)
        Stack:
         ffff88003e0ffde0 ffff88003b8f9538 0000000000000001 ffff88003b8f9d50
         ffff88003d591e28 ffffffff810860f0 ffff88003d591e68 ffffffff8117bfea
         ffff88003d591e68 ffffffff00000000 ffff88003e0ffde1 ffff88003e0ffde0
        Call Trace:
         [<ffffffff810860f0>] call_rcu_sched+0x10/0x12
         [<ffffffff8117bfea>] user_update+0x8d/0xa2
         [<ffffffff8117723a>] key_create_or_update+0x236/0x270
         [<ffffffff811789b1>] sys_add_key+0x123/0x17e
         [<ffffffff813b84bb>] system_call_fastpath+0x16/0x1b
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Acked-by: NJeff Layton <jlayton@redhat.com>
      Acked-by: NNeil Horman <nhorman@redhat.com>
      Acked-by: NSteve Dickson <steved@redhat.com>
      Acked-by: NJames Morris <jmorris@namei.org>
      Cc: stable@kernel.org
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      9f35a33b
  8. 12 11月, 2011 1 次提交
    • C
      Smack: smackfs cipso seq read repair · 40809565
      Casey Schaufler 提交于
      Commit 272cd7a8 introduced
      a change to the way rule lists are handled and reported in
      the smackfs filesystem. One of the issues addressed had to
      do with the termination of read requests on /smack/load.
      This change introduced a error in /smack/cipso, which shares
      some of the same list processing code.
      
      This patch updates all the file access list handling in
      smackfs to use the code introduced for /smack/load.
      Signed-off-by: NCasey Schaufler <casey@schaufler-ca.com>
      40809565
  9. 02 11月, 2011 1 次提交
  10. 01 11月, 2011 3 次提交
    • A
      security: follow rename pack_hex_byte() to hex_byte_pack() · 02473119
      Andy Shevchenko 提交于
      There is no functional change.
      Signed-off-by: NAndy Shevchenko <andriy.shevchenko@linux.intel.com>
      Cc: Mimi Zohar <zohar@us.ibm.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>
      02473119
    • C
      Cross Memory Attach · fcf63409
      Christopher Yeoh 提交于
      The basic idea behind cross memory attach is to allow MPI programs doing
      intra-node communication to do a single copy of the message rather than a
      double copy of the message via shared memory.
      
      The following patch attempts to achieve this by allowing a destination
      process, given an address and size from a source process, to copy memory
      directly from the source process into its own address space via a system
      call.  There is also a symmetrical ability to copy from the current
      process's address space into a destination process's address space.
      
      - Use of /proc/pid/mem has been considered, but there are issues with
        using it:
        - Does not allow for specifying iovecs for both src and dest, assuming
          preadv or pwritev was implemented either the area read from or
        written to would need to be contiguous.
        - Currently mem_read allows only processes who are currently
        ptrace'ing the target and are still able to ptrace the target to read
        from the target. This check could possibly be moved to the open call,
        but its not clear exactly what race this restriction is stopping
        (reason  appears to have been lost)
        - Having to send the fd of /proc/self/mem via SCM_RIGHTS on unix
        domain socket is a bit ugly from a userspace point of view,
        especially when you may have hundreds if not (eventually) thousands
        of processes  that all need to do this with each other
        - Doesn't allow for some future use of the interface we would like to
        consider adding in the future (see below)
        - Interestingly reading from /proc/pid/mem currently actually
        involves two copies! (But this could be fixed pretty easily)
      
      As mentioned previously use of vmsplice instead was considered, but has
      problems.  Since you need the reader and writer working co-operatively if
      the pipe is not drained then you block.  Which requires some wrapping to
      do non blocking on the send side or polling on the receive.  In all to all
      communication it requires ordering otherwise you can deadlock.  And in the
      example of many MPI tasks writing to one MPI task vmsplice serialises the
      copying.
      
      There are some cases of MPI collectives where even a single copy interface
      does not get us the performance gain we could.  For example in an
      MPI_Reduce rather than copy the data from the source we would like to
      instead use it directly in a mathops (say the reduce is doing a sum) as
      this would save us doing a copy.  We don't need to keep a copy of the data
      from the source.  I haven't implemented this, but I think this interface
      could in the future do all this through the use of the flags - eg could
      specify the math operation and type and the kernel rather than just
      copying the data would apply the specified operation between the source
      and destination and store it in the destination.
      
      Although we don't have a "second user" of the interface (though I've had
      some nibbles from people who may be interested in using it for intra
      process messaging which is not MPI).  This interface is something which
      hardware vendors are already doing for their custom drivers to implement
      fast local communication.  And so in addition to this being useful for
      OpenMPI it would mean the driver maintainers don't have to fix things up
      when the mm changes.
      
      There was some discussion about how much faster a true zero copy would
      go. Here's a link back to the email with some testing I did on that:
      
      http://marc.info/?l=linux-mm&m=130105930902915&w=2
      
      There is a basic man page for the proposed interface here:
      
      http://ozlabs.org/~cyeoh/cma/process_vm_readv.txt
      
      This has been implemented for x86 and powerpc, other architecture should
      mainly (I think) just need to add syscall numbers for the process_vm_readv
      and process_vm_writev. There are 32 bit compatibility versions for
      64-bit kernels.
      
      For arch maintainers there are some simple tests to be able to quickly
      verify that the syscalls are working correctly here:
      
      http://ozlabs.org/~cyeoh/cma/cma-test-20110718.tgzSigned-off-by: NChris Yeoh <yeohc@au1.ibm.com>
      Cc: Ingo Molnar <mingo@elte.hu>
      Cc: "H. Peter Anvin" <hpa@zytor.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Cc: Paul Mackerras <paulus@samba.org>
      Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
      Cc: David Howells <dhowells@redhat.com>
      Cc: James Morris <jmorris@namei.org>
      Cc: <linux-man@vger.kernel.org>
      Cc: <linux-arch@vger.kernel.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      fcf63409
    • P
      selinux: Add export.h to files using EXPORT_SYMBOL/THIS_MODULE · 44fc7ea0
      Paul Gortmaker 提交于
      The pervasive, but implicit presence of <linux/module.h> meant
      that things like this file would happily compile as-is.  But
      with the desire to phase out the module.h being included everywhere,
      point this file at export.h which will give it THIS_MODULE and
      the EXPORT_SYMBOL variants.
      Signed-off-by: NPaul Gortmaker <paul.gortmaker@windriver.com>
      44fc7ea0
  11. 29 10月, 2011 1 次提交
  12. 23 10月, 2011 1 次提交
    • T
      TOMOYO: Fix incomplete read after seek. · e0b057b4
      Tetsuo Handa 提交于
      Commit f23571e8 "TOMOYO: Copy directly to userspace buffer." introduced
      tomoyo_flush() that flushes data to be read as soon as possible.
      tomoyo_select_domain() (which is called by write()) enqueues data which meant
      to be read by next read(), but previous read()'s read buffer's size was not
      cleared. As a result, since 2.6.36, sequence like
      
         char *cp = "select global-pid=1\n";
         read(fd, buf1, sizeof(buf1));
         write(fd, cp, strlen(cp));
         read(fd, buf2, sizeof(buf2));
      
      causes enqueued data to be flushed to buf1 rather than buf2.
      Fix this bug by clearing read buffer's size upon write() request.
      Signed-off-by: NTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Signed-off-by: NJames Morris <jmorris@namei.org>
      e0b057b4
  13. 21 10月, 2011 1 次提交
  14. 19 10月, 2011 3 次提交
  15. 14 10月, 2011 1 次提交
  16. 13 10月, 2011 7 次提交
    • J
      Smack: fix for /smack/access output, use string instead of byte · f8859d98
      Jarkko Sakkinen 提交于
      Small fix for the output of access SmackFS file. Use string
      is instead of byte. Makes it easier to extend API if it is
      needed.
      Signed-off-by: NJarkko Sakkinen <jarkko.sakkinen@intel.com>
      f8859d98
    • J
      Smack: domain transition protections (v3) · 84088ba2
      Jarkko Sakkinen 提交于
      Protections for domain transition:
      
      - BPRM unsafe flags
      - Secureexec
      - Clear unsafe personality bits.
      - Clear parent death signal
      Signed-off-by: NJarkko Sakkinen <jarkko.sakkinen@intel.com>
      84088ba2
    • C
      Smack: Provide information for UDS getsockopt(SO_PEERCRED) · 975d5e55
      Casey Schaufler 提交于
      This patch is targeted for the smack-next tree.
      
      This patch takes advantage of the recent changes for performance
      and points the packet labels on UDS connect at the output label of
      the far side. This makes getsockopt(...SO_PEERCRED...) function
      properly. Without this change the getsockopt does not provide any
      information.
      Signed-off-by: NCasey Schaufler <casey@schaufler-ca.com>
      975d5e55
    • C
      Smack: Clean up comments · ce8a4321
      Casey Schaufler 提交于
      There are a number of comments in the Smack code that
      are either malformed or include code. This patch cleans
      them up.
      Signed-off-by: NCasey Schaufler <casey@schaufler-ca.com>
      ce8a4321
    • C
      Smack: Repair processing of fcntl · 531f1d45
      Casey Schaufler 提交于
      Al Viro pointed out that the processing of fcntl done
      by Smack appeared poorly designed. He was right. There
      are three things that required change. Most obviously,
      the list of commands that really imply writing is limited
      to those involving file locking and signal handling.
      The initialization if the file security blob was
      incomplete, requiring use of a heretofore unused LSM hook.
      Finally, the audit information coming from a helper
      masked the identity of the LSM hook. This patch corrects
      all three of these defects.
      
      This is targeted for the smack-next tree pending comments.
      Signed-off-by: NCasey Schaufler <casey@schaufler-ca.com>
      531f1d45
    • C
      Smack: Rule list lookup performance · 272cd7a8
      Casey Schaufler 提交于
      This patch is targeted for the smack-next tree.
      
      Smack access checks suffer from two significant performance
      issues. In cases where there are large numbers of rules the
      search of the single list of rules is wasteful. Comparing the
      string values of the smack labels is less efficient than a
      numeric comparison would.
      
      These changes take advantage of the Smack label list, which
      maintains the mapping of Smack labels to secids and optional
      CIPSO labels. Because the labels are kept perpetually, an
      access check can be done strictly based on the address of the
      label in the list without ever looking at the label itself.
      Rather than keeping one global list of rules the rules with
      a particular subject label can be based off of that label
      list entry. The access check need never look at entries that
      do not use the current subject label.
      
      This requires that packets coming off the network with
      CIPSO direct Smack labels that have never been seen before
      be treated carefully. The only case where they could be
      delivered is where the receiving socket has an IPIN star
      label, so that case is explicitly addressed.
      
      On a system with 39,800 rules (200 labels in all permutations)
      a system with this patch runs an access speed test in 5% of
      the time of the old version. That should be a best case
      improvement. If all of the rules are associated with the
      same subject label and all of the accesses are for processes
      with that label (unlikely) the improvement is about 30%.
      Signed-off-by: NCasey Schaufler <casey@schaufler-ca.com>
      272cd7a8
    • J
      Smack: check permissions from user space (v2) · 828716c2
      Jarkko Sakkinen 提交于
      Adds a new file into SmackFS called 'access'. Wanted
      Smack permission is written into /smack/access.
      After that result can be read from the opened file.
      If access applies result contains 1 and otherwise
      0. File access is protected from race conditions
      by using simple_transaction_get()/set() API.
      
      Fixes from the previous version:
      - Removed smack.h changes, refactoring left-over
      from previous version.
      - Removed #include <linux/smack.h>, refactoring
      left-over from previous version.
      Signed-off-by: NJarkko Sakkinen <jarkko.sakkinen@intel.com>
      Signed-off-by: NCasey Schaufler <cschaufler@cschaufler-intel.(none)>
      828716c2
  17. 12 10月, 2011 2 次提交
  18. 28 9月, 2011 1 次提交
  19. 26 9月, 2011 3 次提交
  20. 21 9月, 2011 2 次提交