Skip to content

Commit 15ba02f

Browse files
gcabidduKelsey Skunberg
authored andcommitted
crypto: qat - use proper type for vf_mask
BugLink: https://bugs.launchpad.net/bugs/1946024 [ Upstream commit 462354d ] Replace vf_mask type with unsigned long to avoid a stack-out-of-bound. This is to fix the following warning reported by KASAN the first time adf_msix_isr_ae() gets called. [ 692.091987] BUG: KASAN: stack-out-of-bounds in find_first_bit+0x28/0x50 [ 692.092017] Read of size 8 at addr ffff88afdf789e60 by task swapper/32/0 [ 692.092076] Call Trace: [ 692.092089] <IRQ> [ 692.092101] dump_stack+0x9c/0xcf [ 692.092132] print_address_description.constprop.0+0x18/0x130 [ 692.092164] ? find_first_bit+0x28/0x50 [ 692.092185] kasan_report.cold+0x7f/0x111 [ 692.092213] ? static_obj+0x10/0x80 [ 692.092234] ? find_first_bit+0x28/0x50 [ 692.092262] find_first_bit+0x28/0x50 [ 692.092288] adf_msix_isr_ae+0x16e/0x230 [intel_qat] Fixes: ed8ccae ("crypto: qat - Add support for SRIOV") Signed-off-by: Giovanni Cabiddu <[email protected]> Reviewed-by: Marco Chiappero <[email protected]> Reviewed-by: Fiona Trahe <[email protected]> Signed-off-by: Herbert Xu <[email protected]> Signed-off-by: Sasha Levin <[email protected]> Signed-off-by: Kamal Mostafa <[email protected]> Signed-off-by: Kelsey Skunberg <[email protected]>
1 parent 3c1efe2 commit 15ba02f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

drivers/crypto/qat/qat_common/adf_isr.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@
5959
#include "adf_transport_access_macros.h"
6060
#include "adf_transport_internal.h"
6161

62+
#define ADF_MAX_NUM_VFS 32
63+
6264
static int adf_enable_msix(struct adf_accel_dev *accel_dev)
6365
{
6466
struct adf_accel_pci *pci_dev_info = &accel_dev->accel_pci_dev;
@@ -111,7 +113,7 @@ static irqreturn_t adf_msix_isr_ae(int irq, void *dev_ptr)
111113
struct adf_bar *pmisc =
112114
&GET_BARS(accel_dev)[hw_data->get_misc_bar_id(hw_data)];
113115
void __iomem *pmisc_bar_addr = pmisc->virt_addr;
114-
u32 vf_mask;
116+
unsigned long vf_mask;
115117

116118
/* Get the interrupt sources triggered by VFs */
117119
vf_mask = ((ADF_CSR_RD(pmisc_bar_addr, ADF_ERRSOU5) &
@@ -132,8 +134,7 @@ static irqreturn_t adf_msix_isr_ae(int irq, void *dev_ptr)
132134
* unless the VF is malicious and is attempting to
133135
* flood the host OS with VF2PF interrupts.
134136
*/
135-
for_each_set_bit(i, (const unsigned long *)&vf_mask,
136-
(sizeof(vf_mask) * BITS_PER_BYTE)) {
137+
for_each_set_bit(i, &vf_mask, ADF_MAX_NUM_VFS) {
137138
vf_info = accel_dev->pf.vf_info + i;
138139

139140
if (!__ratelimit(&vf_info->vf2pf_ratelimit)) {

0 commit comments

Comments
 (0)