Skip to content

Commit b284396

Browse files
johnpgarrykawasaki
authored andcommitted
block: sanitize chunk_sectors for atomic write limits
Currently we just ensure that a non-zero value in chunk_sectors aligns with any atomic write boundary, as the blk boundary functionality uses both these values. However it is also improper to have atomic write unit max > chunk_sectors (for non-zero chunk_sectors), as this would lead to splitting of atomic write bios (which is disallowed). Sanitize atomic write unit max against chunk_sectors to avoid any potential problems. Fixes: d00eea9 ("block: Add extra checks in blk_validate_atomic_write_limits()") Reviewed-by: Nilay Shroff <[email protected]> Signed-off-by: John Garry <[email protected]>
1 parent fa535f7 commit b284396

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

block/blk-settings.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,7 @@ static void blk_atomic_writes_update_limits(struct queue_limits *lim)
180180

181181
static void blk_validate_atomic_write_limits(struct queue_limits *lim)
182182
{
183+
unsigned long long chunk_bytes;
183184
unsigned int boundary_sectors;
184185

185186
if (!(lim->features & BLK_FEAT_ATOMIC_WRITES))
@@ -202,6 +203,13 @@ static void blk_validate_atomic_write_limits(struct queue_limits *lim)
202203
lim->atomic_write_hw_max))
203204
goto unsupported;
204205

206+
chunk_bytes = lim->chunk_sectors << SECTOR_SHIFT;
207+
if (chunk_bytes) {
208+
if (WARN_ON_ONCE(lim->atomic_write_hw_unit_max >
209+
chunk_bytes))
210+
goto unsupported;
211+
}
212+
205213
boundary_sectors = lim->atomic_write_hw_boundary >> SECTOR_SHIFT;
206214

207215
if (boundary_sectors) {

0 commit comments

Comments
 (0)