1. 14 4月, 2021 6 次提交
    • 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
      ima: Add meta_immutable appraisal type · ab8c2a63
      Roberto Sassu 提交于
      hulk inclusion
      category: feature
      feature: IMA Digest Lists extension
      bugzilla: 46797
      
      -------------------------------------------------
      
      Currently, IMA supports the appraise_type=imasig option in the policy to
      require file signatures. This patch introduces the new option
      appraise_type=meta_immutable to require that file metadata are signed and
      immutable. This requirement can be satisfied by portable signatures and
      by digest lists if they are marked as immutable.
      
      The main purpose of this option is to ensure that file metadata are correct
      at the time of access, so that policies relying on labels can be correctly
      enforced. For example, requiring immutable metadata would prevent an
      administrator from altering the label assigned to a process during
      execve() by changing the label of the executable.
      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>
      ab8c2a63
    • 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: Load all digest lists from a directory at boot time · d2f957c7
      Roberto Sassu 提交于
      hulk inclusion
      category: feature
      feature: IMA Digest Lists extension
      bugzilla: 46797
      
      -------------------------------------------------
      
      Digest lists should be uploaded to IMA as soon as possible, otherwise file
      digests would appear in the measurement list or access would be denied if
      appraisal is in enforcing mode.
      
      This patch adds a call to ima_load_digest_lists() in integrity_load_keys(),
      so that the function is executed when rootfs becomes available, before
      files are accessed.
      
      ima_load_digest_lists() iterates in the directory specified as value of
      CONFIG_IMA_DIGEST_LISTS_DIR and uploads all digest lists to the kernel.
      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>
      d2f957c7
    • R
      ima: Add parser of compact digest list · 4bc4c4ca
      Roberto Sassu 提交于
      hulk inclusion
      category: feature
      feature: IMA Digest Lists extension
      bugzilla: 46797
      
      -------------------------------------------------
      
      This patch introduces the parser of the compact digest list. The format is
      optimized to store a large quantity of data with the same type. It is the
      only format supported by the kernel. Digest lists can be uploaded by
      writing the path to securityfs, as the same as for IMA policies.
      
      A compact list is a set of consecutive data blocks, each consisting of a
      header and a payload. The header indicates the version of the header, the
      type of data, type modifiers, the hash algorithm, how many elements and the
      length of the payload.
      
      COMPACT_KEY identifies public keys used for signature verification of the
      digest lists; COMPACT_PARSER identifies digests of user space parsers
      allowed to directly upload parsed digest lists to the kernel; COMPACT_FILE
      identifies digests of regular files; COMPACT_METADATA identifies digest of
      file metadata.
      
      Type modifiers indicate attributes of the elements included in the payload.
      The COMPACT_MOD_IMMUTABLE modifier indicates that a file or metadata are
      immutable.
      
      This patch also introduces ima_lookup_loaded_digest() and
      ima_add_digest_data_entry() to search and add digests in the new hash table
      (ima_digests_htable).
      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>
      4bc4c4ca
  2. 17 7月, 2020 1 次提交
    • L
      integrity: Add errno field in audit message · 2f845882
      Lakshmi Ramasubramanian 提交于
      Error code is not included in the audit messages logged by
      the integrity subsystem.
      
      Define a new function integrity_audit_message() that takes error code
      in the "errno" parameter. Add "errno" field in the audit messages logged
      by the integrity subsystem and set the value passed in the "errno"
      parameter.
      
      [    6.303048] audit: type=1804 audit(1592506281.627:2): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=kernel op=measuring_key cause=ENOMEM comm="swapper/0" name=".builtin_trusted_keys" res=0 errno=-12
      
      [    7.987647] audit: type=1802 audit(1592506283.312:9): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 op=policy_update cause=completed comm="systemd" res=1 errno=0
      
      [    8.019432] audit: type=1804 audit(1592506283.344:10): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=system_u:system_r:init_t:s0 op=measuring_kexec_cmdline cause=hashing_error comm="systemd" name="kexec-cmdline" res=0 errno=-22
      Signed-off-by: NLakshmi Ramasubramanian <nramas@linux.microsoft.com>
      Suggested-by: NSteve Grubb <sgrubb@redhat.com>
      Suggested-by: NMimi Zohar <zohar@linux.ibm.com>
      Signed-off-by: NMimi Zohar <zohar@linux.ibm.com>
      2f845882
  3. 16 6月, 2020 1 次提交
  4. 29 2月, 2020 1 次提交
  5. 12 11月, 2019 1 次提交
    • 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
  6. 06 8月, 2019 2 次提交
  7. 11 7月, 2019 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. 28 6月, 2019 1 次提交
    • D
      keys: Replace uid/gid/perm permissions checking with an ACL · 2e12256b
      David Howells 提交于
      Replace the uid/gid/perm permissions checking on a key with an ACL to allow
      the SETATTR and SEARCH permissions to be split.  This will also allow a
      greater range of subjects to represented.
      
      ============
      WHY DO THIS?
      ============
      
      The problem is that SETATTR and SEARCH cover a slew of actions, not all of
      which should be grouped together.
      
      For SETATTR, this includes actions that are about controlling access to a
      key:
      
       (1) Changing a key's ownership.
      
       (2) Changing a key's security information.
      
       (3) Setting a keyring's restriction.
      
      And actions that are about managing a key's lifetime:
      
       (4) Setting an expiry time.
      
       (5) Revoking a key.
      
      and (proposed) managing a key as part of a cache:
      
       (6) Invalidating a key.
      
      Managing a key's lifetime doesn't really have anything to do with
      controlling access to that key.
      
      Expiry time is awkward since it's more about the lifetime of the content
      and so, in some ways goes better with WRITE permission.  It can, however,
      be set unconditionally by a process with an appropriate authorisation token
      for instantiating a key, and can also be set by the key type driver when a
      key is instantiated, so lumping it with the access-controlling actions is
      probably okay.
      
      As for SEARCH permission, that currently covers:
      
       (1) Finding keys in a keyring tree during a search.
      
       (2) Permitting keyrings to be joined.
      
       (3) Invalidation.
      
      But these don't really belong together either, since these actions really
      need to be controlled separately.
      
      Finally, there are number of special cases to do with granting the
      administrator special rights to invalidate or clear keys that I would like
      to handle with the ACL rather than key flags and special checks.
      
      
      ===============
      WHAT IS CHANGED
      ===============
      
      The SETATTR permission is split to create two new permissions:
      
       (1) SET_SECURITY - which allows the key's owner, group and ACL to be
           changed and a restriction to be placed on a keyring.
      
       (2) REVOKE - which allows a key to be revoked.
      
      The SEARCH permission is split to create:
      
       (1) SEARCH - which allows a keyring to be search and a key to be found.
      
       (2) JOIN - which allows a keyring to be joined as a session keyring.
      
       (3) INVAL - which allows a key to be invalidated.
      
      The WRITE permission is also split to create:
      
       (1) WRITE - which allows a key's content to be altered and links to be
           added, removed and replaced in a keyring.
      
       (2) CLEAR - which allows a keyring to be cleared completely.  This is
           split out to make it possible to give just this to an administrator.
      
       (3) REVOKE - see above.
      
      
      Keys acquire ACLs which consist of a series of ACEs, and all that apply are
      unioned together.  An ACE specifies a subject, such as:
      
       (*) Possessor - permitted to anyone who 'possesses' a key
       (*) Owner - permitted to the key owner
       (*) Group - permitted to the key group
       (*) Everyone - permitted to everyone
      
      Note that 'Other' has been replaced with 'Everyone' on the assumption that
      you wouldn't grant a permit to 'Other' that you wouldn't also grant to
      everyone else.
      
      Further subjects may be made available by later patches.
      
      The ACE also specifies a permissions mask.  The set of permissions is now:
      
      	VIEW		Can view the key metadata
      	READ		Can read the key content
      	WRITE		Can update/modify the key content
      	SEARCH		Can find the key by searching/requesting
      	LINK		Can make a link to the key
      	SET_SECURITY	Can change owner, ACL, expiry
      	INVAL		Can invalidate
      	REVOKE		Can revoke
      	JOIN		Can join this keyring
      	CLEAR		Can clear this keyring
      
      
      The KEYCTL_SETPERM function is then deprecated.
      
      The KEYCTL_SET_TIMEOUT function then is permitted if SET_SECURITY is set,
      or if the caller has a valid instantiation auth token.
      
      The KEYCTL_INVALIDATE function then requires INVAL.
      
      The KEYCTL_REVOKE function then requires REVOKE.
      
      The KEYCTL_JOIN_SESSION_KEYRING function then requires JOIN to join an
      existing keyring.
      
      The JOIN permission is enabled by default for session keyrings and manually
      created keyrings only.
      
      
      ======================
      BACKWARD COMPATIBILITY
      ======================
      
      To maintain backward compatibility, KEYCTL_SETPERM will translate the
      permissions mask it is given into a new ACL for a key - unless
      KEYCTL_SET_ACL has been called on that key, in which case an error will be
      returned.
      
      It will convert possessor, owner, group and other permissions into separate
      ACEs, if each portion of the mask is non-zero.
      
      SETATTR permission turns on all of INVAL, REVOKE and SET_SECURITY.  WRITE
      permission turns on WRITE, REVOKE and, if a keyring, CLEAR.  JOIN is turned
      on if a keyring is being altered.
      
      The KEYCTL_DESCRIBE function translates the ACL back into a permissions
      mask to return depending on possessor, owner, group and everyone ACEs.
      
      It will make the following mappings:
      
       (1) INVAL, JOIN -> SEARCH
      
       (2) SET_SECURITY -> SETATTR
      
       (3) REVOKE -> WRITE if SETATTR isn't already set
      
       (4) CLEAR -> WRITE
      
      Note that the value subsequently returned by KEYCTL_DESCRIBE may not match
      the value set with KEYCTL_SETATTR.
      
      
      =======
      TESTING
      =======
      
      This passes the keyutils testsuite for all but a couple of tests:
      
       (1) tests/keyctl/dh_compute/badargs: The first wrong-key-type test now
           returns EOPNOTSUPP rather than ENOKEY as READ permission isn't removed
           if the type doesn't have ->read().  You still can't actually read the
           key.
      
       (2) tests/keyctl/permitting/valid: The view-other-permissions test doesn't
           work as Other has been replaced with Everyone in the ACL.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      2e12256b
  10. 05 6月, 2019 1 次提交
  11. 18 12月, 2018 1 次提交
  12. 13 12月, 2018 2 次提交
  13. 18 7月, 2018 1 次提交
  14. 17 5月, 2018 1 次提交
  15. 25 3月, 2018 1 次提交
  16. 23 3月, 2018 2 次提交
    • M
      ima: fail signature verification based on policy · 9e67028e
      Mimi Zohar 提交于
      This patch addresses the fuse privileged mounted filesystems in
      environments which are unwilling to accept the risk of trusting the
      signature verification and want to always fail safe, but are for example
      using a pre-built kernel.
      
      This patch defines a new builtin policy named "fail_securely", which can
      be specified on the boot command line as an argument to "ima_policy=".
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      Cc: Miklos Szeredi <miklos@szeredi.hu>
      Cc: Seth Forshee <seth.forshee@canonical.com>
      Cc: Dongsu Park <dongsu@kinvolk.io>
      Cc: Alban Crequy <alban@kinvolk.io>
      Acked-by: NSerge Hallyn <serge@hallyn.com>
      Acked-by: N"Eric W. Biederman" <ebiederm@xmission.com>
      9e67028e
    • M
      IMA: Support using new creds in appraisal policy · d906c10d
      Matthew Garrett 提交于
      The existing BPRM_CHECK functionality in IMA validates against the
      credentials of the existing process, not any new credentials that the
      child process may transition to. Add an additional CREDS_CHECK target
      and refactor IMA to pass the appropriate creds structure. In
      ima_bprm_check(), check with both the existing process credentials and
      the credentials that will be committed when the new process is started.
      This will not change behaviour unless the system policy is extended to
      include CREDS_CHECK targets - BPRM_CHECK will continue to check the same
      credentials that it did previously.
      
      After this patch, an IMA policy rule along the lines of:
      
      measure func=CREDS_CHECK subj_type=unconfined_t
      
      will trigger if a process is executed and runs as unconfined_t, ignoring
      the context of the parent process. This is in contrast to:
      
      measure func=BPRM_CHECK subj_type=unconfined_t
      
      which will trigger if the process that calls exec() is already executing
      in unconfined_t, ignoring the context that the child process executes
      into.
      Signed-off-by: NMatthew Garrett <mjg59@google.com>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      
      Changelog:
      - initialize ima_creds_status
      d906c10d
  17. 18 12月, 2017 1 次提交
    • M
      ima: support new "hash" and "dont_hash" policy actions · da1b0029
      Mimi Zohar 提交于
      The builtin ima_appraise_tcb policy, which is specified on the boot
      command line, can be replaced with a custom policy, normally early in
      the boot process.  Custom policies can be more restrictive in some ways,
      like requiring file signatures, but can be less restrictive in other
      ways, like not appraising mutable files.  With a less restrictive policy
      in place, files in the builtin policy might not be hashed and labeled
      with a security.ima hash.  On reboot, files which should be labeled in
      the ima_appraise_tcb are not labeled, possibly preventing the system
      from booting properly.
      
      To resolve this problem, this patch extends the existing IMA policy
      actions "measure", "dont_measure", "appraise", "dont_appraise", and
      "audit" with "hash" and "dont_hash".  The new "hash" action will write
      the file hash as security.ima, but without requiring the file to be
      appraised as well.
      
      For example, the builtin ima_appraise_tcb policy includes the rule,
      "appraise fowner=0".  Adding the "hash fowner=0" rule to a custom
      policy, will cause the needed file hashes to be calculated and written
      as security.ima xattrs.
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      Signed-off-by: NStefan Berger <stefanb@linux.vnet.ibm.com>
      da1b0029
  18. 12 12月, 2017 2 次提交
    • D
      ima: re-introduce own integrity cache lock · 0d73a552
      Dmitry Kasatkin 提交于
      Before IMA appraisal was introduced, IMA was using own integrity cache
      lock along with i_mutex. process_measurement and ima_file_free took
      the iint->mutex first and then the i_mutex, while setxattr, chmod and
      chown took the locks in reverse order. To resolve the potential deadlock,
      i_mutex was moved to protect entire IMA functionality and the redundant
      iint->mutex was eliminated.
      
      Solution was based on the assumption that filesystem code does not take
      i_mutex further. But when file is opened with O_DIRECT flag, direct-io
      implementation takes i_mutex and produces deadlock. Furthermore, certain
      other filesystem operations, such as llseek, also take i_mutex.
      
      More recently some filesystems have replaced their filesystem specific
      lock with the global i_rwsem to read a file.  As a result, when IMA
      attempts to calculate the file hash, reading the file attempts to take
      the i_rwsem again.
      
      To resolve O_DIRECT related deadlock problem, this patch re-introduces
      iint->mutex. But to eliminate the original chmod() related deadlock
      problem, this patch eliminates the requirement for chmod hooks to take
      the iint->mutex by introducing additional atomic iint->attr_flags to
      indicate calling of the hooks. The allowed locking order is to take
      the iint->mutex first and then the i_rwsem.
      
      Original flags were cleared in chmod(), setxattr() or removwxattr()
      hooks and tested when file was closed or opened again. New atomic flags
      are set or cleared in those hooks and tested to clear iint->flags on
      close or on open.
      
      Atomic flags are following:
      * IMA_CHANGE_ATTR - indicates that chATTR() was called (chmod, chown,
        chgrp) and file attributes have changed. On file open, it causes IMA
        to clear iint->flags to re-evaluate policy and perform IMA functions
        again.
      * IMA_CHANGE_XATTR - indicates that setxattr or removexattr was called
        and extended attributes have changed. On file open, it causes IMA to
        clear iint->flags IMA_DONE_MASK to re-appraise.
      * IMA_UPDATE_XATTR - indicates that security.ima needs to be updated.
        It is cleared if file policy changes and no update is needed.
      * IMA_DIGSIG - indicates that file security.ima has signature and file
        security.ima must not update to file has on file close.
      * IMA_MUST_MEASURE - indicates the file is in the measurement policy.
      
      Fixes: Commit 65523218 ("xfs: remove i_iolock and use i_rwsem in
      the VFS inode instead")
      Signed-off-by: NDmitry Kasatkin <dmitry.kasatkin@huawei.com>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      0d73a552
    • 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
  19. 09 11月, 2017 1 次提交
  20. 22 6月, 2017 1 次提交
    • T
      integrity: Small code improvements · bb543e39
      Thiago Jung Bauermann 提交于
      These changes are too small to warrant their own patches:
      
      The keyid and sig_size members of struct signature_v2_hdr are in BE format,
      so use a type that makes this assumption explicit. Also, use beXX_to_cpu
      instead of __beXX_to_cpu to read them.
      
      Change integrity_kernel_read to take a void * buffer instead of char *
      buffer, so that callers don't have to use a cast if they provide a buffer
      that isn't a char *.
      
      Add missing #endif comment in ima.h pointing out which macro it refers to.
      
      Add missing fall through comment in ima_appraise.c.
      
      Constify mask_tokens and func_tokens arrays.
      Signed-off-by: NThiago Jung Bauermann <bauerman@linux.vnet.ibm.com>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      bb543e39
  21. 30 6月, 2016 1 次提交
  22. 01 5月, 2016 1 次提交
  23. 04 3月, 2016 1 次提交
  24. 21 2月, 2016 2 次提交
  25. 15 12月, 2015 1 次提交
  26. 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
  27. 22 5月, 2015 1 次提交
  28. 18 11月, 2014 3 次提交