1. 22 Mar, 2016 1 commit
  2. 17 Mar, 2016 2 commits
    • Ben Hutchings's avatar
      pipe: iovec: Fix memory corruption when retrying atomic copy as non-atomic · eca06b45
      Ben Hutchings authored
      pipe_iov_copy_{from,to}_user() may be tried twice with the same iovec,
      the first time atomically and the second time not.  The second attempt
      needs to continue from the iovec position, pipe buffer offset and
      remaining length where the first attempt failed, but currently the
      pipe buffer offset and remaining length are reset.  This will corrupt
      the piped data (possibly also leading to an information leak between
      processes) and may also corrupt kernel memory.
      
      This was fixed upstream by commits f0d1bec9d58d ("new helper:
      copy_page_from_iter()") and 637b58c2887e ("switch pipe_read() to
      copy_page_to_iter()"), but those aren't suitable for stable.  This fix
      for older kernel versions was made by Seth Jennings for RHEL and I
      have extracted it from their update.
      
      CVE-2015-1805
      
      Bug: 27275324
      
      Change-Id: I459adb9076fcd50ff1f1c557089c4e421b036ec4
      References: https://bugzilla.redhat.com/show_bug.cgi?id=1202855
      
      Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      (cherry picked from commit 85c34d007116f8a8aafb173966a605fb03532f45)
      eca06b45
    • Patrick Tjin's avatar
      Keep history after reset to 094b859d · c97b5c0d
      Patrick Tjin authored
      c97b5c0d
  3. 24 Feb, 2016 1 commit
  4. 21 Jan, 2016 1 commit
    • Wish Wu's avatar
      msm: null pointer dereferencing · 094b859d
      Wish Wu authored
      
      Prevent unintended kernel NULL pointer dereferencing.
      
      Orignal code:
        hlist_del_rcu(&event->hlist_entry);
      
      Fix: Adding pointer check:
        if(!hlist_unhashed(&p_event->hlist_entry))
          hlist_del_rcu(&p_event->hlist_entry);
      
      Bug: 25364034
      Change-Id: Ieda6d8f4bb567827fa6c7709e9e729905c6c3882
      Signed-off-by: default avatarYuan Lin <yualin@google.com>
      094b859d
  5. 12 Jan, 2016 1 commit
  6. 08 Jan, 2016 1 commit
    • Vasily Kulikov's avatar
      include/linux/poison.h: fix LIST_POISON{1,2} offset · d965aca9
      Vasily Kulikov authored
      Poison pointer values should be small enough to find a room in
      non-mmap'able/hardly-mmap'able space.  E.g.  on x86 "poison pointer space"
      is located starting from 0x0.  Given unprivileged users cannot mmap
      anything below mmap_min_addr, it should be safe to use poison pointers
      lower than mmap_min_addr.
      
      The current poison pointer values of LIST_POISON{1,2} might be too big for
      mmap_min_addr values equal or less than 1 MB (common case, e.g.  Ubuntu
      uses only 0x10000).  There is little point to use such a big value given
      the "poison pointer space" below 1 MB is not yet exhausted.  Changing it
      to a smaller value solves the problem for small mmap_min_addr setups.
      
      The values are suggested by Solar Designer:
      http://www.openwall.com/lists/oss-security/2015/05/02/6
      
      
      
      Bug: 26186802
      Change-Id: Ie2121a417b6a43ee6d119c996b5ec2ad6d01a0a7
      Signed-off-by: default avatarYuan Lin <yualin@google.com>
      d965aca9
  7. 23 Oct, 2015 1 commit
  8. 22 Oct, 2015 1 commit
  9. 14 Oct, 2015 2 commits
    • Patrick Tjin's avatar
      msm: ipc_socket: fix leak of kernel memory to userspace · 4b3d11e7
      Patrick Tjin authored
      
      Limit the size of copy to the minimum of what was asked
      for or the number of results returned to prevent leaking of
      uninitialized kernel memory to userspace.
      
      Bug: 24157888
      Signed-off-by: default avatarPatrick Tjin <pattjin@google.com>
      Change-Id: I7433135ea3345905c053a81d0d759619b46c1430
      4b3d11e7
    • Patrick Tjin's avatar
      arm/configs: flo: Remove SysV IPC from kernel · bd8d871a
      Patrick Tjin authored
      
      System V IPCs are not compliant with Android's application lifecycle
      because allocated resources are not freeable by the low memory killer.
      This lead to global kernel resource leakage.
      
      For example, there is no way to automatically release a SysV
      semaphore allocated in the kernel when:
      - a buggy or malicious process exits
      - a non-buggy and non-malicious process crashes or is explicitly
        killed.
      
      Killing processes automatically to make room for new ones is an
      important part of Android's application lifecycle implementation.
      This means that, even assuming only non-buggy and non-malicious
      code, it is very likely that over time, the kernel global tables
      used to implement SysV IPCs will fill up.
      
      Bug: 24551430
      Bug: 22300191
      Signed-off-by: default avatarPatrick Tjin <pattjin@google.com>
      Change-Id: I98d592819974acbd5fb47d526ed1ce3700ae1bd5
      bd8d871a
  10. 17 Aug, 2015 1 commit
  11. 29 Jul, 2015 2 commits
    • Harshdeep Dhatt's avatar
      msm: kgsl: Increase the wait timeout for context detachment · 3bcea4ed
      Harshdeep Dhatt authored
      
      Increase the wait timeout for context detachment to 30s instead
      of 10s. Large IB's can take longer than 10s to retire and if a
      hang happens then recovering from the hang and completing the
      long IB's will take much longer than 10s, bump this timer to
      30s which should be sufficient for the context's commands to
      retire even if hang happens.
      
      Change-Id: I610186473208c574b0bcada0b62a7407ae171d37
      Signed-off-by: default avatarHarshdeep Dhatt <hdhatt@codeaurora.org>
      3bcea4ed
    • Erik Kline's avatar
      ipv6: sysctl to restrict candidate source addresses · ab98584a
      Erik Kline authored
      
      Per RFC 6724, section 4, "Candidate Source Addresses":
      
          It is RECOMMENDED that the candidate source addresses be the set
          of unicast addresses assigned to the interface that will be used
          to send to the destination (the "outgoing" interface).
      
      Add a sysctl to enable this behaviour.
      Signed-off-by: default avatarErik Kline <ek@google.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      
      [Simplified back-port of net-next 3985e8a3611a93bb36789f65db862e5700aab65e]
      
      Bug: 19470192
      Bug: 21832279
      Bug: 22464419
      Change-Id: Icd96382f814a6f3ea53f05beb98c266b1929c5a3
      ab98584a
  12. 25 Jul, 2015 1 commit
  13. 13 Jul, 2015 21 commits
    • Eric W. Biederman's avatar
      proc: Allow proc_free_inum to be called from any context · 381ca1fb
      Eric W. Biederman authored
      
      While testing the pid namespace code I hit this nasty warning.
      
      [  176.262617] ------------[ cut here ]------------
      [  176.263388] WARNING: at /home/eric/projects/linux/linux-userns-devel/kernel/softirq.c:160 local_bh_enable_ip+0x7a/0xa0()
      [  176.265145] Hardware name: Bochs
      [  176.265677] Modules linked in:
      [  176.266341] Pid: 742, comm: bash Not tainted 3.7.0userns+ #18
      [  176.266564] Call Trace:
      [  176.266564]  [<ffffffff810a539f>] warn_slowpath_common+0x7f/0xc0
      [  176.266564]  [<ffffffff810a53fa>] warn_slowpath_null+0x1a/0x20
      [  176.266564]  [<ffffffff810ad9ea>] local_bh_enable_ip+0x7a/0xa0
      [  176.266564]  [<ffffffff819308c9>] _raw_spin_unlock_bh+0x19/0x20
      [  176.266564]  [<ffffffff8123dbda>] proc_free_inum+0x3a/0x50
      [  176.266564]  [<ffffffff8111d0dc>] free_pid_ns+0x1c/0x80
      [  176.266564]  [<ffffffff8111d195>] put_pid_ns+0x35/0x50
      [  176.266564]  [<ffffffff810c608a>] put_pid+0x4a/0x60
      [  176.266564]  [<ffffffff8146b177>] tty_ioctl+0x717/0xc10
      [  176.266564]  [<ffffffff810aa4d5>] ? wait_consider_task+0x855/0xb90
      [  176.266564]  [<ffffffff81086bf9>] ? default_spin_lock_flags+0x9/0x10
      [  176.266564]  [<ffffffff810cab0a>] ? remove_wait_queue+0x5a/0x70
      [  176.266564]  [<ffffffff811e37e8>] do_vfs_ioctl+0x98/0x550
      [  176.266564]  [<ffffffff810b8a0f>] ? recalc_sigpending+0x1f/0x60
      [  176.266564]  [<ffffffff810b9127>] ? __set_task_blocked+0x37/0x80
      [  176.266564]  [<ffffffff810ab95b>] ? sys_wait4+0xab/0xf0
      [  176.266564]  [<ffffffff811e3d31>] sys_ioctl+0x91/0xb0
      [  176.266564]  [<ffffffff810a95f0>] ? task_stopped_code+0x50/0x50
      [  176.266564]  [<ffffffff81939199>] system_call_fastpath+0x16/0x1b
      [  176.266564] ---[ end trace 387af88219ad6143 ]---
      
      It turns out that spin_unlock_bh(proc_inum_lock) is not safe when
      put_pid is called with another spinlock held and irqs disabled.
      
      For now take the easy path and use spin_lock_irqsave(proc_inum_lock)
      in proc_free_inum and spin_loc_irq in proc_alloc_inum(proc_inum_lock).
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      Bug: 22173056
      Backport: commits 0f7aa3c0
      
       to this one are backport of mnt namespace
      Signed-off-by: default avatarThierry Strudel <tstrudel@google.com>
      (cherry picked from commit dfb2ea45becb198beeb75350d0b7b7ad9076a38f)
      381ca1fb
    • Eric W. Biederman's avatar
      proc: Usable inode numbers for the namespace file descriptors. · 60e6a983
      Eric W. Biederman authored
      
      Assign a unique proc inode to each namespace, and use that
      inode number to ensure we only allocate at most one proc
      inode for every namespace in proc.
      
      A single proc inode per namespace allows userspace to test
      to see if two processes are in the same namespace.
      
      This has been a long requested feature and only blocked because
      a naive implementation would put the id in a global space and
      would ultimately require having a namespace for the names of
      namespaces, making migration and certain virtualization tricks
      impossible.
      
      We still don't have per superblock inode numbers for proc, which
      appears necessary for application unaware checkpoint/restart and
      migrations (if the application is using namespace file descriptors)
      but that is now allowd by the design if it becomes important.
      
      I have preallocated the ipc and uts initial proc inode numbers so
      their structures can be statically initialized.
      Signed-off-by: default avatarEric W. Biederman <ebiederm@xmission.com>
      (cherry picked from commit 98f842e675f96ffac96e6c50315790912b2812be)
      60e6a983
    • Eric W. Biederman's avatar
      proc: Fix the namespace inode permission checks. · dadd033b
      Eric W. Biederman authored
      
      Change the proc namespace files into symlinks so that
      we won't cache the dentries for the namespace files
      which can bypass the ptrace_may_access checks.
      
      To support the symlinks create an additional namespace
      inode with it's own set of operations distinct from the
      proc pid inode and dentry methods as those no longer
      make sense.
      Signed-off-by: default avatarEric W. Biederman <ebiederm@xmission.com>
      (cherry picked from commit bf056bfa80596a5d14b26b17276a56a0dcb080e5)
      dadd033b
    • Eric W. Biederman's avatar
      proc: Generalize proc inode allocation · 75140a91
      Eric W. Biederman authored
      
      Generalize the proc inode allocation so that it can be
      used without having to having to create a proc_dir_entry.
      
      This will allow namespace file descriptors to remain light
      weight entitities but still have the same inode number
      when the backing namespace is the same.
      Acked-by: default avatarSerge E. Hallyn <serge.hallyn@ubuntu.com>
      Signed-off-by: default avatarEric W. Biederman <ebiederm@xmission.com>
      (cherry picked from commit 33d6dce607573b5fd7a43168e0d91221b3ca532b)
      75140a91
    • Eric W. Biederman's avatar
      vfs: Allow unprivileged manipulation of the mount namespace. · 5fe7ef9b
      Eric W. Biederman authored
      
      - Add a filesystem flag to mark filesystems that are safe to mount as
        an unprivileged user.
      
      - Add a filesystem flag to mark filesystems that don't need MNT_NODEV
        when mounted by an unprivileged user.
      
      - Relax the permission checks to allow unprivileged users that have
        CAP_SYS_ADMIN permissions in the user namespace referred to by the
        current mount namespace to be allowed to mount, unmount, and move
        filesystems.
      Acked-by: default avatar"Serge E. Hallyn" <serge@hallyn.com>
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      (cherry picked from commit 0c55cfc4166d9a0f38de779bd4d75a90afbe7734)
      5fe7ef9b
    • Eric W. Biederman's avatar
      vfs: Only support slave subtrees across different user namespaces · 38d441be
      Eric W. Biederman authored
      
      Sharing mount subtress with mount namespaces created by unprivileged
      users allows unprivileged mounts created by unprivileged users to
      propagate to mount namespaces controlled by privileged users.
      
      Prevent nasty consequences by changing shared subtrees to slave
      subtress when an unprivileged users creates a new mount namespace.
      Acked-by: default avatarSerge Hallyn <serge.hallyn@canonical.com>
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      (cherry picked from commit 7a472ef4be8387bc05a42e16309b02c8ca943a40)
      38d441be
    • Eric W. Biederman's avatar
      vfs: Add a user namespace reference from struct mnt_namespace · 6f52736c
      Eric W. Biederman authored
      
      This will allow for support for unprivileged mounts in a new user namespace.
      Acked-by: default avatar"Serge E. Hallyn" <serge@hallyn.com>
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      (cherry picked from commit 771b1371686e0a63e938ada28de020b9a0040f55)
      6f52736c
    • Eric W. Biederman's avatar
      vfs: Add setns support for the mount namespace · cd0ed7c2
      Eric W. Biederman authored
      
      setns support for the mount namespace is a little tricky as an
      arbitrary decision must be made about what to set fs->root and
      fs->pwd to, as there is no expectation of a relationship between
      the two mount namespaces.  Therefore I arbitrarily find the root
      mount point, and follow every mount on top of it to find the top
      of the mount stack.  Then I set fs->root and fs->pwd to that
      location.  The topmost root of the mount stack seems like a
      reasonable place to be.
      
      Bind mount support for the mount namespace inodes has the
      possibility of creating circular dependencies between mount
      namespaces.  Circular dependencies can result in loops that
      prevent mount namespaces from every being freed.  I avoid
      creating those circular dependencies by adding a sequence number
      to the mount namespace and require all bind mounts be of a
      younger mount namespace into an older mount namespace.
      
      Add a helper function proc_ns_inode so it is possible to
      detect when we are attempting to bind mound a namespace inode.
      Acked-by: default avatarSerge Hallyn <serge.hallyn@canonical.com>
      Signed-off-by: default avatarEric W. Biederman <ebiederm@xmission.com>
      (cherry picked from commit 8823c079ba7136dc1948d6f6dcb5f8022bde438e)
      cd0ed7c2
    • Al Viro's avatar
      consitify do_mount() arguments · 5f453c9b
      Al Viro authored
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      (cherry picked from commit 808d4e3cfdcc52b19276175464f6dbca4df13b09)
      5f453c9b
    • Al Viro's avatar
      do_add_mount()/umount -l races · 57e87fa6
      Al Viro authored
      
      normally we deal with lock_mount()/umount races by checking that
      mountpoint to be is still in our namespace after lock_mount() has
      been done.  However, do_add_mount() skips that check when called
      with MNT_SHRINKABLE in flags (i.e. from finish_automount()).  The
      reason is that ->mnt_ns may be a temporary namespace created exactly
      to contain automounts a-la NFS4 referral handling.  It's not the
      namespace of the caller, though, so check_mnt() would fail here.
      We still need to check that ->mnt_ns is non-NULL in that case,
      though.
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      (cherry picked from commit 156cacb1d0d36b0d0582d9e798e58e0044f516b3)
      57e87fa6
    • Josef Bacik's avatar
      fs: introduce inode operation ->update_time · 32d9bbb0
      Josef Bacik authored
      Btrfs has to make sure we have space to allocate new blocks in order to modify
      the inode, so updating time can fail.  We've gotten around this by having our
      own file_update_time but this is kind of a pain, and Christoph has indicated he
      would like to make xfs do something different with atime updates.  So introduce
      ->update_time, where we will deal with i_version an a/m/c time updates and
      indicate which changes need to be made.  The normal version just does what it
      has always done, updates the time and marks the inode dirty, and then
      filesystems can choose to do something different.
      
      I've gone through all of the users of file_update_time and made them check for
      errors with the exception of the fault code since it's complicated and I wasn't
      quite sure what to do there, also Jan is going to be pushing the file time
      updates into page_mkwrite for those who have it so that should satisfy btrfs and
      make it not a big deal to check the file_update_time() return code in ...
      32d9bbb0
    • David Howells's avatar
      VFS: Comment mount following code · a6e63b05
      David Howells authored
      
      Add comments describing what the directions "up" and "down" mean and ref count
      handling to the VFS mount following family of functions.
      
      Signed-off-by: Valerie Aurora <vaurora@redhat.com> (Original author)
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      (cherry picked from commit f015f1267b23d3530d3f874243fb83cb5f443005)
      a6e63b05
    • David Howells's avatar
      VFS: Make clone_mnt()/copy_tree()/collect_mounts() return errors · 42700229
      David Howells authored
      
      copy_tree() can theoretically fail in a case other than ENOMEM, but always
      returns NULL which is interpreted by callers as -ENOMEM.  Change it to return
      an explicit error.
      
      Also change clone_mnt() for consistency and because union mounts will add new
      error cases.
      
      Thanks to Andreas Gruenbacher <agruen@suse.de> for a bug fix.
      [AV: folded braino fix by Dan Carpenter]
      
      Original-author: Valerie Aurora <vaurora@redhat.com>
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Cc: Valerie Aurora <valerie.aurora@gmail.com>
      Cc: Andreas Gruenbacher <agruen@suse.de>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      (cherry picked from commit be34d1a3bc4b6f357a49acb55ae870c81337e4f0)
      42700229
    • Al Viro's avatar
      get rid of magic in proc_namespace.c · ba25d8cb
      Al Viro authored
      
      don't rely on proc_mounts->m being the first field; container_of()
      is there for purpose.  No need to bother with ->private, while
      we are at it - the same container_of will do nicely.
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      (cherry picked from commit 6ce6e24e72233073c8ead9419fc5040d44803dae)
      ba25d8cb
    • Al Viro's avatar
      get rid of ->mnt_longterm · 0c0d1459
      Al Viro authored
      
      it's enough to set ->mnt_ns of internal vfsmounts to something
      distinct from all struct mnt_namespace out there; then we can
      just use the check for ->mnt_ns != NULL in the fast path of
      mntput_no_expire()
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      (cherry picked from commit f7a99c5b7c8bd3d3f533c8b38274e33f3da9096e)
      0c0d1459
    • Al Viro's avatar
      vfs: umount_tree() might be called on subtree that had never made it · 68552709
      Al Viro authored
      
      __mnt_make_shortterm() in there undoes the effect of __mnt_make_longterm()
      we'd done back when we set ->mnt_ns non-NULL; it should not be done to
      vfsmounts that had never gone through commit_tree() and friends.  Kudos to
      lczerner for catching that one...
      
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      (cherry picked from commit 63d37a84ab6004c235314ffd7a76c5eb28c2fae0)
      68552709
    • Andi Kleen's avatar
      brlocks/lglocks: API cleanups · f875ea3d
      Andi Kleen authored
      
      lglocks and brlocks are currently generated with some complicated macros
      in lglock.h.  But there's no reason to not just use common utility
      functions and put all the data into a common data structure.
      
      In preparation, this patch changes the API to look more like normal
      function calls with pointers, not magic macros.
      
      The patch is rather large because I move over all users in one go to keep
      it bisectable.  This impacts the VFS somewhat in terms of lines changed.
      But no actual behaviour change.
      
      [akpm@linux-foundation.org: checkpatch fixes]
      Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Rusty Russell <rusty@rustcorp.com.au>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      
      (cherry picked from commit 962830df366b66e71849040770ae6ba55a8b4aec)
      f875ea3d
    • Andi Kleen's avatar
      brlocks/lglocks: turn into functions · 3e8176d2
      Andi Kleen authored
      
      lglocks and brlocks are currently generated with some complicated macros
      in lglock.h.  But there's no reason to not just use common utility
      functions and put all the data into a common data structure.
      
      Since there are at least two users it makes sense to share this code in a
      library.  This is also easier maintainable than a macro forest.
      
      This will also make it later possible to dynamically allocate lglocks and
      also use them in modules (this would both still need some additional, but
      now straightforward, code)
      
      [akpm@linux-foundation.org: checkpatch fixes]
      Signed-off-by: default avatarAndi Kleen <ak@linux.intel.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Rusty Russell <rusty@rustcorp.com.au>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      
      (cherry picked from commit eea62f831b8030b0eeea8314eed73b6132d1de26)
      3e8176d2
    • Rusty Russell's avatar
      lglock: remove online variants of lock · fcb98c4c
      Rusty Russell authored
      
      Optimizing the slow paths adds a lot of complexity.  If you need to
      grab every lock often, you have other problems.
      Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
      Acked-by: default avatarNick Piggin <npiggin@kernel.dk>
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      (cherry picked from commit 9dd6fa03ab31bb57cee4623a689d058d222fbe68)
      fcb98c4c
    • Thierry Strudel's avatar
      Revert "vfs: umount_tree() might be called on subtree that had never made it" · a9c44d5a
      Thierry Strudel authored
      This reverts commit 61fc3d0b2f95e232c7e4021b9e15790377efb80b.
      a9c44d5a
    • Thierry Strudel's avatar
      Revert "get rid of ->mnt_longterm" · 0f7aa3c0
      Thierry Strudel authored
      This reverts commit e4aab2e3
      
      .
      Signed-off-by: default avatarThierry Strudel <tstrudel@google.com>
      0f7aa3c0
  14. 09 Jul, 2015 2 commits
  15. 06 Jul, 2015 1 commit
  16. 17 Jun, 2015 1 commit
    • Jeff Vander Stoep's avatar
      mm: reorder can_do_mlock to fix audit denial · 51f2ffdb
      Jeff Vander Stoep authored
      
      A userspace call to mmap(MAP_LOCKED) may result in the successful locking
      of memory while also producing a confusing audit log denial.  can_do_mlock
      checks capable and rlimit.  If either of these return positive
      can_do_mlock returns true.  The capable check leads to an LSM hook used by
      apparmour and selinux which produce the audit denial.  Reordering so
      rlimit is checked first eliminates the denial on success, only recording a
      denial when the lock is unsuccessful as a result of the denial.
      
      (cherry picked from e48e8c45925185c02b23ae461671be29c91101d5)
      
      Bug: 19590990
      Signed-off-by: default avatarJeff Vander Stoep <jeffv@google.com>
      Acked-by: default avatarNick Kralevich <nnk@google.com>
      Cc: Jeff Vander Stoep <jeffv@google.com>
      Cc: Sasha Levin <sasha.levin@oracle.com>
      Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
      Cc: Rik van Riel <riel@redhat.com>
      Cc: Vlastimil Babka <vbabka@suse.cz>
      Cc: Paul Cassella <cassella@cray.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      51f2ffdb