Skip to content

Commit 530ec35

Browse files
calebsandergregkh
authored andcommitted
block: validate pi_offset integrity limit
[ Upstream commit ccb8a3c ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 79dd3f1 commit 530ec35

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
@@ -148,10 +148,9 @@ static int blk_validate_integrity_limits(struct queue_limits *lim)
148148
return -EINVAL;
149149
}
150150

151-
if (bi->pi_tuple_size > bi->metadata_size) {
152-
pr_warn("pi_tuple_size (%u) exceeds metadata_size (%u)\n",
153-
bi->pi_tuple_size,
154-
bi->metadata_size);
151+
if (bi->pi_offset + bi->pi_tuple_size > bi->metadata_size) {
152+
pr_warn("pi_offset (%u) + pi_tuple_size (%u) exceeds metadata_size (%u)\n",
153+
bi->pi_offset, bi->pi_tuple_size, bi->metadata_size);
155154
return -EINVAL;
156155
}
157156

0 commit comments

Comments
 (0)