]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
blk-crypto: use BLK_STS_INVAL for alignment errors
authorCarlos Llamas <cmllamas@google.com>
Thu, 30 Oct 2025 04:39:18 +0000 (04:39 +0000)
committerJens Axboe <axboe@kernel.dk>
Thu, 30 Oct 2025 14:52:57 +0000 (08:52 -0600)
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@kernel.org>
Cc: Christoph Hellwig <hch@lst.de>
Link: https://lore.kernel.org/all/aP-c5gPjrpsn0vJA@google.com/
Signed-off-by: Carlos Llamas <cmllamas@google.com>
Reviewed-by: Eric Biggers <ebiggers@kernel.org>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/blk-crypto.c

index 4b1ad84d1b5abc2091dd040f63bab7848b4ead97..3e7bf1974cbd8f44510b609e278e0bdb0dcb7a0f 100644 (file)
@@ -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;
        }