[PATCH 01/20] block: validate pi_offset integrity limit

Caleb Sander Mateos posted 20 patches 1 day, 17 hours ago
[PATCH 01/20] block: validate pi_offset integrity limit
Posted by Caleb Sander Mateos 1 day, 17 hours ago
The PI tuple must be contained within the metadata value, so validate
that pi_offset + pi_tuple_size <= metadata_size. This guards against
block drivers that report invalid pi_offset values.

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
---
 block/blk-settings.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/block/blk-settings.c b/block/blk-settings.c
index 51401f08ce05..d138abc973bb 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -159,14 +159,13 @@ static int blk_validate_integrity_limits(struct queue_limits *lim)
 	    (bi->flags & BLK_INTEGRITY_REF_TAG)) {
 		pr_warn("ref tag not support without checksum.\n");
 		return -EINVAL;
 	}
 
-	if (bi->pi_tuple_size > bi->metadata_size) {
-		pr_warn("pi_tuple_size (%u) exceeds metadata_size (%u)\n",
-			 bi->pi_tuple_size,
-			 bi->metadata_size);
+	if (bi->pi_offset + bi->pi_tuple_size > bi->metadata_size) {
+		pr_warn("pi_offset (%u) + pi_tuple_size (%u) exceeds metadata_size (%u)\n",
+			bi->pi_offset, bi->pi_tuple_size, bi->metadata_size);
 		return -EINVAL;
 	}
 
 	switch (bi->csum_type) {
 	case BLK_INTEGRITY_CSUM_NONE:
-- 
2.45.2
Re: [PATCH 01/20] block: validate pi_offset integrity limit
Posted by Christoph Hellwig 14 hours ago
On Tue, Dec 16, 2025 at 10:34:35PM -0700, Caleb Sander Mateos wrote:
> The PI tuple must be contained within the metadata value, so validate
> that pi_offset + pi_tuple_size <= metadata_size. This guards against
> block drivers that report invalid pi_offset values.

Looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>

Please send this to Jens as a fix ASAP.