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  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Tue, 4 Feb 2020 09:21:28 +0800
From:   Zhiqiang Liu <liuzhiqiang26@...wei.com>
To:     Ming Lei <ming.lei@...hat.com>
CC:     Jens Axboe <axboe@...nel.dk>, <linux-block@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        Mingfangsen <mingfangsen@...wei.com>, Guiyao <guiyao@...wei.com>,
        Louhongxiang <louhongxiang@...wei.com>
Subject: Re: [PATCH V4] brd: check and limit max_part par



On 2020/2/3 20:26, Ming Lei wrote:
> On Tue, Jan 21, 2020 at 12:04:41PM +0800, Zhiqiang Liu wrote:
>>
>> In brd_init func, rd_nr num of brd_device are firstly allocated
>> and add in brd_devices, then brd_devices are traversed to add each
>> brd_device by calling add_disk func. When allocating brd_device,
>> the disk->first_minor is set to i * max_part, if rd_nr * max_part
>> is larger than MINORMASK, two different brd_device may have the same
>> devt, then only one of them can be successfully added.
>> when rmmod brd.ko, it will cause oops when calling brd_exit.
>>

>> +static inline void brd_check_and_reset_par(void)
>> +{
>> +	if (unlikely(!max_part))
>> +		max_part = 1;
>> +
>> +	if (max_part > DISK_MAX_PARTS) {
>> +		pr_info("brd: max_part can't be larger than %d, reset max_part = %d.\n",
>> +			DISK_MAX_PARTS, DISK_MAX_PARTS);
>> +		max_part = DISK_MAX_PARTS;
>> +	}
>> +
>> +	/*
>> +	 * make sure 'max_part' can be divided exactly by (1U << MINORBITS),
>> +	 * otherwise, it is possiable to get same dev_t when adding partitions.
>> +	 */
>> +	if ((1U << MINORBITS) % max_part != 0)
>> +		max_part = 1UL << fls(max_part);
>> +}
> 
> You should move the above change before capping it to DISK_MAX_PARTS
> since  1UL << fls() may increase 'max_part'.
> 
Thanks for your suggestion. I will send the v5 patch.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