14 Nov, 2018

1 commit

  • commit 578bdaabd015b9b164842c3e8ace9802f38e7ecc upstream.

    These are unused, undesired, and have never actually been used by
    anybody. The original authors of this code have changed their mind about
    its inclusion. While originally proposed for disk encryption on low-end
    devices, the idea was discarded [1] in favor of something else before
    that could really get going. Therefore, this patch removes Speck.

    [1] https://marc.info/?l=linux-crypto-vger&m=153359499015659

    Signed-off-by: Jason A. Donenfeld
    Acked-by: Eric Biggers
    Cc: stable@vger.kernel.org
    Acked-by: Ard Biesheuvel
    Signed-off-by: Herbert Xu
    Signed-off-by: Greg Kroah-Hartman

    Jason A. Donenfeld
     

12 Jun, 2018

1 commit

  • Pull f2fs updates from Jaegeuk Kim:
    "In this round, we've mainly focused on discard, aka unmap, control
    along with fstrim for Android-specific usage model. In addition, we've
    fixed writepage flow which returned EAGAIN previously resulting in EIO
    of fsync(2) due to mapping's error state. In order to avoid old MM bug
    [1], we decided not to use __GFP_ZERO for the mapping for node and
    meta page caches. As always, we've cleaned up many places for future
    fsverity and symbol conflicts.

    Enhancements:
    - do discard/fstrim in lower priority considering fs utilization
    - split large discard commands into smaller ones for better responsiveness
    - add more sanity checks to address syzbot reports
    - add a mount option, fsync_mode=nobarrier, which can reduce # of cache flushes
    - clean up symbol namespace with modified function names
    - be strict on block allocation and IO control in corner cases

    Bug fixes:
    - don't use __GFP_ZERO for mappings
    - fix error reports in writepage to avoid fsync() failure
    - avoid selinux denial on CAP_RESOURCE on resgid/resuid
    - fix some subtle race conditions in GC/atomic writes/shutdown
    - fix overflow bugs in sanity_check_raw_super
    - fix missing bits on get_flags

    Clean-ups:
    - prepare the generic flow for future fsverity integration
    - fix some broken coding standard"

    [1] https://lkml.org/lkml/2018/4/8/661

    * tag 'f2fs-for-4.18' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs: (79 commits)
    f2fs: fix to clear FI_VOLATILE_FILE correctly
    f2fs: let sync node IO interrupt async one
    f2fs: don't change wbc->sync_mode
    f2fs: fix to update mtime correctly
    fs: f2fs: insert space around that ':' and ', '
    fs: f2fs: add missing blank lines after declarations
    fs: f2fs: changed variable type of offset "unsigned" to "loff_t"
    f2fs: clean up symbol namespace
    f2fs: make set_de_type() static
    f2fs: make __f2fs_write_data_pages() static
    f2fs: fix to avoid accessing cross the boundary
    f2fs: fix to let caller retry allocating block address
    disable loading f2fs module on PAGE_SIZE > 4KB
    f2fs: fix error path of move_data_page
    f2fs: don't drop dentry pages after fs shutdown
    f2fs: fix to avoid race during access gc_thread pointer
    f2fs: clean up with clear_radix_tree_dirty_tag
    f2fs: fix to don't trigger writeback during recovery
    f2fs: clear discard_wake earlier
    f2fs: let discard thread wait a little longer if dev is busy
    ...

    Linus Torvalds
     

21 May, 2018

