1. 29 9月, 2022 1 次提交
  2. 06 7月, 2022 2 次提交
  3. 27 4月, 2022 1 次提交
  4. 28 1月, 2022 1 次提交
  5. 06 12月, 2021 1 次提交
  6. 09 4月, 2021 1 次提交
  7. 12 1月, 2021 2 次提交
  8. 05 10月, 2020 3 次提交
  9. 16 9月, 2020 1 次提交
  10. 27 8月, 2020 1 次提交
  11. 25 8月, 2020 1 次提交
  12. 24 8月, 2020 2 次提交
  13. 21 8月, 2020 1 次提交
    • S
      selinux: permit removing security.selinux xattr before policy load · 9530a3e0
      Stephen Smalley 提交于
      Currently SELinux denies attempts to remove the security.selinux xattr
      always, even when permissive or no policy is loaded.  This was originally
      motivated by the view that all files should be labeled, even if that label
      is unlabeled_t, and we shouldn't permit files that were once labeled to
      have their labels removed entirely.  This however prevents removing
      SELinux xattrs in the case where one "disables" SELinux by not loading
      a policy (e.g. a system where runtime disable is removed and selinux=0
      was not specified).  Allow removing the xattr before SELinux is
      initialized.  We could conceivably permit it even after initialization
      if permissive, or introduce a separate permission check here.
      Signed-off-by: NStephen Smalley <stephen.smalley.work@gmail.com>
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      9530a3e0
  14. 24 6月, 2020 1 次提交
  15. 21 5月, 2020 1 次提交
    • E
      exec: Factor security_bprm_creds_for_exec out of security_bprm_set_creds · b8bff599
      Eric W. Biederman 提交于
      Today security_bprm_set_creds has several implementations:
      apparmor_bprm_set_creds, cap_bprm_set_creds, selinux_bprm_set_creds,
      smack_bprm_set_creds, and tomoyo_bprm_set_creds.
      
      Except for cap_bprm_set_creds they all test bprm->called_set_creds and
      return immediately if it is true.  The function cap_bprm_set_creds
      ignores bprm->calld_sed_creds entirely.
      
      Create a new LSM hook security_bprm_creds_for_exec that is called just
      before prepare_binprm in __do_execve_file, resulting in a LSM hook
      that is called exactly once for the entire of exec.  Modify the bits
      of security_bprm_set_creds that only want to be called once per exec
      into security_bprm_creds_for_exec, leaving only cap_bprm_set_creds
      behind.
      
      Remove bprm->called_set_creds all of it's former users have been moved
      to security_bprm_creds_for_exec.
      
      Add or upate comments a appropriate to bring them up to date and
      to reflect this change.
      
      Link: https://lkml.kernel.org/r/87v9kszrzh.fsf_-_@x220.int.ebiederm.orgAcked-by: NLinus Torvalds <torvalds@linux-foundation.org>
      Acked-by: Casey Schaufler <casey@schaufler-ca.com> # For the LSM and Smack bits
      Reviewed-by: NKees Cook <keescook@chromium.org>
      Signed-off-by: N"Eric W. Biederman" <ebiederm@xmission.com>
      b8bff599
  16. 19 5月, 2020 2 次提交
    • D
      selinux: Implement the watch_key security hook · 3e412ccc
      David Howells 提交于
      Implement the watch_key security hook to make sure that a key grants the
      caller View permission in order to set a watch on a key.
      
      For the moment, the watch_devices security hook is left unimplemented as
      it's not obvious what the object should be since the queue is global and
      didn't previously exist.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Acked-by: NStephen Smalley <sds@tycho.nsa.gov>
      Reviewed-by: NJames Morris <jamorris@linux.microsoft.com>
      3e412ccc
    • D
      keys: Make the KEY_NEED_* perms an enum rather than a mask · 8c0637e9
      David Howells 提交于
      Since the meaning of combining the KEY_NEED_* constants is undefined, make
      it so that you can't do that by turning them into an enum.
      
      The enum is also given some extra values to represent special
      circumstances, such as:
      
       (1) The '0' value is reserved and causes a warning to trap the parameter
           being unset.
      
       (2) The key is to be unlinked and we require no permissions on it, only
           the keyring, (this replaces the KEY_LOOKUP_FOR_UNLINK flag).
      
       (3) An override due to CAP_SYS_ADMIN.
      
       (4) An override due to an instantiation token being present.
      
       (5) The permissions check is being deferred to later key_permission()
           calls.
      
      The extra values give the opportunity for LSMs to audit these situations.
      
      [Note: This really needs overhauling so that lookup_user_key() tells
       key_task_permission() and the LSM what operation is being done and leaves
       it to those functions to decide how to map that onto the available
       permits.  However, I don't really want to make these change in the middle
       of the notifications patchset.]
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      cc: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
      cc: Paul Moore <paul@paul-moore.com>
      cc: Stephen Smalley <stephen.smalley.work@gmail.com>
      cc: Casey Schaufler <casey@schaufler-ca.com>
      cc: keyrings@vger.kernel.org
      cc: selinux@vger.kernel.org
      8c0637e9
  17. 01 5月, 2020 1 次提交
  18. 23 2月, 2020 1 次提交
  19. 12 2月, 2020 1 次提交
  20. 10 2月, 2020 3 次提交
  21. 08 2月, 2020 2 次提交
  22. 06 2月, 2020 1 次提交
  23. 20 1月, 2020 1 次提交
    • S
      selinux: fix regression introduced by move_mount(2) syscall · 98aa0034
      Stephen Smalley 提交于
      commit 2db154b3 ("vfs: syscall: Add move_mount(2) to move mounts around")
      introduced a new move_mount(2) system call and a corresponding new LSM
      security_move_mount hook but did not implement this hook for any existing
      LSM.  This creates a regression for SELinux with respect to consistent
      checking of mounts; the existing selinux_mount hook checks mounton
      permission to the mount point path.  Provide a SELinux hook
      implementation for move_mount that applies this same check for
      consistency.  In the future we may wish to add a new move_mount
      filesystem permission and check as well, but this addresses
      the immediate regression.
      
      Fixes: 2db154b3 ("vfs: syscall: Add move_mount(2) to move mounts around")
      Signed-off-by: NStephen Smalley <sds@tycho.nsa.gov>
      Reviewed-by: NOndrej Mosnacek <omosnace@redhat.com>
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      98aa0034
  24. 17 1月, 2020 2 次提交
  25. 11 1月, 2020 4 次提交
    • O
      selinux: reorder hooks to make runtime disable less broken · cfff75d8
      Ondrej Mosnacek 提交于
      Commit b1d9e6b0 ("LSM: Switch to lists of hooks") switched the LSM
      infrastructure to use per-hook lists, which meant that removing the
      hooks for a given module was no longer atomic. Even though the commit
      clearly documents that modules implementing runtime revmoval of hooks
      (only SELinux attempts this madness) need to take special precautions to
      avoid race conditions, SELinux has never addressed this.
      
      By inserting an artificial delay between the loop iterations of
      security_delete_hooks() (I used 100 ms), booting to a state where
      SELinux is enabled, but policy is not yet loaded, and running these
      commands:
      
          while true; do ping -c 1 <some IP>; done &
          echo -n 1 >/sys/fs/selinux/disable
          kill %1
          wait
      
      ...I was able to trigger NULL pointer dereferences in various places. I
      also have a report of someone getting panics on a stock RHEL-8 kernel
      after setting SELINUX=disabled in /etc/selinux/config and rebooting
      (without adding "selinux=0" to kernel command-line).
      
      Reordering the SELinux hooks such that those that allocate structures
      are removed last seems to prevent these panics. It is very much possible
      that this doesn't make the runtime disable completely race-free, but at
      least it makes the operation much less fragile.
      
      Cc: stable@vger.kernel.org
      Fixes: b1d9e6b0 ("LSM: Switch to lists of hooks")
      Signed-off-by: NOndrej Mosnacek <omosnace@redhat.com>
      Reviewed-by: NStephen Smalley <sds@tycho.nsa.gov>
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      cfff75d8
    • O
      selinux: treat atomic flags more carefully · 65cddd50
      Ondrej Mosnacek 提交于
      The disabled/enforcing/initialized flags are all accessed concurrently
      by threads so use the appropriate accessors that ensure atomicity and
      document that it is expected.
      
      Use smp_load/acquire...() helpers (with memory barriers) for the
      initialized flag, since it gates access to the rest of the state
      structures.
      
      Note that the disabled flag is currently not used for anything other
      than avoiding double disable, but it will be used for bailing out of
      hooks once security_delete_hooks() is removed.
      Signed-off-by: NOndrej Mosnacek <omosnace@redhat.com>
      Acked-by: NStephen Smalley <sds@tycho.nsa.gov>
      Reviewed-by: NKees Cook <keescook@chromium.org>
      Reviewed-by: NJames Morris <jamorris@linux.microsoft.com>
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      65cddd50
    • S
      selinux: make default_noexec read-only after init · b78b7d59
      Stephen Smalley 提交于
      SELinux checks whether VM_EXEC is set in the VM_DATA_DEFAULT_FLAGS
      during initialization and saves the result in default_noexec for use
      in its mmap and mprotect hook function implementations to decide
      whether to apply EXECMEM, EXECHEAP, EXECSTACK, and EXECMOD checks.
      Mark default_noexec as ro_after_init to prevent later clearing it
      and thereby disabling these checks.  It is only set legitimately from
      init code.
      Signed-off-by: NStephen Smalley <sds@tycho.nsa.gov>
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      b78b7d59
    • H
      selinux: remove redundant msg_msg_alloc_security · b82f3f68
      Huaisheng Ye 提交于
      selinux_msg_msg_alloc_security only calls msg_msg_alloc_security but
      do nothing else. And also msg_msg_alloc_security is just used by the
      former.
      
      Remove the redundant function to simplify the code.
      Signed-off-by: NHuaisheng Ye <yehs1@lenovo.com>
      Acked-by: NStephen Smalley <sds@tycho.nsa.gov>
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      b82f3f68
  26. 07 1月, 2020 1 次提交
  27. 19 12月, 2019 1 次提交
    • S
      selinux: clean up selinux_enabled/disabled/enforcing_boot · 6c5a682e
      Stephen Smalley 提交于
      Rename selinux_enabled to selinux_enabled_boot to make it clear that
      it only reflects whether SELinux was enabled at boot.  Replace the
      references to it in the MAC_STATUS audit log in sel_write_enforce()
      with hardcoded "1" values because this code is only reachable if SELinux
      is enabled and does not change its value, and update the corresponding
      MAC_STATUS audit log in sel_write_disable().  Stop clearing
      selinux_enabled in selinux_disable() since it is not used outside of
      initialization code that runs before selinux_disable() can be reached.
      Mark both selinux_enabled_boot and selinux_enforcing_boot as __initdata
      since they are only used in initialization code.
      
      Wrap the disabled field in the struct selinux_state with
      CONFIG_SECURITY_SELINUX_DISABLE since it is only used for
      runtime disable.
      Signed-off-by: NStephen Smalley <sds@tycho.nsa.gov>
      Signed-off-by: NPaul Moore <paul@paul-moore.com>
      6c5a682e