• Masato Suzuki's avatar
    scsi: sd_zbc: Fix sd_zbc_report_zones() buffer allocation · 85b8532e
    Masato Suzuki authored
    commit 515ce606 upstream.
    
    The function sd_zbc_do_report_zones() issues a REPORT ZONES command with a
    buffer size calculated based on the number of zones requested by the
    caller. This value should however not exceed the capabilities of the
    hardware maximum command size, that is, should not exceed the
    max_hw_sectors limit of the device. This problem leads to failures of
    report zones commands when re-validating disks with some SAS HBAs.
    
    Fix this by limiting a report zone command buffer size to the minimum of
    the device max_hw_sectors and calculated value based on the requested
    number of zones. This does not change the semantic of the report_zones file
    operation as report zones can always return less zone reports than
    requested. Short reports are handled using a loop execution of the
    report_zones file operation in the function blk_report_zones().
    
    [Damien]
    Before patch 'e76239a3 ("block: add a report_zones method")', report
    zones buffer allocation was limited to max_sectors when allocated in
    blk_report_zones(). This however does not consider the actual format of the
    device reply which is interface dependent.  Limiting the allocation based
    on the size of the expected reply format rather than the size of the array
    of generic sturct blkzone passed by blk_report_zones() makes more sense.
    
    Fixes: e76239a3 ("block: add a report_zones method")
    Cc: stable@vger.kernel.org
    Signed-off-by: 's avatarMasato Suzuki <masato.suzuki@wdc.com>
    Signed-off-by: 's avatarDamien Le Moal <damien.lemoal@wdc.com>
    Signed-off-by: Martin K. Petersen's avatarMartin K. Petersen <martin.petersen@oracle.com>
    Signed-off-by: 's avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    85b8532e
Name
Last commit
Last update
Documentation Loading commit data...
LICENSES Loading commit data...
arch Loading commit data...
block Loading commit data...
certs Loading commit data...
crypto Loading commit data...
drivers Loading commit data...
firmware Loading commit data...
fs Loading commit data...
include Loading commit data...
init Loading commit data...
ipc Loading commit data...
kernel Loading commit data...
lib Loading commit data...
mm Loading commit data...
net Loading commit data...
samples Loading commit data...
scripts Loading commit data...
security Loading commit data...
sound Loading commit data...
tools Loading commit data...
usr Loading commit data...
virt Loading commit data...
.clang-format Loading commit data...
.cocciconfig Loading commit data...
.get_maintainer.ignore Loading commit data...
.gitattributes Loading commit data...
.gitignore Loading commit data...
.mailmap Loading commit data...
COPYING Loading commit data...
CREDITS Loading commit data...
Kbuild Loading commit data...
Kconfig Loading commit data...
MAINTAINERS Loading commit data...
Makefile Loading commit data...
README Loading commit data...