]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
s390/dasd: enforce dma_alignment to ensure proper buffer validation
authorJaehoon Kim <jhkim@linux.ibm.com>
Thu, 25 Sep 2025 15:47:08 +0000 (17:47 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 19 Oct 2025 14:33:57 +0000 (16:33 +0200)
commit 130e6de62107116eba124647116276266be0f84c upstream.

The block layer validates buffer alignment using the device's
dma_alignment value. If dma_alignment is smaller than
logical_block_size(bp_block) -1, misaligned buffer incorrectly pass
validation and propagate to the lower-level driver.

This patch adjusts dma_alignment to be at least logical_block_size -1,
ensuring that misalignment buffers are properly rejected at the block
layer and do not reach the DASD driver unnecessarily.

Fixes: 2a07bb64d801 ("s390/dasd: Remove DMA alignment")
Reviewed-by: Stefan Haberland <sth@linux.ibm.com>
Cc: stable@vger.kernel.org #6.11+
Signed-off-by: Jaehoon Kim <jhkim@linux.ibm.com>
Signed-off-by: Stefan Haberland <sth@linux.ibm.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/s390/block/dasd.c

index 42a4a996defbe1e4e39c803340b98eb05472bd69..b80595414e6351c9fdb4bb1f6d06c3752bc52d0c 100644 (file)
@@ -332,6 +332,11 @@ static int dasd_state_basic_to_ready(struct dasd_device *device)
        lim.max_dev_sectors = device->discipline->max_sectors(block);
        lim.max_hw_sectors = lim.max_dev_sectors;
        lim.logical_block_size = block->bp_block;
+       /*
+        * Adjust dma_alignment to match block_size - 1
+        * to ensure proper buffer alignment checks in the block layer.
+        */
+       lim.dma_alignment = lim.logical_block_size - 1;
 
        if (device->discipline->has_discard) {
                unsigned int max_bytes;