20 Dec, 2011

2 commits

  • Don't free a valid measurement entry on TPM PCR extend failure.

    Signed-off-by: Roberto Sassu
    Signed-off-by: Mimi Zohar
    Cc: stable@vger.kernel.org

    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: Roberto Sassu
    Signed-off-by: Mimi Zohar
    Cc: stable@vger.kernel.org

    Roberto Sassu
     

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


10 Sep, 2011

3 commits


09 Aug, 2011

1 commit


27 Jul, 2011

1 commit


19 Jul, 2011

1 commit

  • 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

11 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
     
  • The IMA flags is an unsigned long but there is only 1 flag defined.
    Lets save a little space and make it a char. This packs nicely next to
    the array of u8's.

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

    Eric Paris
     
  • Currently IMA uses 2 longs in struct inode. To save space (and as it
    seems impossible to overflow 32 bits) we switch these to unsigned int.
    The switch to unsigned does require slightly different checks for
    underflow, but it isn't complex.

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

    Eric Paris
     
  • The opencount was used to help debugging to make sure that everything
    which created a struct file also correctly made the IMA calls. Since we
    moved all of that into the VFS this isn't as necessary. We should be
    able to get the same amount of debugging out of just the reader and
    write count.

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

    Eric Paris
     
  • The IMA code needs to store the number of tasks which have an open fd
    granting permission to write a file even when IMA is not in use. It
    needs this information in order to be enabled at a later point in time
    without losing it's integrity garantees.

    At the moment that means we store a little bit of data about every inode
    in a cache. We use a radix tree key'd on the inode's memory address.
    Dave Chinner pointed out that a radix tree is a terrible data structure
    for such a sparse key space. This patch switches to using an rbtree
    which should be more efficient.

    Bug report from Dave:

    "I just noticed that slabtop was reporting an awfully high usage of
    radix tree nodes:

    OBJS ACTIVE USE OBJ SIZE SLABS OBJ/SLAB CACHE SIZE NAME
    4200331 2778082 66% 0.55K 144839 29 2317424K radix_tree_node
    2321500 2060290 88% 1.00K 72581 32 2322592K xfs_inode
    2235648 2069791 92% 0.12K 69864 32 279456K iint_cache

    That is, 2.7M radix tree nodes are allocated, and the cache itself is
    consuming 2.3GB of RAM. I know that the XFS inodei caches are indexed
    by radix tree node, but for 2 million cached inodes that would mean a
    density of 1 inode per radix tree node, which for a system with 16M
    inodes in the filsystems is an impossibly low density. The worst I've
    seen in a production system like kernel.org is about 20-25% density,
    which would mean about 150-200k radix tree nodes for that many inodes.
    So it's not the inode cache.

    So I looked up what the iint_cache was. It appears to used for
    storing per-inode IMA information, and uses a radix tree for indexing.
    It uses the *address* of the struct inode as the indexing key. That
    means the key space is extremely sparse - for XFS the struct inode
    addresses are approximately 1000 bytes apart, which means the closest
    the radix tree index keys get is ~1000. Which means that there is a
    single entry per radix tree leaf node, so the radix tree is using
    roughly 550 bytes for every 120byte structure being cached. For the
    above example, it's probably wasting close to 1GB of RAM...."

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

    Eric Paris
     

08 Sep, 2010

1 commit

  • commit 8262bb85da allocated the inode integrity struct (iint) before any
    inodes were created. Only after IMA was initialized in late_initcall were
    the counters updated. This patch updates the counters, whether or not IMA
    has been initialized, to resolve 'imbalance' messages.

    This patch fixes the bug as reported in bugzilla: 15673. When the i915
    is builtin, the ring_buffer is initialized before IMA, causing the
    imbalance message on suspend.

    Reported-by: Thomas Meyer
    Signed-off-by: Mimi Zohar
    Tested-by: Thomas Meyer
    Tested-by: David Safford
    Cc: Stable Kernel
    Signed-off-by: James Morris

    Mimi Zohar
     

