14 Dec, 2014

1 commit

  • Pull crypto update from Herbert Xu:
    - The crypto API is now documented :)
    - Disallow arbitrary module loading through crypto API.
    - Allow get request with empty driver name through crypto_user.
    - Allow speed testing of arbitrary hash functions.
    - Add caam support for ctr(aes), gcm(aes) and their derivatives.
    - nx now supports concurrent hashing properly.
    - Add sahara support for SHA1/256.
    - Add ARM64 version of CRC32.
    - Misc fixes.

    * git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (77 commits)
    crypto: tcrypt - Allow speed testing of arbitrary hash functions
    crypto: af_alg - add user space interface for AEAD
    crypto: qat - fix problem with coalescing enable logic
    crypto: sahara - add support for SHA1/256
    crypto: sahara - replace tasklets with kthread
    crypto: sahara - add support for i.MX53
    crypto: sahara - fix spinlock initialization
    crypto: arm - replace memset by memzero_explicit
    crypto: powerpc - replace memset by memzero_explicit
    crypto: sha - replace memset by memzero_explicit
    crypto: sparc - replace memset by memzero_explicit
    crypto: algif_skcipher - initialize upon init request
    crypto: algif_skcipher - removed unneeded code
    crypto: algif_skcipher - Fixed blocking recvmsg
    crypto: drbg - use memzero_explicit() for clearing sensitive data
    crypto: drbg - use MODULE_ALIAS_CRYPTO
    crypto: include crypto- module prefix in template
    crypto: user - add MODULE_ALIAS
    crypto: sha-mb - remove a bogus NULL check
    crytpo: qat - Fix 64 bytes requests
    ...

    Linus Torvalds
     

10 Dec, 2014

1 commit

  • Note that the code _using_ ->msg_iter at that point will be very
    unhappy with anything other than unshifted iovec-backed iov_iter.
    We still need to convert users to proper primitives.

    Signed-off-by: Al Viro

    Al Viro
     

02 Dec, 2014

1 commit

  • When using the algif_skcipher, the following call sequence causess a
    re-initialization:

    1. sendmsg with ALG_SET_OP and iov == NULL, iovlen == 0 (i.e
    initializing the cipher, but not sending data)

    2. sendmsg with msg->msg-controllen == 0 and iov != NULL (using the initalized
    cipher handle by sending data)

    In step 2, the cipher operation type (encryption or decryption) is reset
    to always decryption, because the local variable of enc is put into
    ctx->enc as ctx->user is still zero.

    The same applies when all send data is processed and ctx->used falls to
    zero followed by user space to send new data.

    This patch changes the behavior to only reset the cipher operation type
    (and the IV) if such configuration request is received.

    Signed-off-by: Stephan Mueller
    Signed-off-by: Herbert Xu

    Stephan Mueller
     

01 Dec, 2014

1 commit


28 Nov, 2014

1 commit

  • As most (all?) users of algif_skcipher are single-threaded and
    therefore always write before reading from an algif_skcipher
    socket, they never block and exercise that code-path.

    It turns out that code path doesn't even work because we never
    reload ctx->used after waking up so we never even see the new
    data and immediately return an error (and a loud WARN_ON).

    This patch fixes this by always reloading ctx->used.

    Reported-by: Stephan Mueller
    Signed-off-by: Herbert Xu
    Acked-by: Stephan Mueller

    Herbert Xu
     

25 Nov, 2014

1 commit

  • Commit e1bd95bf7c25 ("crypto: algif - zeroize IV buffer") and
    2a6af25befd0 ("crypto: algif - zeroize message digest buffer")
    added memzero_explicit() calls on buffers that are later on
    passed back to sock_kfree_s().

    This is a discussed follow-up that, instead, extends the sock
    API and adds sock_kzfree_s(), which internally uses kzfree()
    instead of kfree() for passing the buffers back to slab.

    Having sock_kzfree_s() allows to keep the changes more minimal
    by just having a drop-in replacement instead of adding
    memzero_explicit() calls everywhere before sock_kfree_s().

    In kzfree(), the compiler is not allowed to optimize the memset()
    away and thus there's no need for memzero_explicit(). Both,
    sock_kfree_s() and sock_kzfree_s() are wrappers for
    __sock_kfree_s() and call into kfree() resp. kzfree(); here,
    __sock_kfree_s() needs to be explicitly inlined as we want the
    compiler to optimize the call and condition away and thus it
    produces e.g. on x86_64 the _same_ assembler output for
    sock_kfree_s() before and after, and thus also allows for
    avoiding code duplication.

    Cc: David S. Miller
    Signed-off-by: Daniel Borkmann
    Signed-off-by: Herbert Xu

    Daniel Borkmann
     

