]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
xen/blkfront: avoid NULL blkfront_info dereference on device removal
authorVasilis Liaskovitis <vliaskovitis@suse.com>
Tue, 12 Mar 2019 06:15:10 +0000 (14:15 +0800)
committerBrian Maly <brian.maly@oracle.com>
Thu, 21 Mar 2019 20:40:36 +0000 (16:40 -0400)
If a block device is hot-added when we are out of grants,
gnttab_grant_foreign_access fails with -ENOSPC (log message "28
granting access to ring page") in this code path:

  talk_to_blkback ->
setup_blkring ->
xenbus_grant_ring ->
gnttab_grant_foreign_access

and the failing path in talk_to_blkback sets the driver_data to NULL:

 destroy_blkring:
        blkif_free(info, 0);

        mutex_lock(&blkfront_mutex);
        free_info(info);
        mutex_unlock(&blkfront_mutex);

        dev_set_drvdata(&dev->dev, NULL);

This results in a NULL pointer BUG when blkfront_remove and blkif_free
try to access the failing device's NULL struct blkfront_info.

Cc: stable@vger.kernel.org # 4.5 and later
Signed-off-by: Vasilis Liaskovitis <vliaskovitis@suse.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Orabug: 29469740

(cherry picked from commit f92898e7f32e3533bfd95be174044bc349d416ca)

Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
Reviewed-by: Bhavesh Davda <bhavesh.davda@oracle.com>
Reviewed-by: Joe Jin <joe.jin@oracle.com>
Signed-off-by: Brian Maly <brian.maly@oracle.com>
drivers/block/xen-blkfront.c

index 24c04b5150954dcdeb410483b748e185a2249611..ec855851d39f6945addd8e2be77a64e902e65942 100644 (file)
@@ -2772,6 +2772,9 @@ static int blkfront_remove(struct xenbus_device *xbdev)
 
        dev_dbg(&xbdev->dev, "%s removed", xbdev->nodename);
 
+       if (!info)
+               return 0;
+
        blkif_free(info, 0);
 
        mutex_lock(&info->mutex);