* [PATCH] dm-settings: fix a possible integer overflow in blk_queue_max_hw_sectors
@ 2020-11-20 9:55 Mikulas Patocka
0 siblings, 0 replies; only message in thread
From: Mikulas Patocka @ 2020-11-20 9:55 UTC (permalink / raw)
To: Jens Axboe, linux-block, dm-devel, Mike Snitzer, John Dorminy
Fix a possible overflow due to shift left.
Also, replace the constant "9" with SECTOR_SHIFT.
Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
---
block/blk-settings.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
Index: linux-2.6/block/blk-settings.c
===================================================================
--- linux-2.6.orig/block/blk-settings.c 2020-11-19 21:20:18.000000000 +0100
+++ linux-2.6/block/blk-settings.c 2020-11-20 10:50:15.000000000 +0100
@@ -151,8 +151,8 @@ void blk_queue_max_hw_sectors(struct req
struct queue_limits *limits = &q->limits;
unsigned int max_sectors;
- if ((max_hw_sectors << 9) < PAGE_SIZE) {
- max_hw_sectors = 1 << (PAGE_SHIFT - 9);
+ if (max_hw_sectors < 1 << (PAGE_SHIFT - SECTOR_SHIFT)) {
+ max_hw_sectors = 1 << (PAGE_SHIFT - SECTOR_SHIFT);
printk(KERN_INFO "%s: set to minimum %d\n",
__func__, max_hw_sectors);
}
@@ -161,7 +161,7 @@ void blk_queue_max_hw_sectors(struct req
max_sectors = min_not_zero(max_hw_sectors, limits->max_dev_sectors);
max_sectors = min_t(unsigned int, max_sectors, BLK_DEF_MAX_SECTORS);
limits->max_sectors = max_sectors;
- q->backing_dev_info->io_pages = max_sectors >> (PAGE_SHIFT - 9);
+ q->backing_dev_info->io_pages = max_sectors >> (PAGE_SHIFT - SECTOR_SHIFT);
}
EXPORT_SYMBOL(blk_queue_max_hw_sectors);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-11-20 9:55 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-20 9:55 [PATCH] dm-settings: fix a possible integer overflow in blk_queue_max_hw_sectors Mikulas Patocka
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).