scsi: scsi_debug: Fix buffer size of REPORT ZONES command
authorShin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Tue, 7 Dec 2021 01:06:38 +0000 (10:06 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 14 Dec 2021 09:57:16 +0000 (10:57 +0100)
commitebacb44cb2042b90951140eda806bedad23ef554
tree908226c2c0a9545eaa6b40fa1cb88c5ee2670a16
parentf8dccc1bdea7e21b5ec06c957aef8831c772661c
scsi: scsi_debug: Fix buffer size of REPORT ZONES command

commit 7db0e0c8190a086ef92ce5bb960836cde49540aa upstream.

According to ZBC and SPC specifications, the unit of ALLOCATION LENGTH
field of REPORT ZONES command is byte. However, current scsi_debug
implementation handles it as number of zones to calculate buffer size to
report zones. When the ALLOCATION LENGTH has a large number, this results
in too large buffer size and causes memory allocation failure.  Fix the
failure by handling ALLOCATION LENGTH as byte unit.

Link: https://lore.kernel.org/r/20211207010638.124280-1-shinichiro.kawasaki@wdc.com
Fixes: f0d1cf9378bd ("scsi: scsi_debug: Add ZBC zone commands")
Reviewed-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/scsi/scsi_debug.c