02 Aug, 2010

1 commit

  • The default for llseek will change to no_llseek,
    so securityfs users need to add explicit .llseek
    assignments. Since we're dealing with regular
    files from a VFS perspective, use generic_file_llseek.

    Signed-off-by: Arnd Bergmann
    Cc: Mimi Zohar
    Signed-off-by: James Morris

    Arnd Bergmann
     

22 May, 2010

1 commit

  • Of the three uses of kref_set in the kernel:

    One really should be kref_put as the code is letting go of a
    reference,
    Two really should be kref_init because the kref is being
    initialised.

    This suggests that making kref_set available encourages bad code.
    So fix the three uses and remove kref_set completely.

    Signed-off-by: NeilBrown
    Acked-by: Mimi Zohar
    Acked-by: Serge Hallyn
    Signed-off-by: Greg Kroah-Hartman

    NeilBrown
     

17 May, 2010

1 commit

  • The ACPI dependency moved to the TPM, where it belongs. Although
    IMA per-se does not require access to the bios measurement log,
    verifying the IMA boot aggregate does, which requires ACPI.

    This patch prereq's 'TPM: ACPI/PNP dependency removal'
    http://lkml.org/lkml/2010/5/4/378.

    Signed-off-by: Mimi Zohar
    Reported-by: Jean-Christophe Dubois
    Acked-by: Serge Hallyn
    Tested-by: Serge Hallyn
    Signed-off-by: James Morris

    Mimi Zohar
     

07 May, 2010

1 commit


06 May, 2010

1 commit


05 May, 2010

1 commit

  • The ACPI dependency moved to the TPM, where it belongs. Although
    IMA per-se does not require access to the bios measurement log,
    verifying the IMA boot aggregate does, which requires ACPI.

    This patch prereq's 'TPM: ACPI/PNP dependency removal'
    http://lkml.org/lkml/2010/5/4/378.

    Signed-off-by: Mimi Zohar
    Reported-by: Jean-Christophe Dubois
    Acked-by: Serge Hallyn
    Tested-by: Serge Hallyn
    Signed-off-by: James Morris

    Mimi Zohar
     

23 Apr, 2010

1 commit

  • As an example IMA emits a warning when it can't find a TPM chip:

    "No TPM chip found, activating TPM-bypass!"

    This patch prefaces that message with IMA so we know what subsystem is
    bypassing the TPM. Do this for all pr_info and pr_err messages.

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

    Eric Paris
     

21 Apr, 2010

6 commits

  • integrity_audit_msg() uses "integrity:" in the audit message. This
    violates the (loosely defined) audit system requirements that everything be
    a key=value pair and it doesn't provide additional information. This can
    be obviously gleaned from the message type. Just drop it.

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

    Eric Paris
     
  • Convert all of the places IMA calls audit_log_format with %s into
    audit_log_untrusted_string(). This is going to cause them all to get
    quoted, but it should make audit log injection harder.

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

    Eric Paris
     
  • IMA policy load parser will reject any policies with a comment. This patch
    will allow the parser to just ignore lines which start with a #. This is not
    very robust. # can ONLY be used at the very beginning of a line. Inline
    comments are not allowed.

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

    Eric Paris
     
  • IMA parser will fail if whitespace is used in any way other than a single
    space. Using a tab or even using 2 spaces in a row will result in a policy
    being rejected. This patch makes the kernel ignore whitespace a bit better.

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

    Eric Paris
     
  • Currently the ima policy load code will print what it doesn't understand
    but really I think it should reject any policy it doesn't understand. This
    patch makes it so!

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

    Eric Paris
     
  • ima_parse_rule currently sets entry->action = -1 and then later tests
    if (entry->action == UNKNOWN). It is true that UNKNOWN == -1 but actually
    setting it to UNKNOWN makes a lot more sense in case things change in the
    future.

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

    Eric Paris