1. 03 11月, 2021 1 次提交
  2. 20 10月, 2021 2 次提交
  3. 15 10月, 2021 1 次提交
  4. 14 10月, 2021 1 次提交
  5. 12 10月, 2021 1 次提交
  6. 30 9月, 2021 1 次提交
    • P
      selinux: remove the SELinux lockdown implementation · f5d0e5e9
      Paul Moore 提交于
      NOTE: This patch intentionally omits any "Fixes:" metadata or stable
      tagging since it removes a SELinux access control check; while
      removing the control point is the right thing to do moving forward,
      removing it in stable kernels could be seen as a regression.
      
      The original SELinux lockdown implementation in 59438b46
      ("security,lockdown,selinux: implement SELinux lockdown") used the
      current task's credentials as both the subject and object in the
      SELinux lockdown hook, selinux_lockdown().  Unfortunately that
      proved to be incorrect in a number of cases as the core kernel was
      calling the LSM lockdown hook in places where the credentials from
      the "current" task_struct were not the correct credentials to use
      in the SELinux access check.
      
      Attempts were made to resolve this by adding a credential pointer
      to the LSM lockdown hook as well as suggesting that the single hook
      be split into two: one for user tasks, one for kernel tasks; however
      neither approach was deemed acceptable by Linus.  Faced with the
      prospect of either changing the subj/obj in the access check to a
      constant context (likely the kernel's label) or removing the SELinux
      lockdown check entirely, the SELinux community decided that removing
      the lockdown check was preferable.
      
      The supporting changes to the general LSM layer are left intact, this
      patch only removes the SELinux implementation.
      Acked-by: NOndrej Mosnacek <omosnace@redhat.com>
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      f5d0e5e9
  7. 29 9月, 2021 1 次提交
    • C
      selinux: enable genfscon labeling for securityfs · 8a764ef1
      Christian Göttsche 提交于
      Add support for genfscon per-file labeling of securityfs files.
      This allows for separate labels and thereby access control for
      different files. For example a genfscon statement
      
          genfscon securityfs /integrity/ima/policy \
      	system_u:object_r:ima_policy_t:s0
      
      will set a private label to the IMA policy file and thus allow to
      control the ability to set the IMA policy. Setting labels directly
      with setxattr(2), e.g. by chcon(1) or setfiles(8), is still not
      supported.
      Signed-off-by: NChristian Göttsche <cgzones@googlemail.com>
      [PM: line width fixes in the commit description]
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      8a764ef1
  8. 24 9月, 2021 1 次提交
    • P
      selinux,smack: fix subjective/objective credential use mixups · a3727a8b
      Paul Moore 提交于
      Jann Horn reported a problem with commit eb1231f7 ("selinux:
      clarify task subjective and objective credentials") where some LSM
      hooks were attempting to access the subjective credentials of a task
      other than the current task.  Generally speaking, it is not safe to
      access another task's subjective credentials and doing so can cause
      a number of problems.
      
      Further, while looking into the problem, I realized that Smack was
      suffering from a similar problem brought about by a similar commit
      1fb057dc ("smack: differentiate between subjective and objective
      task credentials").
      
      This patch addresses this problem by restoring the use of the task's
      objective credentials in those cases where the task is other than the
      current executing task.  Not only does this resolve the problem
      reported by Jann, it is arguably the correct thing to do in these
      cases.
      
      Cc: stable@vger.kernel.org
      Fixes: eb1231f7 ("selinux: clarify task subjective and objective credentials")
      Fixes: 1fb057dc ("smack: differentiate between subjective and objective task credentials")
      Reported-by: NJann Horn <jannh@google.com>
      Acked-by: NEric W. Biederman <ebiederm@xmission.com>
      Acked-by: NCasey Schaufler <casey@schaufler-ca.com>
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      a3727a8b
  9. 20 9月, 2021 1 次提交
    • P
      selinux: add support for the io_uring access controls · 740b0341
      Paul Moore 提交于
      This patch implements two new io_uring access controls, specifically
      support for controlling the io_uring "personalities" and
      IORING_SETUP_SQPOLL.  Controlling the sharing of io_urings themselves
      is handled via the normal file/inode labeling and sharing mechanisms.
      
      The io_uring { override_creds } permission restricts which domains
      the subject domain can use to override it's own credentials.
      Granting a domain the io_uring { override_creds } permission allows
      it to impersonate another domain in io_uring operations.
      
      The io_uring { sqpoll } permission restricts which domains can create
      asynchronous io_uring polling threads.  This is important from a
      security perspective as operations queued by this asynchronous thread
      inherit the credentials of the thread creator by default; if an
      io_uring is shared across process/domain boundaries this could result
      in one domain impersonating another.  Controlling the creation of
      sqpoll threads, and the sharing of io_urings across processes, allow
      policy authors to restrict the ability of one domain to impersonate
      another via io_uring.
      
      As a quick summary, this patch adds a new object class with two
      permissions:
      
       io_uring { override_creds sqpoll }
      
      These permissions can be seen in the two simple policy statements
      below:
      
        allow domA_t domB_t : io_uring { override_creds };
        allow domA_t self : io_uring { sqpoll };
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      740b0341
  10. 29 7月, 2021 1 次提交
  11. 15 7月, 2021 1 次提交
    • A
      selinux: return early for possible NULL audit buffers · 893c47d1
      Austin Kim 提交于
      audit_log_start() may return NULL in below cases:
      
        - when audit is not initialized.
        - when audit backlog limit exceeds.
      
      After the call to audit_log_start() is made and then possible NULL audit
      buffer argument is passed to audit_log_*() functions,
      audit_log_*() functions return immediately in case of a NULL audit buffer
      argument.
      
      But it is optimal to return early when audit_log_start() returns NULL,
      because it is not necessary for audit_log_*() functions to be called with
      NULL audit buffer argument.
      
      So add exception handling for possible NULL audit buffers where
      return value can be handled from callers.
      Signed-off-by: NAustin Kim <austin.kim@lge.com>
      [PM: tweak subject line]
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      893c47d1
  12. 12 6月, 2021 2 次提交
  13. 15 5月, 2021 1 次提交
  14. 23 4月, 2021 1 次提交
  15. 23 3月, 2021 3 次提交
    • P
      selinux: clarify task subjective and objective credentials · eb1231f7
      Paul Moore 提交于
      SELinux has a function, task_sid(), which returns the task's
      objective credentials, but unfortunately is used in a few places
      where the subjective task credentials should be used.  Most notably
      in the new security_task_getsecid_subj() LSM hook.
      
      This patch fixes this and attempts to make things more obvious by
      introducing a new function, task_sid_subj(), and renaming the
      existing task_sid() function to task_sid_obj().
      
      This patch also adds an interesting function in task_sid_binder().
      The task_sid_binder() function has a comment which hopefully
      describes it's reason for being, but it basically boils down to the
      simple fact that we can't safely access another task's subjective
      credentials so in the case of binder we need to stick with the
      objective credentials regardless.
      Reviewed-by: NRichard Guy Briggs <rgb@redhat.com>
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      eb1231f7
    • P
      lsm: separate security_task_getsecid() into subjective and objective variants · 4ebd7651
      Paul Moore 提交于
      Of the three LSMs that implement the security_task_getsecid() LSM
      hook, all three LSMs provide the task's objective security
      credentials.  This turns out to be unfortunate as most of the hook's
      callers seem to expect the task's subjective credentials, although
      a small handful of callers do correctly expect the objective
      credentials.
      
      This patch is the first step towards fixing the problem: it splits
      the existing security_task_getsecid() hook into two variants, one
      for the subjective creds, one for the objective creds.
      
        void security_task_getsecid_subj(struct task_struct *p,
      				   u32 *secid);
        void security_task_getsecid_obj(struct task_struct *p,
      				  u32 *secid);
      
      While this patch does fix all of the callers to use the correct
      variant, in order to keep this patch focused on the callers and to
      ease review, the LSMs continue to use the same implementation for
      both hooks.  The net effect is that this patch should not change
      the behavior of the kernel in any way, it will be up to the latter
      LSM specific patches in this series to change the hook
      implementations and return the correct credentials.
      
      Acked-by: Mimi Zohar <zohar@linux.ibm.com> (IMA)
      Acked-by: NCasey Schaufler <casey@schaufler-ca.com>
      Reviewed-by: NRichard Guy Briggs <rgb@redhat.com>
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      4ebd7651
    • O
      lsm,selinux: add new hook to compare new mount to an existing mount · 69c4a42d
      Olga Kornievskaia 提交于
      Add a new hook that takes an existing super block and a new mount
      with new options and determines if new options confict with an
      existing mount or not.
      
      A filesystem can use this new hook to determine if it can share
      the an existing superblock with a new superblock for the new mount.
      Signed-off-by: NOlga Kornievskaia <kolga@netapp.com>
      Acked-by: NAnna Schumaker <Anna.Schumaker@Netapp.com>
      [PM: tweak the subject line, fix tab/space problems]
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      69c4a42d
  16. 09 3月, 2021 1 次提交
    • V
      selinux: Allow context mounts for unpriviliged overlayfs · 7fa2e79a
      Vivek Goyal 提交于
      Now overlayfs allow unpriviliged mounts. That is root inside a non-init
      user namespace can mount overlayfs. This is being added in 5.11 kernel.
      
      Giuseppe tried to mount overlayfs with option "context" and it failed
      with error -EACCESS.
      
      $ su test
      $ unshare -rm
      $ mkdir -p lower upper work merged
      $ mount -t overlay -o lowerdir=lower,workdir=work,upperdir=upper,userxattr,context='system_u:object_r:container_file_t:s0' none merged
      
      This fails with -EACCESS. It works if option "-o context" is not specified.
      
      Little debugging showed that selinux_set_mnt_opts() returns -EACCESS.
      
      So this patch adds "overlay" to the list, where it is fine to specific
      context from non init_user_ns.
      Reported-by: NGiuseppe Scrivano <gscrivan@redhat.com>
      Signed-off-by: NVivek Goyal <vgoyal@redhat.com>
      [PM: trimmed the changelog from the description]
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      7fa2e79a
  17. 24 1月, 2021 3 次提交
    • C
      commoncap: handle idmapped mounts · 71bc356f
      Christian Brauner 提交于
      When interacting with user namespace and non-user namespace aware
      filesystem capabilities the vfs will perform various security checks to
      determine whether or not the filesystem capabilities can be used by the
      caller, whether they need to be removed and so on. The main
      infrastructure for this resides in the capability codepaths but they are
      called through the LSM security infrastructure even though they are not
      technically an LSM or optional. This extends the existing security hooks
      security_inode_removexattr(), security_inode_killpriv(),
      security_inode_getsecurity() to pass down the mount's user namespace and
      makes them aware of idmapped mounts.
      
      In order to actually get filesystem capabilities from disk the
      capability infrastructure exposes the get_vfs_caps_from_disk() helper.
      For user namespace aware filesystem capabilities a root uid is stored
      alongside the capabilities.
      
      In order to determine whether the caller can make use of the filesystem
      capability or whether it needs to be ignored it is translated according
      to the superblock's user namespace. If it can be translated to uid 0
      according to that id mapping the caller can use the filesystem
      capabilities stored on disk. If we are accessing the inode that holds
      the filesystem capabilities through an idmapped mount we map the root
      uid according to the mount's user namespace. Afterwards the checks are
      identical to non-idmapped mounts: reading filesystem caps from disk
      enforces that the root uid associated with the filesystem capability
      must have a mapping in the superblock's user namespace and that the
      caller is either in the same user namespace or is a descendant of the
      superblock's user namespace. For filesystems that are mountable inside
      user namespace the caller can just mount the filesystem and won't
      usually need to idmap it. If they do want to idmap it they can create an
      idmapped mount and mark it with a user namespace they created and which
      is thus a descendant of s_user_ns. For filesystems that are not
      mountable inside user namespaces the descendant rule is trivially true
      because the s_user_ns will be the initial user namespace.
      
      If the initial user namespace is passed nothing changes so non-idmapped
      mounts will see identical behavior as before.
      
      Link: https://lore.kernel.org/r/20210121131959.646623-11-christian.brauner@ubuntu.com
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: David Howells <dhowells@redhat.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: linux-fsdevel@vger.kernel.org
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Acked-by: NJames Morris <jamorris@linux.microsoft.com>
      Signed-off-by: NChristian Brauner <christian.brauner@ubuntu.com>
      71bc356f
    • T
      xattr: handle idmapped mounts · c7c7a1a1
      Tycho Andersen 提交于
      When interacting with extended attributes the vfs verifies that the
      caller is privileged over the inode with which the extended attribute is
      associated. For posix access and posix default extended attributes a uid
      or gid can be stored on-disk. Let the functions handle posix extended
      attributes on idmapped mounts. If the inode is accessed through an
      idmapped mount we need to map it according to the mount's user
      namespace. Afterwards the checks are identical to non-idmapped mounts.
      This has no effect for e.g. security xattrs since they don't store uids
      or gids and don't perform permission checks on them like posix acls do.
      
      Link: https://lore.kernel.org/r/20210121131959.646623-10-christian.brauner@ubuntu.com
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: David Howells <dhowells@redhat.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: linux-fsdevel@vger.kernel.org
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Reviewed-by: NJames Morris <jamorris@linux.microsoft.com>
      Signed-off-by: NTycho Andersen <tycho@tycho.pizza>
      Signed-off-by: NChristian Brauner <christian.brauner@ubuntu.com>
      c7c7a1a1
    • C
      inode: make init and permission helpers idmapped mount aware · 21cb47be
      Christian Brauner 提交于
      The inode_owner_or_capable() helper determines whether the caller is the
      owner of the inode or is capable with respect to that inode. Allow it to
      handle idmapped mounts. If the inode is accessed through an idmapped
      mount it according to the mount's user namespace. Afterwards the checks
      are identical to non-idmapped mounts. If the initial user namespace is
      passed nothing changes so non-idmapped mounts will see identical
      behavior as before.
      
      Similarly, allow the inode_init_owner() helper to handle idmapped
      mounts. It initializes a new inode on idmapped mounts by mapping the
      fsuid and fsgid of the caller from the mount's user namespace. If the
      initial user namespace is passed nothing changes so non-idmapped mounts
      will see identical behavior as before.
      
      Link: https://lore.kernel.org/r/20210121131959.646623-7-christian.brauner@ubuntu.com
      Cc: Christoph Hellwig <hch@lst.de>
      Cc: David Howells <dhowells@redhat.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: linux-fsdevel@vger.kernel.org
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Reviewed-by: NJames Morris <jamorris@linux.microsoft.com>
      Signed-off-by: NChristian Brauner <christian.brauner@ubuntu.com>
      21cb47be
  18. 15 1月, 2021 1 次提交
    • D
      selinux: teach SELinux about anonymous inodes · 29cd6591
      Daniel Colascione 提交于
      This change uses the anon_inodes and LSM infrastructure introduced in
      the previous patches to give SELinux the ability to control
      anonymous-inode files that are created using the new
      anon_inode_getfd_secure() function.
      
      A SELinux policy author detects and controls these anonymous inodes by
      adding a name-based type_transition rule that assigns a new security
      type to anonymous-inode files created in some domain. The name used
      for the name-based transition is the name associated with the
      anonymous inode for file listings --- e.g., "[userfaultfd]" or
      "[perf_event]".
      
      Example:
      
      type uffd_t;
      type_transition sysadm_t sysadm_t : anon_inode uffd_t "[userfaultfd]";
      allow sysadm_t uffd_t:anon_inode { create };
      
      (The next patch in this series is necessary for making userfaultfd
      support this new interface.  The example above is just
      for exposition.)
      Signed-off-by: NDaniel Colascione <dancol@google.com>
      Signed-off-by: NLokesh Gidra <lokeshgidra@google.com>
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      29cd6591
  19. 13 1月, 2021 1 次提交
  20. 05 1月, 2021 2 次提交
  21. 04 12月, 2020 1 次提交
  22. 24 11月, 2020 2 次提交
  23. 13 11月, 2020 1 次提交
  24. 06 11月, 2020 1 次提交
    • P
      selinux: fix inode_doinit_with_dentry() LABEL_INVALID error handling · 200ea5a2
      Paul Moore 提交于
      A previous fix, commit 83370b31 ("selinux: fix error initialization
      in inode_doinit_with_dentry()"), changed how failures were handled
      before a SELinux policy was loaded.  Unfortunately that patch was
      potentially problematic for two reasons: it set the isec->initialized
      state without holding a lock, and it didn't set the inode's SELinux
      label to the "default" for the particular filesystem.  The later can
      be a problem if/when a later attempt to revalidate the inode fails
      and SELinux reverts to the existing inode label.
      
      This patch should restore the default inode labeling that existed
      before the original fix, without affecting the LABEL_INVALID marking
      such that revalidation will still be attempted in the future.
      
      Fixes: 83370b31 ("selinux: fix error initialization in inode_doinit_with_dentry()")
      Reported-by: NSven Schnelle <svens@linux.ibm.com>
      Tested-by: NSven Schnelle <svens@linux.ibm.com>
      Reviewed-by: NOndrej Mosnacek <omosnace@redhat.com>
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      200ea5a2
  25. 28 10月, 2020 1 次提交
  26. 05 10月, 2020 3 次提交
  27. 16 9月, 2020 1 次提交
  28. 27 8月, 2020 1 次提交
  29. 25 8月, 2020 1 次提交
  30. 24 8月, 2020 1 次提交