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 <[email protected]>
Reviewed-by: Christoph Hellwig <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
This commit is contained in:
Caleb Sander Mateos authored and Jens Axboe committed 2025-12-18 09:51:49 -07:00
1 parent ccb8a3c08a
commit af65faf34f
1 file changed
+6 -1
+6 -1
View File
@@ -193,8 +193,13 @@ static int blk_validate_integrity_limits(struct queue_limits *lim)
break;
}
if (!bi->interval_exp)
if (!bi->interval_exp) {
bi->interval_exp = ilog2(lim->logical_block_size);
} else if (bi->interval_exp < SECTOR_SHIFT ||
bi->interval_exp > ilog2(lim->logical_block_size)) {
pr_warn("invalid interval_exp %u\n", bi->interval_exp);
return -EINVAL;
}
/*
* The PI generation / validation helpers do not expect intervals to