Skip to contentSkip to conversation

crypto: qat - Endian bug in interrupt handler

PATCH In review Dan Carpenter 1 participant 2 messages Jun 24, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 crypto: qat - Endian bug in interrupt handler

The "vf_mask" as a u32 but we were casting it to unsigned long when we do the for_each_set_bit() loop. The problem is that is an out of bounds read on big endian 64 bit systems.

Fixes ed8ccaef52fa ("crypto: qat - Add support for SRIOV")

---
Not tested. I don't know if 64bit big endian support matters...

 drivers/crypto/qat/qat_common/adf_isr.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/crypto/qat/qat_common/adf_isr.c +2 -3
index cd1cdf5305bc..50661f0a6ed4 100644
@@ -111,7 +111,7 @@ static irqreturn_t adf_msix_isr_ae(int irq, void *dev_ptr)
 		struct adf_bar *pmisc  			&GET_BARS(accel_dev)[hw_data->get_misc_bar_id(hw_data)];
 		void __iomem *pmisc_bar_addr = pmisc->virt_addr;
-		u32 vf_mask;
+		unsigned long vf_mask;
 
 		/* Get the interrupt sources triggered by VFs */
 		vf_mask = ((ADF_CSR_RD(pmisc_bar_addr, ADF_ERRSOU5) &
@@ -132,8 +132,7 @@ static irqreturn_t adf_msix_isr_ae(int irq, void *dev_ptr)
 			 * unless the VF is malicious and is attempting to
 			 * flood the host OS with VF2PF interrupts.
 			 */
-			for_each_set_bit(i, (const unsigned long *)&vf_mask,
-					 (sizeof(vf_mask) * BITS_PER_BYTE)) {
+			for_each_set_bit(i, &vf_mask, 32) {
 				vf_info = accel_dev->pf.vf_info + i;
 
 				if (!__ratelimit(&vf_info->vf2pf_ratelimit)) {
Signature · 1 line
2.20.1
#1 lore raw

Never mind. Please ignore this patch.

This is Intel hardware so it's little endian. There are a bunch of other test_bit() casts which would be problematic so this wouldn't really fix anything anyway.

regards,
dan carpenter