17 commits

  • Log the crypto algorithm driver name for each fscrypt encryption mode on
    its first use, also showing a friendly name for the mode.

    This will help people determine whether the expected implementations are
    being used. In some cases we've seen people do benchmarks and reject
    using encryption for performance reasons, when in fact they used a much
    slower implementation of AES-XTS than was possible on the hardware. It
    can make an enormous difference; e.g., AES-XTS on ARM is about 10x
    faster with the crypto extensions (AES instructions) than without.

    This also makes it more obvious which modes are being used, now that
    fscrypt supports multiple combinations of modes.

    Example messages (with default modes, on x86_64):

    [ 35.492057] fscrypt: AES-256-CTS-CBC using implementation "cts(cbc-aes-aesni)"
    [ 35.492171] fscrypt: AES-256-XTS using implementation "xts-aes-aesni"

    Note: algorithms can be dynamically added to the crypto API, which can
    result in different implementations being used at different times. But
    this is rare; for most users, showing the first will be good enough.

    Signed-off-by: Eric Biggers
    Signed-off-by: Theodore Ts'o

    Eric Biggers
     
  • fscrypt currently only supports AES encryption. However, many low-end
    mobile devices have older CPUs that don't have AES instructions, e.g.
    the ARMv8 Cryptography Extensions. Currently, user data on such devices
    is not encrypted at rest because AES is too slow, even when the NEON
    bit-sliced implementation of AES is used. Unfortunately, it is
    infeasible to encrypt these devices at all when AES is the only option.

    Therefore, this patch updates fscrypt to support the Speck block cipher,
    which was recently added to the crypto API. The C implementation of
    Speck is not especially fast, but Speck can be implemented very
    efficiently with general-purpose vector instructions, e.g. ARM NEON.
    For example, on an ARMv7 processor, we measured the NEON-accelerated
    Speck128/256-XTS at 69 MB/s for both encryption and decryption, while
    AES-256-XTS with the NEON bit-sliced implementation was only 22 MB/s
    encryption and 19 MB/s decryption.

    There are multiple variants of Speck. This patch only adds support for
    Speck128/256, which is the variant with a 128-bit block size and 256-bit
    key size -- the same as AES-256. This is believed to be the most secure
    variant of Speck, and it's only about 6% slower than Speck128/128.
    Speck64/128 would be at least 20% faster because it has 20% rounds, and
    it can be even faster on CPUs that can't efficiently do the 64-bit
    operations needed for Speck128. However, Speck64's 64-bit block size is
    not preferred security-wise. ARM NEON also supports the needed 64-bit
    operations even on 32-bit CPUs, resulting in Speck128 being fast enough
    for our targeted use cases so far.

    The chosen modes of operation are XTS for contents and CTS-CBC for
    filenames. These are the same modes of operation that fscrypt defaults
    to for AES. Note that as with the other fscrypt modes, Speck will not
    be used unless userspace chooses to use it. Nor are any of the existing
    modes (which are all AES-based) being removed, of course.

    We intentionally don't make CONFIG_FS_ENCRYPTION select
    CONFIG_CRYPTO_SPECK, so people will have to enable Speck support
    themselves if they need it. This is because we shouldn't bloat the
    FS_ENCRYPTION dependencies with every new cipher, especially ones that
    aren't recommended for most users. Moreover, CRYPTO_SPECK is just the
    generic implementation, which won't be fast enough for many users; in
    practice, they'll need to enable CRYPTO_SPECK_NEON to get acceptable
    performance.

    More details about our choice of Speck can be found in our patches that
    added Speck to the crypto API, and the follow-on discussion threads.
    We're planning a publication that explains the choice in more detail.
    But briefly, we can't use ChaCha20 as we previously proposed, since it
    would be insecure to use a stream cipher in this context, with potential
    IV reuse during writes on f2fs and/or on wear-leveling flash storage.

    We also evaluated many other lightweight and/or ARX-based block ciphers
    such as Chaskey-LTS, RC5, LEA, CHAM, Threefish, RC6, NOEKEON, SPARX, and
    XTEA. However, all had disadvantages vs. Speck, such as insufficient
    performance with NEON, much less published cryptanalysis, or an
    insufficient security level. Various design choices in Speck make it
    perform better with NEON than competing ciphers while still having a
    security margin similar to AES, and in the case of Speck128 also the
    same available security levels. Unfortunately, Speck does have some
    political baggage attached -- it's an NSA designed cipher, and was
    rejected from an ISO standard (though for context, as far as I know none
    of the above-mentioned alternatives are ISO standards either).
    Nevertheless, we believe it is a good solution to the problem from a
    technical perspective.

    Certain algorithms constructed from ChaCha or the ChaCha permutation,
    such as MEM (Masked Even-Mansour) or HPolyC, may also meet our
    performance requirements. However, these are new constructions that
    need more time to receive the cryptographic review and acceptance needed
    to be confident in their security. HPolyC hasn't been published yet,
    and we are concerned that MEM makes stronger assumptions about the
    underlying permutation than the ChaCha stream cipher does. In contrast,
    the XTS mode of operation is relatively well accepted, and Speck has
    over 70 cryptanalysis papers. Of course, these ChaCha-based algorithms
    can still be added later if they become ready.

    The best known attack on Speck128/256 is a differential cryptanalysis
    attack on 25 of 34 rounds with 2^253 time complexity and 2^125 chosen
    plaintexts, i.e. only marginally faster than brute force. There is no
    known attack on the full 34 rounds.

    Signed-off-by: Eric Biggers
    Signed-off-by: Theodore Ts'o

    Eric Biggers
     
  • Currently the key derivation function in fscrypt uses the master key
    length as the amount of output key material to derive. This works, but
    it means we can waste time deriving more key material than is actually
    used, e.g. most commonly, deriving 64 bytes for directories which only
    take a 32-byte AES-256-CTS-CBC key. It also forces us to validate that
    the master key length is a multiple of AES_BLOCK_SIZE, which wouldn't
    otherwise be necessary.

    Fix it to only derive the needed length key.

    Signed-off-by: Eric Biggers
    Signed-off-by: Theodore Ts'o

    Eric Biggers
     
  • Refactor the confusingly-named function 'validate_user_key()' into a new
    function 'find_and_derive_key()' which first finds the keyring key, then
    does the key derivation. Among other benefits this avoids the strange
    behavior we had previously where if key derivation failed for some
    reason, then we would fall back to the alternate key prefix. Now, we'll
    only fall back to the alternate key prefix if a valid key isn't found.

    This patch also improves the warning messages that are logged when the
    keyring key's payload is invalid.

    Signed-off-by: Eric Biggers
    Signed-off-by: Theodore Ts'o

    Eric Biggers
     
  • Use a common function for fscrypt warning and error messages so that all
    the messages are consistently ratelimited, include the "fscrypt:"
    prefix, and include the filesystem name if applicable.

    Also fix up a few of the log messages to be more descriptive.

    Signed-off-by: Eric Biggers
    Signed-off-by: Theodore Ts'o

    Eric Biggers
     
  • With one exception, the internal key size constants such as
    FS_AES_256_XTS_KEY_SIZE are only used for the 'available_modes' array,
    where they really only serve to obfuscate what the values are. Also
    some of the constants are unused, and the key sizes tend to be in the
    names of the algorithms anyway. In the past these values were also
    misused, e.g. we used to have FS_AES_256_XTS_KEY_SIZE in places that
    technically should have been FS_MAX_KEY_SIZE.

    The exception is that FS_AES_128_ECB_KEY_SIZE is used for key
    derivation. But it's more appropriate to use
    FS_KEY_DERIVATION_NONCE_SIZE for that instead.

    Thus, just put the sizes directly in the 'available_modes' array.

    Signed-off-by: Eric Biggers
    Signed-off-by: Theodore Ts'o

    Eric Biggers
     
  • We're passing 'key_type_logon' to request_key(), so the found key is
    guaranteed to be of type "logon". Thus, there is no reason to check
    later that the key is really a "logon" key.

    Signed-off-by: Eric Biggers
    Signed-off-by: Theodore Ts'o

    Eric Biggers
     
  • Now ->max_namelen() is only called to limit the filename length when
    adding NUL padding, and only for real filenames -- not symlink targets.
    It also didn't give the correct length for symlink targets anyway since
    it forgot to subtract 'sizeof(struct fscrypt_symlink_data)'.

    Thus, change ->max_namelen from a function to a simple 'unsigned int'
    that gives the filesystem's maximum filename length.

    Signed-off-by: Eric Biggers
    Signed-off-by: Theodore Ts'o

    Eric Biggers
     
  • fname_decrypt() is validating that the encrypted filename is nonempty.
    However, earlier a stronger precondition was already enforced: the
    encrypted filename must be at least 16 (FS_CRYPTO_BLOCK_SIZE) bytes.

    Drop the redundant check for an empty filename.

    Signed-off-by: Eric Biggers
    Signed-off-by: Theodore Ts'o

    Eric Biggers
     
  • fname_decrypt() returns an error if the input filename is longer than
    the inode's ->max_namelen() as given by the filesystem. But, this
    doesn't actually make sense because the filesystem provided the input
    filename in the first place, where it was subject to the filesystem's
    limits. And fname_decrypt() has no internal limit itself.

    Thus, remove this unnecessary check.

    Signed-off-by: Eric Biggers
    Signed-off-by: Theodore Ts'o

    Eric Biggers
     
  • In fscrypt_setup_filename(), remove the unnecessary check for
    fscrypt_get_encryption_info() returning EOPNOTSUPP. There's no reason
    to handle this error differently from any other. I think there may have
    been some confusion because the "notsupp" version of
    fscrypt_get_encryption_info() returns EOPNOTSUPP -- but that's not
    applicable from inside fs/crypto/.

    Signed-off-by: Eric Biggers
    Signed-off-by: Theodore Ts'o

    Eric Biggers
     
  • fscrypt is clearing the flags on the crypto_skcipher it allocates for
    each inode. But, this is unnecessary and may cause problems in the
    future because it will even clear flags that are meant to be internal to
    the crypto API, e.g. CRYPTO_TFM_NEED_KEY.

    Remove the unnecessary flag clearing.

    Signed-off-by: Eric Biggers
    Signed-off-by: Theodore Ts'o

    Eric Biggers
     
  • Signed-off-by: Eric Biggers
    Signed-off-by: Theodore Ts'o

    Eric Biggers
     
  • skcipher_request_alloc() can only fail due to lack of memory, and in
    that case the memory allocator will have already printed a detailed
    error message. Thus, remove the redundant error messages from fscrypt.

    Signed-off-by: Eric Biggers
    Signed-off-by: Theodore Ts'o

    Eric Biggers
     
  • crypto_alloc_skcipher() returns an ERR_PTR() on failure, not NULL.
    Remove the unnecessary check for NULL.

    Signed-off-by: Eric Biggers
    Signed-off-by: Theodore Ts'o

    Eric Biggers
     
  • Now that all filesystems have been converted to use
    fscrypt_prepare_lookup(), we can remove the fscrypt_set_d_op() and
    fscrypt_set_encrypted_dentry() functions as well as un-export
    fscrypt_d_ops.

    Signed-off-by: Eric Biggers
    Signed-off-by: Theodore Ts'o

    Eric Biggers
     
  • Improve fscrypt read performance by switching the decryption workqueue
    from bound to unbound. With the bound workqueue, when multiple bios
    completed on the same CPU, they were decrypted on that same CPU. But
    with the unbound queue, they are now decrypted in parallel on any CPU.

    Although fscrypt read performance can be tough to measure due to the
    many sources of variation, this change is most beneficial when
    decryption is slow, e.g. on CPUs without AES instructions. For example,
    I timed tarring up encrypted directories on f2fs. On x86 with AES-NI
    instructions disabled, the unbound workqueue improved performance by
    about 25-35%, using 1 to NUM_CPUs jobs with 4 or 8 CPUs available. But
    with AES-NI enabled, performance was unchanged to within ~2%.

    I also did the same test on a quad-core ARM CPU using xts-speck128-neon
    encryption. There performance was usually about 10% better with the
    unbound workqueue, bringing it closer to the unencrypted speed.

    The unbound workqueue may be worse in some cases due to worse locality,
    but I think it's still the better default. dm-crypt uses an unbound
    workqueue by default too, so this change makes fscrypt match.

    Signed-off-by: Eric Biggers
    Signed-off-by: Theodore Ts'o

    Eric Biggers
     

