1. 28 Jul, 2017 3 commits
    • Xulin Sun's avatar
      crypto: caam - free qman_fq after kill_fq · 430f1338
      Xulin Sun authored
      kill_fq removes a complete frame queue, it needs to free the qman_fq
      in the last. Else kmemleak will report the below warning:
      
      unreferenced object 0xffff800073085c80 (size 128):
        comm "cryptomgr_test", pid 199, jiffies 4294937850 (age 67.840s)
        hex dump (first 32 bytes):
          00 00 00 00 00 00 00 00 a0 80 7e 00 00 80 ff ff
          00 00 00 00 00 00 00 00 04 00 04 00 5c 01 00 00
        backtrace:
          [<ffff8000001e5760>] create_object+0xf8/0x258
          [<ffff800000994e38>] kmemleak_alloc+0x58/0xa0
          [<ffff8000001d5f18>] kmem_cache_alloc_trace+0x2c8/0x358
          [<ffff8000007e8410>] create_caam_req_fq+0x40/0x170
          [<ffff8000007e870c>] caam_drv_ctx_update+0x54/0x248
          [<ffff8000007fca54>] aead_setkey+0x154/0x300
          [<ffff800000452120>] setkey+0x50/0xf0
          [<ffff80000045b144>] __test_aead+0x5ec/0x1028
          [<ffff80000045c28c>] test_aead+0x44/0xc8
          [<ffff80000045c368>] alg_test_aead+0x58/0xd0
          [<ffff80000045bdb4>] alg_test+0x14c/0x308
          [<ffff8000004588e8>] cryptomgr_test+0x50/0x58
          [<ffff8000000c3b2c>] kthread+0xdc/0xf0
          [<ffff800000083c00>] ret_from_fork+0x10/0x50
      
      And check where the function kill_fq() is called to remove
      the additional kfree to qman_fq and avoid re-calling the released qman_fq.
      Signed-off-by: default avatarXulin Sun <xulin.sun@windriver.com>
      Acked-by: default avatarHoria Geantă <horia.geanta@nxp.com>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      430f1338
    • Stephan Mueller's avatar
      crypto: algif_aead - overhaul memory management · d887c52d
      Stephan Mueller authored
      The updated memory management is described in the top part of the code.
      As one benefit of the changed memory management, the AIO and synchronous
      operation is now implemented in one common function. The AF_ALG
      operation uses the async kernel crypto API interface for each cipher
      operation. Thus, the only difference between the AIO and sync operation
      types visible from user space is:
      
      1. the callback function to be invoked when the asynchronous operation
         is completed
      
      2. whether to wait for the completion of the kernel crypto API operation
         or not
      
      The change includes the overhaul of the TX and RX SGL handling. The TX
      SGL holding the data sent from user space to the kernel is now dynamic
      similar to algif_skcipher. This dynamic nature allows a continuous
      operation of a thread sending data and a second thread receiving the
      data. These threads do not need to synchronize as the kernel processes
      as much data from the TX SGL to fill the RX SGL.
      
      The caller reading the data from the kernel defines the amount of data
      to be processed. Considering that the interface covers AEAD
      authenticating ciphers, the reader must provide the buffer in the
      correct size. Thus the reader defines the encryption size.
      Signed-off-by: default avatarStephan Mueller <smueller@chronox.de>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      d887c52d
    • Stephan Mueller's avatar
      crypto: algif_skcipher - overhaul memory management · e870456d
      Stephan Mueller authored
      The updated memory management is described in the top part of the code.
      As one benefit of the changed memory management, the AIO and synchronous
      operation is now implemented in one common function. The AF_ALG
      operation uses the async kernel crypto API interface for each cipher
      operation. Thus, the only difference between the AIO and sync operation
      types visible from user space is:
      
      1. the callback function to be invoked when the asynchronous operation
         is completed
      
      2. whether to wait for the completion of the kernel crypto API operation
         or not
      
      In addition, the code structure is adjusted to match the structure of
      algif_aead for easier code assessment.
      
      The user space interface changed slightly as follows: the old AIO
      operation returned zero upon success and < 0 in case of an error to user
      space. As all other AF_ALG interfaces (including the sync skcipher
      interface) returned the number of processed bytes upon success and < 0
      in case of an error, the new skcipher interface (regardless of AIO or
      sync) returns the number of processed bytes in case of success.
      Signed-off-by: default avatarStephan Mueller <smueller@chronox.de>
      Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
      e870456d
  2. 18 Jul, 2017 37 commits