linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ata: dwc_460ex: Avoid potential NULL pointer dereference
@ 2019-03-04 23:08 Aditya Pakki
  2019-03-24 16:28 ` Jens Axboe
  0 siblings, 1 reply; 4+ messages in thread
From: Aditya Pakki @ 2019-03-04 23:08 UTC (permalink / raw)
  To: pakki001; +Cc: kjlu, Jens Axboe, linux-ide, linux-kernel

dma_async_tx_descriptor can contain a NULL variable and using
it in dmaengine_submit without checking can crash the process.
This patch avoids such a scenario.

Signed-off-by: Aditya Pakki <pakki001@umn.edu>
---
 drivers/ata/sata_dwc_460ex.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/ata/sata_dwc_460ex.c b/drivers/ata/sata_dwc_460ex.c
index 6f142aa54f5f..44a0d7a1ef54 100644
--- a/drivers/ata/sata_dwc_460ex.c
+++ b/drivers/ata/sata_dwc_460ex.c
@@ -1052,8 +1052,10 @@ static void sata_dwc_bmdma_start_by_tag(struct ata_queued_cmd *qc, u8 tag)
 					SATA_DWC_DMACR_RXCHEN);
 
 		/* Enable AHB DMA transfer on the specified channel */
-		dmaengine_submit(desc);
-		dma_async_issue_pending(hsdevp->chan);
+		if (desc) {
+			dmaengine_submit(desc);
+			dma_async_issue_pending(hsdevp->chan);
+		}
 	}
 }
 
-- 
2.17.1

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

* Re: [PATCH] ata: dwc_460ex: Avoid potential NULL pointer dereference
  2019-03-04 23:08 [PATCH] ata: dwc_460ex: Avoid potential NULL pointer dereference Aditya Pakki
@ 2019-03-24 16:28 ` Jens Axboe
  2019-03-24 16:47   ` Aditya Pakki
  0 siblings, 1 reply; 4+ messages in thread
From: Jens Axboe @ 2019-03-24 16:28 UTC (permalink / raw)
  To: Aditya Pakki; +Cc: kjlu, linux-ide, linux-kernel

On 3/4/19 4:08 PM, Aditya Pakki wrote:
> dma_async_tx_descriptor can contain a NULL variable and using
> it in dmaengine_submit without checking can crash the process.
> This patch avoids such a scenario.
> 
> Signed-off-by: Aditya Pakki <pakki001@umn.edu>
> ---
>  drivers/ata/sata_dwc_460ex.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/ata/sata_dwc_460ex.c b/drivers/ata/sata_dwc_460ex.c
> index 6f142aa54f5f..44a0d7a1ef54 100644
> --- a/drivers/ata/sata_dwc_460ex.c
> +++ b/drivers/ata/sata_dwc_460ex.c
> @@ -1052,8 +1052,10 @@ static void sata_dwc_bmdma_start_by_tag(struct ata_queued_cmd *qc, u8 tag)
>  					SATA_DWC_DMACR_RXCHEN);
>  
>  		/* Enable AHB DMA transfer on the specified channel */
> -		dmaengine_submit(desc);
> -		dma_async_issue_pending(hsdevp->chan);
> +		if (desc) {
> +			dmaengine_submit(desc);
> +			dma_async_issue_pending(hsdevp->chan);
> +		}
>  	}
>  }

Hmm, if desc == NULL, is that an error condition?

-- 
Jens Axboe

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

* Re: [PATCH] ata: dwc_460ex: Avoid potential NULL pointer dereference
  2019-03-24 16:28 ` Jens Axboe
@ 2019-03-24 16:47   ` Aditya Pakki
  2019-03-24 17:10     ` Jens Axboe
  0 siblings, 1 reply; 4+ messages in thread
From: Aditya Pakki @ 2019-03-24 16:47 UTC (permalink / raw)
  To: Jens Axboe; +Cc: kjlu, linux-ide, linux-kernel

