[PATCH] blk-crypto: use BLK_STS_INVAL for alignment errors

From: Carlos Llamas

Date: Thu Oct 30 2025 - 00:39:59 EST


Make __blk_crypto_bio_prep() propagate BLK_STS_INVAL when IO segments
fail the data unit alignment check.

This was flagged by an LTP test that expects EINVAL when performing an
O_DIRECT read with a misaligned buffer [1].

Cc: Eric Biggers <ebiggers@xxxxxxxxxx>
Cc: Christoph Hellwig <hch@xxxxxx>
Link: https://lore.kernel.org/all/aP-c5gPjrpsn0vJA@xxxxxxxxxx/ [1]
Signed-off-by: Carlos Llamas <cmllamas@xxxxxxxxxx>
---
block/blk-crypto.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/blk-crypto.c b/block/blk-crypto.c
index 4b1ad84d1b5a..3e7bf1974cbd 100644
--- a/block/blk-crypto.c
+++ b/block/blk-crypto.c
@@ -292,7 +292,7 @@ bool __blk_crypto_bio_prep(struct bio **bio_ptr)
}

if (!bio_crypt_check_alignment(bio)) {
- bio->bi_status = BLK_STS_IOERR;
+ bio->bi_status = BLK_STS_INVAL;
goto fail;
}

--
2.51.1.851.g4ebd6896fd-goog