03 May, 2018

1 commit

  • Currently, fscrypt provides fscrypt_decrypt_bio_pages() which decrypts a
    bio's pages asynchronously, then unlocks them afterwards. But, this
    assumes that decryption is the last "postprocessing step" for the bio,
    so it's incompatible with additional postprocessing steps such as
    authenticity verification after decryption.

    Therefore, rename the existing fscrypt_decrypt_bio_pages() to
    fscrypt_enqueue_decrypt_bio(). Then, add fscrypt_decrypt_bio() which
    decrypts the pages in the bio synchronously without unlocking the pages,
    nor setting them Uptodate; and add fscrypt_enqueue_decrypt_work(), which
    enqueues work on the fscrypt_read_workqueue. The new functions will be
    used by filesystems that support both fscrypt and fs-verity.

    Signed-off-by: Eric Biggers
    Signed-off-by: Jaegeuk Kim

    Eric Biggers
     

01 Feb, 2018

1 commit

  • gcc versions prior to 4.6 require an extra level of braces when using a
    designated initializer for a member in an anonymous struct or union.
    This caused a compile error with the 'struct qstr' initialization in
    __fscrypt_encrypt_symlink().

    Fix it by using QSTR_INIT().

    Reported-by: Andrew Morton
    Fixes: 76e81d6d5048 ("fscrypt: new helper functions for ->symlink()")
    Signed-off-by: Eric Biggers
    Signed-off-by: Theodore Ts'o

    Eric Biggers
     

