qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] ide: ahci: add check to avoid null dereference (CVE-2019-12067)
@ 2019-08-08  6:56 P J P
  2019-08-08  9:11 ` Philippe Mathieu-Daudé
  0 siblings, 1 reply; 3+ messages in thread
From: P J P @ 2019-08-08  6:56 UTC (permalink / raw)
  To: QEMU Developers; +Cc: Bugs SysSec, John Snow, Prasad J Pandit

From: Prasad J Pandit <pjp@fedoraproject.org>

AHCI emulator while committing DMA buffer in ahci_commit_buf()
may do a NULL dereference if the command header 'ad->cur_cmd'
is null. Add check to avoid it.

Reported-by: Bugs SysSec <bugs-syssec@rub.de>
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
---
 hw/ide/ahci.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
index 00ba422a48..9fff94075b 100644
--- a/hw/ide/ahci.c
+++ b/hw/ide/ahci.c
@@ -1458,8 +1458,10 @@ static void ahci_commit_buf(IDEDMA *dma, uint32_t tx_bytes)
 {
     AHCIDevice *ad = DO_UPCAST(AHCIDevice, dma, dma);
 
-    tx_bytes += le32_to_cpu(ad->cur_cmd->status);
-    ad->cur_cmd->status = cpu_to_le32(tx_bytes);
+    if (ad->cur_cmd) {
+        tx_bytes += le32_to_cpu(ad->cur_cmd->status);
+        ad->cur_cmd->status = cpu_to_le32(tx_bytes);
+    }
 }
 
 static int ahci_dma_rw_buf(IDEDMA *dma, int is_write)
-- 
2.21.0



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

* Re: [Qemu-devel] [PATCH] ide: ahci: add check to avoid null dereference (CVE-2019-12067)
  2019-08-08  6:56 [Qemu-devel] [PATCH] ide: ahci: add check to avoid null dereference (CVE-2019-12067) P J P
@ 2019-08-08  9:11 ` Philippe Mathieu-Daudé
  2019-08-08 23:11   ` John Snow
  0 siblings, 1 reply; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-08-08  9:11 UTC (permalink / raw)
  To: P J P, QEMU Developers; +Cc: John Snow, Bugs SysSec, Prasad J Pandit

Hi Prasad,

On 8/8/19 8:56 AM, P J P wrote:
> From: Prasad J Pandit <pjp@fedoraproject.org>
> 
> AHCI emulator while committing DMA buffer in ahci_commit_buf()
> may do a NULL dereference if the command header 'ad->cur_cmd'
> is null. Add check to avoid it.
> 
> Reported-by: Bugs SysSec <bugs-syssec@rub.de>
> Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
> ---
>  hw/ide/ahci.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
> index 00ba422a48..9fff94075b 100644
> --- a/hw/ide/ahci.c
> +++ b/hw/ide/ahci.c
> @@ -1458,8 +1458,10 @@ static void ahci_commit_buf(IDEDMA *dma, uint32_t tx_bytes)
>  {
>      AHCIDevice *ad = DO_UPCAST(AHCIDevice, dma, dma);
>  
> -    tx_bytes += le32_to_cpu(ad->cur_cmd->status);
> -    ad->cur_cmd->status = cpu_to_le32(tx_bytes);
> +    if (ad->cur_cmd) {

My 2 cents, John will correct me:

This is not a valid condition, so an assert() might be more appropriate
here.

Why is dma_buf_commit() being called with a null command? This check
should go elsewhere to avoid the call.

> +        tx_bytes += le32_to_cpu(ad->cur_cmd->status);
> +        ad->cur_cmd->status = cpu_to_le32(tx_bytes);
> +    }
>  }
>  
>  static int ahci_dma_rw_buf(IDEDMA *dma, int is_write)
> 


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

* Re: [Qemu-devel] [PATCH] ide: ahci: add check to avoid null dereference (CVE-2019-12067)
  2019-08-08  9:11 ` Philippe Mathieu-Daudé
@ 2019-08-08 23:11   ` John Snow
  0 siblings, 0 replies; 3+ messages in thread
From: John Snow @ 2019-08-08 23:11 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé, P J P, QEMU Developers
  Cc: Bugs SysSec, Prasad J Pandit, Qemu-block



On 8/8/19 5:11 AM, Philippe Mathieu-Daudé wrote:
> Hi Prasad,
> 
> On 8/8/19 8:56 AM, P J P wrote:
>> From: Prasad J Pandit <pjp@fedoraproject.org>
>>
>> AHCI emulator while committing DMA buffer in ahci_commit_buf()
>> may do a NULL dereference if the command header 'ad->cur_cmd'
>> is null. Add check to avoid it.
>>
>> Reported-by: Bugs SysSec <bugs-syssec@rub.de>
>> Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
>> ---
>>  hw/ide/ahci.c | 6 ++++--
>>  1 file changed, 4 insertions(+), 2 deletions(-)
>>
>> diff --git a/hw/ide/ahci.c b/hw/ide/ahci.c
>> index 00ba422a48..9fff94075b 100644
>> --- a/hw/ide/ahci.c
>> +++ b/hw/ide/ahci.c
>> @@ -1458,8 +1458,10 @@ static void ahci_commit_buf(IDEDMA *dma, uint32_t tx_bytes)
>>  {
>>      AHCIDevice *ad = DO_UPCAST(AHCIDevice, dma, dma);
>>  
>> -    tx_bytes += le32_to_cpu(ad->cur_cmd->status);
>> -    ad->cur_cmd->status = cpu_to_le32(tx_bytes);
>> +    if (ad->cur_cmd) {
> 
> My 2 cents, John will correct me:
> 
> This is not a valid condition, so an assert() might be more appropriate
> here.
> 
> Why is dma_buf_commit() being called with a null command? This check
> should go elsewhere to avoid the call.
> 

Yes, something else is broken.

Can you please give a reproducer or more detailed report so I can fix
this properly?

This likely is just adding a whole host of new undefined problems
waiting to happen by adding an if (...), so while it's not nice to have
a host assert() it's probably better than taking the state machine off
the rails and seeing what else breaks.

>> +        tx_bytes += le32_to_cpu(ad->cur_cmd->status);
>> +        ad->cur_cmd->status = cpu_to_le32(tx_bytes);
>> +    }
>>  }
>>  
>>  static int ahci_dma_rw_buf(IDEDMA *dma, int is_write)
>>


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

end of thread, other threads:[~2019-08-08 23:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-08-08  6:56 [Qemu-devel] [PATCH] ide: ahci: add check to avoid null dereference (CVE-2019-12067) P J P
2019-08-08  9:11 ` Philippe Mathieu-Daudé
2019-08-08 23:11   ` John Snow

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).