lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Tue, 12 Jan 2021 23:55:02 +0800 From: Li Feng <fengli@...rtx.com> To: Jens Axboe <axboe@...nel.dk>, linux-block@...r.kernel.org (open list:BLOCK LAYER), linux-kernel@...r.kernel.org (open list) Cc: lifeng1519@...il.com, Li Feng <fengli@...rtx.com> Subject: [PATCH v2] blk: avoid divide-by-zero with zero granularity If the physical_block_size and io_min is less than a sector, the 'granularity >> SECTOR_SHIFT' will be zero. Signed-off-by: Li Feng <fengli@...rtx.com> --- include/linux/blkdev.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index f94ee3089e01..ffffb04ad113 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1485,7 +1485,11 @@ static inline int queue_alignment_offset(const struct request_queue *q) static inline int queue_limit_alignment_offset(struct queue_limits *lim, sector_t sector) { unsigned int granularity = max(lim->physical_block_size, lim->io_min); - unsigned int alignment = sector_div(sector, granularity >> SECTOR_SHIFT) + unsigned int alignment; + if (granularity >> SECTOR_SHIFT == 0) + return 0; + + alignment = sector_div(sector, granularity >> SECTOR_SHIFT) << SECTOR_SHIFT; return (granularity + lim->alignment_offset - alignment) % granularity; -- 2.29.2
Powered by blists - more mailing lists