Skip to content

Commit 437659c

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 34613ea commit 437659c

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

block/blk-settings.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,8 @@ static void blk_atomic_writes_update_limits(struct queue_limits *lim)
181181
static void blk_validate_atomic_write_limits(struct queue_limits *lim)
182182
{
183183
unsigned int boundary_sectors;
184+
unsigned int atomic_write_hw_max_sectors =
185+
lim->atomic_write_hw_max >> SECTOR_SHIFT;
184186

185187
if (!(lim->features & BLK_FEAT_ATOMIC_WRITES))
186188
goto unsupported;
@@ -202,6 +204,10 @@ static void blk_validate_atomic_write_limits(struct queue_limits *lim)
202204
lim->atomic_write_hw_max))
203205
goto unsupported;
204206

207+
if (WARN_ON_ONCE(lim->chunk_sectors &&
208+
atomic_write_hw_max_sectors > lim->chunk_sectors))
209+
goto unsupported;
210+
205211
boundary_sectors = lim->atomic_write_hw_boundary >> SECTOR_SHIFT;
206212

207213
if (boundary_sectors) {

0 commit comments

Comments
 (0)