Skip to content
Snippets Groups Projects
  1. Dec 15, 2022
  2. Dec 14, 2022
  3. Dec 13, 2022
  4. Dec 12, 2022
  5. Dec 08, 2022
  6. Nov 28, 2022
    • Tianjia Zhang's avatar
      ima: Fix hash dependency to correct algorithm · b6018af4
      Tianjia Zhang authored
      
      Commit d2825fa9 ("crypto: sm3,sm4 - move into crypto directory") moves
      the SM3 and SM4 stand-alone library and the algorithm implementation for
      the Crypto API into the same directory, and the corresponding relationship
      of Kconfig is modified, CONFIG_CRYPTO_SM3/4 corresponds to the stand-alone
      library of SM3/4, and CONFIG_CRYPTO_SM3/4_GENERIC corresponds to the
      algorithm implementation for the Crypto API. Therefore, it is necessary
      for this module to depend on the correct algorithm.
      
      Fixes: d2825fa9 ("crypto: sm3,sm4 - move into crypto directory")
      Cc: Jason A. Donenfeld <Jason@zx2c4.com>
      Cc: stable@vger.kernel.org # v5.19+
      Signed-off-by: default avatarTianjia Zhang <tianjia.zhang@linux.alibaba.com>
      Signed-off-by: default avatarMimi Zohar <zohar@linux.ibm.com>
      b6018af4
  7. Nov 25, 2022
    • Al Viro's avatar
      use less confusing names for iov_iter direction initializers · de4eda9d
      Al Viro authored
      
      READ/WRITE proved to be actively confusing - the meanings are
      "data destination, as used with read(2)" and "data source, as
      used with write(2)", but people keep interpreting those as
      "we read data from it" and "we write data to it", i.e. exactly
      the wrong way.
      
      Call them ITER_DEST and ITER_SOURCE - at least that is harder
      to misinterpret...
      
      Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
      de4eda9d
  8. Nov 18, 2022
  9. Nov 16, 2022
    • Wang Weiyang's avatar
      device_cgroup: Roll back to original exceptions after copy failure · e68bfbd3
      Wang Weiyang authored
      
      When add the 'a *:* rwm' entry to devcgroup A's whitelist, at first A's
      exceptions will be cleaned and A's behavior is changed to
      DEVCG_DEFAULT_ALLOW. Then parent's exceptions will be copyed to A's
      whitelist. If copy failure occurs, just return leaving A to grant
      permissions to all devices. And A may grant more permissions than
      parent.
      
      Backup A's whitelist and recover original exceptions after copy
      failure.
      
      Cc: stable@vger.kernel.org
      Fixes: 4cef7299 ("device_cgroup: add proper checking when changing default behavior")
      Signed-off-by: default avatarWang Weiyang <wangweiyang2@huawei.com>
      Reviewed-by: default avatarAristeu Rozanski <aris@redhat.com>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      e68bfbd3
    • Kees Cook's avatar
      LSM: Better reporting of actual LSMs at boot · 86ef3c73
      Kees Cook authored
      
      Enhance the details reported by "lsm.debug" in several ways:
      
      - report contents of "security="
      - report contents of "CONFIG_LSM"
      - report contents of "lsm="
      - report any early LSM details
      - whitespace-align the output of similar phases for easier visual parsing
      - change "disabled" to more accurate "skipped"
      - explain what "skipped" and "ignored" mean in a parenthetical
      
      Upgrade the "security= is ignored" warning from pr_info to pr_warn,
      and include full arguments list to make the cause even more clear.
      
      Replace static "Security Framework initializing" pr_info with specific
      list of the resulting order of enabled LSMs.
      
      For example, if the kernel is built with:
      
      CONFIG_SECURITY_SELINUX=y
      CONFIG_SECURITY_APPARMOR=y
      CONFIG_SECURITY_LOADPIN=y
      CONFIG_SECURITY_YAMA=y
      CONFIG_SECURITY_SAFESETID=y
      CONFIG_SECURITY_LOCKDOWN_LSM=y
      CONFIG_SECURITY_LANDLOCK=y
      CONFIG_INTEGRITY=y
      CONFIG_BPF_LSM=y
      CONFIG_DEFAULT_SECURITY_APPARMOR=y
      CONFIG_LSM="landlock,lockdown,yama,loadpin,safesetid,integrity,selinux,
                  smack,tomoyo,apparmor,bpf"
      
      Booting without options will show:
      
      LSM: initializing lsm=lockdown,capability,landlock,yama,loadpin,
           safesetid,integrity,selinux,bpf
      landlock: Up and running.
      Yama: becoming mindful.
      LoadPin: ready to pin (currently not enforcing)
      SELinux:  Initializing.
      LSM support for eBPF active
      
      Boot with "lsm.debug" will show:
      
      LSM: legacy security= *unspecified*
      LSM: CONFIG_LSM=landlock,lockdown,yama,loadpin,safesetid,integrity,
                      selinux,smack,tomoyo,apparmor,bpf
      LSM: boot arg lsm= *unspecified*
      LSM:   early started: lockdown (enabled)
      LSM:   first ordered: capability (enabled)
      LSM: builtin ordered: landlock (enabled)
      LSM: builtin ignored: lockdown (not built into kernel)
      LSM: builtin ordered: yama (enabled)
      LSM: builtin ordered: loadpin (enabled)
      LSM: builtin ordered: safesetid (enabled)
      LSM: builtin ordered: integrity (enabled)
      LSM: builtin ordered: selinux (enabled)
      LSM: builtin ignored: smack (not built into kernel)
      LSM: builtin ignored: tomoyo (not built into kernel)
      LSM: builtin ordered: apparmor (enabled)
      LSM: builtin ordered: bpf (enabled)
      LSM: exclusive chosen:   selinux
      LSM: exclusive disabled: apparmor
      LSM: initializing lsm=lockdown,capability,landlock,yama,loadpin,
                            safesetid,integrity,selinux,bpf
      LSM: cred blob size       = 32
      LSM: file blob size       = 16
      LSM: inode blob size      = 72
      LSM: ipc blob size        = 8
      LSM: msg_msg blob size    = 4
      LSM: superblock blob size = 80
      LSM: task blob size       = 8
      LSM: initializing capability
      LSM: initializing landlock
      landlock: Up and running.
      LSM: initializing yama
      Yama: becoming mindful.
      LSM: initializing loadpin
      LoadPin: ready to pin (currently not enforcing)
      LSM: initializing safesetid
      LSM: initializing integrity
      LSM: initializing selinux
      SELinux:  Initializing.
      LSM: initializing bpf
      LSM support for eBPF active
      
      And some examples of how the lsm.debug ordering report changes...
      
      With "lsm.debug security=selinux":
      
      LSM: legacy security=selinux
      LSM: CONFIG_LSM=landlock,lockdown,yama,loadpin,safesetid,integrity,
                      selinux,smack,tomoyo,apparmor,bpf
      LSM: boot arg lsm= *unspecified*
      LSM:   early started: lockdown (enabled)
      LSM:   first ordered: capability (enabled)
      LSM: security=selinux disabled: apparmor (only one legacy major LSM)
      LSM: builtin ordered: landlock (enabled)
      LSM: builtin ignored: lockdown (not built into kernel)
      LSM: builtin ordered: yama (enabled)
      LSM: builtin ordered: loadpin (enabled)
      LSM: builtin ordered: safesetid (enabled)
      LSM: builtin ordered: integrity (enabled)
      LSM: builtin ordered: selinux (enabled)
      LSM: builtin ignored: smack (not built into kernel)
      LSM: builtin ignored: tomoyo (not built into kernel)
      LSM: builtin ordered: apparmor (disabled)
      LSM: builtin ordered: bpf (enabled)
      LSM: exclusive chosen:   selinux
      LSM: initializing lsm=lockdown,capability,landlock,yama,loadpin,
      		      safesetid,integrity,selinux,bpf
      
      With "lsm.debug lsm=integrity,selinux,loadpin,crabability,bpf,
                          loadpin,loadpin":
      
      LSM: legacy security= *unspecified*
      LSM: CONFIG_LSM=landlock,lockdown,yama,loadpin,safesetid,integrity,
                      selinux,smack,tomoyo,apparmor,bpf
      LSM: boot arg lsm=integrity,selinux,loadpin,capability,bpf,loadpin,
      		  loadpin
      LSM:   early started: lockdown (enabled)
      LSM:   first ordered: capability (enabled)
      LSM: cmdline ordered: integrity (enabled)
      LSM: cmdline ordered: selinux (enabled)
      LSM: cmdline ordered: loadpin (enabled)
      LSM: cmdline ignored: crabability (not built into kernel)
      LSM: cmdline ordered: bpf (enabled)
      LSM: cmdline skipped: apparmor (not in requested order)
      LSM: cmdline skipped: yama (not in requested order)
      LSM: cmdline skipped: safesetid (not in requested order)
      LSM: cmdline skipped: landlock (not in requested order)
      LSM: exclusive chosen:   selinux
      LSM: initializing lsm=lockdown,capability,integrity,selinux,loadpin,bpf
      
      Cc: Paul Moore <paul@paul-moore.com>
      Cc: James Morris <jmorris@namei.org>
      Cc: "Serge E. Hallyn" <serge@hallyn.com>
      Cc: linux-security-module@vger.kernel.org
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Acked-by: default avatarCasey Schaufler <casey@schaufler-ca.com>
      Acked-by: default avatarMickaël Salaün <mic@digikod.net>
      [PM: line wrapped commit description]
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      86ef3c73
    • Xiu Jianfeng's avatar
      ima: Fix misuse of dereference of pointer in template_desc_init_fields() · 25369175
      Xiu Jianfeng authored
      
      The input parameter @fields is type of struct ima_template_field ***, so
      when allocates array memory for @fields, the size of element should be
      sizeof(**field) instead of sizeof(*field).
      
      Actually the original code would not cause any runtime error, but it's
      better to make it logically right.
      
      Fixes: adf53a77 ("ima: new templates management mechanism")
      Signed-off-by: default avatarXiu Jianfeng <xiujianfeng@huawei.com>
      Reviewed-by: default avatarRoberto Sassu <roberto.sassu@huawei.com>
      Signed-off-by: default avatarMimi Zohar <zohar@linux.ibm.com>
      25369175
    • GUO Zihua's avatar
      integrity: Fix memory leakage in keyring allocation error path · 39419ef7
      GUO Zihua authored
      
      Key restriction is allocated in integrity_init_keyring(). However, if
      keyring allocation failed, it is not freed, causing memory leaks.
      
      Fixes: 2b6aa412 ("KEYS: Use structure to capture key restriction function and data")
      Signed-off-by: default avatarGUO Zihua <guozihua@huawei.com>
      Signed-off-by: default avatarMimi Zohar <zohar@linux.ibm.com>
      39419ef7
  10. Nov 09, 2022
  11. Nov 05, 2022
    • Paul Moore's avatar
      lsm: make security_socket_getpeersec_stream() sockptr_t safe · b10b9c34
      Paul Moore authored
      
      Commit 4ff09db1 ("bpf: net: Change sk_getsockopt() to take the
      sockptr_t argument") made it possible to call sk_getsockopt()
      with both user and kernel address space buffers through the use of
      the sockptr_t type.  Unfortunately at the time of conversion the
      security_socket_getpeersec_stream() LSM hook was written to only
      accept userspace buffers, and in a desire to avoid having to change
      the LSM hook the commit author simply passed the sockptr_t's
      userspace buffer pointer.  Since the only sk_getsockopt() callers
      at the time of conversion which used kernel sockptr_t buffers did
      not allow SO_PEERSEC, and hence the
      security_socket_getpeersec_stream() hook, this was acceptable but
      also very fragile as future changes presented the possibility of
      silently passing kernel space pointers to the LSM hook.
      
      There are several ways to protect against this, including careful
      code review of future commits, but since relying on code review to
      catch bugs is a recipe for disaster and the upstream eBPF maintainer
      is "strongly against defensive programming", this patch updates the
      LSM hook, and all of the implementations to support sockptr_t and
      safely handle both user and kernel space buffers.
      
      Acked-by: default avatarCasey Schaufler <casey@schaufler-ca.com>
      Acked-by: default avatarJohn Johansen <john.johansen@canonical.com>
      Signed-off-by: default avatarPaul Moore <paul@paul-moore.com>
      b10b9c34
  12. Nov 03, 2022
    • Roberto Sassu's avatar
      ima: Fix memory leak in __ima_inode_hash() · 8c1d6a05
      Roberto Sassu authored
      
      Commit f3cc6b25 ("ima: always measure and audit files in policy") lets
      measurement or audit happen even if the file digest cannot be calculated.
      
      As a result, iint->ima_hash could have been allocated despite
      ima_collect_measurement() returning an error.
      
      Since ima_hash belongs to a temporary inode metadata structure, declared
      at the beginning of __ima_inode_hash(), just add a kfree() call if
      ima_collect_measurement() returns an error different from -ENOMEM (in that
      case, ima_hash should not have been allocated).
      
      Cc: stable@vger.kernel.org
      Fixes: 280fe836 ("ima: Always return a file measurement in ima_file_hash()")
      Signed-off-by: default avatarRoberto Sassu <roberto.sassu@huawei.com>
      Signed-off-by: default avatarMimi Zohar <zohar@linux.ibm.com>
      8c1d6a05
  13. Nov 02, 2022
  14. Nov 01, 2022
  15. Oct 28, 2022
  16. Oct 26, 2022
  17. Oct 25, 2022
  18. Oct 20, 2022
    • Christian Brauner's avatar
      evm: remove evm_xattr_acl_change() · e10796b8
      Christian Brauner authored
      
      The security and integrity infrastructure has dedicated hooks now so
      evm_xattr_acl_change() is dead code. Before this commit the callchain was:
      
      evm_protect_xattr()
      -> evm_xattr_change()
         -> evm_xattr_acl_change()
      
      where evm_protect_xattr() was hit from evm_inode_setxattr() and
      evm_inode_removexattr(). But now we have evm_inode_set_acl() and
      evm_inode_remove_acl() and have switched over the vfs to rely on the posix
      acl api so the code isn't hit anymore.
      
      Suggested-by: default avatarPaul Moore <paul@paul-moore.com>
      Signed-off-by: default avatarChristian Brauner (Microsoft) <brauner@kernel.org>
      e10796b8
Loading