[dm-devel] [PATCH] blk-lib: fix blkdev_issue_secure_erase

2022-09-14 Thread Mikulas Patocka
There's a bug in blkdev_issue_secure_erase. The statement "unsigned int len = min_t(sector_t, nr_sects, max_sectors);" sets the variable "len" to the length in sectors, but the statement "bio->bi_iter.bi_size = len" treats it as if it were in bytes. The statements "sector += len << SECTOR_SHIFT" an

Re: [dm-devel] [PATCH] blk-lib: fix blkdev_issue_secure_erase

2022-09-14 Thread Jens Axboe
On Wed, 14 Sep 2022 16:55:51 -0400 (EDT), Mikulas Patocka wrote: > There's a bug in blkdev_issue_secure_erase. The statement > "unsigned int len = min_t(sector_t, nr_sects, max_sectors);" > sets the variable "len" to the length in sectors, but the statement > "bio->bi_iter.bi_size = len" treats it

Re: [dm-devel] [PATCH] blk-lib: fix blkdev_issue_secure_erase

2022-09-20 Thread Christoph Hellwig
On Wed, Sep 14, 2022 at 04:55:51PM -0400, Mikulas Patocka wrote: > + /* make sure that "len << SECTOR_SHIFT" doesn't overflow */ > + if (max_sectors > UINT_MAX >> SECTOR_SHIFT) > + max_sectors = UINT_MAX >> SECTOR_SHIFT; This should use max / max_t: max_sectors = max(m