af51aa2b85
[ Upstream commit 68b6dea802cea0dbdd8bd7ccc60716b5a32a5d8a ]
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 delaying the write of padata->info until after
the inner crypto request's return code is checked. This prevents the
use-after-free by not touching the crypto request's memory after the
next-inner crypto request is made, and stops padata->info from being
overwritten.
Fixes:
|
||
---|---|---|
.. | ||
asymmetric_keys | ||
async_tx | ||
842.c | ||
ablkcipher.c | ||
acompress.c | ||
adiantum.c | ||
aead.c | ||
aegis128-core.c | ||
aegis128-neon-inner.c | ||
aegis128-neon.c | ||
aegis.h | ||
aes_generic.c | ||
aes_ti.c | ||
af_alg.c | ||
ahash.c | ||
akcipher.c | ||
algapi.c | ||
algboss.c | ||
algif_aead.c | ||
algif_hash.c | ||
algif_rng.c | ||
algif_skcipher.c | ||
ansi_cprng.c | ||
anubis.c | ||
api.c | ||
arc4.c | ||
authenc.c | ||
authencesn.c | ||
blkcipher.c | ||
blowfish_common.c | ||
blowfish_generic.c | ||
camellia_generic.c | ||
cast5_generic.c | ||
cast6_generic.c | ||
cast_common.c | ||
cbc.c | ||
ccm.c | ||
cfb.c | ||
chacha20poly1305.c | ||
chacha_generic.c | ||
cipher.c | ||
cmac.c | ||
compress.c | ||
crc32_generic.c | ||
crc32c_generic.c | ||
crct10dif_common.c | ||
crct10dif_generic.c | ||
cryptd.c | ||
crypto_engine.c | ||
crypto_null.c | ||
crypto_user_base.c | ||
crypto_user_stat.c | ||
ctr.c | ||
cts.c | ||
deflate.c | ||
des_generic.c | ||
dh_helper.c | ||
dh.c | ||
drbg.c | ||
ecb.c | ||
ecc_curve_defs.h | ||
ecc.c | ||
ecc.h | ||
ecdh_helper.c | ||
ecdh.c | ||
echainiv.c | ||
ecrdsa_defs.h | ||
ecrdsa_params.asn1 | ||
ecrdsa_pub_key.asn1 | ||
ecrdsa.c | ||
essiv.c | ||
fcrypt.c | ||
fips.c | ||
gcm.c | ||
gf128mul.c | ||
ghash-generic.c | ||
hash_info.c | ||
hmac.c | ||
internal.h | ||
jitterentropy-kcapi.c | ||
jitterentropy.c | ||
Kconfig | ||
keywrap.c | ||
khazad.c | ||
kpp.c | ||
lrw.c | ||
lz4.c | ||
lz4hc.c | ||
lzo-rle.c | ||
lzo.c | ||
Makefile | ||
md4.c | ||
md5.c | ||
memneq.c | ||
michael_mic.c | ||
nhpoly1305.c | ||
ofb.c | ||
pcbc.c | ||
pcrypt.c | ||
poly1305_generic.c | ||
proc.c | ||
ripemd.h | ||
rmd128.c | ||
rmd160.c | ||
rmd256.c | ||
rmd320.c | ||
rng.c | ||
rsa_helper.c | ||
rsa-pkcs1pad.c | ||
rsa.c | ||
rsaprivkey.asn1 | ||
rsapubkey.asn1 | ||
salsa20_generic.c | ||
scatterwalk.c | ||
scompress.c | ||
seed.c | ||
seqiv.c | ||
serpent_generic.c | ||
sha1_generic.c | ||
sha3_generic.c | ||
sha256_generic.c | ||
sha512_generic.c | ||
shash.c | ||
simd.c | ||
skcipher.c | ||
sm3_generic.c | ||
sm4_generic.c | ||
streebog_generic.c | ||
tcrypt.c | ||
tcrypt.h | ||
tea.c | ||
testmgr.c | ||
testmgr.h | ||
tgr192.c | ||
twofish_common.c | ||
twofish_generic.c | ||
vmac.c | ||
wp512.c | ||
xcbc.c | ||
xor.c | ||
xts.c | ||
xxhash_generic.c | ||
zstd.c |