xen/blkfront: avoid NULL blkfront_info dereference on device removal
Subsystems (3)
PATCH v2 1/1 xen/blkfront: avoid NULL blkfront_info dereference on device removal
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.
--- drivers/block/xen-blkfront.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/block/xen-blkfront.c +3 -0
@@ -2493,6 +2493,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);
Signature · 1 line
2.19.0
Quoted 20 lines · Vasilis Liaskovitis
If a block device is hot-added when we are out of grants,
gnttab_grant_foreign_accessfails 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_accessand the failing path in
talk_to_blkbacksets thedriver_datato NULL:
destroy_blkring:blkif_free(info, 0); mutex_lock(&blkfront_mutex); free_info(info); mutex_unlock(&blkfront_mutex); dev_set_drvdata(&dev->dev, NULL);
Quoted 4 lines
This results in a NULL pointer BUG when
blkfront_removeandblkif_freetry to access the failing device's NULL structblkfront_info.Signed-off-by Vasilis Liaskovitis <[email protected]>
Thanks.
I guess this is a candidate for backporting?
Quoted 20 lines · Vasilis Liaskovitis
If a block device is hot-added when we are out of grants,
gnttab_grant_foreign_accessfails 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_accessand the failing path in
talk_to_blkbacksets thedriver_datato NULL:
destroy_blkring:blkif_free(info, 0); mutex_lock(&blkfront_mutex); free_info(info); mutex_unlock(&blkfront_mutex); dev_set_drvdata(&dev->dev, NULL);
Quoted 4 lines
This results in a NULL pointer BUG when
blkfront_removeandblkif_freetry to access the failing device's NULL structblkfront_info.Signed-off-by Vasilis Liaskovitis <[email protected]>
Thanks.
I guess this is a candidate for backporting?
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 8 lines · Roger Pau Monné
Quoted 6 lines
This results in a NULL pointer BUG when
blkfront_removeandblkif_free
try to access the failing device's NULL structblkfront_info.I guess this is a candidate for backporting?
yes, I think so. At least for kernels >=4.5, which could face this issue due to commit c31ecf6c12 (this frees the struct blkinfo in the failing path of talk_to_blkback).
thanks,
- Vasilis
Quoted 8 lines · Roger Pau Monné
Quoted 6 lines
This results in a NULL pointer BUG when
blkfront_removeandblkif_free
try to access the failing device's NULL structblkfront_info.I guess this is a candidate for backporting?
yes, I think so. At least for kernels >=4.5, which could face this issue due to commit c31ecf6c12 (this frees the struct blkinfo in the failing path of talk_to_blkback).
thanks,
- Vasilis
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 7 lines · Vasilis Liaskovitis
Quoted 6 lines · Roger Pau Monn�
Quoted 6 lines
This results in a NULL pointer BUG when
blkfront_removeandblkif_free
try to access the failing device's NULL structblkfront_info.
Quoted 6 lines
Quoted 2 lines
I guess this is a candidate for backporting?
yes, I think so. At least for kernels >=4.5, which could face this issue due to commit
c31ecf6c12(this frees the struct blkinfo in the failing path oftalk_to_blkback).
OK, applied with Cc: [email protected]
Quoted 6 lines
thanks,
- Vasilis
Quoted 7 lines · Vasilis Liaskovitis
Quoted 6 lines · Roger Pau Monné
Quoted 6 lines
This results in a NULL pointer BUG when
blkfront_removeandblkif_free
try to access the failing device's NULL structblkfront_info.
Quoted 6 lines
Quoted 2 lines
I guess this is a candidate for backporting?
yes, I think so. At least for kernels >=4.5, which could face this issue due to commit
c31ecf6c12(this frees the struct blkinfo in the failing path oftalk_to_blkback).
OK, applied with Cc: [email protected]
Quoted 6 lines
thanks,
- Vasilis
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel