1. 26 9月, 2021 10 次提交
  2. 17 7月, 2021 1 次提交
  3. 14 4月, 2021 5 次提交
    • R
      ima: Add support for appraisal with digest lists · a44c2ae6
      Roberto Sassu 提交于
      hulk inclusion
      category: feature
      feature: IMA Digest Lists extension
      bugzilla: 46797
      
      -------------------------------------------------
      
      IMA-Appraise grants access to files with a valid signature or with actual
      file digest equal to the digest included in security.ima.
      
      This patch adds support for appraisal based on digest lists. Instead of
      using the reference value from security.ima, this patch checks if the
      calculated file digest is included in the uploaded digest lists.
      
      This functionality must be explicitly enabled by providing one of the
      following values for the ima_appraise_digest_list= kernel option:
      
      - digest: this mode enables appraisal verification with digest lists until
        EVM is initialized; after that, EVM verification must be successful even
        if the file digest is found in a digest list;
      
      - digest-nometadata: this mode enables appraisal verification with digest
        lists even after EVM has been initialized; files without security.evm are
        allowed if the digest of the content is found in the digest list, and
        security.evm is created with current values of xattrs (trust at first
        use); all files created in this way will have the new security.ima type
        EVM_IMA_XATTR_DIGEST_LIST; they can be accessed later only if this mode
        has been selected.
      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>
      a44c2ae6
    • 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
      ima: Introduce new hook DIGEST_LIST_CHECK · a810bfd8
      Roberto Sassu 提交于
      hulk inclusion
      category: feature
      feature: IMA Digest Lists extension
      bugzilla: 46797
      
      -------------------------------------------------
      
      This patch introduces a new hook called DIGEST_LIST_CHECK to measure
      and appraise digest lists in addition to executables and shared libraries,
      without including the FILE_CHECK hook in the IMA policy.
      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>
      a810bfd8
    • R
      ima: Prevent usage of digest lists not measured or appraised · 5244bba6
      Roberto Sassu 提交于
      hulk inclusion
      category: feature
      feature: IMA Digest Lists extension
      bugzilla: 46797
      
      -------------------------------------------------
      
      Loading a digest list affects the behavior of IMA for subsequent
      operations. For example, if the digest of a file is found in a loaded
      digest list, the file won't be added to the measurement list (with PCR 11).
      If an administrator loaded the digest list before the IMA policy, he could
      hide from verifiers the fact that files in that digest list were accessed.
      
      To avoid this situation, this patch prevents usage of digest lists for an
      IMA submodule if that submodule didn't process it. If a digest list wasn't
      measured, the digest of measured files will not be searched in the digest
      list and regular measurement will be performed. The same mechanism applies
      for appraisal.
      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>
      5244bba6
    • R
      ima: Allow choice of file hash algorithm for measurement and audit · 6214e186
      Roberto Sassu 提交于
      hulk inclusion
      category: feature
      feature: IMA Digest Lists extension
      bugzilla: 46797
      
      -------------------------------------------------
      
      IMA reads the hash algorithm from security.ima, if exists, so that a
      signature can be verified with the correct file digest.
      
      This patch moves ima_read_xattr() and ima_get_hash_algo() to ima_main.c, so
      that the file digest in the measurement list or in the audit logs can be
      compared with a reference value calculated with a specific hash algorithm.
      
      In addition, this patch also allows the usage of security.ima with type
      EVM_IMA_XATTR_DIGSIG and signature length zero, so that the xattr can be
      used just to specify the hash algorithm.
      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>
      6214e186
  4. 13 4月, 2021 1 次提交
  5. 30 10月, 2020 1 次提交
  6. 21 7月, 2020 3 次提交
    • T
      ima: Rename internal filter rule functions · b8867eed
      Tyler Hicks 提交于
      Rename IMA's internal filter rule functions from security_filter_rule_*()
      to ima_filter_rule_*(). This avoids polluting the security_* namespace,
      which is typically reserved for general security subsystem
      infrastructure.
      Signed-off-by: NTyler Hicks <tyhicks@linux.microsoft.com>
      Suggested-by: NCasey Schaufler <casey@schaufler-ca.com>
      [zohar@linux.ibm.com: reword using the term "filter", not "audit"]
      Signed-off-by: NMimi Zohar <zohar@linux.ibm.com>
      b8867eed
    • T
      ima: Support additional conditionals in the KEXEC_CMDLINE hook function · 4834177e
      Tyler Hicks 提交于
      Take the properties of the kexec kernel's inode and the current task
      ownership into consideration when matching a KEXEC_CMDLINE operation to
      the rules in the IMA policy. This allows for some uniformity when
      writing IMA policy rules for KEXEC_KERNEL_CHECK, KEXEC_INITRAMFS_CHECK,
      and KEXEC_CMDLINE operations.
      
      Prior to this patch, it was not possible to write a set of rules like
      this:
      
       dont_measure func=KEXEC_KERNEL_CHECK obj_type=foo_t
       dont_measure func=KEXEC_INITRAMFS_CHECK obj_type=foo_t
       dont_measure func=KEXEC_CMDLINE obj_type=foo_t
       measure func=KEXEC_KERNEL_CHECK
       measure func=KEXEC_INITRAMFS_CHECK
       measure func=KEXEC_CMDLINE
      
      The inode information associated with the kernel being loaded by a
      kexec_kernel_load(2) syscall can now be included in the decision to
      measure or not
      
      Additonally, the uid, euid, and subj_* conditionals can also now be
      used in KEXEC_CMDLINE rules. There was no technical reason as to why
      those conditionals weren't being considered previously other than
      ima_match_rules() didn't have a valid inode to use so it immediately
      bailed out for KEXEC_CMDLINE operations rather than going through the
      full list of conditional comparisons.
      Signed-off-by: NTyler Hicks <tyhicks@linux.microsoft.com>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: kexec@lists.infradead.org
      Reviewed-by: NLakshmi Ramasubramanian <nramas@linux.microsoft.com>
      Signed-off-by: NMimi Zohar <zohar@linux.ibm.com>
      4834177e
    • T
      ima: Move comprehensive rule validation checks out of the token parser · 30031b0e
      Tyler Hicks 提交于
      Use ima_validate_rule(), at the end of the token parsing stage, to
      verify combinations of actions, hooks, and flags. This is useful to
      increase readability by consolidating such checks into a single function
      and also because rule conditionals can be specified in arbitrary order
      making it difficult to do comprehensive rule validation until the entire
      rule has been parsed.
      
      This allows for the check that ties together the "keyrings" conditional
      with the KEY_CHECK function hook to be moved into the final rule
      validation.
      
      The modsig check no longer needs to compiled conditionally because the
      token parser will ensure that modsig support is enabled before accepting
      "imasig|modsig" appraise type values. The final rule validation will
      ensure that appraise_type and appraise_flag options are only present in
      appraise rules.
      
      Finally, this allows for the check that ties together the "pcr"
      conditional with the measure action to be moved into the final rule
      validation.
      Signed-off-by: NTyler Hicks <tyhicks@linux.microsoft.com>
      Signed-off-by: NMimi Zohar <zohar@linux.ibm.com>
      30031b0e
  7. 17 7月, 2020 2 次提交
  8. 25 6月, 2020 1 次提交
  9. 04 6月, 2020 1 次提交
  10. 08 5月, 2020 1 次提交
  11. 20 4月, 2020 3 次提交
  12. 23 1月, 2020 2 次提交
    • 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
    • L
      IMA: Define workqueue for early boot key measurements · 9f81a2ed
      Lakshmi Ramasubramanian 提交于
      Measuring keys requires a custom IMA policy to be loaded.  Keys created
      or updated before a custom IMA policy is loaded should be queued and
      will be processed after a custom policy is loaded.
      
      This patch defines a workqueue for queuing keys when a custom IMA policy
      has not yet been loaded.  An intermediate Kconfig boolean option namely
      IMA_QUEUE_EARLY_BOOT_KEYS is used to declare the workqueue functions.
      
      A flag namely ima_process_keys is used to check if the key should be
      queued or should be processed immediately.
      Signed-off-by: NLakshmi Ramasubramanian <nramas@linux.microsoft.com>
      Signed-off-by: NMimi Zohar <zohar@linux.ibm.com>
      9f81a2ed
  13. 12 12月, 2019 2 次提交
    • L
      IMA: Add support to limit measuring keys · e9085e0a
      Lakshmi Ramasubramanian 提交于
      Limit measuring keys to those keys being loaded onto a given set of
      keyrings only and when the user id (uid) matches if uid is specified
      in the policy.
      
      This patch defines a new IMA policy option namely "keyrings=" that
      can be used to specify a set of keyrings. If this option is specified
      in the policy for "measure func=KEY_CHECK" then only the keys
      loaded onto a keyring given in the "keyrings=" option are measured.
      
      If uid is specified in the policy then the key is measured only if
      the current user id matches the one specified in the policy.
      
      Added a new parameter namely "keyring" (name of the keyring) to
      process_buffer_measurement(). The keyring name is passed to
      ima_get_action() to determine the required action.
      ima_match_rules() is updated to check keyring in the policy, if
      specified, for KEY_CHECK function.
      Signed-off-by: NLakshmi Ramasubramanian <nramas@linux.microsoft.com>
      Signed-off-by: NMimi Zohar <zohar@linux.ibm.com>
      e9085e0a
    • L
      IMA: Add KEY_CHECK func to measure keys · 5808611c
      Lakshmi Ramasubramanian 提交于
      Measure keys loaded onto any keyring.
      
      This patch defines a new IMA policy func namely KEY_CHECK to
      measure keys. Updated ima_match_rules() to check for KEY_CHECK
      and ima_parse_rule() to handle KEY_CHECK.
      Signed-off-by: NLakshmi Ramasubramanian <nramas@linux.microsoft.com>
      Signed-off-by: NMimi Zohar <zohar@linux.ibm.com>
      5808611c
  14. 12 11月, 2019 2 次提交
    • N
      ima: Check against blacklisted hashes for files with modsig · 273df864
      Nayna Jain 提交于
      Asymmetric private keys are used to sign multiple files. The kernel
      currently supports checking against blacklisted keys. However, if the
      public key is blacklisted, any file signed by the blacklisted key will
      automatically fail signature verification. Blacklisting the public key
      is not fine enough granularity, as we might want to only blacklist a
      particular file.
      
      This patch adds support for checking against the blacklisted hash of
      the file, without the appended signature, based on the IMA policy. It
      defines a new policy option "appraise_flag=check_blacklist".
      
      In addition to the blacklisted binary hashes stored in the firmware
      "dbx" variable, the Linux kernel may be configured to load blacklisted
      binary hashes onto the .blacklist keyring as well. The following
      example shows how to blacklist a specific kernel module hash.
      
        $ sha256sum kernel/kheaders.ko
        77fa889b35a05338ec52e51591c1b89d4c8d1c99a21251d7c22b1a8642a6bad3
        kernel/kheaders.ko
      
        $ grep BLACKLIST .config
        CONFIG_SYSTEM_BLACKLIST_KEYRING=y
        CONFIG_SYSTEM_BLACKLIST_HASH_LIST="blacklist-hash-list"
      
        $ cat certs/blacklist-hash-list
        "bin:77fa889b35a05338ec52e51591c1b89d4c8d1c99a21251d7c22b1a8642a6bad3"
      
      Update the IMA custom measurement and appraisal policy
      rules (/etc/ima-policy):
      
        measure func=MODULE_CHECK template=ima-modsig
        appraise func=MODULE_CHECK appraise_flag=check_blacklist
        appraise_type=imasig|modsig
      
      After building, installing, and rebooting the kernel:
      
         545660333 ---lswrv      0     0   \_ blacklist:
        bin:77fa889b35a05338ec52e51591c1b89d4c8d1c99a21251d7c22b1a8642a6bad3
      
        measure func=MODULE_CHECK template=ima-modsig
        appraise func=MODULE_CHECK appraise_flag=check_blacklist
        appraise_type=imasig|modsig
      
        modprobe: ERROR: could not insert 'kheaders': Permission denied
      
        10 0c9834db5a0182c1fb0cdc5d3adcf11a11fd83dd ima-sig
        sha256:3bc6ed4f0b4d6e31bc1dbc9ef844605abc7afdc6d81a57d77a1ec9407997c40
        2 /usr/lib/modules/5.4.0-rc3+/kernel/kernel/kheaders.ko
      
        10 82aad2bcc3fa8ed94762356b5c14838f3bcfa6a0 ima-modsig
        sha256:3bc6ed4f0b4d6e31bc1dbc9ef844605abc7afdc6d81a57d77a1ec9407997c40
        2 /usr/lib/modules/5.4.0rc3+/kernel/kernel/kheaders.ko  sha256:77fa889b3
        5a05338ec52e51591c1b89d4c8d1c99a21251d7c22b1a8642a6bad3
        3082029a06092a864886f70d010702a082028b30820287020101310d300b0609608648
        016503040201300b06092a864886f70d01070131820264....
      
        10 25b72217cc1152b44b134ce2cd68f12dfb71acb3 ima-buf
        sha256:8b58427fedcf8f4b20bc8dc007f2e232bf7285d7b93a66476321f9c2a3aa132
        b blacklisted-hash
        77fa889b35a05338ec52e51591c1b89d4c8d1c99a21251d7c22b1a8642a6bad3
      Signed-off-by: NNayna Jain <nayna@linux.ibm.com>
      [zohar@linux.ibm.com: updated patch description]
      Signed-off-by: NMimi Zohar <zohar@linux.ibm.com>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/1572492694-6520-8-git-send-email-zohar@linux.ibm.com
      273df864
    • N
      ima: Make process_buffer_measurement() generic · e14555e3
      Nayna Jain 提交于
      process_buffer_measurement() is limited to measuring the kexec boot
      command line. This patch makes process_buffer_measurement() more
      generic, allowing it to measure other types of buffer data (e.g.
      blacklisted binary hashes or key hashes).
      
      process_buffer_measurement() may be called directly from an IMA hook
      or as an auxiliary measurement record. In both cases the buffer
      measurement is based on policy. This patch modifies the function to
      conditionally retrieve the policy defined PCR and template for the IMA
      hook case.
      Signed-off-by: NNayna Jain <nayna@linux.ibm.com>
      [zohar@linux.ibm.com: added comment in process_buffer_measurement()]
      Signed-off-by: NMimi Zohar <zohar@linux.ibm.com>
      Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
      Link: https://lore.kernel.org/r/1572492694-6520-6-git-send-email-zohar@linux.ibm.com
      e14555e3
  15. 20 8月, 2019 1 次提交
    • M
      kexec: Allow kexec_file() with appropriate IMA policy when locked down · 29d3c1c8
      Matthew Garrett 提交于
      Systems in lockdown mode should block the kexec of untrusted kernels.
      For x86 and ARM we can ensure that a kernel is trustworthy by validating
      a PE signature, but this isn't possible on other architectures. On those
      platforms we can use IMA digital signatures instead. Add a function to
      determine whether IMA has or will verify signatures for a given event type,
      and if so permit kexec_file() even if the kernel is otherwise locked down.
      This is restricted to cases where CONFIG_INTEGRITY_TRUSTED_KEYRING is set
      in order to prevent an attacker from loading additional keys at runtime.
      Signed-off-by: NMatthew Garrett <mjg59@google.com>
      Acked-by: NMimi Zohar <zohar@linux.ibm.com>
      Cc: Dmitry Kasatkin <dmitry.kasatkin@gmail.com>
      Cc: linux-integrity@vger.kernel.org
      Signed-off-by: NJames Morris <jmorris@namei.org>
      29d3c1c8
  16. 06 8月, 2019 4 次提交