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] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 7 Sep 2022 02:43:47 +0000
From:   Chaitanya Kulkarni <chaitanyak@...dia.com>
To:     Damien Le Moal <damien.lemoal@...nsource.wdc.com>,
        Dennis Maisenbacher <Dennis.Maisenbacher@....com>,
        "linux-nvme@...ts.infradead.org" <linux-nvme@...ts.infradead.org>
CC:     Niklas Cassel <niklas.cassel@....com>,
        Christoph Hellwig <hch@....de>,
        Sagi Grimberg <sagi@...mberg.me>,
        Damien Le Moal <damien.lemoal@....com>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2] nvmet: fix mar and mor off-by-one errors


>>>    	if (le32_to_cpu(req->cmd->identify.nsid) == NVME_NSID_ALL) {
>>>    		req->error_loc = offsetof(struct nvme_identify, nsid);
>>> @@ -130,8 +131,20 @@ void nvmet_execute_identify_cns_cs_ns(struct nvmet_req *req)
>>>    	zsze = (bdev_zone_sectors(req->ns->bdev) << 9) >>
>>>    					req->ns->blksize_shift;
>>>    	id_zns->lbafe[0].zsze = cpu_to_le64(zsze);
>>> -	id_zns->mor = cpu_to_le32(bdev_max_open_zones(req->ns->bdev));
>>> -	id_zns->mar = cpu_to_le32(bdev_max_active_zones(req->ns->bdev));
>>> +
>>> +	mor = bdev_max_open_zones(req->ns->bdev);
>>> +	if (!mor)
>>> +		mor = U32_MAX;
>>> +	else
>>> +		--mor;
>>> +	id_zns->mor = cpu_to_le32(mor);
>>> +
>>> +	mar = bdev_max_active_zones(req->ns->bdev);
>>> +	if (!mar)
>>> +		mar = U32_MAX;
>>> +	else
>>> +		--mar;
>>> +	id_zns->mar = cpu_to_le32(mar);
>>>    
>>
>> above 14 lines of code can be simplified as in 4-5 lines :-
> 
> Simplified ? It is much harder to read in my opinion...
> 
>>

there are two if ... else ... doing identical things on same data
type u32 and its return type is also same le32,
if my suggestion is hard to read then common code needs
to be moved to the helper as it is not clear the need for
code duplication from commit message.

-ck

Powered by blists - more mailing lists