summaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorJohn Garry <john.g.garry@oracle.com>2025-07-29 09:14:47 +0000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-08-28 16:28:30 +0200
commit3b9d69f0e68aa6b0acd9791c45d445154a8c66e9 (patch)
tree3ecf8b997aa076f209cf499a46b03c9bfd687fe5 /block
parent1df5970cd93d9b1cc6fda92c7466dd08e229fe1f (diff)
downloadlinux-3b9d69f0e68aa6b0acd9791c45d445154a8c66e9.tar.gz
linux-3b9d69f0e68aa6b0acd9791c45d445154a8c66e9.tar.bz2
linux-3b9d69f0e68aa6b0acd9791c45d445154a8c66e9.zip
block: avoid possible overflow for chunk_sectors check in blk_stack_limits()
[ Upstream commit 448dfecc7ff807822ecd47a5c052acedca7d09e8 ] 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>
Diffstat (limited to 'block')
-rw-r--r--block/blk-settings.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/block/blk-settings.c b/block/blk-settings.c
index 7019b8e204d9..021994f6d2d8 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -634,7 +634,7 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,
}
/* chunk_sectors a multiple of the physical block size? */
- if ((t->chunk_sectors << 9) & (t->physical_block_size - 1)) {
+ if (t->chunk_sectors % (t->physical_block_size >> SECTOR_SHIFT)) {
t->chunk_sectors = 0;
t->misaligned = 1;
ret = -1;