1. 26 7月, 2014 1 次提交
  2. 17 7月, 2014 1 次提交
  3. 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
  4. 08 3月, 2014 3 次提交
  5. 06 2月, 2014 1 次提交
  6. 26 10月, 2013 1 次提交
  7. 26 2月, 2013 1 次提交
  8. 06 2月, 2013 1 次提交
    • D
      ima: add policy support for file system uuid · 85865c1f
      Dmitry Kasatkin 提交于
      The IMA policy permits specifying rules to enable or disable
      measurement/appraisal/audit based on the file system magic number.
      If, for example, the policy contains an ext4 measurement rule,
      the rule is enabled for all ext4 partitions.
      
      Sometimes it might be necessary to enable measurement/appraisal/audit
      only for one partition and disable it for another partition of the
      same type.  With the existing IMA policy syntax, this can not be done.
      
      This patch provides support for IMA policy rules to specify the file
      system by its UUID (eg. fsuuid=397449cd-687d-4145-8698-7fed4a3e0363).
      
      For partitions not being appraised, it might be a good idea to mount
      file systems with the 'noexec' option to prevent executing non-verified
      binaries.
      Signed-off-by: NDmitry Kasatkin <dmitry.kasatkin@intel.com>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      85865c1f
  9. 23 1月, 2013 3 次提交
    • M
      ima: differentiate appraise status only for hook specific rules · 5a73fcfa
      Mimi Zohar 提交于
      Different hooks can require different methods for appraising a
      file's integrity.  As a result, an integrity appraisal status is
      cached on a per hook basis.
      
      Only a hook specific rule, requires the inode to be re-appraised.
      This patch eliminates unnecessary appraisals.
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      Signed-off-by: NDmitry Kasatkin <dmitry.kasatkin@intel.com>
      5a73fcfa
    • M
      ima: per hook cache integrity appraisal status · d79d72e0
      Mimi Zohar 提交于
      With the new IMA policy 'appraise_type=' option, different hooks
      can require different methods for appraising a file's integrity.
      
      For example, the existing 'ima_appraise_tcb' policy defines a
      generic rule, requiring all root files to be appraised, without
      specfying the appraisal method.  A more specific rule could require
      all kernel modules, for example, to be signed.
      
      appraise fowner=0 func=MODULE_CHECK appraise_type=imasig
      appraise fowner=0
      
      As a result, the integrity appraisal results for the same inode, but
      for different hooks, could differ.  This patch caches the integrity
      appraisal results on a per hook basis.
      
      Changelog v2:
      - Rename ima_cache_status() to ima_set_cache_status()
      - Rename and move get_appraise_status() to ima_get_cache_status()
      Changelog v0:
      - include IMA_APPRAISE/APPRAISED_SUBMASK in IMA_DO/DONE_MASK (Dmitry)
      - Support independent MODULE_CHECK appraise status.
      - fixed IMA_XXXX_APPRAISE/APPRAISED flags
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      Signed-off-by: NDmitry Kasatkin <dmitry.kasatkin@intel.com>
      d79d72e0
    • D
      ima: added policy support for 'security.ima' type · 0e5a247c
      Dmitry Kasatkin 提交于
      The 'security.ima' extended attribute may contain either the file data's
      hash or a digital signature.  This patch adds support for requiring a
      specific extended attribute type.  It extends the IMA policy with a new
      keyword 'appraise_type=imasig'.  (Default is hash.)
      
      Changelog v2:
      - Fixed Documentation/ABI/testing/ima_policy option syntax
      Changelog v1:
      - Differentiate between 'required' vs. 'actual' extended attribute
      Signed-off-by: NDmitry Kasatkin <dmitry.kasatkin@intel.com>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      0e5a247c
  10. 17 1月, 2013 2 次提交
  11. 24 12月, 2012 1 次提交
  12. 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
  13. 21 9月, 2012 1 次提交
  14. 14 9月, 2012 2 次提交
    • 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
    • D
      ima: generic IMA action flag handling · 45e2472e
      Dmitry Kasatkin 提交于
      Make the IMA action flag handling generic in order to support
      additional new actions, without requiring changes to the base
      implementation.  New actions, like audit logging, will only
      need to modify the define statements.
      Signed-off-by: NDmitry Kasatkin <dmitry.kasatkin@intel.com>
      Signed-off-by: NMimi Zohar <zohar@linux.vnet.ibm.com>
      45e2472e
  15. 08 9月, 2012 2 次提交
    • M
      ima: add appraise action keywords and default rules · 07f6a794
      Mimi Zohar 提交于
      Unlike the IMA measurement policy, the appraise policy can not be dependent
      on runtime process information, such as the task uid, as the 'security.ima'
      xattr is written on file close and must be updated each time the file changes,
      regardless of the current task uid.
      
      This patch extends the policy language with 'fowner', defines an appraise
      policy, which appraises all files owned by root, and defines 'ima_appraise_tcb',
      a new boot command line option, to enable the appraise policy.
      
      Changelog v3:
      - separate the measure from the appraise rules in order to support measuring
        without appraising and appraising without measuring.
      - change appraisal default for filesystems without xattr support to fail
      - update default appraise policy for cgroups
      
      Changelog v1:
      - don't appraise RAMFS (Dmitry Kasatkin)
      - merged rest of "ima: ima_must_appraise_or_measure API change" commit
        (Dmtiry Kasatkin)
      
        ima_must_appraise_or_measure() called ima_match_policy twice, which
        searched the policy for a matching rule.  Once for a matching measurement
        rule and subsequently for an appraisal rule. Searching the policy twice
        is unnecessary overhead, which could be noticeable with a large policy.
      
        The new version of ima_must_appraise_or_measure() does everything in a
        single iteration using a new version of ima_match_policy().  It returns
        IMA_MEASURE, IMA_APPRAISE mask.
      
        With the use of action mask only one efficient matching function
        is enough.  Removed other specific versions of matching functions.
      
      Changelog:
      - change 'owner' to 'fowner' to conform to the new LSM conditions posted by
        Roberto Sassu.
      - fix calls to ima_log_string()
      Signed-off-by: NMimi Zohar <zohar@us.ibm.com>
      Signed-off-by: NDmitry Kasatkin <dmitry.kasatkin@intel.com>
      07f6a794
    • 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
  16. 06 7月, 2012 1 次提交
  17. 16 2月, 2012 1 次提交
  18. 20 1月, 2012 1 次提交
  19. 19 1月, 2012 1 次提交
  20. 04 1月, 2011 1 次提交
    • M
      ima: fix add LSM rule bug · 867c2026
      Mimi Zohar 提交于
      If security_filter_rule_init() doesn't return a rule, then not everything
      is as fine as the return code implies.
      
      This bug only occurs when the LSM (eg. SELinux) is disabled at runtime.
      
      Adding an empty LSM rule causes ima_match_rules() to always succeed,
      ignoring any remaining rules.
      
       default IMA TCB policy:
        # PROC_SUPER_MAGIC
        dont_measure fsmagic=0x9fa0
        # SYSFS_MAGIC
        dont_measure fsmagic=0x62656572
        # DEBUGFS_MAGIC
        dont_measure fsmagic=0x64626720
        # TMPFS_MAGIC
        dont_measure fsmagic=0x01021994
        # SECURITYFS_MAGIC
        dont_measure fsmagic=0x73636673
      
        < LSM specific rule >
        dont_measure obj_type=var_log_t
      
        measure func=BPRM_CHECK
        measure func=FILE_MMAP mask=MAY_EXEC
        measure func=FILE_CHECK mask=MAY_READ uid=0
      
      Thus without the patch, with the boot parameters 'tcb selinux=0', adding
      the above 'dont_measure obj_type=var_log_t' rule to the default IMA TCB
      measurement policy, would result in nothing being measured.  The patch
      prevents the default TCB policy from being replaced.
      Signed-off-by: NMimi Zohar <zohar@us.ibm.com>
      Cc: James Morris <jmorris@namei.org>
      Acked-by: NSerge Hallyn <serge.hallyn@canonical.com>
      Cc: David Safford <safford@watson.ibm.com>
      Cc: <stable@kernel.org>
      Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
      867c2026
  21. 21 4月, 2010 7 次提交
  22. 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
  23. 07 2月, 2010 1 次提交
  24. 22 5月, 2009 2 次提交
    • E
      IMA: Add __init notation to ima functions · 932995f0
      Eric Paris 提交于
      A number of IMA functions only used during init are not marked with __init.
      Add those notations so they are freed automatically.
      Signed-off-by: NEric Paris <eparis@redhat.com>
      Acked-by: NMimi Zohar <zohar@us.ibm.com>
      Signed-off-by: NJames Morris <jmorris@namei.org>
      932995f0
    • E
      IMA: Minimal IMA policy and boot param for TCB IMA policy · 5789ba3b
      Eric Paris 提交于
      The IMA TCB policy is dangerous.  A normal use can use all of a system's
      memory (which cannot be freed) simply by building and running lots of
      executables.  The TCB policy is also nearly useless because logging in as root
      often causes a policy violation when dealing with utmp, thus rendering the
      measurements meaningless.
      
      There is no good fix for this in the kernel.  A full TCB policy would need to
      be loaded in userspace using LSM rule matching to get both a protected and
      useful system.  But, if too little is measured before userspace can load a real
      policy one again ends up with a meaningless set of measurements.  One option
      would be to put the policy load inside the initrd in order to get it early
      enough in the boot sequence to be useful, but this runs into trouble with the
      LSM.  For IMA to measure the LSM policy and the LSM policy loading mechanism
      it needs rules to do so, but we already talked about problems with defaulting
      to such broad rules....
      
      IMA also depends on the files being measured to be on an FS which implements
      and supports i_version.  Since the only FS with this support (ext4) doesn't
      even use it by default it seems silly to have any IMA rules by default.
      
      This should reduce the performance overhead of IMA to near 0 while still
      letting users who choose to configure their machine as such to inclue the
      ima_tcb kernel paramenter and get measurements during boot before they can
      load a customized, reasonable policy in userspace.
      Signed-off-by: NEric Paris <eparis@redhat.com>
      Acked-by: NMimi Zohar <zohar@us.ibm.com>
      Signed-off-by: NJames Morris <jmorris@namei.org>
      5789ba3b
  25. 19 5月, 2009 1 次提交
  26. 15 5月, 2009 1 次提交