From: Mikulas Patocka <mpatocka@redhat.com> To: Jens Axboe <axboe@kernel.dk>, linux-block@vger.kernel.org, dm-devel@redhat.com, Mike Snitzer <msnitzer@redhat.com>, John Dorminy <jdorminy@redhat.com> Subject: [PATCH] dm-settings: fix a possible integer overflow in blk_queue_max_hw_sectors Date: Fri, 20 Nov 2020 04:55:12 -0500 (EST) [thread overview] Message-ID: <alpine.LRH.2.02.2011200451180.28876@file01.intranet.prod.int.rdu2.redhat.com> (raw) 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);
WARNING: multiple messages have this Message-ID (diff)
From: Mikulas Patocka <mpatocka@redhat.com> To: Jens Axboe <axboe@kernel.dk>, linux-block@vger.kernel.org, dm-devel@redhat.com, Mike Snitzer <msnitzer@redhat.com>, John Dorminy <jdorminy@redhat.com> Subject: [dm-devel] [PATCH] dm-settings: fix a possible integer overflow in blk_queue_max_hw_sectors Date: Fri, 20 Nov 2020 04:55:12 -0500 (EST) [thread overview] Message-ID: <alpine.LRH.2.02.2011200451180.28876@file01.intranet.prod.int.rdu2.redhat.com> (raw) 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); -- dm-devel mailing list dm-devel@redhat.com https://www.redhat.com/mailman/listinfo/dm-devel
next reply other threads:[~2020-11-20 9:55 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-11-20 9:55 Mikulas Patocka [this message] 2020-11-20 9:55 ` [dm-devel] [PATCH] dm-settings: fix a possible integer overflow in blk_queue_max_hw_sectors Mikulas Patocka
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=alpine.LRH.2.02.2011200451180.28876@file01.intranet.prod.int.rdu2.redhat.com \ --to=mpatocka@redhat.com \ --cc=axboe@kernel.dk \ --cc=dm-devel@redhat.com \ --cc=jdorminy@redhat.com \ --cc=linux-block@vger.kernel.org \ --cc=msnitzer@redhat.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.