* [PATCH 1/2] s390/dasd: Return BLK_STS_INVAL for EINVAL from do_dasd_request
2025-09-25 15:47 [PATCH 0/2] s390/dasd: fix buffer alignment validation Stefan Haberland
@ 2025-09-25 15:47 ` Stefan Haberland
2025-09-25 15:47 ` [PATCH 2/2] s390/dasd: enforce dma_alignment to ensure proper buffer validation Stefan Haberland
2025-09-25 16:35 ` [PATCH 0/2] s390/dasd: fix buffer alignment validation Jens Axboe
2 siblings, 0 replies; 4+ messages in thread
From: Stefan Haberland @ 2025-09-25 15:47 UTC (permalink / raw)
To: Jens Axboe
Cc: linux-block, Jan Hoeppner, linux-s390, Heiko Carstens,
Vasily Gorbik, Christian Borntraeger, Jaehoon Kim
From: Jaehoon Kim <jhkim@linux.ibm.com>
Currently, if CCW request creation fails with -EINVAL, the DASD driver
returns BLK_STS_IOERR to the block layer.
This can happen, for example, when a user-space application such as QEMU
passes a misaligned buffer, but the original cause of the error is
masked as a generic I/O error.
This patch changes the behavior so that -EINVAL is returned as
BLK_STS_INVAL, allowing user space to properly detect alignment issues
instead of interpreting them as I/O errors.
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>
---
drivers/s390/block/dasd.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index 506a947d00a5..6224ba412623 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -3114,12 +3114,14 @@ static blk_status_t do_dasd_request(struct blk_mq_hw_ctx *hctx,
PTR_ERR(cqr) == -ENOMEM ||
PTR_ERR(cqr) == -EAGAIN) {
rc = BLK_STS_RESOURCE;
- goto out;
+ } else if (PTR_ERR(cqr) == -EINVAL) {
+ rc = BLK_STS_INVAL;
+ } else {
+ DBF_DEV_EVENT(DBF_ERR, basedev,
+ "CCW creation failed (rc=%ld) on request %p",
+ PTR_ERR(cqr), req);
+ rc = BLK_STS_IOERR;
}
- DBF_DEV_EVENT(DBF_ERR, basedev,
- "CCW creation failed (rc=%ld) on request %p",
- PTR_ERR(cqr), req);
- rc = BLK_STS_IOERR;
goto out;
}
/*
--
2.48.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* [PATCH 2/2] s390/dasd: enforce dma_alignment to ensure proper buffer validation
2025-09-25 15:47 [PATCH 0/2] s390/dasd: fix buffer alignment validation Stefan Haberland
2025-09-25 15:47 ` [PATCH 1/2] s390/dasd: Return BLK_STS_INVAL for EINVAL from do_dasd_request Stefan Haberland
@ 2025-09-25 15:47 ` Stefan Haberland
2025-09-25 16:35 ` [PATCH 0/2] s390/dasd: fix buffer alignment validation Jens Axboe
2 siblings, 0 replies; 4+ messages in thread
From: Stefan Haberland @ 2025-09-25 15:47 UTC (permalink / raw)
To: Jens Axboe
Cc: linux-block, Jan Hoeppner, linux-s390, Heiko Carstens,
Vasily Gorbik, Christian Borntraeger, Jaehoon Kim
From: Jaehoon Kim <jhkim@linux.ibm.com>
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>
---
drivers/s390/block/dasd.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c
index 6224ba412623..417a2dcf1587 100644
--- a/drivers/s390/block/dasd.c
+++ b/drivers/s390/block/dasd.c
@@ -334,6 +334,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;
--
2.48.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH 0/2] s390/dasd: fix buffer alignment validation
2025-09-25 15:47 [PATCH 0/2] s390/dasd: fix buffer alignment validation Stefan Haberland
2025-09-25 15:47 ` [PATCH 1/2] s390/dasd: Return BLK_STS_INVAL for EINVAL from do_dasd_request Stefan Haberland
2025-09-25 15:47 ` [PATCH 2/2] s390/dasd: enforce dma_alignment to ensure proper buffer validation Stefan Haberland
@ 2025-09-25 16:35 ` Jens Axboe
2 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2025-09-25 16:35 UTC (permalink / raw)
To: Stefan Haberland
Cc: linux-block, Jan Hoeppner, linux-s390, Heiko Carstens,
Vasily Gorbik, Jaehoon Kim, Christian Borntraeger
On Thu, 25 Sep 2025 17:47:06 +0200, Stefan Haberland wrote:
> please apply the following two patches that fix buffer alignment
> handling in the DASD driver.
> The first patch corrects the error mapping for misaligned requests,
> and the second enforces proper alignment validation in the block layer.
>
>
> Jaehoon Kim (2):
> s390/dasd: Return BLK_STS_INVAL for EINVAL from do_dasd_request
> s390/dasd: enforce dma_alignment to ensure proper buffer validation
>
> [...]
Applied, thanks!
[1/2] s390/dasd: Return BLK_STS_INVAL for EINVAL from do_dasd_request
(no commit info)
[2/2] s390/dasd: enforce dma_alignment to ensure proper buffer validation
(no commit info)
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 4+ messages in thread