um: virtio_uml: Fix use-after-free after put_device in probe
PATCH 1/1 um: virtio_uml: Fix use-after-free after put_device in probe
When register_virtio_device() fails in virtio_uml_probe(), the code sets vu_dev->registered = 1 even though the device was not successfully registered.
This can lead to use-after-free or other issues.
Fixes 04e5b1fb0183 ("um: virtio: Remove device on disconnect")
Signed-off-by Miaoqian Lin <[email protected]>
--- arch/um/drivers/virtio_uml.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/um/drivers/virtio_uml.c +3 -1
@@ -1250,8 +1250,10 @@ static int virtio_uml_probe(struct platform_device *pdev)device_set_wakeup_capable (&vu_dev->vdev.dev, true); rc =register_virtio_device (&vu_dev->vdev); -if (rc) +if (rc) {put_device (&vu_dev->vdev.dev); +return rc; + } vu_dev->registered =1 ;return rc;
Signature · 1 line
2.25.1
Johannes Berg
maintainerQuoted 17 lines · Miaoqian Lin
When
register_virtio_device()fails invirtio_uml_probe(), the code setsvu_dev->registered= 1 even though the device was not successfully registered.
This can lead to use-after-free or other issues.Fixes 04e5b1fb0183 ("um: virtio: Remove device on disconnect")Signed-off-by Miaoqian Lin <[email protected]>--- arch/um/drivers/virtio_uml.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)arch/um/drivers/virtio_uml.c +0
-0@@ -1250,8 +1250,10 @@ static int virtio_uml_probe(struct platform_device *pdev)device_set_wakeup_capable (&vu_dev->vdev.dev, true);
arch/um/drivers/virtio_uml.c static int virtio_uml_probe(struct platform_device *pdev) · line 1259
Quoted 10 lines
arch/um/drivers/virtio_uml.c +3
-1rc =register_virtio_device (&vu_dev->vdev); -if (rc) +if (rc) {put_device (&vu_dev->vdev.dev); +return rc; + } vu_dev->registered =1 ;return rc;
This should now statically 'return 0' at the end.
johannes