public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] megaraid: Fix a sleep-in-atomic bug
@ 2017-05-31  2:56 Jia-Ju Bai
  2017-05-31 10:18 ` Sumit Saxena
  0 siblings, 1 reply; 3+ messages in thread
From: Jia-Ju Bai @ 2017-05-31  2:56 UTC (permalink / raw)
  To: kashyap.desai, sumit.saxena, shivasharan.srikanteshwara, jejb,
	martin.petersen
  Cc: megaraidlinux.pdl, linux-scsi, linux-kernel, Jia-Ju Bai

The driver may sleep under a spin lock, and the function call path is:
mraid_mm_attach_buf (acquire the lock by spin_lock_irqsave)
  pci_pool_alloc(GFP_KERNEL) --> may sleep

To fix it, the "GFP_KERNEL" is replaced with "GFP_ATOMIC".

Signed-off-by: Jia-Ju Bai <baijiaju1990@163.com>
---
 drivers/scsi/megaraid/megaraid_mm.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/scsi/megaraid/megaraid_mm.c b/drivers/scsi/megaraid/megaraid_mm.c
index 4cf9ed9..c43afb8 100644
--- a/drivers/scsi/megaraid/megaraid_mm.c
+++ b/drivers/scsi/megaraid/megaraid_mm.c
@@ -574,7 +574,7 @@
 
 	kioc->pool_index	= right_pool;
 	kioc->free_buf		= 1;
-	kioc->buf_vaddr 	= pci_pool_alloc(pool->handle, GFP_KERNEL,
+	kioc->buf_vaddr 	= pci_pool_alloc(pool->handle, GFP_ATOMIC,
 							&kioc->buf_paddr);
 	spin_unlock_irqrestore(&pool->lock, flags);
 
-- 
1.7.9.5

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

* RE: [PATCH] megaraid: Fix a sleep-in-atomic bug
  2017-05-31  2:56 [PATCH] megaraid: Fix a sleep-in-atomic bug Jia-Ju Bai
@ 2017-05-31 10:18 ` Sumit Saxena
  2017-06-01  3:38   ` Jia-Ju Bai
  0 siblings, 1 reply; 3+ messages in thread
From: Sumit Saxena @ 2017-05-31 10:18 UTC (permalink / raw)
  To: Jia-Ju Bai, Kashyap Desai, Shivasharan Srikanteshwara, jejb,
	martin.petersen
  Cc: PDL,MEGARAIDLINUX, linux-scsi, linux-kernel

>-----Original Message-----
>From: Jia-Ju Bai [mailto:baijiaju1990@163.com]
>Sent: Wednesday, May 31, 2017 8:27 AM
>To: kashyap.desai@broadcom.com; sumit.saxena@broadcom.com;
>shivasharan.srikanteshwara@broadcom.com; jejb@linux.vnet.ibm.com;
>martin.petersen@oracle.com
>Cc: megaraidlinux.pdl@broadcom.com; linux-scsi@vger.kernel.org; linux-
>kernel@vger.kernel.org; Jia-Ju Bai
>Subject: [PATCH] megaraid: Fix a sleep-in-atomic bug
>
>The driver may sleep under a spin lock, and the function call path is:
>mraid_mm_attach_buf (acquire the lock by spin_lock_irqsave)
>  pci_pool_alloc(GFP_KERNEL) --> may sleep
>
>To fix it, the "GFP_KERNEL" is replaced with "GFP_ATOMIC".
>
>Signed-off-by: Jia-Ju Bai <baijiaju1990@163.com>
>---
> drivers/scsi/megaraid/megaraid_mm.c |    2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/drivers/scsi/megaraid/megaraid_mm.c
>b/drivers/scsi/megaraid/megaraid_mm.c
>index 4cf9ed9..c43afb8 100644
>--- a/drivers/scsi/megaraid/megaraid_mm.c
>+++ b/drivers/scsi/megaraid/megaraid_mm.c
>@@ -574,7 +574,7 @@
>
> 	kioc->pool_index	= right_pool;
> 	kioc->free_buf		= 1;
>-	kioc->buf_vaddr 	= pci_pool_alloc(pool->handle, GFP_KERNEL,
>+	kioc->buf_vaddr 	= pci_pool_alloc(pool->handle, GFP_ATOMIC,
> 							&kioc->buf_paddr);
> 	spin_unlock_irqrestore(&pool->lock, flags);

This is very old driver and reached EOL. Did you face any issue because of
this bug or discover this through code review?
Anyways patch looks good to me.

Acked-by: Sumit Saxena <sumit.saxena@broadcom.com>

>
>--
>1.7.9.5
>

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

* Re: [PATCH] megaraid: Fix a sleep-in-atomic bug
  2017-05-31 10:18 ` Sumit Saxena
