20 Dec, 2011

2 commits


03 Nov, 2011

1 commit

  • * 'for-linus' of git://github.com/richardweinberger/linux: (90 commits)
    um: fix ubd cow size
    um: Fix kmalloc argument order in um/vdso/vma.c
    um: switch to use of drivers/Kconfig
    UserModeLinux-HOWTO.txt: fix a typo
    UserModeLinux-HOWTO.txt: remove ^H characters
    um: we need sys/user.h only on i386
    um: merge delay_{32,64}.c
    um: distribute exports to where exported stuff is defined
    um: kill system-um.h
    um: generic ftrace.h will do...
    um: segment.h is x86-only and needed only there
    um: asm/pda.h is not needed anymore
    um: hw_irq.h can go generic as well
    um: switch to generic-y
    um: clean Kconfig up a bit
    um: a couple of missing dependencies...
    um: kill useless argument of free_chan() and free_one_chan()
    um: unify ptrace_user.h
    um: unify KSTK_...
    um: fix gcov build breakage
    ...

    Linus Torvalds
     

02 Nov, 2011

1 commit


15 Sep, 2011

5 commits

  • When allocating from slab, initialization is done the first time in
    init_once() and subsequently on free. Because evm_status was not
    re-initialized on free, evm_verify_hmac() skipped verifications.

    This patch re-initializes evm_status.

    Signed-off-by: Dmitry Kasatkin
    Signed-off-by: Mimi Zohar

    Dmitry Kasatkin
     
  • Before permitting 'security.evm' to be updated, 'security.evm' must
    exist and be valid. In the case that there are no existing EVM protected
    xattrs, it is safe for posix acls to update the mode bits.

    To differentiate between no 'security.evm' xattr and no xattrs used to
    calculate 'security.evm', this patch defines INTEGRITY_NOXATTR.

    Signed-off-by: Mimi Zohar

    Mimi Zohar
     
  • The posix xattr acls are 'system' prefixed, which normally would not
    affect security.evm. An interesting side affect of writing posix xattr
    acls is their modifying of the i_mode, which is included in security.evm.

    This patch updates security.evm when posix xattr acls are written.

    Signed-off-by: Mimi Zohar

    Mimi Zohar
     
  • evm_protect_xattr unnecessarily validates the current security.evm
    integrity, before updating non-evm protected extended attributes
    and other file metadata. This patch limits validating the current
    security.evm integrity to evm protected metadata.

    Signed-off-by: Mimi Zohar

    Mimi Zohar
     
  • All tristates selected by EVM(boolean) are forced to be builtin, except
    in the TCG_TPM(tristate) dependency case. Arnaud Lacombe summarizes the
    Kconfig bug as, "So it would seem direct dependency state influence the
    state of reverse dependencies.." For a detailed explanation, refer to
    Arnaud Lacombe's posting http://lkml.org/lkml/2011/8/23/498.

    With the "encrypted-keys: remove trusted-keys dependency" patch, EVM
    can now be built without a dependency on TCG_TPM. The trusted-keys
    dependency requires trusted-keys to either be builtin or not selected.
    This dependency will prevent the boolean/tristate mismatch from
    occuring.

    Reported-by: Stephen Rothwell ,
    Randy Dunlap
    Signed-off-by: Mimi Zohar

    Mimi Zohar
     

10 Sep, 2011

3 commits


18 Aug, 2011

1 commit

  • Although the EVM encrypted-key should be encrypted/decrypted using a
    trusted-key, a user-defined key could be used instead. When using a user-
    defined key, a TCG_TPM dependency should not be required. Unfortunately,
    the encrypted-key code needs to be refactored a bit in order to remove
    this dependency.

    This patch adds the TCG_TPM dependency.

    Reported-by: Stephen Rothwell ,
    Randy Dunlap
    Signed-off-by: Mimi Zohar
    Signed-off-by: James Morris

    Mimi Zohar
     

11 Aug, 2011

1 commit


09 Aug, 2011

2 commits


27 Jul, 2011

1 commit


19 Jul, 2011

