11 Jul, 2019

1 commit

  • …el/git/dhowells/linux-fs"

    This reverts merge 0f75ef6a9cff49ff612f7ce0578bced9d0b38325 (and thus
    effectively commits

    7a1ade847596 ("keys: Provide KEYCTL_GRANT_PERMISSION")
    2e12256b9a76 ("keys: Replace uid/gid/perm permissions checking with an ACL")

    that the merge brought in).

    It turns out that it breaks booting with an encrypted volume, and Eric
    biggers reports that it also breaks the fscrypt tests [1] and loading of
    in-kernel X.509 certificates [2].

    The root cause of all the breakage is likely the same, but David Howells
    is off email so rather than try to work it out it's getting reverted in
    order to not impact the rest of the merge window.

    [1] https://lore.kernel.org/lkml/20190710011559.GA7973@sol.localdomain/
    [2] https://lore.kernel.org/lkml/20190710013225.GB7973@sol.localdomain/

    Link: https://lore.kernel.org/lkml/CAHk-=wjxoeMJfeBahnWH=9zShKp2bsVy527vo3_y8HfOdhwAAw@mail.gmail.com/
    Reported-by: Eric Biggers <ebiggers@kernel.org>
    Cc: David Howells <dhowells@redhat.com>
    Cc: James Morris <jmorris@namei.org>
    Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

    Linus Torvalds
     

09 Jul, 2019

2 commits

  • Pull integrity updates from Mimi Zohar:
    "Bug fixes, code clean up, and new features:

    - IMA policy rules can be defined in terms of LSM labels, making the
    IMA policy dependent on LSM policy label changes, in particular LSM
    label deletions. The new environment, in which IMA-appraisal is
    being used, frequently updates the LSM policy and permits LSM label
    deletions.

    - Prevent an mmap'ed shared file opened for write from also being
    mmap'ed execute. In the long term, making this and other similar
    changes at the VFS layer would be preferable.

    - The IMA per policy rule template format support is needed for a
    couple of new/proposed features (eg. kexec boot command line
    measurement, appended signatures, and VFS provided file hashes).

    - Other than the "boot-aggregate" record in the IMA measuremeent
    list, all other measurements are of file data. Measuring and
    storing the kexec boot command line in the IMA measurement list is
    the first buffer based measurement included in the measurement
    list"

    * 'next-integrity' of git://git.kernel.org/pub/scm/linux/kernel/git/zohar/linux-integrity:
    integrity: Introduce struct evm_xattr
    ima: Update MAX_TEMPLATE_NAME_LEN to fit largest reasonable definition
    KEXEC: Call ima_kexec_cmdline to measure the boot command line args
    IMA: Define a new template field buf
    IMA: Define a new hook to measure the kexec boot command line arguments
    IMA: support for per policy rule template formats
    integrity: Fix __integrity_init_keyring() section mismatch
    ima: Use designated initializers for struct ima_event_data
    ima: use the lsm policy update notifier
    LSM: switch to blocking policy update notifiers
    x86/ima: fix the Kconfig dependency for IMA_ARCH_POLICY
    ima: Make arch_policy_entry static
    ima: prevent a file already mmap'ed write to be mmap'ed execute
    x86/ima: check EFI SetupMode too

    Linus Torvalds
     
  • Pull keyring ACL support from David Howells:
    "This changes the permissions model used by keys and keyrings to be
    based on an internal ACL by the following means:

    - Replace the permissions mask internally with an ACL that contains a
    list of ACEs, each with a specific subject with a permissions mask.
    Potted default ACLs are available for new keys and keyrings.

    ACE subjects can be macroised to indicate the UID and GID specified
    on the key (which remain). Future commits will be able to add
    additional subject types, such as specific UIDs or domain
    tags/namespaces.

    Also split a number of permissions to give finer control. Examples
    include splitting the revocation permit from the change-attributes
    permit, thereby allowing someone to be granted permission to revoke
    a key without allowing them to change the owner; also the ability
    to join a keyring is split from the ability to link to it, thereby
    stopping a process accessing a keyring by joining it and thus
    acquiring use of possessor permits.

    - Provide a keyctl to allow the granting or denial of one or more
    permits to a specific subject. Direct access to the ACL is not
    granted, and the ACL cannot be viewed"

    * tag 'keys-acl-20190703' of git://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs:
    keys: Provide KEYCTL_GRANT_PERMISSION
    keys: Replace uid/gid/perm permissions checking with an ACL

    Linus Torvalds
     

