Skip to content

Commit 71ba2ad

Browse files
philmdmdroth
authored andcommitted
hw/block/fdc: Kludge missing floppy drive to fix CVE-2021-20196
Guest might select another drive on the bus by setting the DRIVE_SEL bit of the DIGITAL OUTPUT REGISTER (DOR). The current controller model doesn't expect a BlockBackend to be NULL. A simple way to fix CVE-2021-20196 is to create an empty BlockBackend when it is missing. All further accesses will be safely handled, and the controller state machines keep behaving correctly. Cc: [email protected] Fixes: CVE-2021-20196 Reported-by: Gaoning Pan (Ant Security Light-Year Lab) <[email protected]> Reviewed-by: Darren Kenny <[email protected]> Reviewed-by: Hanna Reitz <[email protected]> Signed-off-by: Philippe Mathieu-Daudé <[email protected]> Message-id: [email protected] BugLink: https://bugs.launchpad.net/qemu/+bug/1912780 Resolves: https://gitlab.com/qemu-project/qemu/-/issues/338 Reviewed-by: Darren Kenny <[email protected]> Reviewed-by: Hanna Reitz <[email protected]> Signed-off-by: Philippe Mathieu-Daudé <[email protected]> Signed-off-by: John Snow <[email protected]> (cherry picked from commit 1ab95af) Signed-off-by: Michael Roth <[email protected]>
1 parent 7629818 commit 71ba2ad

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

hw/block/fdc.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1166,7 +1166,19 @@ static FDrive *get_drv(FDCtrl *fdctrl, int unit)
11661166

11671167
static FDrive *get_cur_drv(FDCtrl *fdctrl)
11681168
{
1169-
return get_drv(fdctrl, fdctrl->cur_drv);
1169+
FDrive *cur_drv = get_drv(fdctrl, fdctrl->cur_drv);
1170+
1171+
if (!cur_drv->blk) {
1172+
/*
1173+
* Kludge: empty drive line selected. Create an anonymous
1174+
* BlockBackend to avoid NULL deref with various BlockBackend
1175+
* API calls within this model (CVE-2021-20196).
1176+
* Due to the controller QOM model limitations, we don't
1177+
* attach the created to the controller device.
1178+
*/
1179+
cur_drv->blk = blk_create_empty_drive();
1180+
}
1181+
return cur_drv;
11701182
}
11711183

11721184
/* Status A register : 0x00 (read-only) */

0 commit comments

Comments
 (0)