11 commits

  • Permit changing of security.evm only when valid, unless in fixmode.

    Reported-by: Roberto Sassu
    Signed-off-by: Mimi Zohar

    Mimi Zohar
     
  • In addition to requiring CAP_SYS_ADMIN permission to modify/delete
    security.evm, prohibit invalid security.evm xattrs from changing,
    unless in fixmode. This patch prevents inadvertent 'fixing' of
    security.evm to reflect offline modifications.

    Changelog v7:
    - rename boot paramater 'evm_mode' to 'evm'

    Reported-by: Roberto Sassu
    Signed-off-by: Mimi Zohar

    Mimi Zohar
     
  • We will use digital signatures in addtion to hmac.

    Signed-off-by: Dmitry Kasatkin
    Signed-off-by: Mimi Zohar

    Dmitry Kasatkin
     
  • If EVM is not supported or enabled, evm_verify_hmac() returns
    INTEGRITY_UNKNOWN, which ima_appraise_measurement() ignores and sets
    the appraisal status based solely on the security.ima verification.

    evm_verify_hmac() also returns INTEGRITY_UNKNOWN for other failures, such
    as temporary failures like -ENOMEM, resulting in possible attack vectors.
    This patch changes the default return code for temporary/unexpected
    failures, like -ENOMEM, from INTEGRITY_UNKNOWN to INTEGRITY_FAIL, making
    evm_verify_hmac() fail safe.

    As a result, failures need to be re-evaluated in order to catch both
    temporary errors, such as the -ENOMEM, as well as errors that have been
    resolved in fix mode.

    Signed-off-by: Dmitry Kasatkin
    Signed-off-by: Mimi Zohar

    Dmitry Kasatkin
     
  • Additional iint parameter allows to skip lookup in the cache.

    Signed-off-by: Dmitry Kasatkin
    Signed-off-by: Mimi Zohar

    Dmitry Kasatkin
     
  • Using shash is more efficient, because the algorithm is allocated only
    once. Only the descriptor to store the hash state needs to be allocated
    for every operation.

    Changelog v6:
    - check for crypto_shash_setkey failure

    Signed-off-by: Dmitry Kasatkin
    Signed-off-by: Mimi Zohar

    Dmitry Kasatkin
     
  • Initialize 'security.evm' for new files.

    Changelog v7:
    - renamed evm_inode_post_init_security to evm_inode_init_security
    - moved struct xattr definition to earlier patch
    - allocate xattr name
    Changelog v6:
    - Use 'struct evm_ima_xattr_data'

    Signed-off-by: Mimi Zohar

    Mimi Zohar
     
  • Imbed the evm calls evm_inode_setxattr(), evm_inode_post_setxattr(),
    evm_inode_removexattr() in the security hooks. evm_inode_setxattr()
    protects security.evm xattr. evm_inode_post_setxattr() and
    evm_inode_removexattr() updates the hmac associated with an inode.

    (Assumes an LSM module protects the setting/removing of xattr.)

    Changelog:
    - Don't define evm_verifyxattr(), unless CONFIG_INTEGRITY is enabled.
    - xattr_name is a 'const', value is 'void *'

    Signed-off-by: Mimi Zohar
    Acked-by: Serge Hallyn

    Mimi Zohar
     
  • EVM protects a file's security extended attributes(xattrs) against integrity
    attacks. The current patchset maintains an HMAC-sha1 value across the security
    xattrs, storing the value as the extended attribute 'security.evm'. We
    anticipate other methods for protecting the security extended attributes.
    This patch reserves the first byte of 'security.evm' as a place holder for
    the type of method.

    Changelog v6:
    - move evm_ima_xattr_type definition to security/integrity/integrity.h
    - defined a structure for the EVM xattr called evm_ima_xattr_data
    (based on Serge Hallyn's suggestion)
    - removed unnecessary memset

    Signed-off-by: Dmitry Kasatkin
    Signed-off-by: Mimi Zohar
    Acked-by: Serge Hallyn

    Dmitry Kasatkin
     
  • EVM protects a file's security extended attributes(xattrs) against integrity
    attacks. This patchset provides the framework and an initial method. The
    initial method maintains an HMAC-sha1 value across the security extended
    attributes, storing the HMAC value as the extended attribute 'security.evm'.
    Other methods of validating the integrity of a file's metadata will be posted
    separately (eg. EVM-digital-signatures).

    While this patchset does authenticate the security xattrs, and
    cryptographically binds them to the inode, coming extensions will bind other
    directory and inode metadata for more complete protection. To help simplify
    the review and upstreaming process, each extension will be posted separately
    (eg. IMA-appraisal, IMA-appraisal-directory). For a general overview of the
    proposed Linux integrity subsystem, refer to Dave Safford's whitepaper:
    http://downloads.sf.net/project/linux-ima/linux-ima/Integrity_overview.pdf.

    EVM depends on the Kernel Key Retention System to provide it with a
    trusted/encrypted key for the HMAC-sha1 operation. The key is loaded onto the
    root's keyring using keyctl. Until EVM receives notification that the key has
    been successfully loaded onto the keyring (echo 1 > /evm), EVM can
    not create or validate the 'security.evm' xattr, but returns INTEGRITY_UNKNOWN.
    Loading the key and signaling EVM should be done as early as possible. Normally
    this is done in the initramfs, which has already been measured as part of the
    trusted boot. For more information on creating and loading existing
    trusted/encrypted keys, refer to Documentation/keys-trusted-encrypted.txt. A
    sample dracut patch, which loads the trusted/encrypted key and enables EVM, is
    available from http://linux-ima.sourceforge.net/#EVM.

    Based on the LSMs enabled, the set of EVM protected security xattrs is defined
    at compile. EVM adds the following three calls to the existing security hooks:
    evm_inode_setxattr(), evm_inode_post_setxattr(), and evm_inode_removexattr. To
    initialize and update the 'security.evm' extended attribute, EVM defines three
    calls: evm_inode_post_init(), evm_inode_post_setattr() and
    evm_inode_post_removexattr() hooks. To verify the integrity of a security
    xattr, EVM exports evm_verifyxattr().

    Changelog v7:
    - Fixed URL in EVM ABI documentation

    Changelog v6: (based on Serge Hallyn's review)
    - fix URL in patch description
    - remove evm_hmac_size definition
    - use SHA1_DIGEST_SIZE (removed both MAX_DIGEST_SIZE and evm_hmac_size)
    - moved linux include before other includes
    - test for crypto_hash_setkey failure
    - fail earlier for invalid key
    - clear entire encrypted key, even on failure
    - check xattr name length before comparing xattr names

    Changelog:
    - locking based on i_mutex, remove evm_mutex
    - using trusted/encrypted keys for storing the EVM key used in the HMAC-sha1
    operation.
    - replaced crypto hash with shash (Dmitry Kasatkin)
    - support for additional methods of verifying the security xattrs
    (Dmitry Kasatkin)
    - iint not allocated for all regular files, but only for those appraised
    - Use cap_sys_admin in lieu of cap_mac_admin
    - Use __vfs_setxattr_noperm(), without permission checks, from EVM

    Signed-off-by: Mimi Zohar
    Acked-by: Serge Hallyn

    Mimi Zohar
     
  • Move the inode integrity data(iint) management up to the integrity directory
    in order to share the iint among the different integrity models.

    Changelog:
    - don't define MAX_DIGEST_SIZE
    - rename several globally visible 'ima_' prefixed functions, structs,
    locks, etc to 'integrity_'
    - replace '20' with SHA1_DIGEST_SIZE
    - reflect location change in appropriate Kconfig and Makefiles
    - remove unnecessary initialization of iint_initialized to 0
    - rebased on current ima_iint.c
    - define integrity_iint_store/lock as static

    There should be no other functional changes.

    Signed-off-by: Mimi Zohar
    Acked-by: Serge Hallyn

    Mimi Zohar
     

24 Feb, 2011

1 commit

  • The original ima_must_measure() function based its results on cached
    iint information, which required an iint be allocated for all files.
    Currently, an iint is allocated only for files in policy. As a result,
    for those files in policy, ima_must_measure() is now called twice: once
    to determine if the inode is in the measurement policy and, the second
    time, to determine if it needs to be measured/re-measured.

    The second call to ima_must_measure() unnecessarily checks to see if
    the file is in policy. As we already know the file is in policy, this
    patch removes the second unnecessary call to ima_must_measure(), removes
    the vestige iint parameter, and just checks the iint directly to determine
    if the inode has been measured or needs to be measured/re-measured.

    Signed-off-by: Mimi Zohar
    Acked-by: Eric Paris

    Mimi Zohar
     

10 Feb, 2011

3 commits


04 Jan, 2011

1 commit

  • 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: Mimi Zohar
    Cc: James Morris
    Acked-by: Serge Hallyn
    Cc: David Safford
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Mimi Zohar
     

27 Oct, 2010

7 commits

  • Current logic looks like this:

    rc = ima_must_measure(NULL, inode, MAY_READ, FILE_CHECK);
    if (rc < 0)
    goto out;

    if (mode & FMODE_WRITE) {
    if (inode->i_readcount)
    send_tomtou = true;
    goto out;
    }

    if (atomic_read(&inode->i_writecount) > 0)
    send_writers = true;

    Lets assume we have a policy which states that all files opened for read
    by root must be measured.

    Lets assume the file has permissions 777.

    Lets assume that root has the given file open for read.

    Lets assume that a non-root process opens the file write.

    The non-root process will get to ima_counts_get() and will check the
    ima_must_measure(). Since it is not supposed to measure it will goto
    out.

    We should check the i_readcount no matter what since we might be causing
    a ToMToU voilation!

    This is close to correct, but still not quite perfect. The situation
    could have been that root, which was interested in the mesurement opened
    and closed the file and another process which is not interested in the
    measurement is the one holding the i_readcount ATM. This is just overly
    strict on ToMToU violations, which is better than not strict enough...

    Signed-off-by: Eric Paris
    Acked-by: Mimi Zohar
    Signed-off-by: Linus Torvalds

    Eric Paris
     
  • Currently for every removed inode IMA must take a global lock and search
    the IMA rbtree looking for an associated integrity structure. Instead
    we explicitly mark an inode when we add an integrity structure so we
    only have to take the global lock and do the removal if it exists.

    Signed-off-by: Eric Paris
    Acked-by: Mimi Zohar
    Signed-off-by: Linus Torvalds

    Eric Paris
     
  • Since finding a struct ima_iint_cache requires a valid struct inode, and
    the struct ima_iint_cache is supposed to have the same lifetime as a
    struct inode (technically they die together but don't need to be created
    at the same time) we don't have to worry about the ima_iint_cache
    outliving or dieing before the inode. So the refcnt isn't useful. Just
    get rid of it and free the structure when the inode is freed.

    Signed-off-by: Eric Paris
    Acked-by: Mimi Zohar
    Signed-off-by: Linus Torvalds

    Eric Paris
     
  • IMA always allocates an integrity structure to hold information about
    every inode, but only needed this structure to track the number of
    readers and writers currently accessing a given inode. Since that
    information was moved into struct inode instead of the integrity struct
    this patch stops allocating the integrity stucture until it is needed.
    Thus greatly reducing memory usage.

    Signed-off-by: Eric Paris
    Acked-by: Mimi Zohar
    Signed-off-by: Linus Torvalds

    Eric Paris
     
  • IMA currently allocated an inode integrity structure for every inode in
    core. This stucture is about 120 bytes long. Most files however
    (especially on a system which doesn't make use of IMA) will never need
    any of this space. The problem is that if IMA is enabled we need to
    know information about the number of readers and the number of writers
    for every inode on the box. At the moment we collect that information
    in the per inode iint structure and waste the rest of the space. This
    patch moves those counters into the struct inode so we can eventually
    stop allocating an IMA integrity structure except when absolutely
    needed.

    This patch does the minimum needed to move the location of the data.
    Further cleanups, especially the location of counter updates, may still
    be possible.

    Signed-off-by: Eric Paris
    Acked-by: Mimi Zohar
    Signed-off-by: Linus Torvalds

    Eric Paris
     
  • IMA tracks the number of struct files which are holding a given inode
    readonly and the number which are holding the inode write or r/w. It
    needs this information so when a new reader or writer comes in it can
    tell if this new file will be able to invalidate results it already made
    about existing files.

    aka if a task is holding a struct file open RO, IMA measured the file
    and recorded those measurements and then a task opens the file RW IMA
    needs to note in the logs that the old measurement may not be correct.
    It's called a "Time of Measure Time of Use" (ToMToU) issue. The same is
    true is a RO file is opened to an inode which has an open writer. We
    cannot, with any validity, measure the file in question since it could
    be changing.

    This patch attempts to use the i_writecount field to track writers. The
    i_writecount field actually embeds more information in it's value than
    IMA needs but it should work for our purposes and allow us to shrink the
    struct inode even more.

    Signed-off-by: Eric Paris
    Acked-by: Mimi Zohar
    Signed-off-by: Linus Torvalds

    Eric Paris
     
  • Currently IMA used the iint->mutex to protect the i_readcount and
    i_writecount. This patch uses the inode->i_lock since we are going to
    start using in inode objects and that is the most appropriate lock.

    Signed-off-by: Eric Paris
    Acked-by: Mimi Zohar
    Signed-off-by: Linus Torvalds

    Eric Paris