Skip to content

Commit 31f2f08

Browse files
johnpgarrygregkh
authored andcommitted
block: avoid possible overflow for chunk_sectors check in blk_stack_limits()
[ Upstream commit 448dfec ] In blk_stack_limits(), we check that the t->chunk_sectors value is a multiple of the t->physical_block_size value. However, by finding the chunk_sectors value in bytes, we may overflow the unsigned int which holds chunk_sectors, so change the check to be based on sectors. Reviewed-by: Hannes Reinecke <hare@suse.de> Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: John Garry <john.g.garry@oracle.com> Reviewed-by: Damien Le Moal <dlemoal@kernel.org> Link: https://lore.kernel.org/r/20250729091448.1691334-2-john.g.garry@oracle.com Signed-off-by: Jens Axboe <axboe@kernel.dk> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent a8aa5cb commit 31f2f08

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

block/blk-settings.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,
628628
}
629629

630630
/* chunk_sectors a multiple of the physical block size? */
631-
if ((t->chunk_sectors << 9) & (t->physical_block_size - 1)) {
631+
if (t->chunk_sectors % (t->physical_block_size >> SECTOR_SHIFT)) {
632632
t->chunk_sectors = 0;
633633
t->misaligned = 1;
634634
ret = -1;

0 commit comments

Comments
 (0)