summaryrefslogtreecommitdiff
path: root/zbd.c
diff options
context:
space:
mode:
authorDmitry Fomichev <dmitry.fomichev@wdc.com>2021-01-27 13:19:15 +0900
committerJens Axboe <axboe@kernel.dk>2021-01-29 08:14:00 -0700
commit6c3f1cc187103675f65eecd2eba1535df5cd59ec (patch)
treee5948e7e39f4f9b883b8a25e4ecaf808531d0290 /zbd.c
parent8a866de7a310691ec9a93417225c9ff8d375bf16 (diff)
downloadfio-6c3f1cc187103675f65eecd2eba1535df5cd59ec.tar.gz
fio-6c3f1cc187103675f65eecd2eba1535df5cd59ec.tar.bz2
zbd: avoid zone buffer overrun
If the total number of zones on a drive is calculated to a value that is less than the number of zones it can actually report, zone info buffer can be overrun. This may happen not only due to drive firmware problems, but also because of underlying software incorrectly reporting zoned device capacity. Fix this by more carefully setting zone report size. Signed-off-by: Dmitry Fomichev <dmitry.fomichev@wdc.com> Reviewed-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'zbd.c')
-rw-r--r--zbd.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/zbd.c b/zbd.c
index 019eaf62..a3c1ff9a 100644
--- a/zbd.c
+++ b/zbd.c
@@ -526,8 +526,9 @@ static int parse_zone_info(struct thread_data *td, struct fio_file *f)
offset = z->start + z->len;
if (j >= nr_zones)
break;
- nrz = zbd_report_zones(td, f, offset,
- zones, ZBD_REPORT_MAX_ZONES);
+ nrz = zbd_report_zones(td, f, offset, zones,
+ min((uint32_t)(nr_zones - j),
+ ZBD_REPORT_MAX_ZONES));
if (nrz < 0) {
ret = nrz;
log_info("fio: report zones (offset %llu) failed for %s (%d).\n",