22 Jun, 2017

1 commit


21 Dec, 2016

1 commit

  • The TPM PCRs are only reset on a hard reboot. In order to validate a
    TPM's quote after a soft reboot (eg. kexec -e), the IMA measurement
    list of the running kernel must be saved and restored on boot.

    This patch uses the kexec buffer passing mechanism to pass the
    serialized IMA binary_runtime_measurements to the next kernel.

    Link: http://lkml.kernel.org/r/1480554346-29071-7-git-send-email-zohar@linux.vnet.ibm.com
    Signed-off-by: Thiago Jung Bauermann
    Signed-off-by: Mimi Zohar
    Acked-by: "Eric W. Biederman"
    Acked-by: Dmitry Kasatkin
    Cc: Andreas Steffen
    Cc: Josh Sklar
    Cc: Dave Young
    Cc: Vivek Goyal
    Cc: Baoquan He
    Cc: Michael Ellerman
    Cc: Benjamin Herrenschmidt
    Cc: Paul Mackerras
    Cc: Stewart Smith
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Mimi Zohar
     

01 May, 2016

1 commit

  • Commit 3034a14 "ima: pass 'opened' flag to identify newly created files"
    stopped identifying empty files as new files. However new empty files
    can be created using the mknodat syscall. On systems with IMA-appraisal
    enabled, these empty files are not labeled with security.ima extended
    attributes properly, preventing them from subsequently being opened in
    order to write the file data contents. This patch defines a new hook
    named ima_post_path_mknod() to mark these empty files, created using
    mknodat, as new in order to allow the file data contents to be written.

    In addition, files with security.ima xattrs containing a file signature
    are considered "immutable" and can not be modified. The file contents
    need to be written, before signing the file. This patch relaxes this
    requirement for new files, allowing the file signature to be written
    before the file contents.

    Changelog:
    - defer identifying files with signatures stored as security.ima
    (based on Dmitry Rozhkov's comments)
    - removing tests (eg. dentry, dentry->d_inode, inode->i_size == 0)
    (based on Al's review)

    Signed-off-by: Mimi Zohar
    Cc: Al Viro <
    Tested-by: Dmitry Rozhkov

    Mimi Zohar
     

21 Feb, 2016

4 commits

  • Replace copy_module_from_fd() with kernel_read_file_from_fd().

    Although none of the upstreamed LSMs define a kernel_module_from_file
    hook, IMA is called, based on policy, to prevent unsigned kernel modules
    from being loaded by the original kernel module syscall and to
    measure/appraise signed kernel modules.

    The security function security_kernel_module_from_file() was called prior
    to reading a kernel module. Preventing unsigned kernel modules from being
    loaded by the original kernel module syscall remains on the pre-read
    kernel_read_file() security hook. Instead of reading the kernel module
    twice, once for measuring/appraising and again for loading the kernel
    module, the signature validation is moved to the kernel_post_read_file()
    security hook.

    This patch removes the security_kernel_module_from_file() hook and security
    call.

    Signed-off-by: Mimi Zohar
    Acked-by: Kees Cook
    Acked-by: Luis R. Rodriguez
    Cc: Rusty Russell

    Mimi Zohar
     
  • The kernel_read_file security hook is called prior to reading the file
    into memory.

    Changelog v4+:
    - export security_kernel_read_file()

    Signed-off-by: Mimi Zohar
    Acked-by: Kees Cook
    Acked-by: Luis R. Rodriguez
    Acked-by: Casey Schaufler

    Mimi Zohar
     
  • Replace the fw_read_file_contents with kernel_file_read_from_path().

    Although none of the upstreamed LSMs define a kernel_fw_from_file hook,
    IMA is called by the security function to prevent unsigned firmware from
    being loaded and to measure/appraise signed firmware, based on policy.

    Instead of reading the firmware twice, once for measuring/appraising the
    firmware and again for reading the firmware contents into memory, the
    kernel_post_read_file() security hook calculates the file hash based on
    the in memory file buffer. The firmware is read once.

    This patch removes the LSM kernel_fw_from_file() hook and security call.

    Changelog v4+:
    - revert dropped buf->size assignment - reported by Sergey Senozhatsky
    v3:
    - remove kernel_fw_from_file hook
    - use kernel_file_read_from_path() - requested by Luis
    v2:
    - reordered and squashed firmware patches
    - fix MAX firmware size (Kees Cook)

    Signed-off-by: Mimi Zohar
    Acked-by: Kees Cook
    Acked-by: Luis R. Rodriguez

    Mimi Zohar
     
  • This patch defines a new IMA hook ima_post_read_file() for measuring
    and appraising files read by the kernel. The caller loads the file into
    memory before calling this function, which calculates the hash followed by
    the normal IMA policy based processing.

    Changelog v5:
    - fail ima_post_read_file() if either file or buf is NULL
    v3:
    - rename ima_hash_and_process_file() to ima_post_read_file()

    v1:
    - split patch

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

    Mimi Zohar
     

09 Sep, 2014

1 commit


26 Jul, 2014

1 commit

  • The "security: introduce kernel_fw_from_file hook" patch defined a
    new security hook to evaluate any loaded firmware that wasn't built
    into the kernel.

    This patch defines ima_fw_from_file(), which is called from the new
    security hook, to measure and/or appraise the loaded firmware's
    integrity.

    Signed-off-by: Mimi Zohar
    Signed-off-by: Kees Cook

    Mimi Zohar
     

27 Mar, 2013

1 commit


14 Dec, 2012

1 commit

  • 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: Mimi Zohar
    Signed-off-by: Rusty Russell

    Mimi Zohar
     

08 Sep, 2012

2 commits

  • Based on xattr_permission comments, the restriction to modify 'security'
    xattr is left up to the underlying fs or lsm. Ensure that not just anyone
    can modify or remove 'security.ima'.

    Changelog v1:
    - Unless IMA-APPRAISE is configured, use stub ima_inode_removexattr()/setxattr()
    functions. (Moved ima_inode_removexattr()/setxattr() to ima_appraise.c)

    Changelog:
    - take i_mutex to fix locking (Dmitry Kasatkin)
    - ima_reset_appraise_flags should only be called when modifying or
    removing the 'security.ima' xattr. Requires CAP_SYS_ADMIN privilege.
    (Incorporated fix from Roberto Sassu)
    - Even if allowed to update security.ima, reset the appraisal flags,
    forcing re-appraisal.
    - Replace CAP_MAC_ADMIN with CAP_SYS_ADMIN
    - static inline ima_inode_setxattr()/ima_inode_removexattr() stubs
    - ima_protect_xattr should be static

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

    Mimi Zohar
     
  • Changing an inode's metadata may result in our not needing to appraise
    the file. In such cases, we must remove 'security.ima'.

    Changelog v1:
    - use ima_inode_post_setattr() stub function, if IMA_APPRAISE not configured

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

    Mimi Zohar
     

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
     

10 Feb, 2011

1 commit

  • ima_counts_get() updated the readcount and invalidated the PCR,
    as necessary. Only update the i_readcount in the VFS layer.
    Move the PCR invalidation checks to ima_file_check(), where it
    belongs.

    Maintaining the i_readcount in the VFS layer, will allow other
    subsystems to use i_readcount.

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

    Mimi Zohar
     

07 Feb, 2010

2 commits

  • ima_path_check actually deals with files! call it ima_file_check instead.

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

    Mimi Zohar
     
  • The "Untangling ima mess, part 2 with counters" patch messed
    up the counters. Based on conversations with Al Viro, this patch
    streamlines ima_path_check() by removing the counter maintaince.
    The counters are now updated independently, from measuring the file,
    in __dentry_open() and alloc_file() by calling ima_counts_get().
    ima_path_check() is called from nfsd and do_filp_open().
    It also did not measure all files that should have been measured.
    Reason: ima_path_check() got bogus value passed as mask.
    [AV: mea culpa]
    [AV: add missing nfsd bits]

    Signed-off-by: Mimi Zohar
    Signed-off-by: Al Viro

    Mimi Zohar
     

17 Dec, 2009

1 commit

  • Kill the 'update' argument of ima_path_check(), kill
    dead code in ima.

    Current rules: ima counters are bumped at the same time
    when the file switches from put_filp() fodder to fput()
    one. Which happens exactly in two places - alloc_file()
    and __dentry_open(). Nothing else needs to do that at
    all.

    Signed-off-by: Al Viro

    Al Viro
     

29 Jun, 2009

1 commit

  • This patch fixes an imbalance message as reported by J.R. Okajima.
    The IMA file counters are incremented in ima_path_check. If the
    actual open fails, such as ETXTBSY, decrement the counters to
    prevent unnecessary imbalance messages.

    Reported-by: J.R. Okajima
    Signed-off-by: Mimi Zohar
    Signed-off-by: James Morris

    Mimi Zohar
     

22 May, 2009

1 commit

  • - Add support in ima_path_check() for integrity checking without
    incrementing the counts. (Required for nfsd.)
    - rename and export opencount_get to ima_counts_get
    - replace ima_shm_check calls with ima_counts_get
    - export ima_path_check

    Signed-off-by: Mimi Zohar
    Signed-off-by: James Morris

    Mimi Zohar
     

11 Feb, 2009

1 commit

  • Based on comments from Mike Frysinger and Randy Dunlap:
    (http://lkml.org/lkml/2009/2/9/262)
    - moved ima.h include before CONFIG_SHMEM test to fix compiler error
    on Blackfin:
    mm/shmem.c: In function 'shmem_zero_setup':
    mm/shmem.c:2670: error: implicit declaration of function 'ima_shm_check'

    - added 'struct linux_binprm' in ima.h to fix compiler warning on Blackfin:
    In file included from mm/shmem.c:32:
    include/linux/ima.h:25: warning: 'struct linux_binprm' declared inside
    parameter list
    include/linux/ima.h:25: warning: its scope is only this definition or
    declaration, which is probably not what you want

    - moved fs.h include within _LINUX_IMA_H definition

    Signed-off-by: Mimi Zohar
    Signed-off-by: Mike Frysinger
    Signed-off-by: James Morris

    Mimi Zohar
     

06 Feb, 2009

3 commits

  • The number of calls to ima_path_check()/ima_file_free()
    should be balanced. An extra call to fput(), indicates
    the file could have been accessed without first being
    measured.

    Although f_count is incremented/decremented in places other
    than fget/fput, like fget_light/fput_light and get_file, the
    current task must already hold a file refcnt. The call to
    __fput() is delayed until the refcnt becomes 0, resulting
    in ima_file_free() flagging any changes.

    - add hook to increment opencount for IPC shared memory(SYSV),
    shmat files, and /dev/zero
    - moved NULL iint test in opencount_get()

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

    Mimi Zohar
     
  • IMA provides hardware (TPM) based measurement and attestation for
    file measurements. As the Trusted Computing (TPM) model requires,
    IMA measures all files before they are accessed in any way (on the
    integrity_bprm_check, integrity_path_check and integrity_file_mmap
    hooks), and commits the measurements to the TPM. Once added to the
    TPM, measurements can not be removed.

    In addition, IMA maintains a list of these file measurements, which
    can be used to validate the aggregate value stored in the TPM. The
    TPM can sign these measurements, and thus the system can prove, to
    itself and to a third party, the system's integrity in a way that
    cannot be circumvented by malicious or compromised software.

    - alloc ima_template_entry before calling ima_store_template()
    - log ima_add_boot_aggregate() failure
    - removed unused IMA_TEMPLATE_NAME_LEN
    - replaced hard coded string length with #define name

    Signed-off-by: Mimi Zohar
    Signed-off-by: James Morris

    Mimi Zohar
     
  • This patch replaces the generic integrity hooks, for which IMA registered
    itself, with IMA integrity hooks in the appropriate places directly
    in the fs directory.

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

    Mimi Zohar