Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

block: Add extra checks in blk_validate_atomic_write_limits()

It is so far expected that the limits passed are valid.

In future atomic writes will be supported for stacked block devices, and
calculating the limits there will be complicated, so add extra sanity
checks to ensure that the values are always valid.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Link: https://lore.kernel.org/r/20241118105018.1870052-2-john.g.garry@oracle.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>

authored by

John Garry and committed by
Jens Axboe
d00eea91 34c12270

+17
+17
block/blk-settings.c
··· 178 178 if (!lim->atomic_write_hw_max) 179 179 goto unsupported; 180 180 181 + if (WARN_ON_ONCE(!is_power_of_2(lim->atomic_write_hw_unit_min))) 182 + goto unsupported; 183 + 184 + if (WARN_ON_ONCE(!is_power_of_2(lim->atomic_write_hw_unit_max))) 185 + goto unsupported; 186 + 187 + if (WARN_ON_ONCE(lim->atomic_write_hw_unit_min > 188 + lim->atomic_write_hw_unit_max)) 189 + goto unsupported; 190 + 191 + if (WARN_ON_ONCE(lim->atomic_write_hw_unit_max > 192 + lim->atomic_write_hw_max)) 193 + goto unsupported; 194 + 181 195 boundary_sectors = lim->atomic_write_hw_boundary >> SECTOR_SHIFT; 182 196 183 197 if (boundary_sectors) { 198 + if (WARN_ON_ONCE(lim->atomic_write_hw_max > 199 + lim->atomic_write_hw_boundary)) 200 + goto unsupported; 184 201 /* 185 202 * A feature of boundary support is that it disallows bios to 186 203 * be merged which would result in a merged request which