26 Oct, 2020

1 commit


16 Sep, 2020

1 commit

  • This patch checks the size for the EVM_IMA_XATTR_DIGSIG and
    EVM_XATTR_PORTABLE_DIGSIG types to ensure that the algorithm is read from
    the buffer returned by vfs_getxattr_alloc().

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

    Roberto Sassu
     

09 Sep, 2020

1 commit


24 Jun, 2020

1 commit


07 Jun, 2020

1 commit

  • Pull integrity updates from Mimi Zohar:
    "The main changes are extending the TPM 2.0 PCR banks with bank
    specific file hashes, calculating the "boot_aggregate" based on other
    TPM PCR banks, using the default IMA hash algorithm, instead of SHA1,
    as the basis for the cache hash table key, and preventing the mprotect
    syscall to circumvent an IMA mmap appraise policy rule.

    - In preparation for extending TPM 2.0 PCR banks with bank specific
    digests, commit 0b6cf6b97b7e ("tpm: pass an array of
    tpm_extend_digest structures to tpm_pcr_extend()") modified
    tpm_pcr_extend(). The original SHA1 file digests were
    padded/truncated, before being extended into the other TPM PCR
    banks. This pull request calculates and extends the TPM PCR banks
    with bank specific file hashes completing the above change.

    - The "boot_aggregate", the first IMA measurement list record, is the
    "trusted boot" link between the pre-boot environment and the
    running OS. With TPM 2.0, the "boot_aggregate" record is not
    limited to being based on the SHA1 TPM PCR bank, but can be
    calculated based on any enabled bank, assuming the hash algorithm
    is also enabled in the kernel.

    Other changes include the following and five other bug fixes/code
    clean up:

    - supporting both a SHA1 and a larger "boot_aggregate" digest in a
    custom template format containing both the the SHA1 ('d') and
    larger digests ('d-ng') fields.

    - Initial hash table key fix, but additional changes would be good"

    * tag 'integrity-v5.8' of git://git.kernel.org/pub/scm/linux/kernel/git/zohar/linux-integrity:
    ima: Directly free *entry in ima_alloc_init_template() if digests is NULL
    ima: Call ima_calc_boot_aggregate() in ima_eventdigest_init()
    ima: Directly assign the ima_default_policy pointer to ima_rules
    ima: verify mprotect change is consistent with mmap policy
    evm: Fix possible memory leak in evm_calc_hmac_or_hash()
    ima: Set again build_ima_appraise variable
    ima: Remove redundant policy rule set in add_rules()
    ima: Fix ima digest hash table key calculation
    ima: Use ima_hash_algo for collision detection in the measurement list
    ima: Calculate and extend PCR with digests in ima_template_entry
    ima: Allocate and initialize tfm for each PCR bank
    ima: Switch to dynamically allocated buffer for template digests
    ima: Store template digest directly in ima_template_entry
    ima: Evaluate error in init_ima()
    ima: Switch to ima_hash_algo for boot aggregate

    Linus Torvalds
     

25 May, 2020

1 commit


15 May, 2020

1 commit

  • The IS_ERR_OR_NULL() function has two conditions and if we got really
    unlucky we could hit a race where "ptr" started as an error pointer and
    then was set to NULL. Both conditions would be false even though the
    pointer at the end was NULL.

    This patch fixes the problem by ensuring that "*tfm" can only be NULL
    or valid. I have introduced a "tmp_tfm" variable to make that work. I
    also reversed a condition and pulled the code in one tab.

    Reported-by: Roberto Sassu
    Fixes: 53de3b080d5e ("evm: Check also if *tfm is an error pointer in init_desc()")
    Signed-off-by: Dan Carpenter
    Acked-by: Roberto Sassu
    Acked-by: Krzysztof Struczynski
    Signed-off-by: Mimi Zohar

    Dan Carpenter
     

08 May, 2020

3 commits

  • Don't immediately return if the signature is portable and security.ima is
    not present. Just set error so that memory allocated is freed before
    returning from evm_calc_hmac_or_hash().

    Fixes: 50b977481fce9 ("EVM: Add support for portable signature format")
    Signed-off-by: Roberto Sassu
    Cc: stable@vger.kernel.org
    Signed-off-by: Mimi Zohar

    Roberto Sassu
     
  • This patch fixes the following warning and few other instances of
    traversal of evm_config_xattrnames list:

    [ 32.848432] =============================
    [ 32.848707] WARNING: suspicious RCU usage
    [ 32.848966] 5.7.0-rc1-00006-ga8d5875ce5f0b #1 Not tainted
    [ 32.849308] -----------------------------
    [ 32.849567] security/integrity/evm/evm_main.c:231 RCU-list traversed in non-reader section!!

    Since entries are only added to the list and never deleted, use
    list_for_each_entry_lockless() instead of list_for_each_entry_rcu for
    traversing the list. Also, add a relevant comment in evm_secfs.c to
    indicate this fact.

    Reported-by: kernel test robot
    Suggested-by: Paul E. McKenney
    Signed-off-by: Madhuparna Bhowmik
    Acked-by: Paul E. McKenney (RCU viewpoint)
    Signed-off-by: Mimi Zohar

    Madhuparna Bhowmik
     
  • This patch avoids a kernel panic due to accessing an error pointer set by
    crypto_alloc_shash(). It occurs especially when there are many files that
    require an unsupported algorithm, as it would increase the likelihood of
    the following race condition:

    Task A: *tfm = crypto_alloc_shash()
    Signed-off-by: Krzysztof Struczynski
    Signed-off-by: Roberto Sassu
    Signed-off-by: Mimi Zohar

    Roberto Sassu
     

07 Apr, 2020

1 commit


29 Feb, 2020

1 commit

  • The #define for formatting log messages, pr_fmt, is duplicated in the
    files under security/integrity.

    This change moves the definition to security/integrity/integrity.h and
    removes the duplicate definitions in the other files under
    security/integrity.

    With this change, the messages in the following files will be prefixed
    with 'integrity'.

    security/integrity/platform_certs/platform_keyring.c
    security/integrity/platform_certs/load_powerpc.c
    security/integrity/platform_certs/load_uefi.c
    security/integrity/iint.c

    e.g. "integrity: Error adding keys to platform keyring %s\n"

    And the messages in the following file will be prefixed with 'ima'.

    security/integrity/ima/ima_mok.c

    e.g. "ima: Allocating IMA blacklist keyring.\n"

    For the rest of the files under security/integrity, there will be no
    change in the message format.

    Suggested-by: Shuah Khan
    Suggested-by: Joe Perches
    Signed-off-by: Tushar Sugandhi
    Reviewed-by: Lakshmi Ramasubramanian
    Signed-off-by: Mimi Zohar

    Tushar Sugandhi
     

06 Nov, 2019

1 commit

  • Add a flag option to get xattr method that could have a bit flag of
    XATTR_NOSECURITY passed to it. XATTR_NOSECURITY is generally then
    set in the __vfs_getxattr path when called by security
    infrastructure.

    This handles the case of a union filesystem driver that is being
    requested by the security layer to report back the xattr data.

    For the use case where access is to be blocked by the security layer.

    The path then could be security(dentry) ->
    __vfs_getxattr(dentry...XATTR_NOSECURITY) ->
    handler->get(dentry...XATTR_NOSECURITY) ->
    __vfs_getxattr(lower_dentry...XATTR_NOSECURITY) ->
    lower_handler->get(lower_dentry...XATTR_NOSECURITY)
    which would report back through the chain data and success as
    expected, the logging security layer at the top would have the
    data to determine the access permissions and report back the target
    context that was blocked.

    Without the get handler flag, the path on a union filesystem would be
    the errant security(dentry) -> __vfs_getxattr(dentry) ->
    handler->get(dentry) -> vfs_getxattr(lower_dentry) -> nested ->
    security(lower_dentry, log off) -> lower_handler->get(lower_dentry)
    which would report back through the chain no data, and -EACCES.

    For selinux for both cases, this would translate to a correctly
    determined blocked access. In the first case with this change a correct avc
    log would be reported, in the second legacy case an incorrect avc log
    would be reported against an uninitialized u:object_r:unlabeled:s0
    context making the logs cosmetically useless for audit2allow.

    This patch series is inert and is the wide-spread addition of the
    flags option for xattr functions, and a replacement of __vfs_getxattr
    with __vfs_getxattr(...XATTR_NOSECURITY).

    Signed-off-by: Mark Salyzyn
    Reviewed-by: Jan Kara
    Acked-by: Jan Kara
    Acked-by: Jeff Layton
    Acked-by: David Sterba
    Acked-by: Darrick J. Wong
    Acked-by: Mike Marshall
    Cc: Stephen Smalley
    Cc: linux-kernel@vger.kernel.org
    Cc: kernel-team@android.com
    Cc: linux-security-module@vger.kernel.org

    (cherry picked from (rejected from archive because of too many recipients))
    Signed-off-by: Mark Salyzyn
    Bug: 133515582
    Bug: 136124883
    Bug: 129319403
    Change-Id: Iabbb8771939d5f66667a26bb23ddf4c562c349a1

    Mark Salyzyn
     

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