linux-stable/drivers/crypto
Damian Muszynski bb279ead42 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-03 15:32:05 +02:00
..
allwinner crypto: sun8i-ce - Fix use after free in unprepare 2024-02-28 17:12:11 +08:00
amcc crypto: crypto4xx - Remove cfb and ofb 2023-12-08 11:59:45 +08:00
amlogic crypto: amlogic - Use helper to set reqsize 2023-12-29 11:25:55 +08:00
aspeed crypto: aspeed - Remove cfb and ofb 2023-12-08 11:59:45 +08:00
axis crypto: artpec6 - Use helper to set reqsize 2023-12-29 11:25:55 +08:00
bcm crypto: bcm - Remove ofb 2023-12-08 11:59:46 +08:00
caam crypto: caam - fix asynchronous hash 2024-01-26 16:35:55 +08:00
cavium crypto: nitrox - Remove cfb 2023-12-08 11:59:46 +08:00
ccp crypto: ccp - Avoid discarding errors in psp_send_platform_access_msg() 2024-03-26 18:17:11 -04:00
ccree crypto: ccree - Remove ofb 2023-12-08 11:59:46 +08:00
chelsio crypto: chelsio - stop using crypto_ahash::init 2023-10-27 18:04:29 +08:00
gemini crypto: sl3516 - Use helper to set reqsize 2023-12-29 11:25:55 +08:00
hisilicon This update includes the following changes: 2024-01-10 12:23:43 -08:00
inside-secure crypto: safexcel - Remove cfb and ofb 2023-12-08 11:59:46 +08:00
intel crypto: qat - resolve race condition during AER recovery 2024-04-03 15:32:05 +02:00
marvell crypto: octeontx2 - support setting ctx ilen for inline CPT LF 2023-12-29 11:25:55 +08:00
nx crypto: nx - fix build warnings when DEBUG_FS is not enabled 2023-05-24 18:12:33 +08:00
qce crypto: qce - Convert to platform remove callback returning void 2023-10-27 18:04:26 +08:00
rockchip crypto: rk3288 - Fix use after free in unprepare 2024-03-01 18:33:29 +08:00
starfive crypto: starfive - Fix dev_err_probe return error 2023-12-15 17:52:53 +08:00
stm32 crypto: stm32/cryp - Use helper to set reqsize 2023-12-29 11:25:55 +08:00
virtio crypto: virtio/akcipher - Fix stack overflow on memcpy 2024-02-09 12:55:53 +08:00
vmx crypto: vmx - Improved AES/XTS performance of 6-way unrolling for ppc 2023-09-15 18:29:45 +08:00
xilinx crypto: xilinx - call finalize with bh disabled 2024-03-26 18:17:04 -04:00
atmel-aes-regs.h
atmel-aes.c crypto: atmel - Remove cfb and ofb 2023-12-08 11:59:45 +08:00
atmel-authenc.h
atmel-ecc.c crypto: drivers - Explicitly include correct DT includes 2023-08-23 11:04:23 +08:00
atmel-i2c.c This update includes the following changes: 2023-02-21 18:10:50 -08:00
atmel-i2c.h This update includes the following changes: 2023-02-21 18:10:50 -08:00
atmel-sha-regs.h
atmel-sha.c crypto: atmel - remove unnecessary alignmask for ahashes 2023-10-27 18:04:28 +08:00
atmel-sha204a.c crypto: atmel - Switch i2c drivers back to use .probe() 2023-06-02 18:21:32 +08:00
atmel-tdes-regs.h
atmel-tdes.c crypto: atmel - Remove cfb and ofb 2023-12-08 11:59:45 +08:00
exynos-rng.c crypto: exynos-rng - Convert to platform remove callback returning void 2023-10-27 18:04:26 +08:00
geode-aes.c
geode-aes.h
hifn_795x.c crypto: hifn_795x - Remove cfb and ofb 2023-12-08 11:59:46 +08:00
img-hash.c crypto: img-hash - Convert to platform remove callback returning void 2023-10-27 18:04:26 +08:00
Kconfig crypto: sahara - add support for crypto_engine 2023-12-29 11:25:56 +08:00
Makefile crypto: starfive - Add crypto engine support 2023-05-19 16:46:22 +08:00
mxs-dcp.c crypto: mxs-dcp - remove unnecessary alignmask for ahashes 2023-10-27 18:04:28 +08:00
n2_asm.S
n2_core.c crypto: n2 - Remove cfb 2023-12-08 11:59:46 +08:00
n2_core.h
omap-aes-gcm.c crypto: omap - Use new crypto_engine_op interface 2023-08-18 17:01:11 +08:00
omap-aes.c crypto: omap-aes - Convert to platform remove callback returning void 2023-10-27 18:04:26 +08:00
omap-aes.h crypto: omap - Use new crypto_engine_op interface 2023-08-18 17:01:11 +08:00
omap-crypto.c
omap-crypto.h
omap-des.c crypto: omap-des - Convert to platform remove callback returning void 2023-10-27 18:04:26 +08:00
omap-sham.c crypto: omap-sham - stop setting alignmask for ahashes 2023-10-27 18:04:29 +08:00
padlock-aes.c
padlock-sha.c
qcom-rng.c crypto: qcom-rng - Convert to platform remove callback returning void 2023-10-27 18:04:26 +08:00
s5p-sss.c crypto: s5p-sss - remove unnecessary alignmask for ahashes 2023-10-27 18:04:28 +08:00
sa2ul.c crypto: sa2ul - Return crypto_aead_setkey to transfer the error 2023-12-01 18:03:26 +08:00
sa2ul.h crypto: sa2ul - change unsafe data size limit to 255 bytes 2023-05-19 16:45:43 +08:00
sahara.c crypto: sahara - add support for crypto_engine 2023-12-29 11:25:56 +08:00
talitos.c crypto: talitos - stop using crypto_ahash::init 2023-10-27 18:04:29 +08:00
talitos.h