Skip to content

Commit af65faf

Browse files
calebsanderaxboe
authored andcommitted
block: validate interval_exp integrity limit
Various code assumes that the integrity interval is at least 1 sector and evenly divides the logical block size. Add these checks to blk_validate_integrity_limits(). This guards against block drivers that report invalid interval_exp 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 ccb8a3c commit af65faf

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

block/blk-settings.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,13 @@ static int blk_validate_integrity_limits(struct queue_limits *lim)
193193
break;
194194
}
195195

196-
if (!bi->interval_exp)
196+
if (!bi->interval_exp) {
197197
bi->interval_exp = ilog2(lim->logical_block_size);
198+
} else if (bi->interval_exp < SECTOR_SHIFT ||
199+
bi->interval_exp > ilog2(lim->logical_block_size)) {
200+
pr_warn("invalid interval_exp %u\n", bi->interval_exp);
201+
return -EINVAL;
202+
}
198203

199204
/*
200205
* The PI generation / validation helpers do not expect intervals to

0 commit comments

Comments
 (0)