1. 09 1月, 2017 5 次提交
    • S
      selinux: clean up cred usage and simplify · be0554c9
      Stephen Smalley 提交于
      SELinux was sometimes using the task "objective" credentials when
      it could/should use the "subjective" credentials.  This was sometimes
      hidden by the fact that we were unnecessarily passing around pointers
      to the current task, making it appear as if the task could be something
      other than current, so eliminate all such passing of current.  Inline
      various permission checking helper functions that can be reduced to a
      single avc_has_perm() call.
      
      Since the credentials infrastructure only allows a task to alter
      its own credentials, we can always assume that current must be the same
      as the target task in selinux_setprocattr after the check. We likely
      should move this check from selinux_setprocattr() to proc_pid_attr_write()
      and drop the task argument to the security hook altogether; it can only
      serve to confuse things.
      Signed-off-by: NStephen Smalley <sds@tycho.nsa.gov>
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      be0554c9
    • S
      selinux: allow context mounts on tmpfs, ramfs, devpts within user namespaces · 01593d32
      Stephen Smalley 提交于
      commit aad82892 ("selinux: Add support for
      unprivileged mounts from user namespaces") prohibited any use of context
      mount options within non-init user namespaces.  However, this breaks
      use of context mount options for tmpfs mounts within user namespaces,
      which are being used by Docker/runc.  There is no reason to block such
      usage for tmpfs, ramfs or devpts.  Exempt these filesystem types
      from this restriction.
      
      Before:
      sh$ userns_child_exec  -p -m -U -M '0 1000 1' -G '0 1000 1' bash
      sh# mount -t tmpfs -o context=system_u:object_r:user_tmp_t:s0:c13 none /tmp
      mount: tmpfs is write-protected, mounting read-only
      mount: cannot mount tmpfs read-only
      
      After:
      sh$ userns_child_exec  -p -m -U -M '0 1000 1' -G '0 1000 1' bash
      sh# mount -t tmpfs -o context=system_u:object_r:user_tmp_t:s0:c13 none /tmp
      sh# ls -Zd /tmp
      unconfined_u:object_r:user_tmp_t:s0:c13 /tmp
      Signed-off-by: NStephen Smalley <sds@tycho.nsa.gov>
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      01593d32
    • S
      selinux: handle ICMPv6 consistently with ICMP · ef37979a
      Stephen Smalley 提交于
      commit 79c8b348f215 ("selinux: support distinctions among all network
      address families") mapped datagram ICMP sockets to the new icmp_socket
      security class, but left ICMPv6 sockets unchanged.  This change fixes
      that oversight to handle both kinds of sockets consistently.
      Signed-off-by: NStephen Smalley <sds@tycho.nsa.gov>
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      ef37979a
    • Y
      selinux: add security in-core xattr support for tracefs · a2c7c6fb
      Yongqin Liu 提交于
      Since kernel 4.1 ftrace is supported as a new separate filesystem. It
      gets automatically mounted by the kernel under the old path
      /sys/kernel/debug/tracing. Because it lives now on a separate filesystem
      SELinux needs to be updated to also support setting SELinux labels
      on tracefs inodes.  This is required for compatibility in Android
      when moving to Linux 4.1 or newer.
      Signed-off-by: NYongqin Liu <yongqin.liu@linaro.org>
      Signed-off-by: NWilliam Roberts <william.c.roberts@intel.com>
      Acked-by: NStephen Smalley <sds@tycho.nsa.gov>
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      a2c7c6fb
    • S
      selinux: support distinctions among all network address families · da69a530
      Stephen Smalley 提交于
      Extend SELinux to support distinctions among all network address families
      implemented by the kernel by defining new socket security classes
      and mapping to them. Otherwise, many sockets are mapped to the generic
      socket class and are indistinguishable in policy.  This has come up
      previously with regard to selectively allowing access to bluetooth sockets,
      and more recently with regard to selectively allowing access to AF_ALG
      sockets.  Guido Trentalancia submitted a patch that took a similar approach
      to add only support for distinguishing AF_ALG sockets, but this generalizes
      his approach to handle all address families implemented by the kernel.
      Socket security classes are also added for ICMP and SCTP sockets.
      Socket security classes were not defined for AF_* values that are reserved
      but unimplemented in the kernel, e.g. AF_NETBEUI, AF_SECURITY, AF_ASH,
      AF_ECONET, AF_SNA, AF_WANPIPE.
      
      Backward compatibility is provided by only enabling the finer-grained
      socket classes if a new policy capability is set in the policy; older
      policies will behave as before.  The legacy redhat1 policy capability
      that was only ever used in testing within Fedora for ptrace_child
      is reclaimed for this purpose; as far as I can tell, this policy
      capability is not enabled in any supported distro policy.
      
      Add a pair of conditional compilation guards to detect when new AF_* values
      are added so that we can update SELinux accordingly rather than having to
      belatedly update it long after new address families are introduced.
      Signed-off-by: NStephen Smalley <sds@tycho.nsa.gov>
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      da69a530
  2. 25 12月, 2016 1 次提交
  3. 21 12月, 2016 9 次提交
  4. 15 12月, 2016 1 次提交
    • L
      mm: add locked parameter to get_user_pages_remote() · 5b56d49f
      Lorenzo Stoakes 提交于
      Patch series "mm: unexport __get_user_pages_unlocked()".
      
      This patch series continues the cleanup of get_user_pages*() functions
      taking advantage of the fact we can now pass gup_flags as we please.
      
      It firstly adds an additional 'locked' parameter to
      get_user_pages_remote() to allow for its callers to utilise
      VM_FAULT_RETRY functionality.  This is necessary as the invocation of
      __get_user_pages_unlocked() in process_vm_rw_single_vec() makes use of
      this and no other existing higher level function would allow it to do
      so.
      
      Secondly existing callers of __get_user_pages_unlocked() are replaced
      with the appropriate higher-level replacement -
      get_user_pages_unlocked() if the current task and memory descriptor are
      referenced, or get_user_pages_remote() if other task/memory descriptors
      are referenced (having acquiring mmap_sem.)
      
      This patch (of 2):
      
      Add a int *locked parameter to get_user_pages_remote() to allow
      VM_FAULT_RETRY faulting behaviour similar to get_user_pages_[un]locked().
      
      Taking into account the previous adjustments to get_user_pages*()
      functions allowing for the passing of gup_flags, we are now in a
      position where __get_user_pages_unlocked() need only be exported for his
      ability to allow VM_FAULT_RETRY behaviour, this adjustment allows us to
      subsequently unexport __get_user_pages_unlocked() as well as allowing
      for future flexibility in the use of get_user_pages_remote().
      
      [sfr@canb.auug.org.au: merge fix for get_user_pages_remote API change]
        Link: http://lkml.kernel.org/r/20161122210511.024ec341@canb.auug.org.au
      Link: http://lkml.kernel.org/r/20161027095141.2569-2-lstoakes@gmail.comSigned-off-by: NLorenzo Stoakes <lstoakes@gmail.com>
      Acked-by: NMichal Hocko <mhocko@suse.com>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Hugh Dickins <hughd@google.com>
      Cc: Dave Hansen <dave.hansen@linux.intel.com>
      Cc: Rik van Riel <riel@redhat.com>
      Cc: Mel Gorman <mgorman@techsingularity.net>
      Cc: Paolo Bonzini <pbonzini@redhat.com>
      Cc: Radim Krcmar <rkrcmar@redhat.com>
      Signed-off-by: NStephen Rothwell <sfr@canb.auug.org.au>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      5b56d49f
  5. 06 12月, 2016 1 次提交
    • A
      [iov_iter] new primitives - copy_from_iter_full() and friends · cbbd26b8
      Al Viro 提交于
      copy_from_iter_full(), copy_from_iter_full_nocache() and
      csum_and_copy_from_iter_full() - counterparts of copy_from_iter()
      et.al., advancing iterator only in case of successful full copy
      and returning whether it had been successful or not.
      
      Convert some obvious users.  *NOTE* - do not blindly assume that
      something is a good candidate for those unless you are sure that
      not advancing iov_iter in failure case is the right thing in
      this case.  Anything that does short read/short write kind of
      stuff (or is in a loop, etc.) is unlikely to be a good one.
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      cbbd26b8
  6. 05 12月, 2016 2 次提交
    • J
      Yama: allow access for the current ptrace parent · 50523a29
      Josh Stone 提交于
      Under ptrace_scope=1, it's possible to have a tracee that is already
      ptrace-attached, but is no longer a direct descendant.  For instance, a
      forking daemon will be re-parented to init, losing its ancestry to the
      tracer that launched it.
      
      The tracer can continue using ptrace in that state, but it will be
      denied other accesses that check PTRACE_MODE_ATTACH, like process_vm_rw
      and various procfs files.  There's no reason to prevent such access for
      a tracer that already has ptrace control anyway.
      
      This patch adds a case to ptracer_exception_found to allow access for
      any task in the same thread group as the current ptrace parent.
      Signed-off-by: NJosh Stone <jistone@redhat.com>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: James Morris <james.l.morris@oracle.com>
      Cc: "Serge E. Hallyn" <serge@hallyn.com>
      Cc: linux-security-module@vger.kernel.org
      Signed-off-by: NKees Cook <keescook@chromium.org>
      Signed-off-by: NJames Morris <james.l.morris@oracle.com>
      50523a29
    • A
      don't open-code file_inode() · 45063097
      Al Viro 提交于
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      45063097
  7. 03 12月, 2016 1 次提交
  8. 23 11月, 2016 1 次提交
    • A
      selinux: Convert isec->lock into a spinlock · 9287aed2
      Andreas Gruenbacher 提交于
      Convert isec->lock from a mutex into a spinlock.  Instead of holding
      the lock while sleeping in inode_doinit_with_dentry, set
      isec->initialized to LABEL_PENDING and release the lock.  Then, when
      the sid has been determined, re-acquire the lock.  If isec->initialized
      is still set to LABEL_PENDING, set isec->sid; otherwise, the sid has
      been set by another task (LABEL_INITIALIZED) or invalidated
      (LABEL_INVALID) in the meantime.
      
      This fixes a deadlock on gfs2 where
      
       * one task is in inode_doinit_with_dentry -> gfs2_getxattr, holds
         isec->lock, and tries to acquire the inode's glock, and
      
       * another task is in do_xmote -> inode_go_inval ->
         selinux_inode_invalidate_secctx, holds the inode's glock, and
         tries to acquire isec->lock.
      Signed-off-by: NAndreas Gruenbacher <agruenba@redhat.com>
      [PM: minor tweaks to keep checkpatch.pl happy]
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      9287aed2
  9. 22 11月, 2016 1 次提交
    • S
      selinux: keep SELinux in sync with new capability definitions · 3322d0d6
      Stephen Smalley 提交于
      When a new capability is defined, SELinux needs to be updated.
      Trigger a build error if a new capability is defined without
      corresponding update to security/selinux/include/classmap.h's
      COMMON_CAP2_PERMS.  This is similar to BUILD_BUG_ON() guards
      in the SELinux nlmsgtab code to ensure that SELinux tracks
      new netlink message types as needed.
      
      Note that there is already a similar build guard in
      security/selinux/hooks.c to detect when more than 64
      capabilities are defined, since that will require adding
      a third capability class to SELinux.
      
      A nicer way to do this would be to extend scripts/selinux/genheaders
      or a similar tool to auto-generate the necessary definitions and code
      for SELinux capability checking from include/uapi/linux/capability.h.
      AppArmor does something similar in its Makefile, although it only
      needs to generate a single table of names.  That is left as future
      work.
      Signed-off-by: NStephen Smalley <sds@tycho.nsa.gov>
      [PM: reformat the description to keep checkpatch.pl happy]
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      3322d0d6
  10. 21 11月, 2016 2 次提交
  11. 16 11月, 2016 2 次提交
  12. 15 11月, 2016 5 次提交
  13. 14 11月, 2016 4 次提交
  14. 11 11月, 2016 4 次提交
    • C
      Smack: ipv6 label match fix · 2e4939f7
      Casey Schaufler 提交于
      The check for a deleted entry in the list of IPv6 host
      addresses was being performed in the wrong place, leading
      to most peculiar results in some cases. This puts the
      check into the right place.
      Signed-off-by: NCasey Schaufler <casey@schaufler-ca.com>
      2e4939f7
    • H
      SMACK: Fix the memory leak in smack_cred_prepare() hook · b437aba8
      Himanshu Shukla 提交于
      Memory leak in smack_cred_prepare()function.
      smack_cred_prepare() hook returns error if there is error in allocating
      memory in smk_copy_rules() or smk_copy_relabel() function.
      If smack_cred_prepare() function returns error then the calling
      function should call smack_cred_free() function for cleanup.
      In smack_cred_free() function first credential is  extracted and
      then all rules are deleted. In smack_cred_prepare() function security
      field is assigned in the end when all function return success. But this
      function may return before and memory will not be freed.
      Signed-off-by: NHimanshu Shukla <himanshu.sh@samsung.com>
      Acked-by: NCasey Schaufler <casey@schaufler-ca.com>
      b437aba8
    • H
      SMACK: Do not apply star label in smack_setprocattr hook · 7128ea15
      Himanshu Shukla 提交于
      Smack prohibits processes from using the star ("*") and web ("@") labels.
      Checks have been added in other functions. In smack_setprocattr()
      hook, only check for web ("@") label has been added and restricted
      from applying web ("@") label.
      Check for star ("*") label should also be added in smack_setprocattr()
      hook. Return error should be "-EINVAL" not "-EPERM" as permission
      is there for setting label but not the label value as star ("*") or
      web ("@").
      Signed-off-by: NHimanshu Shukla <himanshu.sh@samsung.com>
      Acked-by: NCasey Schaufler <casey@schaufler-ca.com>
      7128ea15
    • H
      smack: parse mnt opts after privileges check · 2097f599
      Himanshu Shukla 提交于
      In smack_set_mnt_opts()first the SMACK mount options are being
      parsed and later it is being checked whether the user calling
      mount has CAP_MAC_ADMIN capability.
      This sequence of operationis will allow unauthorized user to add
      SMACK labels in label list and may cause denial of security attack
      by adding many labels by allocating kernel memory by unauthorized user.
      Superblock smack flag is also being set as initialized though function
      may return with EPERM error.
      First check the capability of calling user then set the SMACK attributes
      and smk_flags.
      Signed-off-by: NHimanshu Shukla <himanshu.sh@samsung.com>
      Acked-by: NCasey Schaufler <casey@schaufler-ca.com>
      2097f599
  15. 05 11月, 2016 1 次提交