On 3/24/19 11:28 AM, Jens Axboe wrote:
> On 3/4/19 4:08 PM, Aditya Pakki wrote:
>> dma_async_tx_descriptor can contain a NULL variable and using
>> it in dmaengine_submit without checking can crash the process.
>> This patch avoids such a scenario.
>>
>> Signed-off-by: Aditya Pakki <pakki001@umn.edu>
>> ---
>>  drivers/ata/sata_dwc_460ex.c | 6 ++++--
>>  1 file changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/ata/sata_dwc_460ex.c b/drivers/ata/sata_dwc_460ex.c
>> index 6f142aa54f5f..44a0d7a1ef54 100644
>> --- a/drivers/ata/sata_dwc_460ex.c
>> +++ b/drivers/ata/sata_dwc_460ex.c
>> @@ -1052,8 +1052,10 @@ static void sata_dwc_bmdma_start_by_tag(struct ata_queued_cmd *qc, u8 tag)
>>  					SATA_DWC_DMACR_RXCHEN);
>>  
>>  		/* Enable AHB DMA transfer on the specified channel */
>> -		dmaengine_submit(desc);
>> -		dma_async_issue_pending(hsdevp->chan);
>> +		if (desc) {
>> +			dmaengine_submit(desc);
>> +			dma_async_issue_pending(hsdevp->chan);
>> +		}
>>  	}
>>  }
> 
> Hmm, if desc == NULL, is that an error condition?
> 
Jens,
In dmaengine_submit, the desc variable is dereferenced without a check for NULL.

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

* Re: [PATCH] ata: dwc_460ex: Avoid potential NULL pointer dereference
  2019-03-24 16:47   ` Aditya Pakki
@ 2019-03-24 17:10     ` Jens Axboe
  0 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2019-03-24 17:10 UTC (permalink / raw)
  To: Aditya Pakki; +Cc: kjlu, linux-ide, linux-kernel

On 3/24/19 10:47 AM, Aditya Pakki wrote:
> On 3/24/19 11:28 AM, Jens Axboe wrote:
>> On 3/4/19 4:08 PM, Aditya Pakki wrote:
>>> dma_async_tx_descriptor can contain a NULL variable and using
>>> it in dmaengine_submit without checking can crash the process.
>>> This patch avoids such a scenario.
>>>
>>> Signed-off-by: Aditya Pakki <pakki001@umn.edu>
>>> ---
>>>  drivers/ata/sata_dwc_460ex.c | 6 ++++--
>>>  1 file changed, 4 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/ata/sata_dwc_460ex.c b/drivers/ata/sata_dwc_460ex.c
>>> index 6f142aa54f5f..44a0d7a1ef54 100644
>>> --- a/drivers/ata/sata_dwc_460ex.c
>>> +++ b/drivers/ata/sata_dwc_460ex.c
>>> @@ -1052,8 +1052,10 @@ static void sata_dwc_bmdma_start_by_tag(struct ata_queued_cmd *qc, u8 tag)
>>>  					SATA_DWC_DMACR_RXCHEN);
>>>  
>>>  		/* Enable AHB DMA transfer on the specified channel */
>>> -		dmaengine_submit(desc);
>>> -		dma_async_issue_pending(hsdevp->chan);
>>> +		if (desc) {
>>> +			dmaengine_submit(desc);
>>> +			dma_async_issue_pending(hsdevp->chan);
>>> +		}
>>>  	}
>>>  }
>>
>> Hmm, if desc == NULL, is that an error condition?
>>
> Jens,
> In dmaengine_submit, the desc variable is dereferenced without a check for NULL.

Yes, that's not my point. My point is if desc is NULL, and you just work around it
by not issuing the DMA, are you just going to hang the drive/box? Should you be
erroring the IO at that point instead?

-- 
Jens Axboe

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

end of thread, other threads:[~2019-03-24 17:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-04 23:08 [PATCH] ata: dwc_460ex: Avoid potential NULL pointer dereference Aditya Pakki
2019-03-24 16:28 ` Jens Axboe
2019-03-24 16:47   ` Aditya Pakki
2019-03-24 17:10     ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).