12 Jan, 2018

12 commits

  • fscrypt_put_encryption_info() is only called when evicting an inode, so
    the 'struct fscrypt_info *ci' parameter is always NULL, and there cannot
    be races with other threads. This was cruft left over from the broken
    key revocation code. Remove the unused parameter and the cmpxchg().

    Also remove the #ifdefs around the fscrypt_put_encryption_info() calls,
    since fscrypt_notsupp.h defines a no-op stub for it.

    Signed-off-by: Eric Biggers
    Signed-off-by: Theodore Ts'o

    Eric Biggers
     
  • Filesystems don't need fscrypt_fname_encrypted_size() anymore, so
    unexport it and move it to fscrypt_private.h.

    We also never calculate the encrypted size of a filename without having
    the fscrypt_info present since it is needed to know the amount of
    NUL-padding which is determined by the encryption policy, and also we
    will always truncate the NUL-padding to the maximum filename length.
    Therefore, also make fscrypt_fname_encrypted_size() assume that the
    fscrypt_info is present, and make it truncate the returned length to the
    specified max_len.

    Signed-off-by: Eric Biggers
    Signed-off-by: Theodore Ts'o

    Eric Biggers
     
  • Previously fscrypt_fname_alloc_buffer() was used to allocate buffers for
    both presented (decrypted or encoded) and encrypted filenames. That was
    confusing, because it had to allocate the worst-case size for either,
    e.g. including NUL-padding even when it was meaningless.

    But now that fscrypt_setup_filename() no longer calls it, it is only
    used in the ->get_link() and ->readdir() paths, which specifically want
    a buffer for presented filenames. Therefore, switch the behavior over
    to allocating the buffer for presented filenames only.

    Signed-off-by: Eric Biggers
    Signed-off-by: Theodore Ts'o

    Eric Biggers
     
  • Currently, when encrypting a filename (either a real filename or a
    symlink target) we calculate the amount of NUL-padding twice: once
    before encryption and once during encryption in fname_encrypt(). It is
    needed before encryption to allocate the needed buffer size as well as
    calculate the size the symlink target will take up on-disk before
    creating the symlink inode. Calculating the size during encryption as
    well is redundant.

    Remove this redundancy by always calculating the exact size beforehand,
    and making fname_encrypt() just add as much NUL padding as is needed to
    fill the output buffer.

    Signed-off-by: Eric Biggers
    Signed-off-by: Theodore Ts'o

    Eric Biggers
     
  • Now that all filesystems have been converted to use the symlink helper
    functions, they no longer need the declaration of 'struct
    fscrypt_symlink_data'. Move it from fscrypt.h to fscrypt_private.h.

    Signed-off-by: Eric Biggers
    Signed-off-by: Theodore Ts'o

    Eric Biggers
     
  • fscrypt_fname_usr_to_disk() sounded very generic but was actually only
    used to encrypt symlinks. Remove it now that all filesystems have been
    switched over to fscrypt_encrypt_symlink().

    Signed-off-by: Eric Biggers
    Signed-off-by: Theodore Ts'o

    Eric Biggers
     
  • Filesystems also have duplicate code to support ->get_link() on
    encrypted symlinks. Factor it out into a new function
    fscrypt_get_symlink(). It takes in the contents of the encrypted
    symlink on-disk and provides the target (decrypted or encoded) that
    should be returned from ->get_link().

    Signed-off-by: Eric Biggers
    Signed-off-by: Theodore Ts'o

    Eric Biggers
     
  • Currently, filesystems supporting fscrypt need to implement some tricky
    logic when creating encrypted symlinks, including handling a peculiar
    on-disk format (struct fscrypt_symlink_data) and correctly calculating
    the size of the encrypted symlink. Introduce helper functions to make
    things a bit easier:

    - fscrypt_prepare_symlink() computes and validates the size the symlink
    target will require on-disk.
    - fscrypt_encrypt_symlink() creates the encrypted target if needed.

    The new helpers actually fix some subtle bugs. First, when checking
    whether the symlink target was too long, filesystems didn't account for
    the fact that the NUL padding is meant to be truncated if it would cause
    the maximum length to be exceeded, as is done for filenames in
    directories. Consequently users would receive ENAMETOOLONG when
    creating symlinks close to what is supposed to be the maximum length.
    For example, with EXT4 with a 4K block size, the maximum symlink target
    length in an encrypted directory is supposed to be 4093 bytes (in
    comparison to 4095 in an unencrypted directory), but in
    FS_POLICY_FLAGS_PAD_32-mode only up to 4064 bytes were accepted.

    Second, symlink targets of "." and ".." were not being encrypted, even
    though they should be, as these names are special in *directory entries*
    but not in symlink targets. Fortunately, we can fix this simply by
    starting to encrypt them, as old kernels already accept them in
    encrypted form.

    Third, the output string length the filesystems were providing when
    doing the actual encryption was incorrect, as it was forgotten to
    exclude 'sizeof(struct fscrypt_symlink_data)'. Fortunately though, this
    bug didn't make a difference.

    Signed-off-by: Eric Biggers
    Signed-off-by: Theodore Ts'o

    Eric Biggers
     
  • fscrypt.h included way too many other headers, given that it is included
    by filesystems both with and without encryption support. Trim down the
    includes list by moving the needed includes into more appropriate
    places, and removing the unneeded ones.

    Signed-off-by: Eric Biggers
    Signed-off-by: Theodore Ts'o

    Eric Biggers
     
  • Only fs/crypto/fname.c cares about treating the "." and ".." filenames
    specially with regards to encryption, so move fscrypt_is_dot_dotdot()
    from fscrypt.h to there.

    Signed-off-by: Eric Biggers
    Signed-off-by: Theodore Ts'o

    Eric Biggers
     
  • The encryption modes are validated by fs/crypto/, not by individual
    filesystems. Therefore, move fscrypt_valid_enc_modes() from fscrypt.h
    to fscrypt_private.h.

    Signed-off-by: Eric Biggers
    Signed-off-by: Theodore Ts'o

    Eric Biggers
     
  • The fscrypt_info kmem_cache is internal to fscrypt; filesystems don't
    need to access it. So move its declaration into fscrypt_private.h.

    Signed-off-by: Eric Biggers
    Signed-off-by: Theodore Ts'o

    Eric Biggers
     