@ 2017-06-01  3:38   ` Jia-Ju Bai
  0 siblings, 0 replies; 3+ messages in thread
From: Jia-Ju Bai @ 2017-06-01  3:38 UTC (permalink / raw)
  To: Sumit Saxena
  Cc: Kashyap Desai, Shivasharan Srikanteshwara, jejb, martin.petersen,
	PDL,MEGARAIDLINUX, linux-scsi, linux-kernel

On 05/31/2017 06:18 PM, Sumit Saxena wrote:
>> -----Original Message-----
>> From: Jia-Ju Bai [mailto:baijiaju1990@163.com]
>> Sent: Wednesday, May 31, 2017 8:27 AM
>> To: kashyap.desai@broadcom.com; sumit.saxena@broadcom.com;
>> shivasharan.srikanteshwara@broadcom.com; jejb@linux.vnet.ibm.com;
>> martin.petersen@oracle.com
>> Cc: megaraidlinux.pdl@broadcom.com; linux-scsi@vger.kernel.org; linux-
>> kernel@vger.kernel.org; Jia-Ju Bai
>> Subject: [PATCH] megaraid: Fix a sleep-in-atomic bug
>>
>> The driver may sleep under a spin lock, and the function call path is:
>> mraid_mm_attach_buf (acquire the lock by spin_lock_irqsave)
>>   pci_pool_alloc(GFP_KERNEL) -->  may sleep
>>
>> To fix it, the "GFP_KERNEL" is replaced with "GFP_ATOMIC".
>>
>> Signed-off-by: Jia-Ju Bai<baijiaju1990@163.com>
>> ---
>> drivers/scsi/megaraid/megaraid_mm.c |    2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/scsi/megaraid/megaraid_mm.c
>> b/drivers/scsi/megaraid/megaraid_mm.c
>> index 4cf9ed9..c43afb8 100644
>> --- a/drivers/scsi/megaraid/megaraid_mm.c
>> +++ b/drivers/scsi/megaraid/megaraid_mm.c
>> @@ -574,7 +574,7 @@
>>
>> 	kioc->pool_index	= right_pool;
>> 	kioc->free_buf		= 1;
>> -	kioc->buf_vaddr 	= pci_pool_alloc(pool->handle, GFP_KERNEL,
>> +	kioc->buf_vaddr 	= pci_pool_alloc(pool->handle, GFP_ATOMIC,
>> 							&kioc->buf_paddr);
>> 	spin_unlock_irqrestore(&pool->lock, flags);
> This is very old driver and reached EOL. Did you face any issue because of
> this bug or discover this through code review?
> Anyways patch looks good to me.
>
> Acked-by: Sumit Saxena<sumit.saxena@broadcom.com>
>
>> --
>> 1.7.9.5
>>
Hi,

This bug is found by a static analysis tool and my code review.

Jia-Ju Bai

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

end of thread, other threads:[~2017-06-01  3:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-05-31  2:56 [PATCH] megaraid: Fix a sleep-in-atomic bug Jia-Ju Bai
2017-05-31 10:18 ` Sumit Saxena
2017-06-01  3:38   ` Jia-Ju Bai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox