1. 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: Check IMA policy flag · c5563bad
      Lakshmi Ramasubramanian 提交于
      process_buffer_measurement() may be called prior to IMA being
      initialized (for instance, when the IMA hook is called when
      a key is added to the .builtin_trusted_keys keyring), which
      would result in a kernel panic.
      
      This patch adds the check in process_buffer_measurement()
      to return immediately if IMA is not initialized yet.
      Signed-off-by: NLakshmi Ramasubramanian <nramas@linux.microsoft.com>
      Signed-off-by: NMimi Zohar <zohar@linux.ibm.com>
      c5563bad
  2. 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
  3. 20 8月, 2019 2 次提交
    • 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
    • J
      kexec_file: split KEXEC_VERIFY_SIG into KEXEC_SIG and KEXEC_SIG_FORCE · 99d5cadf
      Jiri Bohac 提交于
      This is a preparatory patch for kexec_file_load() lockdown.  A locked down
      kernel needs to prevent unsigned kernel images from being loaded with
      kexec_file_load().  Currently, the only way to force the signature
      verification is compiling with KEXEC_VERIFY_SIG.  This prevents loading
      usigned images even when the kernel is not locked down at runtime.
      
      This patch splits KEXEC_VERIFY_SIG into KEXEC_SIG and KEXEC_SIG_FORCE.
      Analogous to the MODULE_SIG and MODULE_SIG_FORCE for modules, KEXEC_SIG
      turns on the signature verification but allows unsigned images to be
      loaded.  KEXEC_SIG_FORCE disallows images without a valid signature.
      Signed-off-by: NJiri Bohac <jbohac@suse.cz>
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Signed-off-by: NMatthew Garrett <mjg59@google.com>
      cc: kexec@lists.infradead.org
      Signed-off-by: NJames Morris <jmorris@namei.org>
      99d5cadf
  4. 06 8月, 2019 4 次提交
  5. 01 7月, 2019 1 次提交
    • P
      IMA: Define a new template field buf · 86b4da8c
      Prakhar Srivastava 提交于
      A buffer(kexec boot command line arguments) measured into IMA
      measuremnt list cannot be appraised, without already being
      aware of the buffer contents. Since hashes are non-reversible,
      raw buffer is needed for validation or regenerating hash for
      appraisal/attestation.
      
      Add support to store/read the buffer contents in HEX.
      The kexec cmdline hash is stored in the "d-ng" field of the
      template data.  It can be verified using
      sudo cat /sys/kernel/security/integrity/ima/ascii_runtime_measurements |
        grep  kexec-cmdline | cut -d' ' -f 6 | xxd -r -p | sha256sum
      
      - Add two new fields to ima_event_data to hold the buf and
      buf_len
      - Add a new template field 'buf' to be used to store/read
      the buffer data.
      - Updated process_buffer_meaurement to add the buffer to
      ima_event_data. process_buffer_measurement added in
      "Define a new IMA hook to measure the boot command line
       arguments"
      - Add a new template policy name ima-buf to represent
      'd-ng|n-ng|buf'
      Signed-off-by: NPrakhar Srivastava <prsriva02@gmail.com>
      Reviewed-by: NRoberto Sassu <roberto.sassu@huawei.com>
      Reviewed-by: NJames Morris <jamorris@linux.microsoft.com>
      Signed-off-by: NMimi Zohar <zohar@linux.ibm.com>
      86b4da8c
  6. 24 6月, 2019 1 次提交
  7. 20 6月, 2019 1 次提交
  8. 14 6月, 2019 1 次提交
  9. 05 6月, 2019 2 次提交
  10. 05 2月, 2019 1 次提交
  11. 21 12月, 2018 1 次提交
  12. 13 12月, 2018 2 次提交
    • N
      ima: Use inode_is_open_for_write · eed9de3b
      Nikolay Borisov 提交于
      Use the aptly named function rather than open coding the check. No
      functional changes.
      Signed-off-by: NNikolay Borisov <nborisov@suse.com>
      Signed-off-by: NMimi Zohar <zohar@linux.ibm.com>
      eed9de3b
    • P
      security: integrity: make ima_main explicitly non-modular · 4f83d5ea
      Paul Gortmaker 提交于
      The Makefile/Kconfig entry controlling compilation of this code is:
      
      obj-$(CONFIG_IMA) += ima.o
      ima-y := ima_fs.o ima_queue.o ima_init.o ima_main.o ima_crypto.o ima_api.o \
               ima_policy.o ima_template.o ima_template_lib.o
      
      security/integrity/ima/Kconfig:config IMA
      security/integrity/ima/Kconfig- bool "Integrity Measurement Architecture(IMA)"
      
      ...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: Dmitry Kasatkin <dmitry.kasatkin@gmail.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>
      4f83d5ea
  13. 11 12月, 2018 1 次提交
    • N
      ima: prevent kexec_load syscall based on runtime secureboot flag · b5ca1173
      Nayna Jain 提交于
      When CONFIG_KEXEC_VERIFY_SIG is enabled, the kexec_file_load syscall
      requires the kexec'd kernel image to be signed. Distros are concerned
      about totally disabling the kexec_load syscall. As a compromise, the
      kexec_load syscall will only be disabled when CONFIG_KEXEC_VERIFY_SIG
      is configured and the system is booted with secureboot enabled.
      
      This patch disables the kexec_load syscall only for systems booted with
      secureboot enabled.
      
      [zohar@linux.ibm.com: add missing mesage on kexec_load failure]
      Signed-off-by: NNayna Jain <nayna@linux.ibm.com>
      Cc: David Howells <dhowells@redhat.com>
      Cc: Eric Biederman <ebiederm@xmission.com>
      Cc: Peter Jones <pjones@redhat.com>
      Cc: Vivek Goyal <vgoyal@redhat.com>
      Cc: Dave Young <dyoung@redhat.com>
      Signed-off-by: NMimi Zohar <zohar@linux.ibm.com>
      b5ca1173
  14. 11 10月, 2018 1 次提交
  15. 17 7月, 2018 4 次提交
  16. 12 7月, 2018 1 次提交
  17. 31 5月, 2018 1 次提交
  18. 22 5月, 2018 1 次提交
  19. 17 5月, 2018 1 次提交
  20. 25 3月, 2018 1 次提交
    • P
      ima: Fallback to the builtin hash algorithm · ab60368a
      Petr Vorel 提交于
      IMA requires having it's hash algorithm be compiled-in due to it's
      early use.  The default IMA algorithm is protected by Kconfig to be
      compiled-in.
      
      The ima_hash kernel parameter allows to choose the hash algorithm. When
      the specified algorithm is not available or available as a module, IMA
      initialization fails, which leads to a kernel panic (mknodat syscall calls
      ima_post_path_mknod()).  Therefore as fallback we force IMA to use
      the default builtin Kconfig hash algorithm.
      
      Fixed crash:
      
      $ grep CONFIG_CRYPTO_MD4 .config
      CONFIG_CRYPTO_MD4=m
      
      [    0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-4.12.14-2.3-default root=UUID=74ae8202-9ca7-4e39-813b-22287ec52f7a video=1024x768-16 plymouth.ignore-serial-consoles console=ttyS0 console=tty resume=/dev/disk/by-path/pci-0000:00:07.0-part3 splash=silent showopts ima_hash=md4
      ...
      [    1.545190] ima: Can not allocate md4 (reason: -2)
      ...
      [    2.610120] BUG: unable to handle kernel NULL pointer dereference at           (null)
      [    2.611903] IP: ima_match_policy+0x23/0x390
      [    2.612967] PGD 0 P4D 0
      [    2.613080] Oops: 0000 [#1] SMP
      [    2.613080] Modules linked in: autofs4
      [    2.613080] Supported: Yes
      [    2.613080] CPU: 0 PID: 1 Comm: systemd Not tainted 4.12.14-2.3-default #1
      [    2.613080] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.0.0-prebuilt.qemu-project.org 04/01/2014
      [    2.613080] task: ffff88003e2d0040 task.stack: ffffc90000190000
      [    2.613080] RIP: 0010:ima_match_policy+0x23/0x390
      [    2.613080] RSP: 0018:ffffc90000193e88 EFLAGS: 00010296
      [    2.613080] RAX: 0000000000000000 RBX: 000000000000000c RCX: 0000000000000004
      [    2.613080] RDX: 0000000000000010 RSI: 0000000000000001 RDI: ffff880037071728
      [    2.613080] RBP: 0000000000008000 R08: 0000000000000000 R09: 0000000000000000
      [    2.613080] R10: 0000000000000008 R11: 61c8864680b583eb R12: 00005580ff10086f
      [    2.613080] R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000008000
      [    2.613080] FS:  00007f5c1da08940(0000) GS:ffff88003fc00000(0000) knlGS:0000000000000000
      [    2.613080] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [    2.613080] CR2: 0000000000000000 CR3: 0000000037002000 CR4: 00000000003406f0
      [    2.613080] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
      [    2.613080] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
      [    2.613080] Call Trace:
      [    2.613080]  ? shmem_mknod+0xbf/0xd0
      [    2.613080]  ima_post_path_mknod+0x1c/0x40
      [    2.613080]  SyS_mknod+0x210/0x220
      [    2.613080]  entry_SYSCALL_64_fastpath+0x1a/0xa5
      [    2.613080] RIP: 0033:0x7f5c1bfde570
      [    2.613080] RSP: 002b:00007ffde1c90dc8 EFLAGS: 00000246 ORIG_RAX: 0000000000000085
      [    2.613080] RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f5c1bfde570
      [    2.613080] RDX: 0000000000000000 RSI: 0000000000008000 RDI: 00005580ff10086f
      [    2.613080] RBP: 00007ffde1c91040 R08: 00005580ff10086f R09: 0000000000000000
      [    2.613080] R10: 0000000000104000 R11: 0000000000000246 R12: 00005580ffb99660
      [    2.613080] R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000002
      [    2.613080] Code: 0f 1f 84 00 00 00 00 00 0f 1f 44 00 00 41 57 41 56 44 8d 14 09 41 55 41 54 55 53 44 89 d3 09 cb 48 83 ec 38 48 8b 05 c5 03 29 01 <4c> 8b 20 4c 39 e0 0f 84 d7 01 00 00 4c 89 44 24 08 89 54 24 20
      [    2.613080] RIP: ima_match_policy+0x23/0x390 RSP: ffffc90000193e88
      [    2.613080] CR2: 0000000000000000
      [    2.613080] ---[ end trace 9a9f0a8a73079f6a ]---
      [    2.673052] Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000009
      [    2.673052]
      [    2.675337] Kernel Offset: disabled
      [    2.676405] ---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000009
      Signed-off-by: NPetr Vorel <pvorel@suse.cz>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      ab60368a
  21. 23 3月, 2018 3 次提交
    • 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: re-evaluate files on privileged mounted filesystems · d77ccdc6
      Mimi Zohar 提交于
      This patch addresses the fuse privileged mounted filesystems in a "secure"
      environment, with a correctly enforced security policy, which is willing
      to assume the inherent risk of specific fuse filesystems that are well
      defined and properly implemented.
      
      As there is no way for the kernel to detect file changes, the kernel
      ignores the cached file integrity results and re-measures, re-appraises,
      and re-audits the file.
      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>
      d77ccdc6
    • 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
  22. 01 2月, 2018 1 次提交
  23. 29 1月, 2018 1 次提交
  24. 18 12月, 2017 4 次提交
    • S
      ima: Use i_version only when filesystem supports it · a2a2c3c8
      Sascha Hauer 提交于
      i_version is only supported by a filesystem when the SB_I_VERSION
      flag is set. This patch tests for the SB_I_VERSION flag before using
      i_version. If we can't use i_version to detect a file change then we
      must assume the file has changed in the last_writer path and remeasure
      it.
      
      On filesystems without i_version support IMA used to measure a file
      only once and didn't detect any changes to a file. With this patch
      IMA now works properly on these filesystems.
      Signed-off-by: NSascha Hauer <s.hauer@pengutronix.de>
      Reviewed-by: NJeff Layton <jlayton@redhat.com>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      a2a2c3c8
    • B
      ima: log message to module appraisal error · 9c655be0
      Bruno E. O. Meneguele 提交于
      Simple but useful message log to the user in case of module appraise is
      forced and fails due to the lack of file descriptor, that might be
      caused by kmod calls to compressed modules.
      Signed-off-by: NBruno E. O. Meneguele <brdeoliv@redhat.com>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      9c655be0
    • R
      ima: pass filename to ima_rdwr_violation_check() · 4e8581ee
      Roberto Sassu 提交于
      ima_rdwr_violation_check() retrieves the full path of a measured file by
      calling ima_d_path(). If process_measurement() calls this function, it
      reuses the pointer and passes it to the functions to measure/appraise/audit
      an accessed file.
      
      After commit bc15ed66 ("ima: fix ima_d_path() possible race with
      rename"), ima_d_path() first tries to retrieve the full path by calling
      d_absolute_path() and, if there is an error, copies the dentry name to the
      buffer passed as argument.
      
      However, ima_rdwr_violation_check() passes to ima_d_path() the pointer of a
      local variable. process_measurement() might be reusing the pointer to an
      area in the stack which may have been already overwritten after
      ima_rdwr_violation_check() returned.
      
      Correct this issue by passing to ima_rdwr_violation_check() the pointer of
      a buffer declared in process_measurement().
      
      Fixes: bc15ed66 ("ima: fix ima_d_path() possible race with rename")
      Signed-off-by: NRoberto Sassu <roberto.sassu@huawei.com>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      4e8581ee
    • 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