• Damien Le Moal's avatar
    dm zoned: Fix zone report handling · 7aedf75f
    Damien Le Moal authored
    The function blkdev_report_zones() returns success even if no zone
    information is reported (empty report). Empty zone reports can only
    happen if the report start sector passed exceeds the device capacity.
    The conditions for this to happen are either a bug in the caller code,
    or, a change in the device that forced the low level driver to change
    the device capacity to a value that is lower than the report start
    sector. This situation includes a failed disk revalidation resulting in
    the disk capacity being changed to 0.
    
    If this change happens while dm-zoned is in its initialization phase
    executing dmz_init_zones(), this function may enter an infinite loop
    and hang the system. To avoid this, add a check to disallow empty zone
    reports and bail out early. Also fix the function dmz_update_zone() to
    make sure that the report for the requested zone was correctly obtained.
    
    Fixes: 3b1a94c8 ("dm zoned: drive-managed zoned block device target")
    Cc: stable@vger.kernel.org
    Signed-off-by: default avatarDamien Le Moal <damien.lemoal@wdc.com>
    Reviewed-by: default avatarShaun Tancheff <shaun@tancheff.com>
    Signed-off-by: default avatarDamien Le Moal <damien.lemoal@wdc.com>
    Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
    7aedf75f
dm-zoned-metadata.c 59 KB