All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] arcmsr: Fix possible sleep-in-atomic bugs in arcmsr_queue_command
@ 2017-12-12 13:33 Jia-Ju Bai
  0 siblings, 0 replies; 2+ messages in thread
From: Jia-Ju Bai @ 2017-12-12 13:33 UTC (permalink / raw)
  To: support, jejb, martin.petersen, keescook
  Cc: linux-scsi, linux-kernel, Jia-Ju Bai

From: Jia-Ju Bai <baijiaju1990@163.com>

The driver may sleep under a spinlock, and the function call paths are:
arcmsr_queue_command(acquire the spinlock)
  arcmsr_queue_command_lck
    arcmsr_handle_virtual_command
      arcmsr_iop_message_xfer
        arcmsr_iop_parking
          arcmsr_stop_adapter_bgrb
            arcmsr_hbaA_stop_bgrb
              arcmsr_hbaA_wait_msgint_ready
                msleep --> may sleep

arcmsr_queue_command(acquire the spinlock)
  arcmsr_queue_command_lck
    arcmsr_handle_virtual_command
      arcmsr_iop_message_xfer
        arcmsr_iop_parking
          arcmsr_stop_adapter_bgrb
            arcmsr_hbaB_stop_bgrb
              arcmsr_hbaB_wait_msgint_ready
                msleep --> may sleep

arcmsr_queue_command(acquire the spinlock)
  arcmsr_queue_command_lck
    arcmsr_handle_virtual_command
      arcmsr_iop_message_xfer
        arcmsr_iop_parking
          arcmsr_stop_adapter_bgrb
            arcmsr_hbaC_stop_bgrb
              arcmsr_hbaC_wait_msgint_ready
                msleep --> may sleep

arcmsr_queue_command(acquire the spinlock)
  arcmsr_queue_command_lck
    arcmsr_handle_virtual_command
      arcmsr_iop_message_xfer
        arcmsr_iop_parking
          arcmsr_stop_adapter_bgrb
            arcmsr_hbaD_stop_bgrb
              arcmsr_hbaD_wait_msgint_ready
                msleep --> may sleep

To fix them, msleep is replaced with mdelay.
These bugs are found by my static analysis tool and my code review.

Signed-off-by: Jia-Ju Bai <baijiaju1990@163.com>
---
 drivers/scsi/arcmsr/arcmsr_hba.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c
index af032c4..31d94bd 100644
--- a/drivers/scsi/arcmsr/arcmsr_hba.c
+++ b/drivers/scsi/arcmsr/arcmsr_hba.c
@@ -347,7 +347,7 @@ static uint8_t arcmsr_hbaA_wait_msgint_ready(struct AdapterControlBlock *acb)
 				&reg->outbound_intstatus);
 			return true;
 		}
-		msleep(10);
+		mdelay(10);
 	} /* max 20 seconds */
 
 	return false;
@@ -367,7 +367,7 @@ static uint8_t arcmsr_hbaB_wait_msgint_ready(struct AdapterControlBlock *acb)
 					reg->drv2iop_doorbell);
 			return true;
 		}
-		msleep(10);
+		mdelay(10);
 	} /* max 20 seconds */
 
 	return false;
@@ -385,7 +385,7 @@ static uint8_t arcmsr_hbaC_wait_msgint_ready(struct AdapterControlBlock *pACB)
 				&phbcmu->outbound_doorbell_clear); /*clear interrupt*/
 			return true;
 		}
-		msleep(10);
+		mdelay(10);
 	} /* max 20 seconds */
 
 	return false;
@@ -403,7 +403,7 @@ static bool arcmsr_hbaD_wait_msgint_ready(struct AdapterControlBlock *pACB)
 				reg->outbound_doorbell);
 			return true;
 		}
-		msleep(10);
+		mdelay(10);
 	} /* max 20 seconds */
 	return false;
 }
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH] arcmsr: Fix possible sleep-in-atomic bugs in arcmsr_queue_command
@ 2017-10-08 12:51 Jia-Ju Bai
  0 siblings, 0 replies; 2+ messages in thread
From: Jia-Ju Bai @ 2017-10-08 12:51 UTC (permalink / raw)
  To: jejb, martin.petersen, ching2048, bhumirks
  Cc: linux-scsi, linux-kernel, Jia-Ju Bai

The driver may sleep under a spinlock, and the function call paths are:
arcmsr_queue_command(acquire the spinlock)
  arcmsr_queue_command_lck
    arcmsr_handle_virtual_command
      arcmsr_iop_message_xfer
        arcmsr_iop_parking
          arcmsr_stop_adapter_bgrb
            arcmsr_hbaA_stop_bgrb
              arcmsr_hbaA_wait_msgint_ready
                msleep --> may sleep

arcmsr_queue_command(acquire the spinlock)
  arcmsr_queue_command_lck
    arcmsr_handle_virtual_command
      arcmsr_iop_message_xfer
        arcmsr_iop_parking
          arcmsr_stop_adapter_bgrb
            arcmsr_hbaB_stop_bgrb
              arcmsr_hbaB_wait_msgint_ready
                msleep --> may sleep

arcmsr_queue_command(acquire the spinlock)
  arcmsr_queue_command_lck
    arcmsr_handle_virtual_command
      arcmsr_iop_message_xfer
        arcmsr_iop_parking
          arcmsr_stop_adapter_bgrb
            arcmsr_hbaC_stop_bgrb
              arcmsr_hbaC_wait_msgint_ready
                msleep --> may sleep

arcmsr_queue_command(acquire the spinlock)
  arcmsr_queue_command_lck
    arcmsr_handle_virtual_command
      arcmsr_iop_message_xfer
        arcmsr_iop_parking
          arcmsr_stop_adapter_bgrb
            arcmsr_hbaD_stop_bgrb
              arcmsr_hbaD_wait_msgint_ready
                msleep --> may sleep

To fix them, msleep is replaced with mdelay.
These bugs are found by my static analysis tool and my code review.

Signed-off-by: Jia-Ju Bai <baijiaju1990@163.com>
---
 drivers/scsi/arcmsr/arcmsr_hba.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/arcmsr/arcmsr_hba.c b/drivers/scsi/arcmsr/arcmsr_hba.c
index af032c4..31d94bd 100644
--- a/drivers/scsi/arcmsr/arcmsr_hba.c
+++ b/drivers/scsi/arcmsr/arcmsr_hba.c
@@ -347,7 +347,7 @@ static uint8_t arcmsr_hbaA_wait_msgint_ready(struct AdapterControlBlock *acb)
 				&reg->outbound_intstatus);
 			return true;
 		}
-		msleep(10);
+		mdelay(10);
 	} /* max 20 seconds */
 
 	return false;
@@ -367,7 +367,7 @@ static uint8_t arcmsr_hbaB_wait_msgint_ready(struct AdapterControlBlock *acb)
 					reg->drv2iop_doorbell);
 			return true;
 		}
-		msleep(10);
+		mdelay(10);
 	} /* max 20 seconds */
 
 	return false;
@@ -385,7 +385,7 @@ static uint8_t arcmsr_hbaC_wait_msgint_ready(struct AdapterControlBlock *pACB)
 				&phbcmu->outbound_doorbell_clear); /*clear interrupt*/
 			return true;
 		}
-		msleep(10);
+		mdelay(10);
 	} /* max 20 seconds */
 
 	return false;
@@ -403,7 +403,7 @@ static bool arcmsr_hbaD_wait_msgint_ready(struct AdapterControlBlock *pACB)
 				reg->outbound_doorbell);
 			return true;
 		}
-		msleep(10);
+		mdelay(10);
 	} /* max 20 seconds */
 	return false;
 }
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-12-12 13:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-12 13:33 [PATCH] arcmsr: Fix possible sleep-in-atomic bugs in arcmsr_queue_command Jia-Ju Bai
  -- strict thread matches above, loose matches on Subject: below --
2017-10-08 12:51 Jia-Ju Bai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.