1. 13 11月, 2021 1 次提交
    • P
      net,lsm,selinux: revert the security_sctp_assoc_established() hook · 32a370ab
      Paul Moore 提交于
      This patch reverts two prior patches, e7310c94
      ("security: implement sctp_assoc_established hook in selinux") and
      7c2ef024 ("security: add sctp_assoc_established hook"), which
      create the security_sctp_assoc_established() LSM hook and provide a
      SELinux implementation.  Unfortunately these two patches were merged
      without proper review (the Reviewed-by and Tested-by tags from
      Richard Haines were for previous revisions of these patches that
      were significantly different) and there are outstanding objections
      from the SELinux maintainers regarding these patches.
      
      Work is currently ongoing to correct the problems identified in the
      reverted patches, as well as others that have come up during review,
      but it is unclear at this point in time when that work will be ready
      for inclusion in the mainline kernel.  In the interest of not keeping
      objectionable code in the kernel for multiple weeks, and potentially
      a kernel release, we are reverting the two problematic patches.
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      32a370ab
  2. 07 11月, 2021 1 次提交
  3. 04 11月, 2021 3 次提交
  4. 03 11月, 2021 8 次提交
  5. 02 11月, 2021 1 次提交
  6. 29 10月, 2021 1 次提交
  7. 22 10月, 2021 2 次提交
  8. 21 10月, 2021 1 次提交
  9. 20 10月, 2021 3 次提交
    • E
      ucounts: Move get_ucounts from cred_alloc_blank to key_change_session_keyring · 5ebcbe34
      Eric W. Biederman 提交于
      Setting cred->ucounts in cred_alloc_blank does not make sense.  The
      uid and user_ns are deliberately not set in cred_alloc_blank but
      instead the setting is delayed until key_change_session_keyring.
      
      So move dealing with ucounts into key_change_session_keyring as well.
      
      Unfortunately that movement of get_ucounts adds a new failure mode to
      key_change_session_keyring.  I do not see anything stopping the parent
      process from calling setuid and changing the relevant part of it's
      cred while keyctl_session_to_parent is running making it fundamentally
      necessary to call get_ucounts in key_change_session_keyring.  Which
      means that the new failure mode cannot be avoided.
      
      A failure of key_change_session_keyring results in a single threaded
      parent keeping it's existing credentials.  Which results in the parent
      process not being able to access the session keyring and whichever
      keys are in the new keyring.
      
      Further get_ucounts is only expected to fail if the number of bits in
      the refernece count for the structure is too few.
      
      Since the code has no other way to report the failure of get_ucounts
      and because such failures are not expected to be common add a WARN_ONCE
      to report this problem to userspace.
      
      Between the WARN_ONCE and the parent process not having access to
      the keys in the new session keyring I expect any failure of get_ucounts
      will be noticed and reported and we can find another way to handle this
      condition.  (Possibly by just making ucounts->count an atomic_long_t).
      
      Cc: stable@vger.kernel.org
      Fixes: 905ae01c ("Add a reference to ucounts for each cred")
      Link: https://lkml.kernel.org/r/7k0ias0uf.fsf_-_@disp2133Tested-by: NYu Zhao <yuzhao@google.com>
      Reviewed-by: NAlexey Gladkov <legion@kernel.org>
      Signed-off-by: N"Eric W. Biederman" <ebiederm@xmission.com>
      5ebcbe34
    • V
      security: Return xattr name from security_dentry_init_security() · 15bf3239
      Vivek Goyal 提交于
      Right now security_dentry_init_security() only supports single security
      label and is used by SELinux only. There are two users of this hook,
      namely ceph and nfs.
      
      NFS does not care about xattr name. Ceph hardcodes the xattr name to
      security.selinux (XATTR_NAME_SELINUX).
      
      I am making changes to fuse/virtiofs to send security label to virtiofsd
      and I need to send xattr name as well. I also hardcoded the name of
      xattr to security.selinux.
      
      Stephen Smalley suggested that it probably is a good idea to modify
      security_dentry_init_security() to also return name of xattr so that
      we can avoid this hardcoding in the callers.
      
      This patch adds a new parameter "const char **xattr_name" to
      security_dentry_init_security() and LSM puts the name of xattr
      too if caller asked for it (xattr_name != NULL).
      Signed-off-by: NVivek Goyal <vgoyal@redhat.com>
      Reviewed-by: NJeff Layton <jlayton@kernel.org>
      Reviewed-by: NChristian Brauner <christian.brauner@ubuntu.com>
      Acked-by: NJames Morris <jamorris@linux.microsoft.com>
      [PM: fixed typos in the commit description]
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      15bf3239
    • P
      selinux: fix a sock regression in selinux_ip_postroute_compat() · 1c73213b
      Paul Moore 提交于
      Unfortunately we can't rely on nf_hook_state->sk being the proper
      originating socket so revert to using skb_to_full_sk(skb).
      
      Fixes: 1d1e1ded ("selinux: make better use of the nf_hook_state passed to the NF hooks")
      Reported-by: NLinux Kernel Functional Testing <lkft@linaro.org>
      Suggested-by: NFlorian Westphal <fw@strlen.de>
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      1c73213b
  10. 15 10月, 2021 2 次提交
    • T
      binder: use cred instead of task for selinux checks · 52f88693
      Todd Kjos 提交于
      Since binder was integrated with selinux, it has passed
      'struct task_struct' associated with the binder_proc
      to represent the source and target of transactions.
      The conversion of task to SID was then done in the hook
      implementations. It turns out that there are race conditions
      which can result in an incorrect security context being used.
      
      Fix by using the 'struct cred' saved during binder_open and pass
      it to the selinux subsystem.
      
      Cc: stable@vger.kernel.org # 5.14 (need backport for earlier stables)
      Fixes: 79af7307 ("Add security hooks to binder and implement the hooks for SELinux.")
      Suggested-by: NJann Horn <jannh@google.com>
      Signed-off-by: NTodd Kjos <tkjos@google.com>
      Acked-by: NCasey Schaufler <casey@schaufler-ca.com>
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      52f88693
    • K
      LSM: Avoid warnings about potentially unused hook variables · 86dd9fd5
      Kees Cook 提交于
      Building with W=1 shows many unused const variable warnings. These can
      be silenced, as we're well aware of their being potentially unused:
      
      ./include/linux/lsm_hook_defs.h:36:18: error: 'ptrace_access_check_default' defined but not used [-Werror=unused-const-variable=]
         36 | LSM_HOOK(int, 0, ptrace_access_check, struct task_struct *child,
            |                  ^~~~~~~~~~~~~~~~~~~
      security/security.c:706:32: note: in definition of macro 'LSM_RET_DEFAULT'
        706 | #define LSM_RET_DEFAULT(NAME) (NAME##_default)
            |                                ^~~~
      security/security.c:711:9: note: in expansion of macro 'DECLARE_LSM_RET_DEFAULT_int'
        711 |         DECLARE_LSM_RET_DEFAULT_##RET(DEFAULT, NAME)
            |         ^~~~~~~~~~~~~~~~~~~~~~~~
      ./include/linux/lsm_hook_defs.h:36:1: note: in expansion of macro 'LSM_HOOK'
         36 | LSM_HOOK(int, 0, ptrace_access_check, struct task_struct *child,
            | ^~~~~~~~
      
      Cc: James Morris <jmorris@namei.org>
      Cc: "Serge E. Hallyn" <serge@hallyn.com>
      Cc: Paul Moore <paul@paul-moore.com>
      Cc: Casey Schaufler <casey@schaufler-ca.com>
      Cc: KP Singh <kpsingh@chromium.org>
      Cc: linux-security-module@vger.kernel.org
      Reported-by: Nkernel test robot <lkp@intel.com>
      Link: https://lore.kernel.org/linux-mm/202110131608.zms53FPR-lkp@intel.com/
      Fixes: 98e828a0 ("security: Refactor declaration of LSM hooks")
      Signed-off-by: NKees Cook <keescook@chromium.org>
      Acked-by: NJames Morris <jamorris@linux.microsoft.com>
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      86dd9fd5
  11. 14 10月, 2021 3 次提交
  12. 12 10月, 2021 3 次提交
  13. 10 10月, 2021 5 次提交
  14. 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
  15. 29 9月, 2021 2 次提交
  16. 25 9月, 2021 3 次提交