• Daniel Jordan's avatar
    crypto: pcrypt - Delay write to padata->info · af51aa2b
    Daniel Jordan authored
    [ Upstream commit 68b6dea8 ]
    
    These three events can race when pcrypt is used multiple times in a
    template ("pcrypt(pcrypt(...))"):
    
      1.  [taskA] The caller makes the crypto request via crypto_aead_encrypt()
      2.  [kworkerB] padata serializes the inner pcrypt request
      3.  [kworkerC] padata serializes the outer pcrypt request
    
    3 might finish before the call to crypto_aead_encrypt() returns in 1,
    resulting in two possible issues.
    
    First, a use-after-free of the crypto request's memory when, for
    example, taskA writes to the outer pcrypt request's padata->info in
    pcrypt_aead_enc() after kworkerC completes the request.
    
    Second, the outer pcrypt request overwrites the inner pcrypt request's
    return code with -EINPROGRESS, making a successful request appear to
    fail.  For instance, kworkerB writes the outer pcrypt request's
    padata->info in pcrypt_aead_done() and then taskA overwrites it
    in pcrypt_aead_enc().
    
    Avoid both situations by de...
    af51aa2b
pcrypt.c 9.73 KB