]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit - drivers/block/xen-blkfront.c
xen/blkfront: avoid NULL blkfront_info dereference on device removal
authorVasilis Liaskovitis <vliaskovitis@suse.com>
Mon, 15 Oct 2018 13:25:08 +0000 (15:25 +0200)
committerJuerg Haefliger <juergh@canonical.com>
Wed, 24 Jul 2019 01:57:05 +0000 (19:57 -0600)
commit282e6259e774899fefdea2f4de255f02ebe22aab
treeea83e608ee655db3f659af5f318067c0b97bcb94
parente9e611431a1cf767fe4c1b1866f8b19c5451ea5b
xen/blkfront: avoid NULL blkfront_info dereference on device removal

BugLink: https://bugs.launchpad.net/bugs/1836802
commit f92898e7f32e3533bfd95be174044bc349d416ca upstream.

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/block/xen-blkfront.c