Skip to content

Commit cd68c48

Browse files
hoeppnerjaxboe
authored andcommitted
s390/dasd: Fix read for ESE with blksize < 4k
When reading unformatted tracks on ESE devices, the corresponding memory areas are simply set to zero for each segment. This is done incorrectly for blocksizes < 4096. There are two problems. First, the increment of dst is done using the counter of the loop (off), which is increased by blksize every iteration. This leads to a much bigger increment for dst as actually intended. Second, the increment of dst is done before the memory area is set to 0, skipping a significant amount of bytes of memory. This leads to illegal overwriting of memory and ultimately to a kernel panic. This is not a problem with 4k blocksize because blk_queue_max_segment_size is set to PAGE_SIZE, always resulting in a single iteration for the inner segment loop (bv.bv_len == blksize). The incorrectly used 'off' value to increment dst is 0 and the correct memory area is used. In order to fix this for blksize < 4k, increment dst correctly using the blksize and only do it at the end of the loop. Fixes: 5e2b17e ("s390/dasd: Add dynamic formatting support for ESE volumes") Cc: [email protected] # v5.3+ Signed-off-by: Jan Höppner <[email protected]> Reviewed-by: Stefan Haberland <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 71f3871 commit cd68c48

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

drivers/s390/block/dasd_eckd.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3285,12 +3285,11 @@ static int dasd_eckd_ese_read(struct dasd_ccw_req *cqr, struct irb *irb)
32853285
cqr->proc_bytes = blk_count * blksize;
32863286
return 0;
32873287
}
3288-
if (dst && !skip_block) {
3289-
dst += off;
3288+
if (dst && !skip_block)
32903289
memset(dst, 0, blksize);
3291-
} else {
3290+
else
32923291
skip_block--;
3293-
}
3292+
dst += blksize;
32943293
blk_count++;
32953294
}
32963295
}

0 commit comments

Comments
 (0)