summaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorCaleb Sander Mateos <csander@purestorage.com>2025-12-16 22:34:35 -0700
committerJens Axboe <axboe@kernel.dk>2025-12-18 09:51:49 -0700
commitccb8a3c08adf8121e2afb8e704f007ce99324d79 (patch)
tree4d1b4e66e43cb9dc77b0c7440840062cc34fbdeb /block
parentc9b5645fd8ca10f310e41b07540f98e6a9720f40 (diff)
block: validate pi_offset integrity limit
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> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block')
-rw-r--r--block/blk-settings.c7
1 files 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
@@ -161,10 +161,9 @@ static int blk_validate_integrity_limits(struct queue_limits *lim)
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;
}