1. 28 3月, 2016 1 次提交
  2. 21 2月, 2016 1 次提交
  3. 19 2月, 2016 2 次提交
  4. 22 5月, 2015 2 次提交
    • R
      ima: pass iint to ima_add_violation() · 8d94eb9b
      Roberto Sassu 提交于
      This patch adds the iint associated to the current inode as a new
      parameter of ima_add_violation(). The passed iint is always not NULL
      if a violation is detected. This modification will be used to determine
      the inode for which there is a violation.
      
      Since the 'd' and 'd-ng' template field init() functions were detecting
      a violation from the value of the iint pointer, they now check the new
      field 'violation', added to the 'ima_event_data' structure.
      
      Changelog:
       - v1:
         - modified an old comment (Roberto Sassu)
      Signed-off-by: NRoberto Sassu <rsassu@suse.de>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      8d94eb9b
    • R
      ima: wrap event related data to the new ima_event_data structure · 23b57419
      Roberto Sassu 提交于
      All event related data has been wrapped into the new 'ima_event_data'
      structure. The main benefit of this patch is that a new information
      can be made available to template fields initialization functions
      by simply adding a new field to the new structure instead of modifying
      the definition of those functions.
      
      Changelog:
       - v2:
         - f_dentry replaced with f_path.dentry (Roberto Sassu)
         - removed declaration of temporary variables in template field functions
           when possible (suggested by Dmitry Kasatkin)
      Signed-off-by: NRoberto Sassu <rsassu@suse.de>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      23b57419
  5. 20 11月, 2014 1 次提交
  6. 18 11月, 2014 1 次提交
    • D
      ima: load x509 certificate from the kernel · fd5f4e90
      Dmitry Kasatkin 提交于
      Define configuration option to load X509 certificate into the
      IMA trusted kernel keyring. It implements ima_load_x509() hook
      to load X509 certificate into the .ima trusted kernel keyring
      from the root filesystem.
      
      Changes in v3:
      * use ima_policy_flag in ima_get_action()
        ima_load_x509 temporarily clears ima_policy_flag to disable
        appraisal to load key. Use it to skip appraisal rules.
      * Key directory path changed to /etc/keys (Mimi)
      * Expand IMA_LOAD_X509 Kconfig help
      
      Changes in v2:
      * added '__init'
      * use ima_policy_flag to disable appraisal to load keys
      Signed-off-by: NDmitry Kasatkin <d.kasatkin@samsung.com>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      fd5f4e90
  7. 08 10月, 2014 1 次提交
  8. 18 9月, 2014 1 次提交
    • 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
  9. 09 9月, 2014 1 次提交
    • D
      ima: remove usage of filename parameter · 17f4bad3
      Dmitry Kasatkin 提交于
      In all cases except ima_bprm_check() the filename was not defined
      and ima_d_path() was used to find the full path.  Unfortunately,
      the bprm filename is a relative pathname (eg. ./<dir>/filename).
      
      ima_bprm_check() selects between bprm->interp and bprm->filename.
      The following dump demonstrates the differences between using
      filename and interp.
      
      bprm->filename
       filename: ./foo.sh, pathname: /root/bin/foo.sh
       filename: ./foo.sh, pathname: /bin/dash
      
      bprm->interp
       filename: ./foo.sh, pathname: /root/bin/foo.sh
       filename: /bin/sh, pathname: /bin/dash
      
      In both cases the pathnames are currently the same.  This patch
      removes usage of filename and interp in favor of d_absolute_path.
      
      Changes v3:
      - 11 extra bytes for "deleted" not needed (Mimi)
      - purpose "replace relative bprm filename with full pathname" (Mimi)
      
      Changes v2:
      - use d_absolute_path() instead of d_path to work in chroot environments.
      Signed-off-by: NDmitry Kasatkin <d.kasatkin@samsung.com>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      17f4bad3
  10. 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
  11. 08 3月, 2014 3 次提交
  12. 05 3月, 2014 1 次提交
  13. 03 12月, 2013 1 次提交
    • 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
  14. 25 11月, 2013 1 次提交
  15. 01 11月, 2013 1 次提交
    • 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
  16. 27 10月, 2013 1 次提交
  17. 26 10月, 2013 9 次提交
    • R
      ima: switch to new template management mechanism · a71dc65d
      Roberto Sassu 提交于
      This patch performs the switch to the new template mechanism by modifying
      the functions ima_alloc_init_template(), ima_measurements_show() and
      ima_ascii_measurements_show(). The old function ima_template_show() was
      removed as it is no longer needed. Also, if the template descriptor used
      to generate a measurement entry is not 'ima', the whole length of field
      data stored for an entry is provided before the data itself through the
      binary_runtime_measurement interface.
      
      Changelog:
      - unnecessary to use strncmp() (Mimi Zohar)
      - create new variable 'field' in ima_alloc_init_template() (Roberto Sassu)
      - use GFP_NOFS flag in ima_alloc_init_template() (Roberto Sassu)
      - new variable 'num_fields' in ima_store_template() (Roberto Sassu,
        proposed by Mimi Zohar)
      - rename ima_calc_buffer_hash/template_hash() to ima_calc_field_array_hash(),
        something more generic (Mimi, requested by Dmitry)
      - sparse error fix - Fengguang Wu
      - fix lindent warnings
      - always include the field length in the template data length
      - include the template field length variable size in the template data length
      - include both the template field data and field length in the template digest
        calculation. Simplifies verifying the template digest. (Mimi)
      Signed-off-by: NRoberto Sassu <roberto.sassu@polito.it>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      a71dc65d
    • R
      ima: define new function ima_alloc_init_template() to API · 7bc5f447
      Roberto Sassu 提交于
      Instead of allocating and initializing the template entry from multiple
      places (eg. boot aggregate, violation, and regular measurements), this
      patch defines a new function called ima_alloc_init_template().  The new
      function allocates and initializes the measurement entry with the inode
      digest and the filename.
      
      In respect to the current behavior, it truncates the file name passed
      in the 'filename' argument if the latter's size is greater than 255 bytes
      and the passed file descriptor is NULL.
      
      Changelog:
      - initialize 'hash' variable for non TPM case - Mimi
      - conform to expectation for 'iint' to be defined as a pointer. - Mimi
      - add missing 'file' dependency for recalculating file hash. - Mimi
      Signed-off-by: NRoberto Sassu <roberto.sassu@polito.it>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      7bc5f447
    • R
      ima: pass the filename argument up to ima_add_template_entry() · 9803d413
      Roberto Sassu 提交于
      Pass the filename argument to ima_add_template_entry() in order to
      eliminate a dependency on template specific data (third argument of
      integrity_audit_msg).
      
      This change is required because, with the new template management
      mechanism, the generation of a new measurement entry will be performed
      by new specific functions (introduced in next patches) and the current IMA
      code will not be aware anymore of how data is stored in the entry payload.
      Signed-off-by: NRoberto Sassu <roberto.sassu@polito.it>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      9803d413
    • R
      ima: pass the file descriptor to ima_add_violation() · 7d802a22
      Roberto Sassu 提交于
      Pass the file descriptor instead of the inode to ima_add_violation(),
      to make the latter consistent with ima_store_measurement() in
      preparation for the new template architecture.
      Signed-off-by: NRoberto Sassu <roberto.sassu@polito.it>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      7d802a22
    • D
      ima: support arbitrary hash algorithms in ima_calc_buffer_hash · ea593993
      Dmitry Kasatkin 提交于
      ima_calc_buffer_hash will be used with different hash algorithms.
      This patch provides support for arbitrary hash algorithms in
      ima_calc_buffer_hash.
      Signed-off-by: NDmitry Kasatkin <d.kasatkin@samsung.com>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      ea593993
    • M
      ima: differentiate between template hash and file data hash sizes · 140d8022
      Mimi Zohar 提交于
      The TPM v1.2 limits the template hash size to 20 bytes.  This
      patch differentiates between the template hash size, as defined
      in the ima_template_entry, and the file data hash size, as
      defined in the ima_template_data.  Subsequent patches add support
      for different file data hash algorithms.
      
      Change log:
      - hash digest definition in ima_store_template() should be TPM_DIGEST_SIZE
      Signed-off-by: NMimi Zohar <zohar@us.ibm.com>
      140d8022
    • D
      ima: use dynamically allocated hash storage · a35c3fb6
      Dmitry Kasatkin 提交于
      For each inode in the IMA policy, an iint is allocated.  To support
      larger hash digests, the iint digest size changed from 20 bytes to
      the maximum supported hash digest size.  Instead of allocating the
      maximum size, which most likely is not needed, this patch dynamically
      allocates the needed hash storage.
      
      Changelog:
      - fix krealloc bug
      Signed-off-by: NDmitry Kasatkin <d.kasatkin@samsung.com>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      a35c3fb6
    • D
      ima: read and use signature hash algorithm · d3634d0f
      Dmitry Kasatkin 提交于
      All files on the filesystem, currently, are hashed using the same hash
      algorithm.  In preparation for files from different packages being
      signed using different hash algorithms, this patch adds support for
      reading the signature hash algorithm from the 'security.ima' extended
      attribute and calculates the appropriate file data hash based on it.
      
      Changelog:
      - fix scripts Lindent and checkpatch msgs - Mimi
      - fix md5 support for older version, which occupied 20 bytes in the
        xattr, not the expected 16 bytes.  Fix the comparison to compare
        only the first 16 bytes.
      Signed-off-by: NDmitry Kasatkin <d.kasatkin@samsung.com>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      d3634d0f
    • D
      ima: provide support for arbitrary hash algorithms · c7c8bb23
      Dmitry Kasatkin 提交于
      In preparation of supporting more hash algorithms with larger hash sizes
      needed for signature verification, this patch replaces the 20 byte sized
      digest, with a more flexible structure.  The new structure includes the
      hash algorithm, digest size, and digest.
      
      Changelog:
      - recalculate filedata hash for the measurement list, if the signature
        hash digest size is greater than 20 bytes.
      - use generic HASH_ALGO_
      - make ima_calc_file_hash static
      - scripts lindent and checkpatch fixes
      Signed-off-by: NDmitry Kasatkin <d.kasatkin@samsung.com>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      c7c8bb23
  18. 23 2月, 2013 1 次提交
  19. 06 2月, 2013 1 次提交
  20. 17 1月, 2013 2 次提交
  21. 14 12月, 2012 1 次提交
    • M
      ima: support new kernel module syscall · fdf90729
      Mimi Zohar 提交于
      With the addition of the new kernel module syscall, which defines two
      arguments - a file descriptor to the kernel module and a pointer to a NULL
      terminated string of module arguments - it is now possible to measure and
      appraise kernel modules like any other file on the file system.
      
      This patch adds support to measure and appraise kernel modules in an
      extensible and consistent manner.
      
      To support filesystems without extended attribute support, additional
      patches could pass the signature as the first parameter.
      Signed-off-by: NMimi Zohar <zohar@us.ibm.com>
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      fdf90729
  22. 14 9月, 2012 1 次提交
    • P
      ima: audit log hashes · e7c568e0
      Peter Moody 提交于
      This adds an 'audit' policy action which audit logs file measurements.
      
      Changelog v6:
       - use new action flag handling (Dmitry Kasatkin).
       - removed whitespace (Mimi)
      
      Changelog v5:
       - use audit_log_untrustedstring.
      
      Changelog v4:
       - cleanup digest -> hash conversion.
       - use filename rather than d_path in ima_audit_measurement.
      
      Changelog v3:
       - Use newly exported audit_log_task_info for logging pid/ppid/uid/etc.
       - Update the ima_policy ABI documentation.
      
      Changelog v2:
       - Use 'audit' action rather than 'measure_and_audit' to permit
       auditing in the absence of measuring..
      
      Changelog v1:
       - Initial posting.
      Signed-off-by: NPeter Moody <pmoody@google.com>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      e7c568e0
  23. 12 9月, 2012 1 次提交
  24. 08 9月, 2012 2 次提交
    • M
      ima: add support for different security.ima data types · 5a44b412
      Mimi Zohar 提交于
      IMA-appraisal currently verifies the integrity of a file based on a
      known 'good' measurement value.  This patch reserves the first byte
      of 'security.ima' as a place holder for the type of method used for
      verifying file data integrity.
      
      Changelog v1:
      - Use the newly defined 'struct evm_ima_xattr_data'
      Signed-off-by: NDmitry Kasatkin <dmitry.kasatkin@nokia.com>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      5a44b412
    • M
      ima: integrity appraisal extension · 2fe5d6de
      Mimi Zohar 提交于
      IMA currently maintains an integrity measurement list used to assert the
      integrity of the running system to a third party.  The IMA-appraisal
      extension adds local integrity validation and enforcement of the
      measurement against a "good" value stored as an extended attribute
      'security.ima'.  The initial methods for validating 'security.ima' are
      hashed based, which provides file data integrity, and digital signature
      based, which in addition to providing file data integrity, provides
      authenticity.
      
      This patch creates and maintains the 'security.ima' xattr, containing
      the file data hash measurement.  Protection of the xattr is provided by
      EVM, if enabled and configured.
      
      Based on policy, IMA calls evm_verifyxattr() to verify a file's metadata
      integrity and, assuming success, compares the file's current hash value
      with the one stored as an extended attribute in 'security.ima'.
      
      Changelov v4:
      - changed iint cache flags to hex values
      
      Changelog v3:
      - change appraisal default for filesystems without xattr support to fail
      
      Changelog v2:
      - fix audit msg 'res' value
      - removed unused 'ima_appraise=' values
      
      Changelog v1:
      - removed unused iint mutex (Dmitry Kasatkin)
      - setattr hook must not reset appraised (Dmitry Kasatkin)
      - evm_verifyxattr() now differentiates between no 'security.evm' xattr
        (INTEGRITY_NOLABEL) and no EVM 'protected' xattrs included in the
        'security.evm' (INTEGRITY_NOXATTRS).
      - replace hash_status with ima_status (Dmitry Kasatkin)
      - re-initialize slab element ima_status on free (Dmitry Kasatkin)
      - include 'security.ima' in EVM if CONFIG_IMA_APPRAISE, not CONFIG_IMA
      - merged half "ima: ima_must_appraise_or_measure API change" (Dmitry Kasatkin)
      - removed unnecessary error variable in process_measurement() (Dmitry Kasatkin)
      - use ima_inode_post_setattr() stub function, if IMA_APPRAISE not configured
        (moved ima_inode_post_setattr() to ima_appraise.c)
      - make sure ima_collect_measurement() can read file
      
      Changelog:
      - add 'iint' to evm_verifyxattr() call (Dimitry Kasatkin)
      - fix the race condition between chmod, which takes the i_mutex and then
        iint->mutex, and ima_file_free() and process_measurement(), which take
        the locks in the reverse order, by eliminating iint->mutex. (Dmitry Kasatkin)
      - cleanup of ima_appraise_measurement() (Dmitry Kasatkin)
      - changes as a result of the iint not allocated for all regular files, but
        only for those measured/appraised.
      - don't try to appraise new/empty files
      - expanded ima_appraisal description in ima/Kconfig
      - IMA appraise definitions required even if IMA_APPRAISE not enabled
      - add return value to ima_must_appraise() stub
      - unconditionally set status = INTEGRITY_PASS *after* testing status,
        not before.  (Found by Joe Perches)
      Signed-off-by: NMimi Zohar <zohar@us.ibm.com>
      Signed-off-by: NDmitry Kasatkin <dmitry.kasatkin@intel.com>
      2fe5d6de
  25. 03 7月, 2012 1 次提交
    • M
      ima: use full pathnames in measurement list · 08e1b76a
      Mimi Zohar 提交于
      The IMA measurement list contains filename hints, which can be
      ambigious without the full pathname.  This patch replaces the
      filename hint with the full pathname, simplifying for userspace
      the correlating of file hash measurements with files.
      
      Change log v1:
      - Revert to short filenames, when full pathname is longer than IMA
        measurement buffer size. (Based on Dmitry's review)
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      08e1b76a
  26. 20 12月, 2011 1 次提交
    • R
      ima: free duplicate measurement memory · 45fae749
      Roberto Sassu 提交于
      Info about new measurements are cached in the iint for performance.  When
      the inode is flushed from cache, the associated iint is flushed as well.
      Subsequent access to the inode will cause the inode to be re-measured and
      will attempt to add a duplicate entry to the measurement list.
      
      This patch frees the duplicate measurement memory, fixing a memory leak.
      Signed-off-by: NRoberto Sassu <roberto.sassu@polito.it>
      Signed-off-by: NMimi Zohar <zohar@us.ibm.com>
      Cc: stable@vger.kernel.org
      45fae749