Patch "scsi: megaraid_sas: Fix concurrent access to ISR between IRQ polling and real interrupt" has been added to the 5.14-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    scsi: megaraid_sas: Fix concurrent access to ISR between IRQ polling and real interrupt

to the 5.14-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     scsi-megaraid_sas-fix-concurrent-access-to-isr-betwe.patch
and it can be found in the queue-5.14 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 36b60270c789f3c265b71c2cad09307d621f1740
Author: Sumit Saxena <sumit.saxena@xxxxxxxxxxxx>
Date:   Wed Sep 29 18:10:20 2021 +0530

    scsi: megaraid_sas: Fix concurrent access to ISR between IRQ polling and real interrupt
    
    [ Upstream commit e7dcc514a49e74051b869697d5ab0370f6301d57 ]
    
    IRQ polling thread calls ISR after enable_irq() to handle any missed I/O
    completion. The atomic flag "in_used" was added to have the synchronization
    between the IRQ polling thread and the interrupt context. There is a bug
    around it leading to a race condition.
    
    Below is the sequence:
    
     - IRQ polling thread accesses ISR, fetches the reply descriptor.
    
     - Real interrupt arrives and pre-empts polling thread (enable_irq() is
       already called).
    
     - Interrupt context picks the same reply descriptor as fetched by polling
       thread, processes it, and exits.
    
     - Polling thread resumes and processes the descriptor which is already
       processed by interrupt thread leads to kernel crash.
    
    Setting the "in_used" flag before fetching the reply descriptor ensures
    synchronized access to ISR.
    
    Link: https://www.spinics.net/lists/linux-scsi/msg159440.html
    Link: https://lore.kernel.org/r/20210929124022.24605-2-sumit.saxena@xxxxxxxxxxxx
    Fixes: 9bedd36e9146 ("scsi: megaraid_sas: Handle missing interrupts while re-enabling IRQs")
    Signed-off-by: Sumit Saxena <sumit.saxena@xxxxxxxxxxxx>
    Signed-off-by: Martin K. Petersen <martin.petersen@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index 06399c026a8d5..1ff2198583a71 100644
--- a/drivers/scsi/megaraid/megaraid_sas_fusion.c
+++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c
@@ -3530,6 +3530,9 @@ complete_cmd_fusion(struct megasas_instance *instance, u32 MSIxIndex,
 	if (atomic_read(&instance->adprecovery) == MEGASAS_HW_CRITICAL_ERROR)
 		return IRQ_HANDLED;
 
+	if (irq_context && !atomic_add_unless(&irq_context->in_used, 1, 1))
+		return 0;
+
 	desc = fusion->reply_frames_desc[MSIxIndex] +
 				fusion->last_reply_idx[MSIxIndex];
 
@@ -3540,11 +3543,11 @@ complete_cmd_fusion(struct megasas_instance *instance, u32 MSIxIndex,
 	reply_descript_type = reply_desc->ReplyFlags &
 		MPI2_RPY_DESCRIPT_FLAGS_TYPE_MASK;
 
-	if (reply_descript_type == MPI2_RPY_DESCRIPT_FLAGS_UNUSED)
+	if (reply_descript_type == MPI2_RPY_DESCRIPT_FLAGS_UNUSED) {
+		if (irq_context)
+			atomic_dec(&irq_context->in_used);
 		return IRQ_NONE;
-
-	if (irq_context && !atomic_add_unless(&irq_context->in_used, 1, 1))
-		return 0;
+	}
 
 	num_completed = 0;
 



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux