1. 26 7月, 2014 1 次提交
  2. 17 7月, 2014 7 次提交
    • M
      ima: define '.ima' as a builtin 'trusted' keyring · 7d2ce232
      Mimi Zohar 提交于
      Require all keys added to the IMA keyring be signed by an
      existing trusted key on the system trusted keyring.
      
      Changelog v6:
      - remove ifdef CONFIG_IMA_TRUSTED_KEYRING in C code - Dmitry
      - update Kconfig dependency and help
      - select KEYS_DEBUG_PROC_KEYS - Dmitry
      
      Changelog v5:
      - Move integrity_init_keyring() to init_ima() - Dmitry
      - reset keyring[id] on failure - Dmitry
      
      Changelog v1:
      - don't link IMA trusted keyring to user keyring
      
      Changelog:
      - define stub integrity_init_keyring() function (reported-by Fengguang Wu)
      - differentiate between regular and trusted keyring names.
      - replace printk with pr_info (D. Kasatkin)
      - only make the IMA keyring a trusted keyring (reported-by D. Kastatkin)
      - define stub integrity_init_keyring() definition based on
        CONFIG_INTEGRITY_SIGNATURE, not CONFIG_INTEGRITY_ASYMMETRIC_KEYS.
        (reported-by Jim Davis)
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      Signed-off-by: NDmitry Kasatkin <d.kasatkin@samsung.com>
      Acked-by: NDavid Howells <dhowells@redhat.com>
      7d2ce232
    • D
      ima: provide double buffering for hash calculation · 32c2e675
      Dmitry Kasatkin 提交于
      The asynchronous hash API allows initiating a hash calculation and
      then performing other tasks, while waiting for the hash calculation
      to complete.
      
      This patch introduces usage of double buffering for simultaneous
      hashing and reading of the next chunk of data from storage.
      
      Changes in v3:
      - better comments
      Signed-off-by: NDmitry Kasatkin <d.kasatkin@samsung.com>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      32c2e675
    • D
      ima: introduce multi-page collect buffers · 6edf7a89
      Dmitry Kasatkin 提交于
      Use of multiple-page collect buffers reduces:
      1) the number of block IO requests
      2) the number of asynchronous hash update requests
      
      Second is important for HW accelerated hashing, because significant
      amount of time is spent for preparation of hash update operation,
      which includes configuring acceleration HW, DMA engine, etc...
      Thus, HW accelerators are more efficient when working on large
      chunks of data.
      
      This patch introduces usage of multi-page collect buffers. Buffer size
      can be specified using 'ahash_bufsize' module parameter. Default buffer
      size is 4096 bytes.
      
      Changes in v3:
      - kernel parameter replaced with module parameter
      Signed-off-by: NDmitry Kasatkin <d.kasatkin@samsung.com>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      6edf7a89
    • D
      ima: use ahash API for file hash calculation · 3bcced39
      Dmitry Kasatkin 提交于
      Async hash API allows the use of HW acceleration for hash calculation.
      It may give significant performance gain and/or reduce power consumption,
      which might be very beneficial for battery powered devices.
      
      This patch introduces hash calculation using ahash API. ahash performance
      depends on the data size and the particular HW. Depending on the specific
      system, shash performance may be better.
      
      This patch defines 'ahash_minsize' module parameter, which is used to
      define the minimal file size to use with ahash.  If this minimum file size
      is not set or the file is smaller than defined by the parameter, shash will
      be used.
      
      Changes in v3:
      - kernel parameter replaced with module parameter
      - pr_crit replaced with pr_crit_ratelimited
      - more comment changes - Mimi
      
      Changes in v2:
      - ima_ahash_size became as ima_ahash
      - ahash pre-allocation moved out from __init code to be able to use
        ahash crypto modules. Ahash allocated once on the first use.
      - hash calculation falls back to shash if ahash allocation/calculation fails
      - complex initialization separated from variable declaration
      - improved comments
      Signed-off-by: NDmitry Kasatkin <d.kasatkin@samsung.com>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      3bcced39
    • R
      audit: fix dangling keywords in integrity ima message output · 7e9001f6
      Richard Guy Briggs 提交于
      Replace spaces in op keyword labels in log output since userspace audit tools
      can't parse orphaned keywords.
      Reported-by: NSteve Grubb <sgrubb@redhat.com>
      Signed-off-by: NRichard Guy Briggs <rgb@redhat.com>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      7e9001f6
    • D
      ima: delay template descriptor lookup until use · 209b43ca
      Dmitry Kasatkin 提交于
      process_measurement() always calls ima_template_desc_current(),
      including when an IMA policy has not been defined.
      
      This patch delays template descriptor lookup until action is
      determined.
      Signed-off-by: NDmitry Kasatkin <d.kasatkin@samsung.com>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      209b43ca
    • D
      ima: remove unnecessary i_mutex locking from ima_rdwr_violation_check() · 2c50b964
      Dmitry Kasatkin 提交于
      Before 2.6.39 inode->i_readcount was maintained by IMA. It was not atomic
      and protected using spinlock. For 2.6.39, i_readcount was converted to
      atomic and maintaining was moved VFS layer. Spinlock for some unclear
      reason was replaced by i_mutex.
      
      After analyzing the code, we came to conclusion that i_mutex locking is
      unnecessary, especially when an IMA policy has not been defined.
      
      This patch removes i_mutex locking from ima_rdwr_violation_check().
      Signed-off-by: NDmitry Kasatkin <d.kasatkin@samsung.com>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      2c50b964
  3. 13 6月, 2014 4 次提交
    • D
      ima: introduce ima_kernel_read() · 0430e49b
      Dmitry Kasatkin 提交于
      Commit 8aac6270 "move exit_task_namespaces() outside of exit_notify"
      introduced the kernel opps since the kernel v3.10, which happens when
      Apparmor and IMA-appraisal are enabled at the same time.
      
      ----------------------------------------------------------------------
      [  106.750167] BUG: unable to handle kernel NULL pointer dereference at
      0000000000000018
      [  106.750221] IP: [<ffffffff811ec7da>] our_mnt+0x1a/0x30
      [  106.750241] PGD 0
      [  106.750254] Oops: 0000 [#1] SMP
      [  106.750272] Modules linked in: cuse parport_pc ppdev bnep rfcomm
      bluetooth rpcsec_gss_krb5 nfsd auth_rpcgss nfs_acl nfs lockd sunrpc
      fscache dm_crypt intel_rapl x86_pkg_temp_thermal intel_powerclamp
      kvm_intel snd_hda_codec_hdmi kvm crct10dif_pclmul crc32_pclmul
      ghash_clmulni_intel aesni_intel aes_x86_64 glue_helper lrw gf128mul
      ablk_helper cryptd snd_hda_codec_realtek dcdbas snd_hda_intel
      snd_hda_codec snd_hwdep snd_pcm snd_page_alloc snd_seq_midi
      snd_seq_midi_event snd_rawmidi psmouse snd_seq microcode serio_raw
      snd_timer snd_seq_device snd soundcore video lpc_ich coretemp mac_hid lp
      parport mei_me mei nbd hid_generic e1000e usbhid ahci ptp hid libahci
      pps_core
      [  106.750658] CPU: 6 PID: 1394 Comm: mysqld Not tainted 3.13.0-rc7-kds+ #15
      [  106.750673] Hardware name: Dell Inc. OptiPlex 9010/0M9KCM, BIOS A08
      09/19/2012
      [  106.750689] task: ffff8800de804920 ti: ffff880400fca000 task.ti:
      ffff880400fca000
      [  106.750704] RIP: 0010:[<ffffffff811ec7da>]  [<ffffffff811ec7da>]
      our_mnt+0x1a/0x30
      [  106.750725] RSP: 0018:ffff880400fcba60  EFLAGS: 00010286
      [  106.750738] RAX: 0000000000000000 RBX: 0000000000000100 RCX:
      ffff8800d51523e7
      [  106.750764] RDX: ffffffffffffffea RSI: ffff880400fcba34 RDI:
      ffff880402d20020
      [  106.750791] RBP: ffff880400fcbae0 R08: 0000000000000000 R09:
      0000000000000001
      [  106.750817] R10: 0000000000000000 R11: 0000000000000001 R12:
      ffff8800d5152300
      [  106.750844] R13: ffff8803eb8df510 R14: ffff880400fcbb28 R15:
      ffff8800d51523e7
      [  106.750871] FS:  0000000000000000(0000) GS:ffff88040d200000(0000)
      knlGS:0000000000000000
      [  106.750910] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      [  106.750935] CR2: 0000000000000018 CR3: 0000000001c0e000 CR4:
      00000000001407e0
      [  106.750962] Stack:
      [  106.750981]  ffffffff813434eb ffff880400fcbb20 ffff880400fcbb18
      0000000000000000
      [  106.751037]  ffff8800de804920 ffffffff8101b9b9 0001800000000000
      0000000000000100
      [  106.751093]  0000010000000000 0000000000000002 000000000000000e
      ffff8803eb8df500
      [  106.751149] Call Trace:
      [  106.751172]  [<ffffffff813434eb>] ? aa_path_name+0x2ab/0x430
      [  106.751199]  [<ffffffff8101b9b9>] ? sched_clock+0x9/0x10
      [  106.751225]  [<ffffffff8134a68d>] aa_path_perm+0x7d/0x170
      [  106.751250]  [<ffffffff8101b945>] ? native_sched_clock+0x15/0x80
      [  106.751276]  [<ffffffff8134aa73>] aa_file_perm+0x33/0x40
      [  106.751301]  [<ffffffff81348c5e>] common_file_perm+0x8e/0xb0
      [  106.751327]  [<ffffffff81348d78>] apparmor_file_permission+0x18/0x20
      [  106.751355]  [<ffffffff8130c853>] security_file_permission+0x23/0xa0
      [  106.751382]  [<ffffffff811c77a2>] rw_verify_area+0x52/0xe0
      [  106.751407]  [<ffffffff811c789d>] vfs_read+0x6d/0x170
      [  106.751432]  [<ffffffff811cda31>] kernel_read+0x41/0x60
      [  106.751457]  [<ffffffff8134fd45>] ima_calc_file_hash+0x225/0x280
      [  106.751483]  [<ffffffff8134fb52>] ? ima_calc_file_hash+0x32/0x280
      [  106.751509]  [<ffffffff8135022d>] ima_collect_measurement+0x9d/0x160
      [  106.751536]  [<ffffffff810b552d>] ? trace_hardirqs_on+0xd/0x10
      [  106.751562]  [<ffffffff8134f07c>] ? ima_file_free+0x6c/0xd0
      [  106.751587]  [<ffffffff81352824>] ima_update_xattr+0x34/0x60
      [  106.751612]  [<ffffffff8134f0d0>] ima_file_free+0xc0/0xd0
      [  106.751637]  [<ffffffff811c9635>] __fput+0xd5/0x300
      [  106.751662]  [<ffffffff811c98ae>] ____fput+0xe/0x10
      [  106.751687]  [<ffffffff81086774>] task_work_run+0xc4/0xe0
      [  106.751712]  [<ffffffff81066fad>] do_exit+0x2bd/0xa90
      [  106.751738]  [<ffffffff8173c958>] ? retint_swapgs+0x13/0x1b
      [  106.751763]  [<ffffffff8106780c>] do_group_exit+0x4c/0xc0
      [  106.751788]  [<ffffffff81067894>] SyS_exit_group+0x14/0x20
      [  106.751814]  [<ffffffff8174522d>] system_call_fastpath+0x1a/0x1f
      [  106.751839] Code: c3 0f 1f 44 00 00 55 48 89 e5 e8 22 fe ff ff 5d c3
      0f 1f 44 00 00 55 65 48 8b 04 25 c0 c9 00 00 48 8b 80 28 06 00 00 48 89
      e5 5d <48> 8b 40 18 48 39 87 c0 00 00 00 0f 94 c0 c3 0f 1f 80 00 00 00
      [  106.752185] RIP  [<ffffffff811ec7da>] our_mnt+0x1a/0x30
      [  106.752214]  RSP <ffff880400fcba60>
      [  106.752236] CR2: 0000000000000018
      [  106.752258] ---[ end trace 3c520748b4732721 ]---
      ----------------------------------------------------------------------
      
      The reason for the oops is that IMA-appraisal uses "kernel_read()" when
      file is closed. kernel_read() honors LSM security hook which calls
      Apparmor handler, which uses current->nsproxy->mnt_ns. The 'guilty'
      commit changed the order of cleanup code so that nsproxy->mnt_ns was
      not already available for Apparmor.
      
      Discussion about the issue with Al Viro and Eric W. Biederman suggested
      that kernel_read() is too high-level for IMA. Another issue, except
      security checking, that was identified is mandatory locking. kernel_read
      honors it as well and it might prevent IMA from calculating necessary hash.
      It was suggested to use simplified version of the function without security
      and locking checks.
      
      This patch introduces special version ima_kernel_read(), which skips security
      and mandatory locking checking. It prevents the kernel oops to happen.
      Signed-off-by: NDmitry Kasatkin <d.kasatkin@samsung.com>
      Suggested-by: NEric W. Biederman <ebiederm@xmission.com>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      Cc: <stable@vger.kernel.org>
      0430e49b
    • D
      ima: check inode integrity cache in violation check · 14503eb9
      Dmitry Kasatkin 提交于
      When IMA did not support ima-appraisal, existance of the S_IMA flag
      clearly indicated that the file was measured. With IMA appraisal S_IMA
      flag indicates that file was measured and/or appraised. Because of
      this, when measurement is not enabled by the policy, violations are
      still reported.
      
      To differentiate between measurement and appraisal policies this
      patch checks the inode integrity cache flags.  The IMA_MEASURED
      flag indicates whether the file was actually measured, while the
      IMA_MEASURE flag indicates whether the file should be measured.
      Unfortunately, the IMA_MEASURED flag is reset to indicate the file
      needs to be re-measured.  Thus, this patch checks the IMA_MEASURE
      flag.
      
      This patch limits the false positive violation reports, but does
      not fix it entirely.  The IMA_MEASURE/IMA_MEASURED flags are
      indications that, at some point in time, the file opened for read
      was in policy, but might not be in policy now (eg. different uid).
      Other changes would be needed to further limit false positive
      violation reports.
      
      Changelog:
      - expanded patch description based on conversation with Roberto (Mimi)
      Signed-off-by: NDmitry Kasatkin <d.kasatkin@samsung.com>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      14503eb9
    • D
      ima: prevent unnecessary policy checking · b882fae2
      Dmitry Kasatkin 提交于
      ima_rdwr_violation_check is called for every file openning.
      The function checks the policy even when violation condition
      is not met. It causes unnecessary policy checking.
      
      This patch does policy checking only if violation condition is met.
      
      Changelog:
      - check writecount is greater than zero (Mimi)
      Signed-off-by: NDmitry Kasatkin <d.kasatkin@samsung.com>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      b882fae2
    • M
      ima: prevent new digsig xattr from being replaced · 060bdebf
      Mimi Zohar 提交于
      Even though a new xattr will only be appraised on the next access,
      set the DIGSIG flag to prevent a signature from being replaced with
      a hash on file close.
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      060bdebf
  4. 04 6月, 2014 1 次提交
    • M
      ima: audit log files opened with O_DIRECT flag · f9b2a735
      Mimi Zohar 提交于
      Files are measured or appraised based on the IMA policy.  When a
      file, in policy, is opened with the O_DIRECT flag, a deadlock
      occurs.
      
      The first attempt at resolving this lockdep temporarily removed the
      O_DIRECT flag and restored it, after calculating the hash.  The
      second attempt introduced the O_DIRECT_HAVELOCK flag. Based on this
      flag, do_blockdev_direct_IO() would skip taking the i_mutex a second
      time.  The third attempt, by Dmitry Kasatkin, resolves the i_mutex
      locking issue, by re-introducing the IMA mutex, but uncovered
      another problem.  Reading a file with O_DIRECT flag set, writes
      directly to userspace pages.  A second patch allocates a user-space
      like memory.  This works for all IMA hooks, except ima_file_free(),
      which is called on __fput() to recalculate the file hash.
      
      Until this last issue is addressed, do not 'collect' the
      measurement for measuring, appraising, or auditing files opened
      with the O_DIRECT flag set.  Based on policy, permit or deny file
      access.  This patch defines a new IMA policy rule option named
      'permit_directio'.  Policy rules could be defined, based on LSM
      or other criteria, to permit specific applications to open files
      with the O_DIRECT flag set.
      
      Changelog v1:
      - permit or deny file access based IMA policy rules
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      Acked-by: NDmitry Kasatkin <d.kasatkin@samsung.com>
      Cc: <stable@vger.kernel.org>
      f9b2a735
  5. 08 3月, 2014 8 次提交
  6. 05 3月, 2014 1 次提交
  7. 06 2月, 2014 1 次提交
  8. 03 1月, 2014 3 次提交
  9. 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
  10. 30 11月, 2013 1 次提交
  11. 26 11月, 2013 1 次提交
    • R
      ima: make a copy of template_fmt in template_desc_init_fields() · dbc335d2
      Roberto Sassu 提交于
      This patch makes a copy of the 'template_fmt' function argument so that
      the latter will not be modified by strsep(), which does the splitting by
      replacing the given separator with '\0'.
      
       IMA: No TPM chip found, activating TPM-bypass!
       Unable to handle kernel pointer dereference at virtual kernel address 0000000000842000
       Oops: 0004 [#1] SMP
       Modules linked in:
       CPU: 3 PID: 1 Comm: swapper/0 Not tainted 3.12.0-rc2-00098-g3ce1217d #17
       task: 000000003ffa0000 ti: 000000003ff84000 task.ti: 000000003ff84000
       Krnl PSW : 0704e00180000000 000000000044bf88 (strsep+0x7c/0xa0)
                  R:0 T:1 IO:1 EX:1 Key:0 M:1 W:0 P:0 AS:3 CC:2 PM:0 EA:3
       Krnl GPRS: 000000000000007c 000000000000007c 000000003ff87d90 0000000000821fd8
                  0000000000000000 000000000000007c 0000000000aa37e0 0000000000aa9008
                  0000000000000051 0000000000a114d8 0000000100000002 0000000000842bde
                  0000000000842bdf 00000000006f97f0 000000000040062c 000000003ff87cf0
       Krnl Code: 000000000044bf7c: a7f4000a           brc     15,44bf90
                  000000000044bf80: b90200cc           ltgr    %r12,%r12
                 #000000000044bf84: a7840006           brc     8,44bf90
                 >000000000044bf88: 9200c000           mvi     0(%r12),0
                  000000000044bf8c: 41c0c001           la      %r12,1(%r12)
                  000000000044bf90: e3c020000024       stg     %r12,0(%r2)
                  000000000044bf96: b904002b           lgr     %r2,%r11
                  000000000044bf9a: ebbcf0700004       lmg     %r11,%r12,112(%r15)
       Call Trace:
       ([<00000000004005fe>] ima_init_template+0xa2/0x1bc)
        [<0000000000a7c896>] ima_init+0x7a/0xa8
        [<0000000000a7c938>] init_ima+0x24/0x40
        [<00000000001000e8>] do_one_initcall+0x68/0x128
        [<0000000000a4eb56>] kernel_init_freeable+0x20a/0x2b4
        [<00000000006a1ff4>] kernel_init+0x30/0x178
        [<00000000006b69fe>] kernel_thread_starter+0x6/0xc
        [<00000000006b69f8>] kernel_thread_starter+0x0/0xc
       Last Breaking-Event-Address:
        [<000000000044bf42>] strsep+0x36/0xa0
      
      Fixes commit: adf53a77 ima: new templates management mechanism
      
      Changelog v1:
      - make template_fmt 'const char *' (reported-by James Morris)
      - fix kstrdup memory leak (reported-by James Morris)
      Reported-by: NHeiko Carstens <heiko.carstens@de.ibm.com>
      Signed-off-by: NRoberto Sassu <roberto.sassu@polito.it>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      Tested-by: NHeiko Carstens <heiko.carstens@de.ibm.com>
      dbc335d2
  12. 25 11月, 2013 2 次提交
  13. 24 11月, 2013 1 次提交
  14. 01 11月, 2013 2 次提交
    • M
      ima: define '_ima' as a builtin 'trusted' keyring · 217091dd
      Mimi Zohar 提交于
      Require all keys added to the IMA keyring be signed by an
      existing trusted key on the system trusted keyring.
      
      Changelog:
      - define stub integrity_init_keyring() function (reported-by Fengguang Wu)
      - differentiate between regular and trusted keyring names.
      - replace printk with pr_info (D. Kasatkin)
      Signed-off-by: NMimi Zohar <zohar@us.ibm.com>
      217091dd
    • 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
  15. 27 10月, 2013 5 次提交
    • D
      ima: provide hash algo info in the xattr · 3ea7a560
      Dmitry Kasatkin 提交于
      All files labeled with 'security.ima' hashes, are hashed using the
      same hash algorithm.  Changing from one hash algorithm to another,
      requires relabeling the filesystem.  This patch defines a new xattr
      type, which includes the hash algorithm, permitting different files
      to be hashed with different algorithms.
      Signed-off-by: NDmitry Kasatkin <d.kasatkin@samsung.com>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      3ea7a560
    • M
      ima: enable support for larger default filedata hash algorithms · e7a2ad7e
      Mimi Zohar 提交于
      The IMA measurement list contains two hashes - a template data hash
      and a filedata hash.  The template data hash is committed to the TPM,
      which is limited, by the TPM v1.2 specification, to 20 bytes.  The
      filedata hash is defined as 20 bytes as well.
      
      Now that support for variable length measurement list templates was
      added, the filedata hash is not limited to 20 bytes.  This patch adds
      Kconfig support for defining larger default filedata hash algorithms
      and replacing the builtin default with one specified on the kernel
      command line.
      
      <uapi/linux/hash_info.h> contains a list of hash algorithms.  The
      Kconfig default hash algorithm is a subset of this list, but any hash
      algorithm included in the list can be specified at boot, using the
      'ima_hash=' kernel command line option.
      
      Changelog v2:
      - update Kconfig
      
      Changelog:
      - support hashes that are configured
      - use generic HASH_ALGO_ definitions
      - add Kconfig support
      - hash_setup must be called only once (Dmitry)
      - removed trailing whitespaces (Roberto Sassu)
      Signed-off-by: NMimi Zohar <zohar@us.ibm.com>
      Signed-off-by: NRoberto Sassu <roberto.sassu@polito.it>
      e7a2ad7e
    • R
      ima: define kernel parameter 'ima_template=' to change configured default · 9b9d4ce5
      Roberto Sassu 提交于
      This patch allows users to specify from the kernel command line the
      template descriptor, among those defined, that will be used to generate
      and display measurement entries. If an user specifies a wrong template,
      IMA reverts to the template descriptor set in the kernel configuration.
      Signed-off-by: NRoberto Sassu <roberto.sassu@polito.it>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      9b9d4ce5
    • M
      ima: add Kconfig default measurement list template · 4286587d
      Mimi Zohar 提交于
      This patch adds a Kconfig option to select the default IMA
      measurement list template.  The 'ima' template limited the
      filedata hash to 20 bytes and the pathname to 255 charaters.
      The 'ima-ng' measurement list template permits larger hash
      digests and longer pathnames.
      
      Changelog:
      - keep 'select CRYPTO_HASH_INFO' in 'config IMA' section (Kconfig)
        (Roberto Sassu);
      - removed trailing whitespaces (Roberto Sassu).
      - Lindent fixes
      Signed-off-by: NMimi Zohar <zohar@us.ibm.com>
      Signed-off-by: NRoberto Sassu <roberto.sassu@polito.it>
      4286587d
    • R
      ima: defer determining the appraisal hash algorithm for 'ima' template · add1c05d
      Roberto Sassu 提交于
      The same hash algorithm should be used for calculating the file
      data hash for the IMA measurement list, as for appraising the file
      data integrity.  (The appraise hash algorithm is stored in the
      'security.ima' extended attribute.)  The exception is when the
      reference file data hash digest, stored in the extended attribute,
      is larger than the one supported by the template.  In this case,
      the file data hash needs to be calculated twice, once for the
      measurement list and, again, for appraisal.
      Signed-off-by: NRoberto Sassu <roberto.sassu@polito.it>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      add1c05d