]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
vhost-vdpa: fix use after free in vhost_vdpa_probe()
authorDan Carpenter <dan.carpenter@linaro.org>
Fri, 27 Oct 2023 12:12:54 +0000 (15:12 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 28 Nov 2023 17:14:53 +0000 (17:14 +0000)
[ Upstream commit e07754e0a1ea2d63fb29574253d1fd7405607343 ]

The put_device() calls vhost_vdpa_release_dev() which calls
ida_simple_remove() and frees "v".  So this call to
ida_simple_remove() is a use after free and a double free.

Fixes: ebe6a354fa7e ("vhost-vdpa: Call ida_simple_remove() when failed")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Message-Id: <cf53cb61-0699-4e36-a980-94fd4268ff00@moroto.mountain>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/vhost/vdpa.c

index b43e8680eee8dc4a3cef2d612279a98f3096b484..48357c403867fade2c97d1df41a690ef182988cd 100644 (file)
@@ -1498,7 +1498,6 @@ static int vhost_vdpa_probe(struct vdpa_device *vdpa)
 
 err:
        put_device(&v->dev);
-       ida_simple_remove(&vhost_vdpa_ida, v->minor);
        return r;
 }