01 Jul, 2019

1 commit

  • Even though struct evm_ima_xattr_data includes a fixed-size array to hold a
    SHA1 digest, most of the code ignores the array and uses the struct to mean
    "type indicator followed by data of unspecified size" and tracks the real
    size of what the struct represents in a separate length variable.

    The only exception to that is the EVM code, which correctly uses the
    definition of struct evm_ima_xattr_data.

    So make this explicit in the code by removing the length specification from
    the array in struct evm_ima_xattr_data. Also, change the name of the
    element from digest to data since in most places the array doesn't hold a
    digest.

    A separate struct evm_xattr is introduced, with the original definition of
    evm_ima_xattr_data to be used in the places that actually expect that
    definition, specifically the EVM HMAC code.

    Signed-off-by: Thiago Jung Bauermann
    Signed-off-by: Mimi Zohar

    Thiago Jung Bauermann
     

28 Jun, 2019

1 commit

  • Replace the uid/gid/perm permissions checking on a key with an ACL to allow
    the SETATTR and SEARCH permissions to be split. This will also allow a
    greater range of subjects to represented.

    ============
    WHY DO THIS?
    ============

    The problem is that SETATTR and SEARCH cover a slew of actions, not all of
    which should be grouped together.

    For SETATTR, this includes actions that are about controlling access to a
    key:

    (1) Changing a key's ownership.

    (2) Changing a key's security information.

    (3) Setting a keyring's restriction.

    And actions that are about managing a key's lifetime:

    (4) Setting an expiry time.

    (5) Revoking a key.

    and (proposed) managing a key as part of a cache:

    (6) Invalidating a key.

    Managing a key's lifetime doesn't really have anything to do with
    controlling access to that key.

    Expiry time is awkward since it's more about the lifetime of the content
    and so, in some ways goes better with WRITE permission. It can, however,
    be set unconditionally by a process with an appropriate authorisation token
    for instantiating a key, and can also be set by the key type driver when a
    key is instantiated, so lumping it with the access-controlling actions is
    probably okay.

    As for SEARCH permission, that currently covers:

    (1) Finding keys in a keyring tree during a search.

    (2) Permitting keyrings to be joined.

    (3) Invalidation.

    But these don't really belong together either, since these actions really
    need to be controlled separately.

    Finally, there are number of special cases to do with granting the
    administrator special rights to invalidate or clear keys that I would like
    to handle with the ACL rather than key flags and special checks.

    ===============
    WHAT IS CHANGED
    ===============

    The SETATTR permission is split to create two new permissions:

    (1) SET_SECURITY - which allows the key's owner, group and ACL to be
    changed and a restriction to be placed on a keyring.

    (2) REVOKE - which allows a key to be revoked.

    The SEARCH permission is split to create:

    (1) SEARCH - which allows a keyring to be search and a key to be found.

    (2) JOIN - which allows a keyring to be joined as a session keyring.

    (3) INVAL - which allows a key to be invalidated.

    The WRITE permission is also split to create:

    (1) WRITE - which allows a key's content to be altered and links to be
    added, removed and replaced in a keyring.

    (2) CLEAR - which allows a keyring to be cleared completely. This is
    split out to make it possible to give just this to an administrator.

    (3) REVOKE - see above.

    Keys acquire ACLs which consist of a series of ACEs, and all that apply are
    unioned together. An ACE specifies a subject, such as:

    (*) Possessor - permitted to anyone who 'possesses' a key
    (*) Owner - permitted to the key owner
    (*) Group - permitted to the key group
    (*) Everyone - permitted to everyone

    Note that 'Other' has been replaced with 'Everyone' on the assumption that
    you wouldn't grant a permit to 'Other' that you wouldn't also grant to
    everyone else.

    Further subjects may be made available by later patches.

    The ACE also specifies a permissions mask. The set of permissions is now:

    VIEW Can view the key metadata
    READ Can read the key content
    WRITE Can update/modify the key content
    SEARCH Can find the key by searching/requesting
    LINK Can make a link to the key
    SET_SECURITY Can change owner, ACL, expiry
    INVAL Can invalidate
    REVOKE Can revoke
    JOIN Can join this keyring
    CLEAR Can clear this keyring

    The KEYCTL_SETPERM function is then deprecated.

    The KEYCTL_SET_TIMEOUT function then is permitted if SET_SECURITY is set,
    or if the caller has a valid instantiation auth token.

    The KEYCTL_INVALIDATE function then requires INVAL.

    The KEYCTL_REVOKE function then requires REVOKE.

    The KEYCTL_JOIN_SESSION_KEYRING function then requires JOIN to join an
    existing keyring.

    The JOIN permission is enabled by default for session keyrings and manually
    created keyrings only.

    ======================
    BACKWARD COMPATIBILITY
    ======================

    To maintain backward compatibility, KEYCTL_SETPERM will translate the
    permissions mask it is given into a new ACL for a key - unless
    KEYCTL_SET_ACL has been called on that key, in which case an error will be
    returned.

    It will convert possessor, owner, group and other permissions into separate
    ACEs, if each portion of the mask is non-zero.

    SETATTR permission turns on all of INVAL, REVOKE and SET_SECURITY. WRITE
    permission turns on WRITE, REVOKE and, if a keyring, CLEAR. JOIN is turned
    on if a keyring is being altered.

    The KEYCTL_DESCRIBE function translates the ACL back into a permissions
    mask to return depending on possessor, owner, group and everyone ACEs.

    It will make the following mappings:

    (1) INVAL, JOIN -> SEARCH

    (2) SET_SECURITY -> SETATTR

    (3) REVOKE -> WRITE if SETATTR isn't already set

    (4) CLEAR -> WRITE

    Note that the value subsequently returned by KEYCTL_DESCRIBE may not match
    the value set with KEYCTL_SETATTR.

    =======
    TESTING
    =======

    This passes the keyutils testsuite for all but a couple of tests:

    (1) tests/keyctl/dh_compute/badargs: The first wrong-key-type test now
    returns EOPNOTSUPP rather than ENOKEY as READ permission isn't removed
    if the type doesn't have ->read(). You still can't actually read the
    key.

    (2) tests/keyctl/permitting/valid: The view-other-permissions test doesn't
    work as Other has been replaced with Everyone in the ACL.

    Signed-off-by: David Howells

    David Howells
     