15 Nov, 2017

2 commits

  • Pull fscrypt updates from Ted Ts'o:
    "Lots of cleanups, mostly courtesy by Eric Biggers"

    * tag 'fscrypt-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/fscrypt:
    fscrypt: lock mutex before checking for bounce page pool
    fscrypt: add a documentation file for filesystem-level encryption
    ext4: switch to fscrypt_prepare_setattr()
    ext4: switch to fscrypt_prepare_lookup()
    ext4: switch to fscrypt_prepare_rename()
    ext4: switch to fscrypt_prepare_link()
    ext4: switch to fscrypt_file_open()
    fscrypt: new helper function - fscrypt_prepare_setattr()
    fscrypt: new helper function - fscrypt_prepare_lookup()
    fscrypt: new helper function - fscrypt_prepare_rename()
    fscrypt: new helper function - fscrypt_prepare_link()
    fscrypt: new helper function - fscrypt_file_open()
    fscrypt: new helper function - fscrypt_require_key()
    fscrypt: remove unneeded empty fscrypt_operations structs
    fscrypt: remove ->is_encrypted()
    fscrypt: switch from ->is_encrypted() to IS_ENCRYPTED()
    fs, fscrypt: add an S_ENCRYPTED inode flag
    fscrypt: clean up include file mess

    Linus Torvalds
     
  • Pull crypto updates from Herbert Xu:
    "Here is the crypto update for 4.15:

    API:

    - Disambiguate EBUSY when queueing crypto request by adding ENOSPC.
    This change touches code outside the crypto API.
    - Reset settings when empty string is written to rng_current.

    Algorithms:

    - Add OSCCA SM3 secure hash.

    Drivers:

    - Remove old mv_cesa driver (replaced by marvell/cesa).
    - Enable rfc3686/ecb/cfb/ofb AES in crypto4xx.
    - Add ccm/gcm AES in crypto4xx.
    - Add support for BCM7278 in iproc-rng200.
    - Add hash support on Exynos in s5p-sss.
    - Fix fallback-induced error in vmx.
    - Fix output IV in atmel-aes.
    - Fix empty GCM hash in mediatek.

    Others:

    - Fix DoS potential in lib/mpi.
    - Fix potential out-of-order issues with padata"

    * 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (162 commits)
    lib/mpi: call cond_resched() from mpi_powm() loop
    crypto: stm32/hash - Fix return issue on update
    crypto: dh - Remove pointless checks for NULL 'p' and 'g'
    crypto: qat - Clean up error handling in qat_dh_set_secret()
    crypto: dh - Don't permit 'key' or 'g' size longer than 'p'
    crypto: dh - Don't permit 'p' to be 0
    crypto: dh - Fix double free of ctx->p
    hwrng: iproc-rng200 - Add support for BCM7278
    dt-bindings: rng: Document BCM7278 RNG200 compatible
    crypto: chcr - Replace _manual_ swap with swap macro
    crypto: marvell - Add a NULL entry at the end of mv_cesa_plat_id_table[]
    hwrng: virtio - Virtio RNG devices need to be re-registered after suspend/resume
    crypto: atmel - remove empty functions
    crypto: ecdh - remove empty exit()
    MAINTAINERS: update maintainer for qat
    crypto: caam - remove unused param of ctx_map_to_sec4_sg()
    crypto: caam - remove unneeded edesc zeroization
    crypto: atmel-aes - Reset the controller before each use
    crypto: atmel-aes - properly set IV after {en,de}crypt
    hwrng: core - Reset user selected rng by writing "" to rng_current
    ...

    Linus Torvalds
     

