android_kernel_xiaomi_sm7250/crypto
Daniel Jordan fca288ae3d crypto: pcrypt - Delay write to padata->info
[ 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: 5068c7a883 ("crypto: pcrypt - Add pcrypt crypto parallelization wrapper")
Reported-by: syzbot+b187b77c8474f9648fae@syzkaller.appspotmail.com
Signed-off-by: Daniel Jordan <daniel.m.jordan@oracle.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2021-11-26 11:36:11 +01:00
..
asymmetric_keys
async_tx
842.c
ablkcipher.c
acompress.c
aead.c
aegis128.c
aegis128l.c
aegis256.c
aegis.h
aes_generic.c
aes_ti.c
af_alg.c crypto: af_alg - avoid undefined behavior accessing salg_name 2020-12-30 11:25:48 +01:00
ahash.c
akcipher.c
algapi.c
algboss.c crypto: algboss - don't wait during notifier callback 2020-06-25 15:33:09 +02:00
algif_aead.c crypto: algif_aead - Do not set MAY_BACKLOG on the async path 2020-10-29 09:54:59 +01:00
algif_hash.c crypto: af_alg - fix use-after-free in af_alg_accept() due to bh_lock_sock() 2020-07-09 09:37:10 +02:00
algif_rng.c
algif_skcipher.c crypto: algif_skcipher - EBUSY on aio should be an error 2020-10-29 09:55:01 +01:00
ansi_cprng.c
anubis.c
api.c crypto: api - check for ERR pointers in crypto_destroy_tfm() 2021-05-22 10:59:14 +02:00
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
chacha20_generic.c
chacha20poly1305.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.c
crypto_wq.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 crypto: ecdh_helper - Ensure 'len >= secret.len' in decode_key() 2021-03-04 09:39:41 +01:00
ecdh.c crypto: ecdh - avoid buffer overflow in ecdh_set_secret() 2021-01-12 20:10:20 +01:00
echainiv.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.c
Makefile
mcryptd.c
md4.c
md5.c
memneq.c
michael_mic.c
morus640.c
morus1280.c
pcbc.c
pcrypt.c crypto: pcrypt - Delay write to padata->info 2021-11-26 11:36:11 +01:00
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 crypto: shash - avoid comparing pointers to exported functions under CFI 2021-07-20 16:15:44 +02:00
simd.c
skcipher.c
sm3_generic.c
sm4_generic.c
tcrypt.c crypto: tcrypt - avoid signed overflow in byte count 2021-03-07 12:18:58 +01:00
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
zstd.c