05 Jun, 2019

1 commit

  • Based on 1 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license as published by
    the free software foundation version 2 of the license

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-only

    has been chosen to replace the boilerplate/reference in 315 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Allison Randal
    Reviewed-by: Armijn Hemel
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190531190115.503150771@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

01 Jun, 2019

1 commit

  • …l/git/zohar/linux-integrity

    Pull integrity subsystem fixes from Mimi Zohar:
    "Four bug fixes, none 5.2-specific, all marked for stable.

    The first two are related to the architecture specific IMA policy
    support. The other two patches, one is related to EVM signatures,
    based on additional hash algorithms, and the other is related to
    displaying the IMA policy"

    * 'next-fixes-for-5.2-rc' of git://git.kernel.org/pub/scm/linux/kernel/git/zohar/linux-integrity:
    ima: show rules with IMA_INMASK correctly
    evm: check hash algorithm passed to init_desc()
    ima: fix wrong signed policy requirement when not appraising
    x86/ima: Check EFI_RUNTIME_SERVICES before using

    Linus Torvalds
     

30 May, 2019

1 commit

  • This patch prevents memory access beyond the evm_tfm array by checking the
    validity of the index (hash algorithm) passed to init_desc(). The hash
    algorithm can be arbitrarily set if the security.ima xattr type is not
    EVM_XATTR_HMAC.

    Fixes: 5feeb61183dde ("evm: Allow non-SHA1 digital signatures")
    Signed-off-by: Roberto Sassu
    Cc: stable@vger.kernel.org
    Signed-off-by: Mimi Zohar

    Roberto Sassu
     

