1. 12 1月, 2018 1 次提交
  2. 22 12月, 2017 1 次提交
  3. 11 12月, 2017 1 次提交
  4. 29 11月, 2017 1 次提交
  5. 28 11月, 2017 1 次提交
  6. 24 11月, 2017 1 次提交
    • S
      crypto: af_alg - remove locking in async callback · 7d2c3f54
      Stephan Mueller 提交于
      The code paths protected by the socket-lock do not use or modify the
      socket in a non-atomic fashion. The actions pertaining the socket do not
      even need to be handled as an atomic operation. Thus, the socket-lock
      can be safely ignored.
      
      This fixes a bug regarding scheduling in atomic as the callback function
      may be invoked in interrupt context.
      
      In addition, the sock_hold is moved before the AIO encrypt/decrypt
      operation to ensure that the socket is always present. This avoids a
      tiny race window where the socket is unprotected and yet used by the AIO
      operation.
      
      Finally, the release of resources for a crypto operation is moved into a
      common function of af_alg_free_resources.
      
      Cc: <stable@vger.kernel.org>
      Fixes: e870456d ("crypto: algif_skcipher - overhaul memory management")
      Fixes: d887c52d ("crypto: algif_aead - overhaul memory management")
      Reported-by: NRomain Izard <romain.izard.pro@gmail.com>
      Signed-off-by: NStephan Mueller <smueller@chronox.de>
      Tested-by: NRomain Izard <romain.izard.pro@gmail.com>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      7d2c3f54
  7. 03 11月, 2017 1 次提交
  8. 20 9月, 2017 1 次提交
  9. 22 8月, 2017 1 次提交
  10. 09 8月, 2017 1 次提交
    • S
      crypto: af_alg - consolidation of duplicate code · 2d97591e
      Stephan Mueller 提交于
      Consolidate following data structures:
      
      skcipher_async_req, aead_async_req -> af_alg_async_req
      skcipher_rsgl, aead_rsql -> af_alg_rsgl
      skcipher_tsgl, aead_tsql -> af_alg_tsgl
      skcipher_ctx, aead_ctx -> af_alg_ctx
      
      Consolidate following functions:
      
      skcipher_sndbuf, aead_sndbuf -> af_alg_sndbuf
      skcipher_writable, aead_writable -> af_alg_writable
      skcipher_rcvbuf, aead_rcvbuf -> af_alg_rcvbuf
      skcipher_readable, aead_readable -> af_alg_readable
      aead_alloc_tsgl, skcipher_alloc_tsgl -> af_alg_alloc_tsgl
      aead_count_tsgl, skcipher_count_tsgl -> af_alg_count_tsgl
      aead_pull_tsgl, skcipher_pull_tsgl -> af_alg_pull_tsgl
      aead_free_areq_sgls, skcipher_free_areq_sgls -> af_alg_free_areq_sgls
      aead_wait_for_wmem, skcipher_wait_for_wmem -> af_alg_wait_for_wmem
      aead_wmem_wakeup, skcipher_wmem_wakeup -> af_alg_wmem_wakeup
      aead_wait_for_data, skcipher_wait_for_data -> af_alg_wait_for_data
      aead_data_wakeup, skcipher_data_wakeup -> af_alg_data_wakeup
      aead_sendmsg, skcipher_sendmsg -> af_alg_sendmsg
      aead_sendpage, skcipher_sendpage -> af_alg_sendpage
      aead_async_cb, skcipher_async_cb -> af_alg_async_cb
      aead_poll, skcipher_poll -> af_alg_poll
      
      Split out the following common code from recvmsg:
      
      af_alg_alloc_areq: allocation of the request data structure for the
      cipher operation
      
      af_alg_get_rsgl: creation of the RX SGL anchored in the request data
      structure
      
      The following changes to the implementation without affecting the
      functionality have been applied to synchronize slightly different code
      bases in algif_skcipher and algif_aead:
      
      The wakeup in af_alg_wait_for_data is triggered when either more data
      is received or the indicator that more data is to be expected is
      released. The first is triggered by user space, the second is
      triggered by the kernel upon finishing the processing of data
      (i.e. the kernel is ready for more).
      
      af_alg_sendmsg uses size_t in min_t calculation for obtaining len.
      Return code determination is consistent with algif_skcipher. The
      scope of the variable i is reduced to match algif_aead. The type of the
      variable i is switched from int to unsigned int to match algif_aead.
      
      af_alg_sendpage does not contain the superfluous err = 0 from
      aead_sendpage.
      
      af_alg_async_cb requires to store the number of output bytes in
      areq->outlen before the AIO callback is triggered.
      
      The POLLIN / POLLRDNORM is now set when either not more data is given or
      the kernel is supplied with data. This is consistent to the wakeup from
      sleep when the kernel waits for data.
      
      The request data structure is extended by the field last_rsgl which
      points to the last RX SGL list entry. This shall help recvmsg
      implementation to chain the RX SGL to other SG(L)s if needed. It is
      currently used by algif_aead which chains the tag SGL to the RX SGL
      during decryption.
      Signed-off-by: NStephan Mueller <smueller@chronox.de>
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      2d97591e
  11. 12 7月, 2017 1 次提交
  12. 10 4月, 2017 1 次提交
  13. 10 3月, 2017 1 次提交
    • D
      net: Work around lockdep limitation in sockets that use sockets · cdfbabfb
      David Howells 提交于
      Lockdep issues a circular dependency warning when AFS issues an operation
      through AF_RXRPC from a context in which the VFS/VM holds the mmap_sem.
      
      The theory lockdep comes up with is as follows:
      
       (1) If the pagefault handler decides it needs to read pages from AFS, it
           calls AFS with mmap_sem held and AFS begins an AF_RXRPC call, but
           creating a call requires the socket lock:
      
      	mmap_sem must be taken before sk_lock-AF_RXRPC
      
       (2) afs_open_socket() opens an AF_RXRPC socket and binds it.  rxrpc_bind()
           binds the underlying UDP socket whilst holding its socket lock.
           inet_bind() takes its own socket lock:
      
      	sk_lock-AF_RXRPC must be taken before sk_lock-AF_INET
      
       (3) Reading from a TCP socket into a userspace buffer might cause a fault
           and thus cause the kernel to take the mmap_sem, but the TCP socket is
           locked whilst doing this:
      
      	sk_lock-AF_INET must be taken before mmap_sem
      
      However, lockdep's theory is wrong in this instance because it deals only
      with lock classes and not individual locks.  The AF_INET lock in (2) isn't
      really equivalent to the AF_INET lock in (3) as the former deals with a
      socket entirely internal to the kernel that never sees userspace.  This is
      a limitation in the design of lockdep.
      
      Fix the general case by:
      
       (1) Double up all the locking keys used in sockets so that one set are
           used if the socket is created by userspace and the other set is used
           if the socket is created by the kernel.
      
       (2) Store the kern parameter passed to sk_alloc() in a variable in the
           sock struct (sk_kern_sock).  This informs sock_lock_init(),
           sock_init_data() and sk_clone_lock() as to the lock keys to be used.
      
           Note that the child created by sk_clone_lock() inherits the parent's
           kern setting.
      
       (3) Add a 'kern' parameter to ->accept() that is analogous to the one
           passed in to ->create() that distinguishes whether kernel_accept() or
           sys_accept4() was the caller and can be passed to sk_alloc().
      
           Note that a lot of accept functions merely dequeue an already
           allocated socket.  I haven't touched these as the new socket already
           exists before we get the parameter.
      
           Note also that there are a couple of places where I've made the accepted
           socket unconditionally kernel-based:
      
      	irda_accept()
      	rds_rcp_accept_one()
      	tcp_accept_from_sock()
      
           because they follow a sock_create_kern() and accept off of that.
      
      Whilst creating this, I noticed that lustre and ocfs don't create sockets
      through sock_create_kern() and thus they aren't marked as for-kernel,
      though they appear to be internal.  I wonder if these should do that so
      that they use the new set of lock keys.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      cdfbabfb
  14. 18 1月, 2016 5 次提交
  15. 22 6月, 2015 1 次提交
    • H
      crypto: af_alg - Forbid the use internal algorithms · 15539de5
      Herbert Xu 提交于
      The bit CRYPTO_ALG_INTERNAL was added to stop af_alg from accessing
      internal algorithms.  However, af_alg itself was never modified to
      actually stop that bit from being used by the user.  Therefore the
      user could always override it by specifying the relevant bit in the
      type and/or mask.
      
      This patch silently discards the bit in both type and mask.
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      15539de5
  16. 11 5月, 2015 1 次提交
  17. 02 4月, 2015 1 次提交
  18. 24 3月, 2015 1 次提交
  19. 12 2月, 2015 1 次提交
  20. 11 2月, 2015 2 次提交
  21. 04 2月, 2015 1 次提交
    • A
      crypto: switch af_alg_make_sg() to iov_iter · 1d10eb2f
      Al Viro 提交于
      With that, all ->sendmsg() instances are converted to iov_iter primitives
      and are agnostic wrt the kind of iov_iter they are working with.
      So's the last remaining ->recvmsg() instance that wasn't kind-agnostic yet.
      All ->sendmsg() and ->recvmsg() advance ->msg_iter by the amount actually
      copied and none of them modifies the underlying iovec, etc.
      
      Cc: linux-crypto@vger.kernel.org
      Signed-off-by: NAl Viro <viro@zeniv.linux.org.uk>
      1d10eb2f
  22. 26 12月, 2014 1 次提交
  23. 22 12月, 2014 3 次提交
  24. 11 12月, 2014 1 次提交
  25. 05 12月, 2014 1 次提交
  26. 31 7月, 2014 1 次提交
  27. 15 11月, 2013 1 次提交
  28. 27 7月, 2011 1 次提交
  29. 21 12月, 2010 1 次提交
  30. 08 12月, 2010 1 次提交
  31. 19 11月, 2010 1 次提交
    • H
      crypto: af_alg - User-space interface for Crypto API · 03c8efc1
      Herbert Xu 提交于
      This patch creates the backbone of the user-space interface for
      the Crypto API, through a new socket family AF_ALG.
      
      Each session corresponds to one or more connections obtained from
      that socket.  The number depends on the number of inputs/outputs
      of that particular type of operation.  For most types there will
      be a s ingle connection/file descriptor that is used for both input
      and output.  AEAD is one of the few that require two inputs.
      
      Each algorithm type will provide its own implementation that plugs
      into af_alg.  They're keyed using a string such as "skcipher" or
      "hash".
      
      IOW this patch only contains the boring bits that is required
      to hold everything together.
      
      Thakns to Miloslav Trmac for reviewing this and contributing
      fixes and improvements.
      Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
      Acked-by: NDavid S. Miller <davem@davemloft.net>
      Tested-by: NMartin Willi <martin@strongswan.org>
      03c8efc1