1. 26 9月, 2021 6 次提交
  2. 14 4月, 2021 2 次提交
    • R
      ima: Add support for measurement with digest lists · 31604143
      Roberto Sassu 提交于
      hulk inclusion
      category: feature
      feature: IMA Digest Lists extension
      bugzilla: 46797
      
      -------------------------------------------------
      
      IMA-Measure creates a new measurement entry every time a file is measured,
      unless the same entry is already in the measurement list.
      
      This patch introduces a new type of measurement list, recognizable by the
      PCR number specified with the new ima_digest_list_pcr= kernel option. This
      type of measurement list includes measurements of digest lists and files
      not found in those lists.
      
      The benefit of this patch is the availability of a predictable PCR that
      can be used to seal data or TPM keys to the OS software. Unlike standard
      measurements, digest list measurements only indicate that files with a
      digest in those lists could have been accessed, but not if and when. With
      standard measurements, however, the chosen PCR is unlikely predictable.
      
      Both standard and digest list measurements can be generated at the same
      time by adding '+' as a prefix to the value of ima_digest_list_pcr=
      (example: with ima_digest_list_pcr=+11, IMA generates standard measurements
      with PCR 10 and digest list measurements with PCR 11).
      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>
      31604143
    • R
      evm: Load EVM key in ima_load_x509() to avoid appraisal · 9a37a4f2
      Roberto Sassu 提交于
      hulk inclusion
      category: feature
      feature: IMA Digest Lists extension
      bugzilla: 46797
      
      ---------------------------
      
      Public keys do not need to be appraised by IMA as the restriction on the
      IMA/EVM keyrings ensures that a key can be loaded only if it is signed with
      a key in the primary or secondary keyring.
      
      However, when evm_load_x509() is called, appraisal is already enabled and
      a valid IMA signature must be added to the EVM key to pass verification.
      
      Since the restriction is applied on both IMA and EVM keyrings, it is safe
      to disable appraisal also when the EVM key is loaded. This patch calls
      evm_load_x509() inside ima_load_x509() if CONFIG_IMA_LOAD_X509 is enabled.
      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>
      9a37a4f2
  3. 04 6月, 2020 1 次提交
  4. 20 4月, 2020 1 次提交
    • R
      ima: Switch to ima_hash_algo for boot aggregate · 6f1a1d10
      Roberto Sassu 提交于
      boot_aggregate is the first entry of IMA measurement list. Its purpose is
      to link pre-boot measurements to IMA measurements. As IMA was designed to
      work with a TPM 1.2, the SHA1 PCR bank was always selected even if a
      TPM 2.0 with support for stronger hash algorithms is available.
      
      This patch first tries to find a PCR bank with the IMA default hash
      algorithm. If it does not find it, it selects the SHA256 PCR bank for
      TPM 2.0 and SHA1 for TPM 1.2. Ultimately, it selects SHA1 also for TPM 2.0
      if the SHA256 PCR bank is not found.
      
      If none of the PCR banks above can be found, boot_aggregate file digest is
      filled with zeros, as for TPM bypass, making it impossible to perform a
      remote attestation of the system.
      
      Cc: stable@vger.kernel.org # 5.1.x
      Fixes: 879b5892 ("tpm: retrieve digest size of unknown algorithms with PCR read")
      Reported-by: NJerry Snitselaar <jsnitsel@redhat.com>
      Suggested-by: NJames Bottomley <James.Bottomley@HansenPartnership.com>
      Signed-off-by: NRoberto Sassu <roberto.sassu@huawei.com>
      Signed-off-by: NMimi Zohar <zohar@linux.ibm.com>
      6f1a1d10
  5. 29 2月, 2020 1 次提交
  6. 23 1月, 2020 1 次提交
    • L
      IMA: Defined delayed workqueue to free the queued keys · 5b3014b9
      Lakshmi Ramasubramanian 提交于
      Keys queued for measurement should be freed if a custom IMA policy
      was not loaded.  Otherwise, the keys will remain queued forever
      consuming kernel memory.
      
      This patch defines a delayed workqueue to handle the above scenario.
      The workqueue handler is setup to execute 5 minutes after IMA
      initialization is completed.
      
      If a custom IMA policy is loaded before the workqueue handler is
      scheduled to execute, the workqueue task is cancelled and any queued keys
      are processed for measurement.  But if a custom policy was not loaded then
      the queued keys are just freed when the delayed workqueue handler is run.
      Signed-off-by: NLakshmi Ramasubramanian <nramas@linux.microsoft.com>
      Reported-by: kernel test robot <rong.a.chen@intel.com> # sleeping
      function called from invalid context
      Reported-by: kbuild test robot <lkp@intel.com> # redefinition of
      ima_init_key_queue() function.
      Signed-off-by: NMimi Zohar <zohar@linux.ibm.com>
      5b3014b9
  7. 20 6月, 2019 1 次提交
  8. 14 6月, 2019 1 次提交
  9. 05 6月, 2019 1 次提交
  10. 13 2月, 2019 1 次提交
    • R
      tpm: pass an array of tpm_extend_digest structures to tpm_pcr_extend() · 0b6cf6b9
      Roberto Sassu 提交于
      Currently, tpm_pcr_extend() accepts as an input only a SHA1 digest.
      
      This patch replaces the hash parameter of tpm_pcr_extend() with an array of
      tpm_digest structures, so that the caller can provide a digest for each PCR
      bank currently allocated in the TPM.
      
      tpm_pcr_extend() will not extend banks for which no digest was provided,
      as it happened before this patch, but instead it requires that callers
      provide the full set of digests. Since the number of digests will always be
      chip->nr_allocated_banks, the count parameter has been removed.
      
      Due to the API change, ima_pcr_extend() and pcrlock() have been modified.
      Since the number of allocated banks is not known in advance, the memory for
      the digests must be dynamically allocated. To avoid performance degradation
      and to avoid that a PCR extend is not done due to lack of memory, the array
      of tpm_digest structures is allocated by the users of the TPM driver at
      initialization time.
      Signed-off-by: NRoberto Sassu <roberto.sassu@huawei.com>
      Reviewed-by: NJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
      Tested-by: NJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
      Tested-by: Mimi Zohar <zohar@linux.ibm.com> (on x86 for TPM 1.2 & PTT TPM 2.0)
      Signed-off-by: NJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
      0b6cf6b9
  11. 13 12月, 2018 1 次提交
    • P
      security: audit and remove any unnecessary uses of module.h · 876979c9
      Paul Gortmaker 提交于
      Historically a lot of these existed because we did not have
      a distinction between what was modular code and what was providing
      support to modules via EXPORT_SYMBOL and friends.  That changed
      when we forked out support for the latter into the export.h file.
      This means we should be able to reduce the usage of module.h
      in code that is obj-y Makefile or bool Kconfig.
      
      The advantage in removing such instances is that module.h itself
      sources about 15 other headers; adding significantly to what we feed
      cpp, and it can obscure what headers we are effectively using.
      
      Since module.h might have been the implicit source for init.h
      (for __init) and for export.h (for EXPORT_SYMBOL) we consider each
      instance for the presence of either and replace as needed.
      
      Cc: James Morris <jmorris@namei.org>
      Cc: "Serge E. Hallyn" <serge@hallyn.com>
      Cc: John Johansen <john.johansen@canonical.com>
      Cc: Mimi Zohar <zohar@linux.ibm.com>
      Cc: Dmitry Kasatkin <dmitry.kasatkin@gmail.com>
      Cc: David Howells <dhowells@redhat.com>
      Cc: linux-security-module@vger.kernel.org
      Cc: linux-integrity@vger.kernel.org
      Cc: keyrings@vger.kernel.org
      Signed-off-by: NPaul Gortmaker <paul.gortmaker@windriver.com>
      Signed-off-by: NJames Morris <james.morris@microsoft.com>
      876979c9
  12. 11 10月, 2018 1 次提交
  13. 28 7月, 2018 2 次提交
  14. 08 1月, 2018 1 次提交
  15. 21 12月, 2016 1 次提交
  16. 14 11月, 2016 1 次提交
  17. 30 6月, 2016 1 次提交
  18. 19 2月, 2016 1 次提交
  19. 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
  20. 22 5月, 2015 3 次提交
  21. 18 11月, 2014 1 次提交
    • D
      ima: load x509 certificate from the kernel · fd5f4e90
      Dmitry Kasatkin 提交于
      Define configuration option to load X509 certificate into the
      IMA trusted kernel keyring. It implements ima_load_x509() hook
      to load X509 certificate into the .ima trusted kernel keyring
      from the root filesystem.
      
      Changes in v3:
      * use ima_policy_flag in ima_get_action()
        ima_load_x509 temporarily clears ima_policy_flag to disable
        appraisal to load key. Use it to skip appraisal rules.
      * Key directory path changed to /etc/keys (Mimi)
      * Expand IMA_LOAD_X509 Kconfig help
      
      Changes in v2:
      * added '__init'
      * use ima_policy_flag to disable appraisal to load keys
      Signed-off-by: NDmitry Kasatkin <d.kasatkin@samsung.com>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      fd5f4e90
  22. 18 9月, 2014 2 次提交
  23. 08 3月, 2014 2 次提交
  24. 03 12月, 2013 2 次提交
    • R
      ima: properly free ima_template_entry structures · a7ed7c60
      Roberto Sassu 提交于
      The new templates management mechanism records information associated
      to an event into an array of 'ima_field_data' structures and makes it
      available through the 'template_data' field of the 'ima_template_entry'
      structure (the element of the measurements list created by IMA).
      
      Since 'ima_field_data' contains dynamically allocated data (which length
      varies depending on the data associated to a selected template field),
      it is not enough to just free the memory reserved for a
      'ima_template_entry' structure if something goes wrong.
      
      This patch creates the new function ima_free_template_entry() which
      walks the array of 'ima_field_data' structures, frees the memory
      referenced by the 'data' pointer and finally the space reserved for
      the 'ima_template_entry' structure. Further, it replaces existing kfree()
      that have a pointer to an 'ima_template_entry' structure as argument
      with calls to the new function.
      
      Fixes: a71dc65d: ima: switch to new template management mechanism
      Signed-off-by: NRoberto Sassu <roberto.sassu@polito.it>
      Signed-off-by: NMimi Zohar <zohar@us.ibm.com>
      a7ed7c60
    • C
      ima: Do not free 'entry' before it is initialized · 09ae6345
      Christoph Paasch 提交于
      7bc5f447 (ima: define new function ima_alloc_init_template() to
      API) moved the initialization of 'entry' in ima_add_boot_aggregate() a
      bit more below, after the if (ima_used_chip).
      
      So, 'entry' is not initialized while being inside this if-block. So, we
      should not attempt to free it.
      
      Found by Coverity (CID: 1131971)
      
      Fixes: 7bc5f447 (ima: define new function ima_alloc_init_template() to API)
      Signed-off-by: NChristoph Paasch <christoph.paasch@uclouvain.be>
      Signed-off-by: NMimi Zohar <zohar@us.ibm.com>
      09ae6345
  25. 01 11月, 2013 1 次提交
    • M
      ima: extend the measurement list to include the file signature · bcbc9b0c
      Mimi Zohar 提交于
      This patch defines a new template called 'ima-sig', which includes
      the file signature in the template data, in addition to the file's
      digest and pathname.
      
      A template is composed of a set of fields.  Associated with each
      field is an initialization and display function.  This patch defines
      a new template field called 'sig', the initialization function
      ima_eventsig_init(), and the display function ima_show_template_sig().
      
      This patch modifies the .field_init() function definition to include
      the 'security.ima' extended attribute and length.
      
      Changelog:
      - remove unused code (Dmitry Kasatkin)
      - avoid calling ima_write_template_field_data() unnecesarily (Roberto Sassu)
      - rename DATA_FMT_SIG to DATA_FMT_HEX
      - cleanup ima_eventsig_init() based on Roberto's comments
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      Signed-off-by: NDmitry Kasatkin <d.kasatkin@samsung.com>
      Signed-off-by: NRoberto Sassu <roberto.sassu@polito.it>
      bcbc9b0c
  26. 26 10月, 2013 3 次提交
    • R
      ima: new templates management mechanism · adf53a77
      Roberto Sassu 提交于
      The original 'ima' template is fixed length, containing the filedata hash
      and pathname.  The filedata hash is limited to 20 bytes (md5/sha1).  The
      pathname is a null terminated string, limited to 255 characters.  To
      overcome these limitations and to add additional file metadata, it is
      necessary to extend the current version of IMA by defining additional
      templates.
      
      The main reason to introduce this feature is that, each time a new
      template is defined, the functions that generate and display the
      measurement list would include the code for handling a new format and,
      thus, would significantly grow over time.
      
      This patch set solves this problem by separating the template management
      from the remaining IMA code. The core of this solution is the definition
      of two new data structures: a template descriptor, to determine which
      information should be included in the measurement list, and a template
      field, to generate and display data of a given type.
      
      To define a new template field, developers define the field identifier
      and implement two functions, init() and show(), respectively to generate
      and display measurement entries.  Initially, this patch set defines the
      following template fields (support for additional data types will be
      added later):
       - 'd': the digest of the event (i.e. the digest of a measured file),
              calculated with the SHA1 or MD5 hash algorithm;
       - 'n': the name of the event (i.e. the file name), with size up to
              255 bytes;
       - 'd-ng': the digest of the event, calculated with an arbitrary hash
                 algorithm (field format: [<hash algo>:]digest, where the digest
                 prefix is shown only if the hash algorithm is not SHA1 or MD5);
       - 'n-ng': the name of the event, without size limitations.
      
      Defining a new template descriptor requires specifying the template format,
      a string of field identifiers separated by the '|' character.  This patch
      set defines the following template descriptors:
       - "ima": its format is 'd|n';
       - "ima-ng" (default): its format is 'd-ng|n-ng'
      
      Further details about the new template architecture can be found in
      Documentation/security/IMA-templates.txt.
      
      Changelog:
      - don't defer calling ima_init_template() - Mimi
      - don't define ima_lookup_template_desc() until used - Mimi
      - squashed with documentation patch - Mimi
      Signed-off-by: NRoberto Sassu <roberto.sassu@polito.it>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      adf53a77
    • R
      ima: define new function ima_alloc_init_template() to API · 7bc5f447
      Roberto Sassu 提交于
      Instead of allocating and initializing the template entry from multiple
      places (eg. boot aggregate, violation, and regular measurements), this
      patch defines a new function called ima_alloc_init_template().  The new
      function allocates and initializes the measurement entry with the inode
      digest and the filename.
      
      In respect to the current behavior, it truncates the file name passed
      in the 'filename' argument if the latter's size is greater than 255 bytes
      and the passed file descriptor is NULL.
      
      Changelog:
      - initialize 'hash' variable for non TPM case - Mimi
      - conform to expectation for 'iint' to be defined as a pointer. - Mimi
      - add missing 'file' dependency for recalculating file hash. - Mimi
      Signed-off-by: NRoberto Sassu <roberto.sassu@polito.it>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      7bc5f447
    • R
      ima: pass the filename argument up to ima_add_template_entry() · 9803d413
      Roberto Sassu 提交于
      Pass the filename argument to ima_add_template_entry() in order to
      eliminate a dependency on template specific data (third argument of
      integrity_audit_msg).
      
      This change is required because, with the new template management
      mechanism, the generation of a new measurement entry will be performed
      by new specific functions (introduced in next patches) and the current IMA
      code will not be aware anymore of how data is stored in the entry payload.
      Signed-off-by: NRoberto Sassu <roberto.sassu@polito.it>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      9803d413