Skip to content

Commit ccb8a3c

Browse files
calebsanderaxboe
authored andcommitted
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>
1 parent c9b5645 commit ccb8a3c

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

block/blk-settings.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,10 +161,9 @@ static int blk_validate_integrity_limits(struct queue_limits *lim)
161161
return -EINVAL;
162162
}
163163

164-
if (bi->pi_tuple_size > bi->metadata_size) {
165-
pr_warn("pi_tuple_size (%u) exceeds metadata_size (%u)\n",
166-
bi->pi_tuple_size,
167-
bi->metadata_size);
164+
if (bi->pi_offset + bi->pi_tuple_size > bi->metadata_size) {
165+
pr_warn("pi_offset (%u) + pi_tuple_size (%u) exceeds metadata_size (%u)\n",
166+
bi->pi_offset, bi->pi_tuple_size, bi->metadata_size);
168167
return -EINVAL;
169168
}
170169

0 commit comments

Comments
 (0)