linux-stable/drivers/crypto
Damian Muszynski 8e81cd58ae crypto: qat - resolve race condition during AER recovery
[ Upstream commit 7d42e09760 ]

During the PCI AER system's error recovery process, the kernel driver
may encounter a race condition with freeing the reset_data structure's
memory. If the device restart will take more than 10 seconds the function
scheduling that restart will exit due to a timeout, and the reset_data
structure will be freed. However, this data structure is used for
completion notification after the restart is completed, which leads
to a UAF bug.

This results in a KFENCE bug notice.

  BUG: KFENCE: use-after-free read in adf_device_reset_worker+0x38/0xa0 [intel_qat]
  Use-after-free read at 0x00000000bc56fddf (in kfence-#142):
  adf_device_reset_worker+0x38/0xa0 [intel_qat]
  process_one_work+0x173/0x340

To resolve this race condition, the memory associated to the container
of the work_struct is freed on the worker if the timeout expired,
otherwise on the function that schedules the worker.
The timeout detection can be done by checking if the caller is
still waiting for completion or not by using completion_done() function.

Fixes: d8cba25d2c ("crypto: qat - Intel(R) QAT driver framework")
Cc: <stable@vger.kernel.org>
Signed-off-by: Damian Muszynski <damian.muszynski@intel.com>
Reviewed-by: Giovanni Cabiddu <giovanni.cabiddu@intel.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-04-13 12:51:23 +02:00
..
amcc
axis
bcm
caam crypto: caam/jr - fix Chacha20 + Poly1305 self test failure 2023-11-20 10:30:12 +01:00
cavium
ccp crypto: ccp - fix memleak in ccp_init_dm_workarea 2024-01-25 14:34:23 -08:00
ccree
chelsio chtls: fix tp->rcv_tstamp initialization 2023-11-20 10:30:09 +01:00
hisilicon
inside-secure crypto: safexcel - Cleanup ring IRQ workqueues on load failure 2023-05-17 11:35:58 +02:00
marvell crypto: marvell/cesa - Fix type mismatch warning 2023-07-27 08:37:18 +02:00
mediatek
nx crypto: nx - fix build warnings when DEBUG_FS is not enabled 2023-07-27 08:37:18 +02:00
qat crypto: qat - resolve race condition during AER recovery 2024-04-13 12:51:23 +02:00
qce
rockchip
stm32 crypto: stm32/crc32 - fix parsing list of devices 2024-02-23 08:24:55 +01:00
sunxi-ss
ux500
virtio crypto: virtio - Wait for tasklet to complete on device remove 2024-01-25 14:34:24 -08:00
vmx
atmel-aes-regs.h
atmel-aes.c
atmel-authenc.h
atmel-ecc.c
atmel-i2c.c
atmel-i2c.h
atmel-sha-regs.h
atmel-sha.c
atmel-sha204a.c
atmel-tdes-regs.h
atmel-tdes.c
exynos-rng.c
geode-aes.c
geode-aes.h
hifn_795x.c
img-hash.c
ixp4xx_crypto.c
Kconfig
Makefile
mxs-dcp.c
n2_asm.S
n2_core.c
n2_core.h
omap-aes-gcm.c
omap-aes.c
omap-aes.h
omap-crypto.c
omap-crypto.h
omap-des.c
omap-sham.c
padlock-aes.c
padlock-sha.c
picoxcell_crypto.c
picoxcell_crypto_regs.h
qcom-rng.c
s5p-sss.c
sahara.c crypto: sahara - do not resize req->src when doing hash operations 2024-01-25 14:34:24 -08:00
talitos.c
talitos.h