21 May, 2019

1 commit


08 May, 2019

1 commit

  • Pull audit updates from Paul Moore:
    "We've got a reasonably broad set of audit patches for the v5.2 merge
    window, the highlights are below:

    - The biggest change, and the source of all the arch/* changes, is
    the patchset from Dmitry to help enable some of the work he is
    doing around PTRACE_GET_SYSCALL_INFO.

    To be honest, including this in the audit tree is a bit of a
    stretch, but it does help move audit a little further along towards
    proper syscall auditing for all arches, and everyone else seemed to
    agree that audit was a "good" spot for this to land (or maybe they
    just didn't want to merge it? dunno.).

    - We can now audit time/NTP adjustments.

    - We continue the work to connect associated audit records into a
    single event"

    * tag 'audit-pr-20190507' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/audit: (21 commits)
    audit: fix a memory leak bug
    ntp: Audit NTP parameters adjustment
    timekeeping: Audit clock adjustments
    audit: purge unnecessary list_empty calls
    audit: link integrity evm_write_xattrs record to syscall event
    syscall_get_arch: add "struct task_struct *" argument
    unicore32: define syscall_get_arch()
    Move EM_UNICORE to uapi/linux/elf-em.h
    nios2: define syscall_get_arch()
    nds32: define syscall_get_arch()
    Move EM_NDS32 to uapi/linux/elf-em.h
    m68k: define syscall_get_arch()
    hexagon: define syscall_get_arch()
    Move EM_HEXAGON to uapi/linux/elf-em.h
    h8300: define syscall_get_arch()
    c6x: define syscall_get_arch()
    arc: define syscall_get_arch()
    Move EM_ARCOMPACT and EM_ARCV2 to uapi/linux/elf-em.h
    audit: Make audit_log_cap and audit_copy_inode static
    audit: connect LOGIN record to its syscall record
    ...

    Linus Torvalds
     

25 Apr, 2019

1 commit

  • The flags field in 'struct shash_desc' never actually does anything.
    The only ostensibly supported flag is CRYPTO_TFM_REQ_MAY_SLEEP.
    However, no shash algorithm ever sleeps, making this flag a no-op.

    With this being the case, inevitably some users who can't sleep wrongly
    pass MAY_SLEEP. These would all need to be fixed if any shash algorithm
    actually started sleeping. For example, the shash_ahash_*() functions,
    which wrap a shash algorithm with the ahash API, pass through MAY_SLEEP
    from the ahash API to the shash API. However, the shash functions are
    called under kmap_atomic(), so actually they're assumed to never sleep.

    Even if it turns out that some users do need preemption points while
    hashing large buffers, we could easily provide a helper function
    crypto_shash_update_large() which divides the data into smaller chunks
    and calls crypto_shash_update() and cond_resched() for each chunk. It's
    not necessary to have a flag in 'struct shash_desc', nor is it necessary
    to make individual shash algorithms aware of this at all.

    Therefore, remove shash_desc::flags, and document that the
    crypto_shash_*() functions can be called from any context.

    Signed-off-by: Eric Biggers
    Signed-off-by: Herbert Xu

    Eric Biggers
     

28 Mar, 2019

1 commit

  • In commit fa516b66a1bf ("EVM: Allow runtime modification of the set of
    verified xattrs"), the call to audit_log_start() is missing a context to
    link it to an audit event. Since this event is in user context, add
    the process' syscall context to the record.

    In addition, the orphaned keyword "locked" appears in the record.
    Normalize this by changing it to logging the locking string "." as any
    other user input in the "xattr=" field.

    Please see the github issue
    https://github.com/linux-audit/audit-kernel/issues/109

    Signed-off-by: Richard Guy Briggs
    Acked-by: Mimi Zohar
    Signed-off-by: Paul Moore

    Richard Guy Briggs
     

05 Feb, 2019

2 commits

  • Instead of sizeof use pre-defined constant for UUID representation.

    While here, drop the implementation details of uuid_t type.

    Signed-off-by: Andy Shevchenko
    Signed-off-by: Mimi Zohar

    Andy Shevchenko
     
  • Fixes gcc '-Wunused-but-set-variable' warning:

    security/integrity/evm/evm_main.c: In function 'init_evm':
    security/integrity/evm/evm_main.c:566:21: warning:
    variable 'xattr' set but not used [-Wunused-but-set-variable]

    Commit 21af76631476 ("EVM: turn evm_config_xattrnames into a list")
    defined and set "xattr", but never used it.

    [zohar@linux.ibm.com: tweaked the patch description explanation]
    Signed-off-by: YueHaibing
    Signed-off-by: Mimi Zohar

    YueHaibing
     

28 Dec, 2018

1 commit

  • Pull crypto updates from Herbert Xu:
    "API:
    - Add 1472-byte test to tcrypt for IPsec
    - Reintroduced crypto stats interface with numerous changes
    - Support incremental algorithm dumps

    Algorithms:
    - Add xchacha12/20
    - Add nhpoly1305
    - Add adiantum
    - Add streebog hash
    - Mark cts(cbc(aes)) as FIPS allowed

    Drivers:
    - Improve performance of arm64/chacha20
    - Improve performance of x86/chacha20
    - Add NEON-accelerated nhpoly1305
    - Add SSE2 accelerated nhpoly1305
    - Add AVX2 accelerated nhpoly1305
    - Add support for 192/256-bit keys in gcmaes AVX
    - Add SG support in gcmaes AVX
    - ESN for inline IPsec tx in chcr
    - Add support for CryptoCell 703 in ccree
    - Add support for CryptoCell 713 in ccree
    - Add SM4 support in ccree
    - Add SM3 support in ccree
    - Add support for chacha20 in caam/qi2
    - Add support for chacha20 + poly1305 in caam/jr
    - Add support for chacha20 + poly1305 in caam/qi2
    - Add AEAD cipher support in cavium/nitrox"

    * 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (130 commits)
    crypto: skcipher - remove remnants of internal IV generators
    crypto: cavium/nitrox - Fix build with !CONFIG_DEBUG_FS
    crypto: salsa20-generic - don't unnecessarily use atomic walk
    crypto: skcipher - add might_sleep() to skcipher_walk_virt()
    crypto: x86/chacha - avoid sleeping under kernel_fpu_begin()
    crypto: cavium/nitrox - Added AEAD cipher support
    crypto: mxc-scc - fix build warnings on ARM64
    crypto: api - document missing stats member
    crypto: user - remove unused dump functions
    crypto: chelsio - Fix wrong error counter increments
    crypto: chelsio - Reset counters on cxgb4 Detach
    crypto: chelsio - Handle PCI shutdown event
    crypto: chelsio - cleanup:send addr as value in function argument
    crypto: chelsio - Use same value for both channel in single WR
    crypto: chelsio - Swap location of AAD and IV sent in WR
    crypto: chelsio - remove set but not used variable 'kctx_len'
    crypto: ux500 - Use proper enum in hash_set_dma_transfer
    crypto: ux500 - Use proper enum in cryp_set_dma_transfer
    crypto: aesni - Add scatter/gather avx stubs, and use them in C
    crypto: aesni - Introduce partial block macro
    ..

    Linus Torvalds
     

13 Dec, 2018

2 commits

  • Historically a lot of these existed because we did not have
    a distinction between what was modular code and what was providing
    support to modules via EXPORT_SYMBOL and friends. That changed
    when we forked out support for the latter into the export.h file.
    This means we should be able to reduce the usage of module.h
    in code that is obj-y Makefile or bool Kconfig.

    The advantage in removing such instances is that module.h itself
    sources about 15 other headers; adding significantly to what we feed
    cpp, and it can obscure what headers we are effectively using.

    Since module.h might have been the implicit source for init.h
    (for __init) and for export.h (for EXPORT_SYMBOL) we consider each
    instance for the presence of either and replace as needed.

    Cc: James Morris
    Cc: "Serge E. Hallyn"
    Cc: John Johansen
    Cc: Mimi Zohar
    Cc: Dmitry Kasatkin
    Cc: David Howells
    Cc: linux-security-module@vger.kernel.org
    Cc: linux-integrity@vger.kernel.org
    Cc: keyrings@vger.kernel.org
    Signed-off-by: Paul Gortmaker
    Signed-off-by: James Morris

    Paul Gortmaker
     
  • The Makefile/Kconfig entry controlling compilation of this code is:

    obj-$(CONFIG_EVM) += evm.o
    evm-y := evm_main.o evm_crypto.o evm_secfs.o

    security/integrity/evm/Kconfig:config EVM
    security/integrity/evm/Kconfig: bool "EVM support"

    ...meaning that it currently is not being built as a module by anyone.

    Lets remove the couple traces of modular infrastructure use, so that
    when reading the driver there is no doubt it is builtin-only.

    We also delete the MODULE_LICENSE tag etc. since all that information
    is already contained at the top of the file in the comments.

    Cc: Mimi Zohar
    Cc: James Morris
    Cc: "Serge E. Hallyn"
    Cc: linux-ima-devel@lists.sourceforge.net
    Cc: linux-security-module@vger.kernel.org
    Signed-off-by: Paul Gortmaker
    Signed-off-by: James Morris

    Paul Gortmaker
     

20 Nov, 2018

1 commit

  • 'shash' algorithms are always synchronous, so passing CRYPTO_ALG_ASYNC
    in the mask to crypto_alloc_shash() has no effect. Many users therefore
    already don't pass it, but some still do. This inconsistency can cause
    confusion, especially since the way the 'mask' argument works is
    somewhat counterintuitive.

    Thus, just remove the unneeded CRYPTO_ALG_ASYNC flags.

    This patch shouldn't change any actual behavior.

    Signed-off-by: Eric Biggers
    Signed-off-by: Herbert Xu

    Eric Biggers
     

11 Oct, 2018

1 commit


23 Jul, 2018

1 commit

  • In case of error, the function audit_log_start() returns NULL pointer
    not ERR_PTR(). The IS_ERR() test in the return value check should be
    replaced with NULL test.

    Fixes: fa516b66a1bf ("EVM: Allow runtime modification of the set of verified xattrs")
    Signed-off-by: Wei Yongjun
    Acked-by: Serge Hallyn
    Signed-off-by: Mimi Zohar

    Wei Yongjun
     

18 Jul, 2018

2 commits

  • SHA1 is reasonable in HMAC constructs, but it's desirable to be able to
    use stronger hashes in digital signatures. Modify the EVM crypto code so
    the hash type is imported from the digital signature and passed down to
    the hash calculation code, and return the digest size to higher layers
    for validation.

    Signed-off-by: Matthew Garrett
    Signed-off-by: Mimi Zohar

    Matthew Garrett
     
  • When EVM attempts to appraise a file signed with a crypto algorithm the
    kernel doesn't have support for, it will cause the kernel to trigger a
    module load. If the EVM policy includes appraisal of kernel modules this
    will in turn call back into EVM - since EVM is holding a lock until the
    crypto initialisation is complete, this triggers a deadlock. Add a
    CRYPTO_NOLOAD flag and skip module loading if it's set, and add that flag
    in the EVM case in order to fail gracefully with an error message
    instead of deadlocking.

    Signed-off-by: Matthew Garrett
    Acked-by: Herbert Xu
    Signed-off-by: Mimi Zohar

    Matthew Garrett
     

08 Jun, 2018

1 commit

  • …morris/linux-security

    Pull integrity updates from James Morris:
    "From Mimi:

    - add run time support for specifying additional security xattrs
    included in the security.evm HMAC/signature

    - some code clean up and bug fixes"

    * 'next-integrity' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security:
    EVM: unlock on error path in evm_read_xattrs()
    EVM: prevent array underflow in evm_write_xattrs()
    EVM: Fix null dereference on xattr when xattr fails to allocate
    EVM: fix memory leak of temporary buffer 'temp'
    IMA: use list_splice_tail_init_rcu() instead of its open coded variant
    ima: use match_string() helper
    ima: fix updating the ima_appraise flag
    ima: based on policy verify firmware signatures (pre-allocated buffer)
    ima: define a new policy condition based on the filesystem name
    EVM: Allow runtime modification of the set of verified xattrs
    EVM: turn evm_config_xattrnames into a list
    integrity: Add an integrity directory in securityfs
    ima: Remove unused variable ima_initialized
    ima: Unify logging
    ima: Reflect correct permissions for policy

    Linus Torvalds
     

01 Jun, 2018

1 commit


31 May, 2018

3 commits

  • If the user sets xattr->name[0] to NUL then we would read one character
    before the start of the array. This bug seems harmless as far as I can
    see but perhaps it would trigger a warning in KASAN.

    Fixes: fa516b66a1bf ("EVM: Allow runtime modification of the set of verified xattrs")
    Signed-off-by: Dan Carpenter
    Signed-off-by: Mimi Zohar

    Dan Carpenter
     
  • In the case where the allocation of xattr fails and xattr is NULL, the
    error exit return path via label 'out' will dereference xattr when
    kfree'ing xattr-name. Fix this by only kfree'ing xattr->name and xattr
    when xattr is non-null.

    Detected by CoverityScan, CID#1469366 ("Dereference after null check")

    Fixes: fa516b66a1bf ("EVM: Allow runtime modification of the set of verified xattrs")
    Signed-off-by: Colin Ian King
    Signed-off-by: Mimi Zohar

    Colin Ian King
     
  • The allocation of 'temp' is not kfree'd and hence there is a memory
    leak on each call of evm_read_xattrs. Fix this by kfree'ing it
    after copying data from it back to the user space buffer 'buf'.

    Detected by CoverityScan, CID#1469386 ("Resource Leak")

    Fixes: fa516b66a1bf ("EVM: Allow runtime modification of the set of verified xattrs")
    Signed-off-by: Colin Ian King
    Signed-off-by: Mimi Zohar

    Colin Ian King
     

19 May, 2018

2 commits

  • Sites may wish to provide additional metadata alongside files in order
    to make more fine-grained security decisions[1]. The security of this is
    enhanced if this metadata is protected, something that EVM makes
    possible. However, the kernel cannot know about the set of extended
    attributes that local admins may wish to protect, and hardcoding this
    policy in the kernel makes it difficult to change over time and less
    convenient for distributions to enable.

    This patch adds a new /sys/kernel/security/integrity/evm/evm_xattrs node,
    which can be read to obtain the current set of EVM-protected extended
    attributes or written to in order to add new entries. Extending this list
    will not change the validity of any existing signatures provided that the
    file in question does not have any of the additional extended attributes -
    missing xattrs are skipped when calculating the EVM hash.

    [1] For instance, a package manager could install information about the
    package uploader in an additional extended attribute. Local LSM policy
    could then be associated with that extended attribute in order to
    restrict the privileges available to packages from less trusted
    uploaders.

    Signed-off-by: Matthew Garrett
    Reviewed-by: James Morris
    Signed-off-by: Mimi Zohar

    Matthew Garrett
     
  • Use a list of xattrs rather than an array - this makes it easier to
    extend the list at runtime.

    Signed-off-by: Matthew Garrett
    Reviewed-by: James Morris
    Signed-off-by: Mimi Zohar

    Matthew Garrett
     

17 May, 2018

1 commit

  • We want to add additional evm control nodes, and it'd be preferable not
    to clutter up the securityfs root directory any further. Create a new
    integrity directory, move the ima directory into it, create an evm
    directory for the evm attribute and add compatibility symlinks.

    Signed-off-by: Matthew Garrett
    Signed-off-by: Mimi Zohar

    Matthew Garrett
     

04 May, 2018

1 commit

  • The kernel should not calculate new hmacs for mounts done by
    non-root users. Update evm_calc_hmac_or_hash() to refuse to
    calculate new hmacs for mounts for non-init user namespaces.

    Cc: linux-integrity@vger.kernel.org
    Cc: linux-security-module@vger.kernel.org
    Cc: linux-kernel@vger.kernel.org
    Cc: James Morris
    Cc: Mimi Zohar
    Cc: "Serge E. Hallyn"
    Signed-off-by: Seth Forshee
    Signed-off-by: Dongsu Park
    Signed-off-by: Eric W. Biederman

    Seth Forshee
     

25 Mar, 2018

1 commit

  • EVM might update the evm xattr while the VFS performs a remount to
    readonly mode. This is not properly checked for, additionally check
    the s_readonly_remount superblock flag before writing.

    The bug can for example be observed with UBIFS. UBIFS checks the free
    space on the device before and after a remount. With EVM enabled the
    free space sometimes differs between both checks.

    Signed-off-by: Sascha Hauer
    Signed-off-by: Mimi Zohar

    Sascha Hauer
     

23 Mar, 2018

2 commits


12 Dec, 2017

2 commits

  • The EVM signature includes the inode number and (optionally) the
    filesystem UUID, making it impractical to ship EVM signatures in
    packages. This patch adds a new portable format intended to allow
    distributions to include EVM signatures. It is identical to the existing
    format but hardcodes the inode and generation numbers to 0 and does not
    include the filesystem UUID even if the kernel is configured to do so.

    Removing the inode means that the metadata and signature from one file
    could be copied to another file without invalidating it. This is avoided
    by ensuring that an IMA xattr is present during EVM validation.

    Portable signatures are intended to be immutable - ie, they will never
    be transformed into HMACs.

    Based on earlier work by Dmitry Kasatkin and Mikhail Kurinnoi.

    Signed-off-by: Matthew Garrett
    Cc: Dmitry Kasatkin
    Cc: Mikhail Kurinnoi
    Signed-off-by: Mimi Zohar

    Matthew Garrett
     
  • When EVM is enabled it forbids modification of metadata protected by
    EVM unless there is already a valid EVM signature. If any modification
    is made, the kernel will then generate a new EVM HMAC. However, this
    does not map well on use cases which use only asymmetric EVM signatures,
    as in this scenario the kernel is unable to generate new signatures.

    This patch extends the /sys/kernel/security/evm interface to allow
    userland to request that modification of these xattrs be permitted. This
    is only permitted if no keys have already been loaded. In this
    configuration, modifying the metadata will invalidate the EVM appraisal
    on the file in question. This allows packaging systems to write out new
    files, set the relevant extended attributes and then move them into
    place.

    There's also some refactoring of the use of evm_initialized in order to
    avoid heading down codepaths that assume there's a key available.

    Signed-off-by: Matthew Garrett
    Signed-off-by: Mimi Zohar

    Matthew Garrett
     

09 Nov, 2017

3 commits

  • A system can validate EVM digital signatures without requiring an HMAC
    key, but every EVM validation will generate a kernel error. Change this
    so we only generate an error once.

    Signed-off-by: Matthew Garrett
    Signed-off-by: Mimi Zohar

    Matthew Garrett
     
  • EVM will only perform validation once a key has been loaded. This key
    may either be a symmetric trusted key (for HMAC validation and creation)
    or the public half of an asymmetric key (for digital signature
    validation). The /sys/kernel/security/evm interface allows userland to
    signal that a symmetric key has been loaded, but does not allow userland
    to signal that an asymmetric public key has been loaded.

    This patch extends the interface to permit userspace to pass a bitmask
    of loaded key types. It also allows userspace to block loading of a
    symmetric key in order to avoid a compromised system from being able to
    load an additional key type later.

    Signed-off-by: Matthew Garrett
    Signed-off-by: Mimi Zohar

    Matthew Garrett
     
  • Apparmor will be gaining support for security.apparmor labels, and it
    would be helpful to include these in EVM validation now so appropriate
    signatures can be generated even before full support is merged.

    Signed-off-by: Matthew Garrett
    Acked-by: John Johansen
    Signed-off-by: Mimi Zohar

    Matthew Garrett
     

05 Jun, 2017

1 commit

  • For some file systems we still memcpy into it, but in various places this
    already allows us to use the proper uuid helpers. More to come..

    Signed-off-by: Christoph Hellwig
    Reviewed-by: Amir Goldstein
    Acked-by: Mimi Zohar  (Changes to IMA/EVM)
    Reviewed-by: Andy Shevchenko

    Christoph Hellwig