Re: [PATCH v3 0/7] Fix bio splitting by the crypto fallback code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 7/15/25 1:10 PM, Bart Van Assche wrote:
[ ... ]

(replying to my own email)

If nobody objects I will integrate the patch below in patch 6/7 from
this series. This patch addresses all concerns about this patch series
that have been formulated so far and that I'm aware of, including
restoring inline encryption support for all block devices. This is
realized by moving the blk_crypto_bio_prep() call from
bio_submit_split() back to where it was originally, namely in
blk_crypto_bio_prep(). Because of this change it is necessary to restore
bio splitting in blk_crypto_fallback_encrypt_bio(). Instead of restoring
the custom bio splitting code, call bio_split_to_limits(). This call
takes the inline encryption fallback bio limits into account because
patch 6/7 modifies get_max_io_size().

Thanks,

Bart.


diff --git a/block/blk-core.c b/block/blk-core.c
index 5af5f8c3cd06..2c3c8576aa9b 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -626,6 +626,10 @@ static void __submit_bio(struct bio *bio)
 	/* If plug is not used, add new plug here to cache nsecs time. */
 	struct blk_plug plug;

+	bio = blk_crypto_bio_prep(bio);
+	if (unlikely(!bio))
+		return;
+
 	blk_start_plug(&plug);

 	if (!bdev_test_flag(bio->bi_bdev, BD_HAS_SUBMIT_BIO)) {
diff --git a/block/blk-crypto-fallback.c b/block/blk-crypto-fallback.c
index b08e4d89d9a6..3b1c277e4375 100644
--- a/block/blk-crypto-fallback.c
+++ b/block/blk-crypto-fallback.c
@@ -262,12 +262,8 @@ static struct bio *blk_crypto_fallback_encrypt_bio(struct bio *src_bio)
 	unsigned int i, j;
 	blk_status_t blk_st;

-	/* Verify that bio splitting has occurred. */
-	if (WARN_ON_ONCE(bio_sectors(src_bio) >
-			 blk_crypto_max_io_size(src_bio))) {
-		src_bio->bi_status = BLK_STS_IOERR;
-		return NULL;
-	}
+	/* Split the bio if it's too big for single page bvec */
+	src_bio = bio_split_to_limits(src_bio);

 	bc = src_bio->bi_crypt_context;
 	data_unit_size = bc->bc_key->crypto_cfg.data_unit_size;
diff --git a/block/blk-merge.c b/block/blk-merge.c
index f4e210279cd3..990f2847c820 100644
--- a/block/blk-merge.c
+++ b/block/blk-merge.c
@@ -125,11 +125,10 @@ static struct bio *bio_submit_split(struct bio *bio, int split_sectors)
 		trace_block_split(split, bio->bi_iter.bi_sector);
 		WARN_ON_ONCE(bio_zone_write_plugging(bio));
 		submit_bio_noacct(bio);
-
-		bio = split;
+		return split;
 	}

-	return blk_crypto_bio_prep(bio);
+	return bio;

 error:
 	bio->bi_status = errno_to_blk_status(split_sectors);





[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux