1. 09 6月, 2021 1 次提交
    • R
      ima/evm: Fix type mismatch · 6b26285f
      Roberto Sassu 提交于
      The endianness of a variable written to the measurement list cannot be
      determined at compile time, as it depends on the value of the
      ima_canonical_fmt global variable (set through a kernel option with the
      same name if the machine is big endian).
      
      If ima_canonical_fmt is false, the endianness of a variable is the same as
      the machine; if ima_canonical_fmt is true, the endianness is little endian.
      The warning arises due to this type of instruction:
      
      var = cpu_to_leXX(var)
      
      which tries to assign a value in little endian to a variable with native
      endianness (little or big endian).
      
      Given that the variables set with this instruction are not used in any
      operation but just written to a buffer, it is safe to force the type of the
      value being set to be the same of the type of the variable with:
      
      var = (__force <var type>)cpu_to_leXX(var)
      Reported-by: Nkernel test robot <lkp@intel.com>
      Signed-off-by: NRoberto Sassu <roberto.sassu@huawei.com>
      Signed-off-by: NMimi Zohar <zohar@linux.ibm.com>
      6b26285f
  2. 29 11月, 2020 1 次提交
    • R
      ima: Don't modify file descriptor mode on the fly · 207cdd56
      Roberto Sassu 提交于
      Commit a408e4a8 ("ima: open a new file instance if no read
      permissions") already introduced a second open to measure a file when the
      original file descriptor does not allow it. However, it didn't remove the
      existing method of changing the mode of the original file descriptor, which
      is still necessary if the current process does not have enough privileges
      to open a new one.
      
      Changing the mode isn't really an option, as the filesystem might need to
      do preliminary steps to make the read possible. Thus, this patch removes
      the code and keeps the second open as the only option to measure a file
      when it is unreadable with the original file descriptor.
      
      Cc: <stable@vger.kernel.org> # 4.20.x: 0014cc04 ima: Set file->f_mode
      Fixes: 2fe5d6de ("ima: integrity appraisal extension")
      Signed-off-by: NRoberto Sassu <roberto.sassu@huawei.com>
      Reviewed-by: NChristoph Hellwig <hch@lst.de>
      Signed-off-by: NMimi Zohar <zohar@linux.ibm.com>
      207cdd56
  3. 16 9月, 2020 1 次提交
  4. 25 6月, 2020 1 次提交
  5. 08 6月, 2020 1 次提交
  6. 04 6月, 2020 1 次提交
  7. 08 5月, 2020 1 次提交
  8. 20 4月, 2020 6 次提交
  9. 29 2月, 2020 1 次提交
  10. 12 12月, 2019 1 次提交
  11. 06 8月, 2019 2 次提交
    • S
      ima: fix freeing ongoing ahash_request · 4ece3125
      Sascha Hauer 提交于
      integrity_kernel_read() can fail in which case we forward to call
      ahash_request_free() on a currently running request. We have to wait
      for its completion before we can free the request.
      
      This was observed by interrupting a "find / -type f -xdev -print0 | xargs -0
      cat 1>/dev/null" with ctrl-c on an IMA enabled filesystem.
      Signed-off-by: NSascha Hauer <s.hauer@pengutronix.de>
      Signed-off-by: NMimi Zohar <zohar@linux.ibm.com>
      4ece3125
    • S
      ima: always return negative code for error · f5e10401
      Sascha Hauer 提交于
      integrity_kernel_read() returns the number of bytes read. If this is
      a short read then this positive value is returned from
      ima_calc_file_hash_atfm(). Currently this is only indirectly called from
      ima_calc_file_hash() and this function only tests for the return value
      being zero or nonzero and also doesn't forward the return value.
      Nevertheless there's no point in returning a positive value as an error,
      so translate a short read into -EINVAL.
      Signed-off-by: NSascha Hauer <s.hauer@pengutronix.de>
      Signed-off-by: NMimi Zohar <zohar@linux.ibm.com>
      f5e10401
  12. 05 6月, 2019 1 次提交
  13. 25 4月, 2019 1 次提交
    • E
      crypto: shash - remove shash_desc::flags · 877b5691
      Eric Biggers 提交于
      The flags field in 'struct shash_desc' never actually does anything.
      The only ostensibly supported flag is CRYPTO_TFM_REQ_MAY_SLEEP.
      However, no shash algorithm ever sleeps, making this flag a no-op.
      
      With this being the case, inevitably some users who can't sleep wrongly
      pass MAY_SLEEP.  These would all need to be fixed if any shash algorithm
      actually started sleeping.  For example, the shash_ahash_*() functions,
      which wrap a shash algorithm with the ahash API, pass through MAY_SLEEP
      from the ahash API to the shash API.  However, the shash functions are
      called under kmap_atomic(), so actually they're assumed to never sleep.
      
      Even if it turns out that some users do need preemption points while
      hashing large buffers, we could easily provide a helper function
      crypto_shash_update_large() which divides the data into smaller chunks
      and calls crypto_shash_update() and cond_resched() for each chunk.  It's
      not necessary to have a flag in 'struct shash_desc', nor is it necessary
      to make individual shash algorithms aware of this at all.
      
      Therefore, remove shash_desc::flags, and document that the
      crypto_shash_*() functions can be called from any context.
      Signed-off-by: NEric Biggers <ebiggers@google.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      877b5691
  14. 13 2月, 2019 1 次提交
    • R
      tpm: retrieve digest size of unknown algorithms with PCR read · 879b5892
      Roberto Sassu 提交于
      Currently, the TPM driver retrieves the digest size from a table mapping
      TPM algorithms identifiers to identifiers defined by the crypto subsystem.
      If the algorithm is not defined by the latter, the digest size can be
      retrieved from the output of the PCR read command.
      
      The patch modifies the definition of tpm_pcr_read() and tpm2_pcr_read() to
      pass the desired hash algorithm and obtain the digest size at TPM startup.
      Algorithms and corresponding digest sizes are stored in the new structure
      tpm_bank_info, member of tpm_chip, so that the information can be used by
      other kernel subsystems.
      
      tpm_bank_info contains: the TPM algorithm identifier, necessary to generate
      the event log as defined by Trusted Computing Group (TCG); the digest size,
      to pad/truncate a digest calculated with a different algorithm; the crypto
      subsystem identifier, to calculate the digest of event data.
      
      This patch also protects against data corruption that could happen in the
      bus, by checking that the digest size returned by the TPM during a PCR read
      matches the size of the algorithm passed to tpm2_pcr_read().
      
      For the initial PCR read, when digest sizes are not yet available, this
      patch ensures that the amount of data copied from the output returned by
      the TPM does not exceed the size of the array data are copied to.
      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>
      Acked-by: NMimi Zohar <zohar@linux.ibm.com>
      Signed-off-by: NJarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
      879b5892
  15. 13 11月, 2018 1 次提交
  16. 11 10月, 2018 1 次提交
  17. 28 7月, 2018 2 次提交
  18. 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
  19. 08 1月, 2018 1 次提交
  20. 09 11月, 2017 1 次提交
    • M
      ima: always measure and audit files in policy · f3cc6b25
      Mimi Zohar 提交于
      All files matching a "measure" rule must be included in the IMA
      measurement list, even when the file hash cannot be calculated.
      Similarly, all files matching an "audit" rule must be audited, even when
      the file hash can not be calculated.
      
      The file data hash field contained in the IMA measurement list template
      data will contain 0's instead of the actual file hash digest.
      
      Note:
      In general, adding, deleting or in anyway changing which files are
      included in the IMA measurement list is not a good idea, as it might
      result in not being able to unseal trusted keys sealed to a specific
      TPM PCR value.  This patch not only adds file measurements that were
      not previously measured, but specifies that the file hash value for
      these files will be 0's.
      
      As the IMA measurement list ordering is not consistent from one boot
      to the next, it is unlikely that anyone is sealing keys based on the
      IMA measurement list.  Remote attestation servers should be able to
      process these new measurement records, but might complain about
      these unknown records.
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      Reviewed-by: NDmitry Kasatkin <dmitry.kasatkin@huawei.com>
      f3cc6b25
  21. 03 11月, 2017 1 次提交
  22. 21 12月, 2016 1 次提交
  23. 19 2月, 2016 3 次提交
  24. 07 11月, 2015 1 次提交
  25. 28 5月, 2015 1 次提交
    • L
      kernel/params: constify struct kernel_param_ops uses · 9c27847d
      Luis R. Rodriguez 提交于
      Most code already uses consts for the struct kernel_param_ops,
      sweep the kernel for the last offending stragglers. Other than
      include/linux/moduleparam.h and kernel/params.c all other changes
      were generated with the following Coccinelle SmPL patch. Merge
      conflicts between trees can be handled with Coccinelle.
      
      In the future git could get Coccinelle merge support to deal with
      patch --> fail --> grammar --> Coccinelle --> new patch conflicts
      automatically for us on patches where the grammar is available and
      the patch is of high confidence. Consider this a feature request.
      
      Test compiled on x86_64 against:
      
      	* allnoconfig
      	* allmodconfig
      	* allyesconfig
      
      @ const_found @
      identifier ops;
      @@
      
      const struct kernel_param_ops ops = {
      };
      
      @ const_not_found depends on !const_found @
      identifier ops;
      @@
      
      -struct kernel_param_ops ops = {
      +const struct kernel_param_ops ops = {
      };
      
      Generated-by: Coccinelle SmPL
      Cc: Rusty Russell <rusty@rustcorp.com.au>
      Cc: Junio C Hamano <gitster@pobox.com>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Kees Cook <keescook@chromium.org>
      Cc: Tejun Heo <tj@kernel.org>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: cocci@systeme.lip6.fr
      Cc: linux-kernel@vger.kernel.org
      Signed-off-by: NLuis R. Rodriguez <mcgrof@suse.com>
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      9c27847d
  26. 18 11月, 2014 1 次提交
    • D
      integrity: define a new function integrity_read_file() · e3c4abbf
      Dmitry Kasatkin 提交于
      This patch defines a new function called integrity_read_file()
      to read file from the kernel into a buffer. Subsequent patches
      will read a file containing the public keys and load them onto
      the IMA keyring.
      
      This patch moves and renames ima_kernel_read(), the non-security
      checking version of kernel_read(), to integrity_kernel_read().
      
      Changes in v3:
      * Patch descriptions improved (Mimi)
      * Add missing cast (kbuild test robot)
      
      Changes in v2:
      * configuration option removed
      * function declared as '__init'
      Signed-off-by: NDmitry Kasatkin <d.kasatkin@samsung.com>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      e3c4abbf
  27. 14 10月, 2014 1 次提交
  28. 09 9月, 2014 1 次提交
  29. 03 9月, 2014 3 次提交