ide: ahci: reset ncq object to unused on error
PATCH v2 1/1 ide: ahci: reset ncq object to unused on error
From: Prasad J Pandit <[email protected]>
When processing NCQ commands, ACHI device emulation prepares a NCQ transfer object; To which an aio control block(aiocb) object is assigned in 'execute_ncq_command'. In case, when the NCQ command is invalid, the 'aiocb' object is not assigned, and NCQ transfer object is left as 'used'. This leads to a use after free kind of error in 'bdrv_aio_cancel_async' via 'ahci_reset_port'. Reset NCQ transfer object to 'unused' to avoid it.
--- hw/ide/ahci.c | 1 + 1 file changed, 1 insertion(+)
Update as per review in
-> https://lists.gnu.org/archive/html/qemu-devel/2016-01/msg01175.html
hw/ide/ahci.c +1 -0
@@ -910,6 +910,7 @@ static void ncq_err(NCQTransferState *ncq_tfs) ide_state->error =ABRT_ERR ; ide_state->status =READY_STAT |ERR_STAT ; ncq_tfs->drive->port_regs.scr_err |= (1 << ncq_tfs->tag); + ncq_tfs->used =0 ; }static void ncq_finish (NCQTransferState *ncq_tfs)
Signature · 1 line
2.4.3
Quoted 25 lines · P J P
From: Prasad J Pandit <[email protected]>
When processing NCQ commands, ACHI device emulation prepares a NCQ transfer object; To which an aio control block(aiocb) object is assigned in '
execute_ncq_command'. In case, when the NCQ command is invalid, the 'aiocb' object is not assigned, and NCQ transfer object is left as 'used'. This leads to a use after free kind of error in 'bdrv_aio_cancel_async' via 'ahci_reset_port'. Reset NCQ transfer object to 'unused' to avoid it.Reported-by Qinghao Tang <[email protected]>Signed-off-by Prasad J Pandit <[email protected]>--- hw/ide/ahci.c | 1 + 1 file changed, 1 insertion(+)Update as per review in
-> https://lists.gnu.org/archive/html/qemu-devel/2016-01/msg01175.htmlhw/ide/ahci.c +0
-0
hw/ide/ahci.c static void ncq_err(NCQTransferState *ncq_tfs) · line 916
Quoted 7 lines
hw/ide/ahci.c +1
-0@@ -910,6 +910,7 @@ static void ncq_err(NCQTransferState *ncq_tfs) ide_state->error =ABRT_ERR ; ide_state->status =READY_STAT |ERR_STAT ; ncq_tfs->drive->port_regs.scr_err |= (1 << ncq_tfs->tag); + ncq_tfs->used =0 ; }static void ncq_finish (NCQTransferState *ncq_tfs)
John Snow
AppliedQuoted 25 lines · P J P
From: Prasad J Pandit <[email protected]>
When processing NCQ commands, ACHI device emulation prepares a NCQ transfer object; To which an aio control block(aiocb) object is assigned in '
execute_ncq_command'. In case, when the NCQ command is invalid, the 'aiocb' object is not assigned, and NCQ transfer object is left as 'used'. This leads to a use after free kind of error in 'bdrv_aio_cancel_async' via 'ahci_reset_port'. Reset NCQ transfer object to 'unused' to avoid it.Reported-by Qinghao Tang <[email protected]>Signed-off-by Prasad J Pandit <[email protected]>--- hw/ide/ahci.c | 1 + 1 file changed, 1 insertion(+)Update as per review in
-> https://lists.gnu.org/archive/html/qemu-devel/2016-01/msg01175.htmlhw/ide/ahci.c +0
-0
hw/ide/ahci.c static void ncq_err(NCQTransferState *ncq_tfs) · line 916
Quoted 7 lines
hw/ide/ahci.c +1
-0@@ -910,6 +910,7 @@ static void ncq_err(NCQTransferState *ncq_tfs) ide_state->error =ABRT_ERR ; ide_state->status =READY_STAT |ERR_STAT ; ncq_tfs->drive->port_regs.scr_err |= (1 << ncq_tfs->tag); + ncq_tfs->used =0 ; }static void ncq_finish (NCQTransferState *ncq_tfs)
Thanks, applied to my IDE tree:
https://github.com/jnsnow/qemu/commits/ide
https://github.com/jnsnow/qemu.git
--js
+-- On Fri, 8 Jan 2016, John Snow wrote --+ | > ide_state->status = READY_STAT | ERR_STAT; | > ncq_tfs->drive->port_regs.scr_err |= (1 << ncq_tfs->tag); | > + ncq_tfs->used = 0; | > } | | Thanks, applied to my IDE tree: | | https://github.com/jnsnow/qemu/commits/ide | https://github.com/jnsnow/qemu.git
Great! Thank you.
--
Prasad J Pandit / Red Hat Product Security Team
47AF CE69 3A90 54AA 9045 1053 DD13 3D32 FE5B 041F
Am 08.01.2016 um 20:48 hat P J P geschrieben:
Quoted 3 lines
From: Prasad J Pandit <[email protected]>
When processing NCQ commands, ACHI device emulation prepares a
s/ACHI/AHCI/
Can you still fix this in your tree, John?
Kevin
Quoted 9 lines
NCQ transfer object; To which an aio control block(aiocb) object is assigned in '
execute_ncq_command'. In case, when the NCQ command is invalid, the 'aiocb' object is not assigned, and NCQ transfer object is left as 'used'. This leads to a use after free kind of error in 'bdrv_aio_cancel_async' via 'ahci_reset_port'. Reset NCQ transfer object to 'unused' to avoid it.Reported-by Qinghao Tang <[email protected]>Signed-off-by Prasad J Pandit <[email protected]>
Quoted 11 lines · Kevin Wolf
Am 08.01.2016 um 20:48 hat P J P geschrieben:
Quoted 3 lines
From: Prasad J Pandit <[email protected]>
When processing NCQ commands, ACHI device emulation prepares a
s/ACHI/AHCI/
Can you still fix this in your tree, John?
Kevin
Yes, thanks.
Quoted 10 lines
Quoted 9 lines
NCQ transfer object; To which an aio control block(aiocb) object is assigned in '
execute_ncq_command'. In case, when the NCQ command is invalid, the 'aiocb' object is not assigned, and NCQ transfer object is left as 'used'. This leads to a use after free kind of error in 'bdrv_aio_cancel_async' via 'ahci_reset_port'. Reset NCQ transfer object to 'unused' to avoid it.Reported-by Qinghao Tang <[email protected]>Signed-off-by Prasad J Pandit <[email protected]>
+-- On Mon, 11 Jan 2016, John Snow wrote --+ | On 01/11/2016 10:00 AM, Kevin Wolf wrote: | >> When processing NCQ commands, ACHI device emulation prepares a | > | > s/ACHI/AHCI/
Ah, sorry.:(
| > Can you still fix this in your tree, John?
| Yes, thanks.
Thank you.
--
Prasad J Pandit / Red Hat Product Security Team
47AF CE69 3A90 54AA 9045 1053 DD13 3D32 FE5B 041F