1. 05 7月, 2022 1 次提交
  2. 06 12月, 2021 1 次提交
  3. 14 4月, 2021 9 次提交
    • R
      evm: Propagate choice of HMAC algorithm in evm_crypto.c · c79f6084
      Roberto Sassu 提交于
      hulk inclusion
      category: feature
      feature: IMA Digest Lists extension
      bugzilla: 46797
      
      -------------------------------------------------
      
      Commit 5feeb611 ("evm: Allow non-SHA1 digital signatures") introduced
      the possibility to use different hash algorithm for signatures, but kept
      the algorithm for the HMAC hard-coded (SHA1). Switching to a different
      algorithm for HMAC would require to change the code in different places.
      
      This patch introduces a new global variable called evm_hash_algo, and
      consistently uses it whenever EVM perform HMAC-related operations. It also
      introduces a new kernel configuration option called CONFIG_EVM_DEFAULT_HASH
      so that evm_hash_algo can be defined at kernel compilation time.
      Signed-off-by: NRoberto Sassu <roberto.sassu@huawei.com>
      Acked-by: NHanjun Guo <guohanjun@huawei.com>
      Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
      Signed-off-by: NTianxing Zhang <zhangtianxing3@huawei.com>
      Reviewed-by: NJason Yan <yanaijie@huawei.com>
      Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
      c79f6084
    • R
      evm: Extend evm= with x509. allow_metadata_writes and complete values · 1b8602d0
      Roberto Sassu 提交于
      hulk inclusion
      category: feature
      feature: IMA Digest Lists extension
      bugzilla: 46797
      
      -------------------------------------------------
      
      Introduce three new values for evm= kernel option:
      
      x509: enable EVM by setting x509 flag;
      allow_metadata_writes: permit metadata modificatons;
      complete: don't allow further changes of the EVM status.
      Signed-off-by: NRoberto Sassu <roberto.sassu@huawei.com>
      Signed-off-by: NTianxing Zhang <zhangtianxing3@huawei.com>
      Reviewed-by: NJason Yan <yanaijie@huawei.com>
      Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
      1b8602d0
    • R
      evm: Reset status even when security.evm is modified · 9ce5f5ac
      Roberto Sassu 提交于
      hulk inclusion
      category: feature
      feature: IMA Digest Lists extension
      bugzilla: 46797
      
      -------------------------------------------------
      
      Without resetting the status when security.evm is modified, IMA appraisal
      would continue to use the cached result and wouldn't detect whether the
      meta_immutable requirement is still satisfied.
      
      This patch calls evm_reset_status() in the post hooks when security.evm is
      modified.
      Signed-off-by: NRoberto Sassu <roberto.sassu@huawei.com>
      Signed-off-by: NTianxing Zhang <zhangtianxing3@huawei.com>
      Reviewed-by: NJason Yan <yanaijie@huawei.com>
      Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
      9ce5f5ac
    • R
      evm: Add support for digest lists of metadata · f51e0ce9
      Roberto Sassu 提交于
      hulk inclusion
      category: feature
      feature: IMA Digest Lists extension
      bugzilla: 46797
      
      -------------------------------------------------
      
      This patch adds support in EVM to verify file metadata digest with digest
      lists. Metadata digest, calculated in the same way as for portable
      signatures, is searched in the digest lists only if the file has the
      security.evm xattr with type EVM_IMA_XATTR_DIGEST_LIST.
      
      If the found digest is marked as immutable, content and xattr/attr updates
      are not allowed. Otherwise, after verification, the existing security.evm
      with the new type will be replaced with an HMAC, similarly to non-portable
      signatures.
      Signed-off-by: NRoberto Sassu <roberto.sassu@huawei.com>
      Signed-off-by: NTianxing Zhang <zhangtianxing3@huawei.com>
      Reviewed-by: NJason Yan <yanaijie@huawei.com>
      Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
      f51e0ce9
    • R
      evm: Allow setxattr() and setattr() for unmodified metadata · ce02fabf
      Roberto Sassu 提交于
      hulk inclusion
      category: feature
      feature: IMA Digest Lists extension
      bugzilla: 46797
      
      ---------------------------
      
      With the patch to allow xattr/attr operations if a portable signature
      verification fails, cp and tar can copy all xattrs/attrs so that at the
      end of the process verification succeeds.
      
      However, it might happen that the xattrs/attrs are already set to the
      correct value (taken at signing time) and signature verification succeeds
      before the copy has completed. For example, an archive might contains files
      owned by root and the archive is extracted by root.
      
      Then, since portable signatures are immutable, all subsequent operations
      fail (e.g. fchown()), even if the operation is legitimate (does not alter
      the current value).
      
      This patch avoids this problem by reporting successful operation to user
      space when that operation does not alter the current value of xattrs/attrs.
      Signed-off-by: NRoberto Sassu <roberto.sassu@huawei.com>
      Reviewed-by: NJason Yan <yanaijie@huawei.com>
      Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
      ce02fabf
    • R
      evm: Allow xattr/attr operations for portable signatures · 475be7fa
      Roberto Sassu 提交于
      hulk inclusion
      category: feature
      feature: IMA Digest Lists extension
      bugzilla: 46797
      
      ---------------------------
      
      If files with portable signatures are copied from one location to another
      or are extracted from an archive, verification can temporarily fail until
      all xattrs/attrs are set in the destination. Only portable signatures may
      be moved or copied from one file to another, as they don't depend on
      system-specific information such as the inode generation. Instead portable
      signatures must include security.ima.
      
      Unlike other security.evm types, EVM portable signatures are also
      immutable. Thus, it wouldn't be a problem to allow xattr/attr operations
      when verification fails, as portable signatures will never be replaced with
      the HMAC on possibly corrupted xattrs/attrs.
      
      This patch first introduces a new integrity status called
      INTEGRITY_FAIL_IMMUTABLE, that allows callers of
      evm_verify_current_integrity() to detect that a portable signature didn't
      pass verification and then adds an exception in evm_protect_xattr() and
      evm_inode_setattr() for this status and returns 0 instead of -EPERM.
      Signed-off-by: NRoberto Sassu <roberto.sassu@huawei.com>
      Reviewed-by: NMimi Zohar <zohar@linux.ibm.com>
      Reviewed-by: NJason Yan <yanaijie@huawei.com>
      Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
      475be7fa
    • R
      evm: Ignore INTEGRITY_NOLABEL/INTEGRITY_NOXATTRS if conditions are safe · f74c413c
      Roberto Sassu 提交于
      hulk inclusion
      category: feature
      feature: IMA Digest Lists extension
      bugzilla: 46797
      
      ---------------------------
      
      When a file is being created, LSMs can set the initial label with the
      inode_init_security hook. If no HMAC key is loaded, the new file will have
      LSM xattrs but not the HMAC. It is also possible that the file remains
      without protected xattrs after creation if no active LSM provided it.
      
      Unfortunately, EVM will deny any further metadata operation on new files,
      as evm_protect_xattr() will always return the INTEGRITY_NOLABEL error, or
      INTEGRITY_NOXATTRS if no protected xattrs exist. This would limit the
      usability of EVM when only a public key is loaded, as commands such as cp
      or tar with the option to preserve xattrs won't work.
      
      This patch ignores these errors when they won't be an issue, if no HMAC key
      is loaded and cannot be loaded in the future (which can be enforced by
      setting the EVM_SETUP_COMPLETE initialization flag).
      Signed-off-by: NRoberto Sassu <roberto.sassu@huawei.com>
      Reviewed-by: NJason Yan <yanaijie@huawei.com>
      Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
      f74c413c
    • R
      evm: Introduce evm_status_revalidate() · 1c8c2846
      Roberto Sassu 提交于
      hulk inclusion
      category: feature
      feature: IMA Digest Lists extension
      bugzilla: 46797
      
      ---------------------------
      
      When EVM_ALLOW_METADATA_WRITES is set, EVM allows any operation on
      metadata. Its main purpose is to allow users to freely set metadata when it
      is protected by a portable signature, until an HMAC key is loaded.
      
      However, callers of evm_verifyxattr() are not notified about metadata
      changes and continue to rely on the last status returned by the function.
      For example IMA, since it caches the appraisal result, will not call again
      evm_verifyxattr() until the appraisal flags are cleared, and will grant
      access to the file even if there was a metadata operation that made the
      portable signature invalid.
      
      This patch introduces evm_status_revalidate(), which callers of
      evm_verifyxattr() can use in their xattr post hooks to determine whether
      re-validation is necessary and to do the proper actions. IMA calls it in
      its xattr post hooks to reset the appraisal flags, so that the EVM status
      is re-evaluated after a metadata operation.
      
      Lastly, this patch also adds a call to evm_reset_status() in
      evm_inode_post_setattr() to invalidate the cached EVM status after a
      setattr operation.
      Signed-off-by: NRoberto Sassu <roberto.sassu@huawei.com>
      Reviewed-by: NJason Yan <yanaijie@huawei.com>
      Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
      1c8c2846
    • R
      evm: Execute evm_inode_init_security() only when an HMAC key is loaded · 92aa9c3e
      Roberto Sassu 提交于
      hulk inclusion
      category: feature
      feature: IMA Digest Lists extension
      bugzilla: 46797
      
      ---------------------------
      
      evm_inode_init_security() requires an HMAC key to calculate the HMAC on
      initial xattrs provided by LSMs. However, it checks generically whether a
      key has been loaded, including also public keys, which is not correct as
      public keys are not suitable to calculate the HMAC.
      
      Originally, support for signature verification was introduced to verify a
      possibly immutable initial ram disk, when no new files are created, and to
      switch to HMAC for the root filesystem. By that time, an HMAC key should
      have been loaded and usable to calculate HMACs for new files.
      
      More recently support for requiring an HMAC key was removed from the
      kernel, so that signature verification can be used alone. Since this is a
      legitimate use case, evm_inode_init_security() should not return an error
      when no HMAC key has been loaded.
      
      This patch fixes this problem by replacing the evm_key_loaded() check with
      a check of the EVM_INIT_HMAC flag in evm_initialized.
      
      Cc: stable@vger.kernel.org # 4.5.x
      Fixes: 26ddabfe ("evm: enable EVM when X509 certificate is loaded")
      Signed-off-by: NRoberto Sassu <roberto.sassu@huawei.com>
      Reviewed-by: NMimi Zohar <zohar@linux.ibm.com>
      Reviewed-by: NJason Yan <yanaijie@huawei.com>
      Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
      92aa9c3e
  4. 16 9月, 2020 1 次提交
  5. 09 9月, 2020 1 次提交
  6. 08 5月, 2020 1 次提交
    • M
      evm: Fix RCU list related warnings · 770f6058
      Madhuparna Bhowmik 提交于
      This patch fixes the following warning and few other instances of
      traversal of evm_config_xattrnames list:
      
      [   32.848432] =============================
      [   32.848707] WARNING: suspicious RCU usage
      [   32.848966] 5.7.0-rc1-00006-ga8d5875ce5f0b #1 Not tainted
      [   32.849308] -----------------------------
      [   32.849567] security/integrity/evm/evm_main.c:231 RCU-list traversed in non-reader section!!
      
      Since entries are only added to the list and never deleted, use
      list_for_each_entry_lockless() instead of list_for_each_entry_rcu for
      traversing the list.  Also, add a relevant comment in evm_secfs.c to
      indicate this fact.
      Reported-by: Nkernel test robot <lkp@intel.com>
      Suggested-by: NPaul E. McKenney <paulmck@kernel.org>
      Signed-off-by: NMadhuparna Bhowmik <madhuparnabhowmik10@gmail.com>
      Acked-by: Paul E. McKenney <paulmck@kernel.org> (RCU viewpoint)
      Signed-off-by: NMimi Zohar <zohar@linux.ibm.com>
      770f6058
  7. 29 2月, 2020 1 次提交
  8. 01 7月, 2019 1 次提交
    • T
      integrity: Introduce struct evm_xattr · 650b29db
      Thiago Jung Bauermann 提交于
      Even though struct evm_ima_xattr_data includes a fixed-size array to hold a
      SHA1 digest, most of the code ignores the array and uses the struct to mean
      "type indicator followed by data of unspecified size" and tracks the real
      size of what the struct represents in a separate length variable.
      
      The only exception to that is the EVM code, which correctly uses the
      definition of struct evm_ima_xattr_data.
      
      So make this explicit in the code by removing the length specification from
      the array in struct evm_ima_xattr_data. Also, change the name of the
      element from digest to data since in most places the array doesn't hold a
      digest.
      
      A separate struct evm_xattr is introduced, with the original definition of
      evm_ima_xattr_data to be used in the places that actually expect that
      definition, specifically the EVM HMAC code.
      Signed-off-by: NThiago Jung Bauermann <bauerman@linux.ibm.com>
      Signed-off-by: NMimi Zohar <zohar@linux.ibm.com>
      650b29db
  9. 05 6月, 2019 1 次提交
  10. 05 2月, 2019 1 次提交
  11. 13 12月, 2018 1 次提交
    • P
      security: integrity: make evm_main explicitly non-modular · 3aafb1fb
      Paul Gortmaker 提交于
      The Makefile/Kconfig entry controlling compilation of this code is:
      
      obj-$(CONFIG_EVM) += evm.o
      evm-y := evm_main.o evm_crypto.o evm_secfs.o
      
      security/integrity/evm/Kconfig:config EVM
      security/integrity/evm/Kconfig: bool "EVM support"
      
      ...meaning that it currently is not being built as a module by anyone.
      
      Lets remove the couple traces of modular infrastructure use, so that
      when reading the driver there is no doubt it is builtin-only.
      
      We also delete the MODULE_LICENSE tag etc. since all that information
      is already contained at the top of the file in the comments.
      
      Cc: Mimi Zohar <zohar@linux.ibm.com>
      Cc: James Morris <jmorris@namei.org>
      Cc: "Serge E. Hallyn" <serge@hallyn.com>
      Cc: linux-ima-devel@lists.sourceforge.net
      Cc: linux-security-module@vger.kernel.org
      Signed-off-by: NPaul Gortmaker <paul.gortmaker@windriver.com>
      Signed-off-by: NJames Morris <james.morris@microsoft.com>
      3aafb1fb
  12. 18 7月, 2018 1 次提交
  13. 19 5月, 2018 2 次提交
    • M
      EVM: Allow runtime modification of the set of verified xattrs · fa516b66
      Matthew Garrett 提交于
      Sites may wish to provide additional metadata alongside files in order
      to make more fine-grained security decisions[1]. The security of this is
      enhanced if this metadata is protected, something that EVM makes
      possible. However, the kernel cannot know about the set of extended
      attributes that local admins may wish to protect, and hardcoding this
      policy in the kernel makes it difficult to change over time and less
      convenient for distributions to enable.
      
      This patch adds a new /sys/kernel/security/integrity/evm/evm_xattrs node,
      which can be read to obtain the current set of EVM-protected extended
      attributes or written to in order to add new entries. Extending this list
      will not change the validity of any existing signatures provided that the
      file in question does not have any of the additional extended attributes -
      missing xattrs are skipped when calculating the EVM hash.
      
      [1] For instance, a package manager could install information about the
      package uploader in an additional extended attribute. Local LSM policy
      could then be associated with that extended attribute in order to
      restrict the privileges available to packages from less trusted
      uploaders.
      Signed-off-by: NMatthew Garrett <mjg59@google.com>
      Reviewed-by: NJames Morris <james.morris@microsoft.com>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      fa516b66
    • M
      EVM: turn evm_config_xattrnames into a list · 21af7663
      Matthew Garrett 提交于
      Use a list of xattrs rather than an array - this makes it easier to
      extend the list at runtime.
      Signed-off-by: NMatthew Garrett <mjg59@google.com>
      Reviewed-by: NJames Morris <james.morris@microsoft.com>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      21af7663
  14. 25 3月, 2018 1 次提交
  15. 23 3月, 2018 2 次提交
  16. 12 12月, 2017 2 次提交
    • M
      EVM: Add support for portable signature format · 50b97748
      Matthew Garrett 提交于
      The EVM signature includes the inode number and (optionally) the
      filesystem UUID, making it impractical to ship EVM signatures in
      packages. This patch adds a new portable format intended to allow
      distributions to include EVM signatures. It is identical to the existing
      format but hardcodes the inode and generation numbers to 0 and does not
      include the filesystem UUID even if the kernel is configured to do so.
      
      Removing the inode means that the metadata and signature from one file
      could be copied to another file without invalidating it. This is avoided
      by ensuring that an IMA xattr is present during EVM validation.
      
      Portable signatures are intended to be immutable - ie, they will never
      be transformed into HMACs.
      
      Based on earlier work by Dmitry Kasatkin and Mikhail Kurinnoi.
      Signed-off-by: NMatthew Garrett <mjg59@google.com>
      Cc: Dmitry Kasatkin <dmitry.kasatkin@huawei.com>
      Cc: Mikhail Kurinnoi <viewizard@viewizard.com>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      50b97748
    • M
      EVM: Allow userland to permit modification of EVM-protected metadata · ae1ba167
      Matthew Garrett 提交于
      When EVM is enabled it forbids modification of metadata protected by
      EVM unless there is already a valid EVM signature. If any modification
      is made, the kernel will then generate a new EVM HMAC. However, this
      does not map well on use cases which use only asymmetric EVM signatures,
      as in this scenario the kernel is unable to generate new signatures.
      
      This patch extends the /sys/kernel/security/evm interface to allow
      userland to request that modification of these xattrs be permitted. This
      is only permitted if no keys have already been loaded. In this
      configuration, modifying the metadata will invalidate the EVM appraisal
      on the file in question. This allows packaging systems to write out new
      files, set the relevant extended attributes and then move them into
      place.
      
      There's also some refactoring of the use of evm_initialized in order to
      avoid heading down codepaths that assume there's a key available.
      Signed-off-by: NMatthew Garrett <mjg59@google.com>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      ae1ba167
  17. 09 11月, 2017 1 次提交
  18. 02 3月, 2017 1 次提交
  19. 14 11月, 2016 1 次提交
  20. 08 10月, 2016 1 次提交
  21. 11 4月, 2016 2 次提交
  22. 12 2月, 2016 1 次提交
  23. 15 12月, 2015 3 次提交
  24. 24 11月, 2015 1 次提交
    • D
      integrity: define '.evm' as a builtin 'trusted' keyring · f4dc3778
      Dmitry Kasatkin 提交于
      Require all keys added to the EVM keyring be signed by an
      existing trusted key on the system trusted keyring.
      
      This patch also switches IMA to use integrity_init_keyring().
      
      Changes in v3:
      * Added 'init_keyring' config based variable to skip initializing
        keyring instead of using  __integrity_init_keyring() wrapper.
      * Added dependency back to CONFIG_IMA_TRUSTED_KEYRING
      
      Changes in v2:
      * Replace CONFIG_EVM_TRUSTED_KEYRING with IMA and EVM common
        CONFIG_INTEGRITY_TRUSTED_KEYRING configuration option
      * Deprecate CONFIG_IMA_TRUSTED_KEYRING but keep it for config
        file compatibility. (Mimi Zohar)
      Signed-off-by: NDmitry Kasatkin <dmitry.kasatkin@huawei.com>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      f4dc3778
  25. 22 5月, 2015 2 次提交