[PATCH master] virtio: implement remove callbacks

Sascha Hauer sha at pengutronix.de
Sat Oct 2 02:16:46 PDT 2021


On Thu, Sep 16, 2021 at 11:34:58AM +0200, Ahmad Fatoum wrote:
> virtio parent device drivers (e.g. PCI and MMIO) create child devices
> and free them on remove. The virtio drivers for the child devices (e.g.
> block and console) however don't unregister with their respective
> subsystems in the remove callbacks. So these subsystems may have stale
> pointers pointing at removed devices. This is especially problematic for
> the console driver, because the virtio console device_d will be removed,
> but the console itself remains registered leading to a use-after-free
> as soon as printf is invoked for the previously active console.
> 
> This leads to a crash when typing reset in
> 
>   https://www.barebox.org/jsbarebox/?graphic=0
> 
> Fix this for all virtio drivers.
> 
> Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
> ---
>  drivers/block/virtio_blk.c      |  6 ++++++
>  drivers/hw_random/core.c        | 12 ++++++++++++
>  drivers/hw_random/virtio-rng.c  |  6 ++++++
>  drivers/input/virtio_input.c    |  5 +++--
>  drivers/serial/virtio_console.c | 14 ++++++++++++++
>  include/linux/hw_random.h       |  2 ++
>  6 files changed, 43 insertions(+), 2 deletions(-)

Applied, thanks

Sascha


-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list