1. 13 10月, 2014 1 次提交
    • 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
  2. 12 10月, 2014 2 次提交
    • D
      ima: use atomic bit operations to protect policy update interface · 0716abbb
      Dmitry Kasatkin 提交于
      The current implementation uses an atomic counter to provide exclusive
      access to the sysfs 'policy' entry to update the IMA policy. While it is
      highly unlikely, the usage of a counter might potentially allow another
      process to overflow the counter, open the interface and insert additional
      rules into the policy being loaded.
      
      This patch replaces using an atomic counter with atomic bit operations
      which is more reliable and a widely used method to provide exclusive access.
      
      As bit operation keep the interface locked after successful update, it makes
      it unnecessary to verify if the default policy was set or not during parsing
      and interface closing. This patch also removes that code.
      
      Changes in v3:
      * move audit log message to ima_relead_policy() to report successful and
        unsuccessful result
      * unnecessary comment removed
      
      Changes in v2:
      * keep interface locked after successful policy load as in original design
      * remove sysfs entry as in original design
      Signed-off-by: NDmitry Kasatkin <d.kasatkin@samsung.com>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      0716abbb
    • D
      ima: report policy load status · 78bb5d0b
      Dmitry Kasatkin 提交于
      Audit messages are rate limited, often causing the policy update
      info to not be visible.  Report policy loading status also using
      pr_info.
      
      Changes in v2:
      * reporting moved to ima_release_policy to notice parsing errors
      * reporting both completed and failed status
      Signed-off-by: NDmitry Kasatkin <d.kasatkin@samsung.com>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      78bb5d0b
  3. 08 3月, 2014 2 次提交
    • D
      integrity: fix checkpatch errors · 2bb930ab
      Dmitry Kasatkin 提交于
      Between checkpatch changes (eg. sizeof) and inconsistencies between
      Lindent and checkpatch, unfixed checkpatch errors make it difficult
      to see new errors. This patch fixes them. Some lines with over 80 chars
      remained unchanged to improve code readability.
      
      The "extern" keyword is removed from internal evm.h to make it consistent
      with internal ima.h.
      Signed-off-by: NDmitry Kasatkin <d.kasatkin@samsung.com>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      2bb930ab
    • R
      ima: restore the original behavior for sending data with ima template · c019e307
      Roberto Sassu 提交于
      With the new template mechanism introduced in IMA since kernel 3.13,
      the format of data sent through the binary_runtime_measurements interface
      is slightly changed. Now, for a generic measurement, the format of
      template data (after the template name) is:
      
      template_len | field1_len | field1 | ... | fieldN_len | fieldN
      
      In addition, fields containing a string now include the '\0' termination
      character.
      
      Instead, the format for the 'ima' template should be:
      
      SHA1 digest | event name length | event name
      
      It must be noted that while in the IMA 3.13 code 'event name length' is
      'IMA_EVENT_NAME_LEN_MAX + 1' (256 bytes), so that the template digest
      is calculated correctly, and 'event name' contains '\0', in the pre 3.13
      code 'event name length' is exactly the string length and 'event name'
      does not contain the termination character.
      
      The patch restores the behavior of the IMA code pre 3.13 for the 'ima'
      template so that legacy userspace tools obtain a consistent behavior
      when receiving data from the binary_runtime_measurements interface
      regardless of which kernel version is used.
      Signed-off-by: NRoberto Sassu <roberto.sassu@polito.it>
      Cc: <stable@vger.kernel.org> # 3.3.13: 3ce1217d ima: define template fields library
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      c019e307
  4. 25 11月, 2013 1 次提交
  5. 26 10月, 2013 4 次提交
    • 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 template fields library and new helpers · 3ce1217d
      Roberto Sassu 提交于
      This patch defines a library containing two initial template fields,
      inode digest (d) and file name (n), the 'ima' template descriptor,
      whose format is 'd|n', and two helper functions,
      ima_write_template_field_data() and ima_show_template_field_data().
      
      Changelog:
      - replace ima_eventname_init() parameter NULL checking with BUG_ON.
        (suggested by Mimi)
      - include "new template fields for inode digest (d) and file name (n)"
        definitions to fix a compiler warning.  - Mimi
      - unnecessary to prefix static function names with 'ima_'. remove
        prefix to resolve Lindent formatting changes. - Mimi
      - abbreviated/removed inline comments - Mimi
      - always send the template field length - Mimi
      Signed-off-by: NRoberto Sassu <roberto.sassu@polito.it>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      3ce1217d
    • 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: fix script messages · 089bc8e9
      Dmitry Kasatkin 提交于
      Fix checkpatch, lindent, etc, warnings/errors
      Signed-off-by: NDmitry Kasatkin <d.kasatkin@samsung.com>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      089bc8e9
  6. 03 7月, 2012 2 次提交
  7. 10 9月, 2011 1 次提交
  8. 02 8月, 2010 1 次提交
  9. 21 4月, 2010 1 次提交
    • E
      ima: handle multiple rules per write · 6ccd0456
      Eric Paris 提交于
      Currently IMA will only accept one rule per write().  This patch allows IMA to
      accept writes which contain multiple rules but only processes one rule per
      write.  \n is used as the delimiter between rules.  IMA will return a short
      write indicating that it only accepted up to the first \n.
      
      This allows simple userspace utilities like cat to be used to load an IMA
      policy instead of needing a special userspace utility that understood 'one
      write per rule'
      Signed-off-by: NEric Paris <eparis@redhat.com>
      Acked-by: NMimi Zohar <zohar@us.ibm.com>
      Signed-off-by: NJames Morris <jmorris@namei.org>
      6ccd0456
  10. 30 3月, 2010 1 次提交
    • T
      include cleanup: Update gfp.h and slab.h includes to prepare for breaking... · 5a0e3ad6
      Tejun Heo 提交于
      include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
      
      percpu.h is included by sched.h and module.h and thus ends up being
      included when building most .c files.  percpu.h includes slab.h which
      in turn includes gfp.h making everything defined by the two files
      universally available and complicating inclusion dependencies.
      
      percpu.h -> slab.h dependency is about to be removed.  Prepare for
      this change by updating users of gfp and slab facilities include those
      headers directly instead of assuming availability.  As this conversion
      needs to touch large number of source files, the following script is
      used as the basis of conversion.
      
        http://userweb.kernel.org/~tj/misc/slabh-sweep.py
      
      The script does the followings.
      
      * Scan files for gfp and slab usages and update includes such that
        only the necessary includes are there.  ie. if only gfp is used,
        gfp.h, if slab is used, slab.h.
      
      * When the script inserts a new include, it looks at the include
        blocks and try to put the new include such that its order conforms
        to its surrounding.  It's put in the include block which contains
        core kernel includes, in the same order that the rest are ordered -
        alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
        doesn't seem to be any matching order.
      
      * If the script can't find a place to put a new include (mostly
        because the file doesn't have fitting include block), it prints out
        an error message indicating which .h file needs to be added to the
        file.
      
      The conversion was done in the following steps.
      
      1. The initial automatic conversion of all .c files updated slightly
         over 4000 files, deleting around 700 includes and adding ~480 gfp.h
         and ~3000 slab.h inclusions.  The script emitted errors for ~400
         files.
      
      2. Each error was manually checked.  Some didn't need the inclusion,
         some needed manual addition while adding it to implementation .h or
         embedding .c file was more appropriate for others.  This step added
         inclusions to around 150 files.
      
      3. The script was run again and the output was compared to the edits
         from #2 to make sure no file was left behind.
      
      4. Several build tests were done and a couple of problems were fixed.
         e.g. lib/decompress_*.c used malloc/free() wrappers around slab
         APIs requiring slab.h to be added manually.
      
      5. The script was run on all .h files but without automatically
         editing them as sprinkling gfp.h and slab.h inclusions around .h
         files could easily lead to inclusion dependency hell.  Most gfp.h
         inclusion directives were ignored as stuff from gfp.h was usually
         wildly available and often used in preprocessor macros.  Each
         slab.h inclusion directive was examined and added manually as
         necessary.
      
      6. percpu.h was updated not to include slab.h.
      
      7. Build test were done on the following configurations and failures
         were fixed.  CONFIG_GCOV_KERNEL was turned off for all tests (as my
         distributed build env didn't work with gcov compiles) and a few
         more options had to be turned off depending on archs to make things
         build (like ipr on powerpc/64 which failed due to missing writeq).
      
         * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
         * powerpc and powerpc64 SMP allmodconfig
         * sparc and sparc64 SMP allmodconfig
         * ia64 SMP allmodconfig
         * s390 SMP allmodconfig
         * alpha SMP allmodconfig
         * um on x86_64 SMP allmodconfig
      
      8. percpu.h modifications were reverted so that it could be applied as
         a separate patch and serve as bisection point.
      
      Given the fact that I had only a couple of failures from tests on step
      6, I'm fairly confident about the coverage of this conversion patch.
      If there is a breakage, it's likely to be something in one of the arch
      headers which should be easily discoverable easily on most builds of
      the specific arch.
      Signed-off-by: NTejun Heo <tj@kernel.org>
      Guess-its-ok-by: NChristoph Lameter <cl@linux-foundation.org>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
      5a0e3ad6
  11. 02 10月, 2009 1 次提交
  12. 23 9月, 2009 1 次提交
  13. 22 5月, 2009 1 次提交
  14. 15 5月, 2009 1 次提交
  15. 15 4月, 2009 1 次提交
  16. 12 2月, 2009 1 次提交
  17. 06 2月, 2009 3 次提交