24 Nov, 2014

1 commit


12 Nov, 2014

1 commit


04 Sep, 2014

1 commit

  • On archs with PAGE_SIZE >= 64 KiB the function skcipher_alloc_sgl()
    fails with -ENOMEM no matter what user space actually requested.
    This is caused by the fact sock_kmalloc call inside the function tried
    to allocate more memory than allowed by the default kernel socket buffer
    size (kernel param net.core.optmem_max).

    Signed-off-by: Ondrej Kozina
    Signed-off-by: Herbert Xu

    Ondrej Kozina
     

30 Nov, 2013

1 commit

  • Commit 35f9c09fe (tcp: tcp_sendpages() should call tcp_push() once)
    added an internal flag MSG_SENDPAGE_NOTLAST, similar to
    MSG_MORE.

    algif_hash, algif_skcipher, and udp used MSG_MORE from tcp_sendpages()
    and need to see the new flag as identical to MSG_MORE.

    This fixes sendfile() on AF_ALG.

    v3: also fix udp

    Cc: Tom Herbert
    Cc: Eric Dumazet
    Cc: David S. Miller
    Cc: # 3.4.x + 3.2.x
    Reported-and-tested-by: Shawn Landden
    Original-patch: Richard Weinberger
    Signed-off-by: Shawn Landden
    Signed-off-by: David S. Miller

    Shawn Landden
     

21 Nov, 2013

1 commit


10 Apr, 2013

1 commit


30 Nov, 2010

2 commits

  • As it is if user-space passes through a receive buffer that's not
    aligned to to the cipher block size, we'll end up encrypting or
    decrypting a partial block which causes a spurious EINVAL to be
    returned.

    This patch fixes this by moving the partial block test after the
    af_alg_make_sg call.

    Signed-off-by: Herbert Xu

    Herbert Xu
     
  • When sk_sndbuf is not a multiple of PAGE_SIZE, the limit tests
    in sendmsg fail as the limit variable becomes negative and we're
    using an unsigned comparison.

    The same thing can happen if sk_sndbuf is lowered after a sendmsg
    call.

    This patch fixes this by always taking the signed maximum of limit
    and 0 before we perform the comparison.

    It also rounds the value of sk_sndbuf down to a multiple of PAGE_SIZE
    so that we don't end up allocating a page only to use a small number
    of bytes in it because we're bound by sk_sndbuf.

    Signed-off-by: Herbert Xu

    Herbert Xu
     

28 Nov, 2010

1 commit


26 Nov, 2010

1 commit

  • This patch adds the af_alg plugin for symmetric key ciphers,
    corresponding to the ablkcipher kernel operation type.

    Keys can optionally be set through the setsockopt interface.

    Once a sendmsg call occurs without MSG_MORE no further writes
    may be made to the socket until all previous data has been read.

    IVs and and whether encryption/decryption is performed can be
    set through the setsockopt interface or as a control message
    to sendmsg.

    The interface is completely synchronous, all operations are
    carried out in recvmsg(2) and will complete prior to the system
    call returning.

    The splice(2) interface support reading the user-space data directly
    without copying (except that the Crypto API itself may copy the data
    if alignment is off).

    The recvmsg(2) interface supports directly writing to user-space
    without additional copying, i.e., the kernel crypto interface will
    receive the user-space address as its output SG list.

    Thakns to Miloslav Trmac for reviewing this and contributing
    fixes and improvements.

    Signed-off-by: Herbert Xu
    Acked-by: David S. Miller

    Herbert Xu