1. 18 11月, 2014 6 次提交
  2. 13 10月, 2014 5 次提交
    • R
      ima: added support for new kernel cmdline parameter ima_template_fmt · c2426d2a
      Roberto Sassu 提交于
      This patch allows users to provide a custom template format through the
      new kernel command line parameter 'ima_template_fmt'. If the supplied
      format is not valid, IMA uses the default template descriptor.
      
      Changelog:
       - v3:
         - added check for 'fields' and 'num_fields' in
           template_desc_init_fields() (suggested by Mimi Zohar)
      
       - v2:
         - using template_desc_init_fields() to validate a format string
           (Roberto Sassu)
         - updated documentation by stating that only the chosen template
           descriptor is initialized (Roberto Sassu)
      
       - v1:
         - simplified code of ima_template_fmt_setup()
           (Roberto Sassu, suggested by Mimi Zohar)
      Signed-off-by: NRoberto Sassu <roberto.sassu@polito.it>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      c2426d2a
    • R
      ima: allocate field pointers array on demand in template_desc_init_fields() · 1bd7face
      Roberto Sassu 提交于
      The allocation of a field pointers array is moved at the end of
      template_desc_init_fields() and done only if the value of the 'fields'
      and 'num_fields' parameters is not NULL. For just validating a template
      format string, retrieved template field pointers are placed in a temporary
      array.
      
      Changelog:
       - v3:
         - do not check in this patch if 'fields' and 'num_fields' are NULL
           (suggested by Mimi Zohar)
      Signed-off-by: NRoberto Sassu <roberto.sassu@polito.it>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      1bd7face
    • R
      ima: don't allocate a copy of template_fmt in template_desc_init_fields() · 9f3166b8
      Roberto Sassu 提交于
      This patch removes the allocation of a copy of 'template_fmt', needed for
      iterating over all fields in the passed template format string. The removal
      was possible by replacing strcspn(), which modifies the passed string,
      with strchrnul(). The currently processed template field is copied in
      a temporary variable.
      
      The purpose of this change is use template_desc_init_fields() in two ways:
      for just validating a template format string (the function should work
      if called by a setup function, when memory cannot be allocated), and for
      actually initializing a template descriptor. The implementation of this
      feature will be complete with the next patch.
      
      Changelog:
       - v3:
         - added 'goto out' in template_desc_init_fields() to free allocated
           memory if a template field length is not valid (suggested by
           Mimi Zohar)
      Signed-off-by: NRoberto Sassu <roberto.sassu@polito.it>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      9f3166b8
    • R
      ima: display template format in meas. list if template name length is zero · 7dbdb420
      Roberto Sassu 提交于
      With the introduction of the 'ima_template_fmt' kernel cmdline parameter,
      a user can define a new template descriptor with custom format. However,
      in this case, userspace tools will be unable to parse the measurements
      list because the new template is unknown. For this reason, this patch
      modifies the current IMA behavior to display in the list the template
      format instead of the name (only if the length of the latter is zero)
      so that a tool can extract needed information if it can handle listed
      fields.
      
      This patch also correctly displays the error log message in
      ima_init_template() if the selected template cannot be initialized.
      
      Changelog:
       - v3:
         - check the first byte of 'e->template_desc->name' instead of using
           strlen() in ima_fs.c (suggested by Mimi Zohar)
      
       - v2:
         - print the template format in ima_init_template(), if the selected
           template is custom (Roberto Sassu)
      
       - v1:
         - fixed patch description (Roberto Sassu, suggested by Mimi Zohar)
         - set 'template_name' variable in ima_fs.c only once
           (Roberto Sassu, suggested by Mimi Zohar)
      Signed-off-by: NRoberto Sassu <roberto.sassu@polito.it>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      7dbdb420
    • R
      ima: added error messages to template-related functions · 71fed2ee
      Roberto Sassu 提交于
      This patch adds some error messages to inform users about the following
      events: template descriptor not found, invalid template descriptor,
      template field not found and template initialization failed.
      
      Changelog:
       - v2:
         - display an error message if the format string contains too many
           fields (Roberto Sassu)
      Signed-off-by: NRoberto Sassu <roberto.sassu@polito.it>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      71fed2ee
  3. 12 10月, 2014 4 次提交
  4. 08 10月, 2014 4 次提交
  5. 07 10月, 2014 3 次提交
  6. 06 10月, 2014 2 次提交
  7. 03 10月, 2014 2 次提交
    • D
      X.509: If available, use the raw subjKeyId to form the key description · dd2f6c44
      David Howells 提交于
      Module signing matches keys by comparing against the key description exactly.
      However, the way the key description gets constructed got changed to be
      composed of the subject name plus the certificate serial number instead of the
      subject name and the subjectKeyId.  I changed this to avoid problems with
      certificates that don't *have* a subjectKeyId.
      
      Instead, if available, use the raw subjectKeyId to form the key description
      and only use the serial number if the subjectKeyId doesn't exist.
      Reported-by: NDmitry Kasatkin <d.kasatkin@samsung.com>
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      dd2f6c44
    • D
      KEYS: handle error code encoded in pointer · 40b50e80
      Dmitry Kasatkin 提交于
      If hexlen is odd then function returns an error.
      Use IS_ERR to check for error, otherwise invalid pointer
      is used and kernel gives oops:
      
      [  132.816522] BUG: unable to handle kernel paging request at
      ffffffffffffffea
      [  132.819902] IP: [<ffffffff812bfc20>] asymmetric_key_id_same+0x14/0x36
      [  132.820302] PGD 1a12067 PUD 1a14067 PMD 0
      [  132.820302] Oops: 0000 [#1] SMP
      [  132.820302] Modules linked in: bridge(E) stp(E) llc(E) evdev(E)
      serio_raw(E) i2c_piix4(E) button(E) fuse(E)
      [  132.820302] CPU: 0 PID: 2993 Comm: cat Tainted: G            E
      3.16.0-kds+ #2847
      [  132.820302] Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
      [  132.820302] task: ffff88004249a430 ti: ffff880056640000 task.ti:
      ffff880056640000
      [  132.820302] RIP: 0010:[<ffffffff812bfc20>]  [<ffffffff812bfc20>]
      asymmetric_key_id_same+0x14/0x36
      [  132.820302] RSP: 0018:ffff880056643930  EFLAGS: 00010246
      [  132.820302] RAX: 0000000000000000 RBX: ffffffffffffffea RCX:
      ffff880056643ae0
      [  132.820302] RDX: 000000000000005e RSI: ffffffffffffffea RDI:
      ffff88005bac9300
      [  132.820302] RBP: ffff880056643948 R08: 0000000000000003 R09:
      00000007504aa01a
      [  132.820302] R10: 0000000000000000 R11: 0000000000000000 R12:
      ffff88005d68ca40
      [  132.820302] R13: 0000000000000101 R14: 0000000000000000 R15:
      ffff88005bac5280
      [  132.820302] FS:  00007f67a153c740(0000) GS:ffff88005da00000(0000)
      knlGS:0000000000000000
      [  132.820302] CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
      [  132.820302] CR2: ffffffffffffffea CR3: 000000002e663000 CR4:
      00000000000006f0
      [  132.820302] Stack:
      [  132.820302]  ffffffff812bfc66 ffff880056643ae0 ffff88005bac5280
      ffff880056643958
      [  132.820302]  ffffffff812bfc9d ffff880056643980 ffffffff812971d9
      ffff88005ce930c1
      [  132.820302]  ffff88005ce930c0 0000000000000000 ffff8800566439c8
      ffffffff812fb753
      [  132.820302] Call Trace:
      [  132.820302]  [<ffffffff812bfc66>] ? asymmetric_match_key_ids+0x24/0x42
      [  132.820302]  [<ffffffff812bfc9d>] asymmetric_key_cmp+0x19/0x1b
      [  132.820302]  [<ffffffff812971d9>] keyring_search_iterator+0x74/0xd7
      [  132.820302]  [<ffffffff812fb753>] assoc_array_subtree_iterate+0x67/0xd2
      [  132.820302]  [<ffffffff81297165>] ? key_default_cmp+0x20/0x20
      [  132.820302]  [<ffffffff812fbaa1>] assoc_array_iterate+0x19/0x1e
      [  132.820302]  [<ffffffff81297332>] search_nested_keyrings+0xf6/0x2b6
      [  132.820302]  [<ffffffff810728da>] ? sched_clock_cpu+0x91/0xa2
      [  132.820302]  [<ffffffff810860d2>] ? mark_held_locks+0x58/0x6e
      [  132.820302]  [<ffffffff810a137d>] ? current_kernel_time+0x77/0xb8
      [  132.820302]  [<ffffffff81297871>] keyring_search_aux+0xe1/0x14c
      [  132.820302]  [<ffffffff812977fc>] ? keyring_search_aux+0x6c/0x14c
      [  132.820302]  [<ffffffff8129796b>] keyring_search+0x8f/0xb6
      [  132.820302]  [<ffffffff812bfc84>] ? asymmetric_match_key_ids+0x42/0x42
      [  132.820302]  [<ffffffff81297165>] ? key_default_cmp+0x20/0x20
      [  132.820302]  [<ffffffff812ab9e3>] asymmetric_verify+0xa4/0x214
      [  132.820302]  [<ffffffff812ab90e>] integrity_digsig_verify+0xb1/0xe2
      [  132.820302]  [<ffffffff812abe41>] ? evm_verifyxattr+0x6a/0x7a
      [  132.820302]  [<ffffffff812b0390>] ima_appraise_measurement+0x160/0x370
      [  132.820302]  [<ffffffff81161db2>] ? d_absolute_path+0x5b/0x7a
      [  132.820302]  [<ffffffff812ada30>] process_measurement+0x322/0x404
      Reported-by: NDmitry Kasatkin <d.kasatkin@samsung.com>
      Signed-off-by: NDmitry Kasatkin <d.kasatkin@samsung.com>
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      40b50e80
  8. 02 10月, 2014 1 次提交
  9. 30 9月, 2014 2 次提交
  10. 23 9月, 2014 2 次提交
  11. 22 9月, 2014 2 次提交
    • J
      Merge tag 'keys-next-20140922' of... · 35e1efd2
      James Morris 提交于
      Merge tag 'keys-next-20140922' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs into next
      35e1efd2
    • D
      KEYS: Check hex2bin()'s return when generating an asymmetric key ID · d1ac5540
      David Howells 提交于
      As it stands, the code to generate an asymmetric key ID prechecks the hex
      string it is given whilst determining the length, before it allocates the
      buffer for hex2bin() to translate into - which mean that checking the result of
      hex2bin() is redundant.
      
      Unfortunately, hex2bin() is marked as __must_check, which means that the
      following warning may be generated if the return value isn't checked:
      
      	crypto/asymmetric_keys/asymmetric_type.c: In function
      	asymmetric_key_hex_to_key_id:
      	crypto/asymmetric_keys/asymmetric_type.c:110: warning: ignoring return
      	value of hex2bin, declared with attribute warn_unused_result
      
      The warning can't be avoided by casting the result to void.
      
      Instead, use strlen() to check the length of the string and ignore the fact
      that the string might not be entirely valid hex until after the allocation has
      been done - in which case we can use the result of hex2bin() for this.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      d1ac5540
  12. 18 9月, 2014 7 次提交
    • R
      ima: detect violations for mmaped files · 1b68bdf9
      Roberto Sassu 提交于
      This patch fixes the detection of the 'open_writers' violation for mmaped
      files.
      
      before) an 'open_writers' violation is detected if the policy contains
              a rule with the criteria: func=FILE_CHECK mask=MAY_READ
      
      after) an 'open_writers' violation is detected if the current event
             matches one of the policy rules.
      
      With the old behaviour, the 'open_writers' violation is not detected
      in the following case:
      
      policy:
      measure func=FILE_MMAP mask=MAY_EXEC
      
      steps:
      1) open a shared library for writing
      2) execute a binary that links that shared library
      3) during the binary execution, modify the shared library and save
         the change
      
      result:
      the 'open_writers' violation measurement is not present in the IMA list.
      
      Only binaries executed are protected from writes. For libraries mapped
      in memory there is the flag MAP_DENYWRITE for this purpose, but according
      to the output of 'man mmap', the mmap flag is ignored.
      
      Since ima_rdwr_violation_check() is now called by process_measurement()
      the information about if the inode must be measured is already provided
      by ima_get_action(). Thus the unnecessary function ima_must_measure()
      has been removed.
      
      Changes in v3 (Dmitry Kasatkin):
      - Violation for MMAP_CHECK function are verified since this patch
      - Changed patch description a bit
      Signed-off-by: NRoberto Sassu <roberto.sassu@polito.it>
      Signed-off-by: NDmitry Kasatkin <d.kasatkin@samsung.com>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      1b68bdf9
    • R
      ima: fix race condition on ima_rdwr_violation_check and process_measurement · f7a859ff
      Roberto Sassu 提交于
      This patch fixes a race condition between two functions that try to access
      the same inode. Since the i_mutex lock is held and released separately
      in the two functions, there may be the possibility that a violation is
      not correctly detected.
      
      Suppose there are two processes, A (reader) and B (writer), if the
      following sequence happens:
      
      A: ima_rdwr_violation_check()
      B: ima_rdwr_violation_check()
      B: process_measurement()
      B: starts writing the inode
      A: process_measurement()
      
      the ToMToU violation (a reader may be accessing a content different from
      that measured, due to a concurrent modification by a writer) will not be
      detected. To avoid this issue, the violation check and the measurement
      must be done atomically.
      
      This patch fixes the problem by moving the violation check inside
      process_measurement() when the i_mutex lock is held. Differently from
      the old code, the violation check is executed also for the MMAP_CHECK
      hook (other than for FILE_CHECK). This allows to detect ToMToU violations
      that are possible because shared libraries can be opened for writing
      while they are in use (according to the output of 'man mmap', the mmap()
      flag MAP_DENYWRITE is ignored).
      
      Changes in v5 (Roberto Sassu):
      * get iint if action is not zero
      * exit process_measurement() after the violation check if action is zero
      * reverse order process_measurement() exit cleanup (Mimi)
      
      Changes in v4 (Dmitry Kasatkin):
      * iint allocation is done before calling ima_rdrw_violation_check()
        (Suggested-by Mimi)
      * do not check for violations if the policy does not contain 'measure'
        rules (done by Roberto Sassu)
      
      Changes in v3 (Dmitry Kasatkin):
      * no violation checking for MMAP_CHECK function in this patch
      * remove use of filename from violation
      * removes checking if ima is enabled from ima_rdrw_violation_check
      * slight style change
      Suggested-by: NDmitry Kasatkin <d.kasatkin@samsung.com>
      Signed-off-by: NRoberto Sassu <roberto.sassu@polito.it>
      Signed-off-by: NDmitry Kasatkin <d.kasatkin@samsung.com>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      f7a859ff
    • J
    • R
      ima: added ima_policy_flag variable · a756024e
      Roberto Sassu 提交于
      This patch introduces the new variable 'ima_policy_flag', whose bits
      are set depending on the action of the current policy rules. Only the
      flags IMA_MEASURE, IMA_APPRAISE and IMA_AUDIT are set.
      
      The new variable will be used to improve performance by skipping the
      unnecessary execution of IMA code if the policy does not contain rules
      with the above actions.
      
      Changes in v6 (Roberto Sassu)
      * do not check 'ima_initialized' before calling ima_update_policy_flag()
        in ima_update_policy() (suggested by Dmitry)
      * calling ima_update_policy_flag() moved to init_ima to co-locate with
        ima_initialized (Dmitry)
      * add/revise comments (Mimi)
      
      Changes in v5 (Roberto Sassu)
      * reset IMA_APPRAISE flag in 'ima_policy_flag' if 'ima_appraise' is set
        to zero (reported by Dmitry)
      * update 'ima_policy_flag' only if IMA initialization is successful
        (suggested by Mimi and Dmitry)
      * check 'ima_policy_flag' instead of 'ima_initialized'
        (suggested by Mimi and Dmitry)
      Signed-off-by: NRoberto Sassu <roberto.sassu@polito.it>
      Signed-off-by: NDmitry Kasatkin <d.kasatkin@samsung.com>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      a756024e
    • R
      ima: return an error code from ima_add_boot_aggregate() · be39ffc2
      Roberto Sassu 提交于
      This patch modifies ima_add_boot_aggregate() to return an error code.
      This way we can determine if all the initialization procedures have
      been executed successfully.
      Signed-off-by: NRoberto Sassu <roberto.sassu@polito.it>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      be39ffc2
    • D
      ima: provide 'ima_appraise=log' kernel option · 2faa6ef3
      Dmitry Kasatkin 提交于
      The kernel boot parameter "ima_appraise" currently defines 'off',
      'enforce' and 'fix' modes.  When designing a policy and labeling
      the system, access to files are either blocked in the default
      'enforce' mode or automatically fixed in the 'fix' mode.  It is
      beneficial to be able to run the system in a logging only mode,
      without fixing it, in order to properly analyze the system. This
      patch adds a 'log' mode to run the system in a permissive mode and
      log the appraisal results.
      Signed-off-by: NDmitry Kasatkin <d.kasatkin@samsung.com>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      2faa6ef3
    • D
      ima: move keyring initialization to ima_init() · 31b70f66
      Dmitry Kasatkin 提交于
      ima_init() is used as a single place for all initializations.
      Experimental keyring patches used the 'late_initcall' which was
      co-located with the late_initcall(init_ima). When the late_initcall
      for the keyring initialization was abandoned, initialization moved
      to init_ima, though it would be more logical to move it to ima_init,
      where the rest of the initialization is done. This patch moves the
      keyring initialization to ima_init() as a preparatory step for
      loading the keys which will be added to ima_init() in following
      patches.
      Signed-off-by: NDmitry Kasatkin <d.kasatkin@samsung.com>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      31b70f66