07 Nov, 2017

1 commit


03 Nov, 2017

1 commit


02 Nov, 2017

1 commit

  • Many source files in the tree are missing licensing information, which
    makes it harder for compliance tools to determine the correct license.

    By default all files without license information are under the default
    license of the kernel, which is GPL version 2.

    Update the files which contain no license information with the 'GPL-2.0'
    SPDX license identifier. The SPDX identifier is a legally binding
    shorthand, which can be used instead of the full boiler plate text.

    This patch is based on work done by Thomas Gleixner and Kate Stewart and
    Philippe Ombredanne.

    How this work was done:

    Patches were generated and checked against linux-4.14-rc6 for a subset of
    the use cases:
    - file had no licensing information it it.
    - file was a */uapi/* one with no licensing information in it,
    - file was a */uapi/* one with existing licensing information,

    Further patches will be generated in subsequent months to fix up cases
    where non-standard license headers were used, and references to license
    had to be inferred by heuristics based on keywords.

    The analysis to determine which SPDX License Identifier to be applied to
    a file was done in a spreadsheet of side by side results from of the
    output of two independent scanners (ScanCode & Windriver) producing SPDX
    tag:value files created by Philippe Ombredanne. Philippe prepared the
    base worksheet, and did an initial spot review of a few 1000 files.

    The 4.13 kernel was the starting point of the analysis with 60,537 files
    assessed. Kate Stewart did a file by file comparison of the scanner
    results in the spreadsheet to determine which SPDX license identifier(s)
    to be applied to the file. She confirmed any determination that was not
    immediately clear with lawyers working with the Linux Foundation.

    Criteria used to select files for SPDX license identifier tagging was:
    - Files considered eligible had to be source code files.
    - Make and config files were included as candidates if they contained >5
    lines of source
    - File already had some variant of a license header in it (even if
    Reviewed-by: Philippe Ombredanne
    Reviewed-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

01 Nov, 2017

1 commit

  • fscrypt_initialize(), which allocates the global bounce page pool when
    an encrypted file is first accessed, uses "double-checked locking" to
    try to avoid locking fscrypt_init_mutex. However, it doesn't use any
    memory barriers, so it's theoretically possible for a thread to observe
    a bounce page pool which has not been fully initialized. This is a
    classic bug with "double-checked locking".

    While "only a theoretical issue" in the latest kernel, in pre-4.8
    kernels the pointer that was checked was not even the last to be
    initialized, so it was easily possible for a crash (NULL pointer
    dereference) to happen. This was changed only incidentally by the large
    refactor to use fs/crypto/.

    Solve both problems in a trivial way that can easily be backported: just
    always take the mutex. It's theoretically less efficient, but it
    shouldn't be noticeable in practice as the mutex is only acquired very
    briefly once per encrypted file.

    Later I'd like to make this use a helper macro like DO_ONCE(). However,
    DO_ONCE() runs in atomic context, so we'd need to add a new macro that
    allows blocking.

    Cc: stable@vger.kernel.org # v4.1+
    Signed-off-by: Eric Biggers
    Signed-off-by: Theodore Ts'o

    Eric Biggers
     

25 Oct, 2017

1 commit

  • …READ_ONCE()/WRITE_ONCE()

    Please do not apply this to mainline directly, instead please re-run the
    coccinelle script shown below and apply its output.

    For several reasons, it is desirable to use {READ,WRITE}_ONCE() in
    preference to ACCESS_ONCE(), and new code is expected to use one of the
    former. So far, there's been no reason to change most existing uses of
    ACCESS_ONCE(), as these aren't harmful, and changing them results in
    churn.

    However, for some features, the read/write distinction is critical to
    correct operation. To distinguish these cases, separate read/write
    accessors must be used. This patch migrates (most) remaining
    ACCESS_ONCE() instances to {READ,WRITE}_ONCE(), using the following
    coccinelle script:

    ----
    // Convert trivial ACCESS_ONCE() uses to equivalent READ_ONCE() and
    // WRITE_ONCE()

    // $ make coccicheck COCCI=/home/mark/once.cocci SPFLAGS="--include-headers" MODE=patch

    virtual patch

    @ depends on patch @
    expression E1, E2;
    @@

    - ACCESS_ONCE(E1) = E2
    + WRITE_ONCE(E1, E2)

    @ depends on patch @
    expression E;
    @@

    - ACCESS_ONCE(E)
    + READ_ONCE(E)
    ----

    Signed-off-by: Mark Rutland <mark.rutland@arm.com>
    Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
    Cc: Linus Torvalds <torvalds@linux-foundation.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: davem@davemloft.net
    Cc: linux-arch@vger.kernel.org
    Cc: mpe@ellerman.id.au
    Cc: shuah@kernel.org
    Cc: snitzer@redhat.com
    Cc: thor.thayer@linux.intel.com
    Cc: tj@kernel.org
    Cc: viro@zeniv.linux.org.uk
    Cc: will.deacon@arm.com
    Link: http://lkml.kernel.org/r/1508792849-3115-19-git-send-email-paulmck@linux.vnet.ibm.com
    Signed-off-by: Ingo Molnar <mingo@kernel.org>

    Mark Rutland