Skip to contentSkip to conversation

Patch "dm-verity: provide dma_alignment limit in io_hints" has been added to the 6.6-stable tree

PATCH Sasha Levin 1 participant 1 message Oct 16 Device mapper

lore
Share & tools
lore

Sasha Levin

author Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

dm-verity: provide dma_alignment limit in io_hints

to the 6.6-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
dm-verity-provide-dma_alignment-limit-in-io_hints.patch
and it can be found in the queue-6.6 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

commit a730677767bdac568f6e3438068b076cc3019a7e

Author: Eric Biggers <[email protected]>
Date:   Tue Jul 2 16:39:51 2024 +0200

dm-verity: provide dma_alignment limit in io_hints

[ Upstream commit 09d1430896e38933470045408d7a350dac7d841b ]

Since Linux v6.1, some filesystems support submitting direct I/O that is aligned to only dma_alignment instead of the logical_block_size alignment that was required before. I/O that is not aligned to the logical_block_size is difficult to handle in device-mapper targets that do cryptographic processing of data, as it makes the units of data that are hashed or encrypted possibly be split across pages, creating rarely used and rarely tested edge cases.

As such, dm-crypt and dm-integrity have already opted out of this by setting dma_alignment to 'logical_block_size - 1'.

Although dm-verity does have code that handles these cases (or at least is intended to do so), supporting direct I/O with such a low amount of alignment is not really useful on dm-verity devices. So, opt dm-verity out of it too so that it's not necessary to handle these edge cases.

Stable-dep-of: 1071d560afb4 ("dm-stripe: fix a possible integer overflow")

drivers/md/dm-verity-target.c +8 -0
index 7e877c6adb2ea..bfd0e80bb9f3a 100644
@@ -997,6 +997,14 @@ static void verity_io_hints(struct dm_target *ti, struct queue_limits *limits)
 		limits->physical_block_size = 1 << v->data_dev_block_bits;
 
 	blk_limits_io_min(limits, limits->logical_block_size);
+
+	/*
+	 * Similar to what dm-crypt does, opt dm-verity out of support for
+	 * direct I/O that is aligned to less than the traditional direct I/O
+	 * alignment requirement of logical_block_size.  This prevents dm-verity
+	 * data blocks from crossing pages, eliminating various edge cases.
+	 */
+	limits->dma_alignment = limits->logical_block_size - 1;
 }
 
 static void verity_dtr(struct dm_target *ti)