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 crypto: crypto4xx - Call dma_unmap_page when done 2023-03-11 16:43:42 +01:00
axis
bcm crypto: bcm - Rename struct device_private to bcm_device_private 2021-03-04 10:26:21 +01:00
caam crypto: caam/jr - fix Chacha20 + Poly1305 self test failure 2023-11-20 10:30:12 +01:00
cavium crypto: cavium - prevent integer overflow loading firmware 2022-10-26 13:22:46 +02:00
ccp crypto: ccp - fix memleak in ccp_init_dm_workarea 2024-01-25 14:34:23 -08:00
ccree crypto: ccree - Make cc_debugfs_global_fini() available for module init function 2023-01-18 11:41:18 +01:00
chelsio chtls: fix tp->rcv_tstamp initialization 2023-11-20 10:30:09 +01:00
hisilicon crypto: hisilicon - Kunpeng916 crypto driver don't sleep when in softirq 2022-08-25 11:17:42 +02:00
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 cypto: mediatek - fix leaks in mtk_desc_ring_alloc 2020-10-29 09:57:33 +01:00
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 crypto: qce - fix uaf on qce_ahash_register_one 2022-01-27 09:19:30 +01:00
rockchip
stm32 crypto: stm32/crc32 - fix parsing list of devices 2024-02-23 08:24:55 +01:00
sunxi-ss crypto: sun4i-ss - initialize need_fallback 2021-03-04 10:26:45 +01:00
ux500 crypto: ux500 - Fix error return code in hash_hw_final() 2021-07-14 16:53:20 +02:00
virtio crypto: virtio - Wait for tasklet to complete on device remove 2024-01-25 14:34:24 -08:00
vmx crypto: vmx - add missing dependencies 2022-04-15 14:18:05 +02:00
Kconfig crypto: atmel-i2c - select CONFIG_BITREVERSE 2020-12-30 11:51:24 +01:00
Makefile
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 crypto: img-hash - Fix variable dereferenced before check 'hdev->req' 2023-01-18 11:41:21 +01:00
ixp4xx_crypto.c crypto: ixp4xx - dma_unmap the correct address 2021-07-14 16:53:20 +02:00
mxs-dcp.c crypto: mxs-dcp - Fix scatterlist processing 2022-04-15 14:18:04 +02:00
n2_asm.S
n2_core.c crypto: n2 - add missing hash statesize 2023-01-18 11:41:50 +01:00
n2_core.h
omap-aes-gcm.c
omap-aes.c crypto: omap-aes - Fix broken pm_runtime_and_get() usage 2022-01-27 09:19:49 +01:00
omap-aes.h
omap-crypto.c
omap-crypto.h
omap-des.c
omap-sham.c crypto: omap-sham - Use pm_runtime_resume_and_get() in omap_sham_probe() 2023-01-18 11:41:20 +01:00
padlock-aes.c
padlock-sha.c
picoxcell_crypto.c crypto: picoxcell - Fix potential race condition bug 2020-10-29 09:57:31 +01:00
picoxcell_crypto_regs.h
qcom-rng.c crypto: qcom-rng - fix infinite loop on requests not multiple of WORD_SZ 2022-05-25 09:14:34 +02:00
s5p-sss.c crypto: s5p-sss - Add error handling in s5p_aes_probe() 2021-11-17 09:48:17 +01:00
sahara.c crypto: sahara - do not resize req->src when doing hash operations 2024-01-25 14:34:24 -08:00
talitos.c crypto: talitos - Work around SEC6 ERRATA (AES-CTR mode data size error) 2021-03-04 10:26:23 +01:00
talitos.h crypto: talitos - Work around SEC6 ERRATA (AES-CTR mode data size error) 2021-03-04 10:26:23 +01:00