linux/drivers/s390/block
Stefan Haberland 7f40b34646 s390/dasd: Fix undersized format-check buffer
fmt_buffer_size in dasd_eckd_check_device_format() is declared as
int, even though one of the multiplicands, sizeof(struct eckd_count),
is a size_t. The expression

    trkcount * rpt_max * sizeof(struct eckd_count)

is therefore correctly evaluated at 64-bit width, but the result is
silently truncated when it is stored back into the 32-bit
fmt_buffer_size variable. For a sufficiently large track range
(start_unit/stop_unit are caller-controlled) this truncation
yields a buffer size far smaller than the number of tracks actually
requested. kzalloc() then succeeds with an undersized allocation,
while the subsequent channel program build still operates on the
untruncated track count and writes past the end of that buffer.

Compute the buffer size with check_mul_overflow() and keep it in a
size_t, so that a value that no longer fits results in -EINVAL
instead of a silently truncated allocation size.

Fixes: 8fd575200d ("s390/dasd: Add new ioctl BIODASDCHECKFMT")
Cc: stable@vger.kernel.org #4.7
Reviewed-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
Link: https://patch.msgid.link/20260727142840.567286-4-sth@linux.ibm.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
History 2026-07-31 08:28:08 -06:00
..
dasd.c s390/dasd: Fix path verification interrupted by concurrent dasd_sleep_on_immediatly 2026-07-31 08:28:05 -06:00
dasd_3990_erp.c s390/dasd: fix error recovery leading to data corruption on ESE devices 2024-08-12 10:31:08 -06:00
dasd_alias.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
dasd_devmap.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
dasd_diag.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
dasd_diag.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
dasd_eckd.c s390/dasd: Fix undersized format-check buffer 2026-07-31 08:28:08 -06:00
dasd_eckd.h s390/dasd: add device ping attribute 2022-09-21 08:32:51 -06:00
dasd_eer.c s390/dasd: Replace get_zeroed_page() with kzalloc() 2026-06-03 15:32:44 +02:00
dasd_erp.c s390/drivers: Explicitly include <linux/export.h> 2025-06-17 18:18:02 +02:00
dasd_fba.c treewide: Replace kmalloc with kmalloc_obj for non-scalar types 2026-02-21 01:02:28 -08:00
dasd_fba.h s390/dasd: fix typo in copyright statement 2019-12-20 11:52:01 -07:00
dasd_genhd.c s390/dasd: Move device name formatting into separate function 2025-11-26 10:14:17 -07:00
dasd_int.h s390/dasd: fix error recovery leading to data corruption on ESE devices 2024-08-12 10:31:08 -06:00
dasd_ioctl.c s390/dasd: Fix potential NULL pointer dereference 2026-07-31 08:28:06 -06:00
dasd_proc.c s390/dasd: fix redundant /proc/dasd* entries removal 2024-11-09 20:06:58 -07:00
dcssblk.c Convert more 'alloc_obj' cases to default GFP_KERNEL arguments 2026-02-21 20:03:00 -08:00
Kconfig s390/dcssblk: Add DAX support 2025-09-16 16:56:39 +02:00
Makefile s390: remove xpram device driver 2021-09-07 13:38:42 +02:00
scm_blk.c Convert more 'alloc_obj' cases to default GFP_KERNEL arguments 2026-02-21 20:03:00 -08:00
scm_blk.h block: remove genhd.h 2022-02-02 07:49:59 -07:00
scm_drv.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00