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>
pull/1354/merge
Caleb Sander Mateos 2025-12-16 22:34:35 -07:00 committed by Jens Axboe
parent c9b5645fd8
commit ccb8a3c08a
1 changed files with 3 additions and 4 deletions

View File

@ -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;
}