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:	Tue, 24 Dec 2013 11:35:45 +0800
From:	Chen Gang <gang.chen.5i5j@...il.com>
To:	"Nicholas A. Bellinger" <nab@...ux-iscsi.org>
CC:	James Hogan <james.hogan@...tec.com>, linux-scsi@...r.kernel.org,
	target-devel@...r.kernel.org,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	hare@...e.de, Fengguang Wu <fengguang.wu@...el.com>
Subject: Re: [PATCH] drivers: target: target_core_mod: use div64_u64_rem()
 instead of operator '%' for u64

On 12/23/2013 02:51 PM, Nicholas A. Bellinger wrote:
> On Sun, 2013-12-22 at 17:17 +0800, Chen Gang wrote:
>> On 12/22/2013 10:56 AM, Nicholas A. Bellinger wrote:
>>> Hi Chen,
>>>
>>> On Sat, 2013-12-21 at 10:08 +0800, Chen Gang wrote:
>>>> In kernel, need use div64_u64_rem() instead of operator '%' for u64, or
>>>> can not pass compiling (with allmodconfig under metag):
>>>>
>>>>     MODPOST 2909 modules
>>>>   ERROR: "__umoddi3" [drivers/target/target_core_mod.ko] undefined!
>>>>
>>>> Also need u64 type cast for u32 variable multiply u32 variable, or will
>>>> cause type overflow issue.
>>>>
>>>>
>>>> Signed-off-by: Chen Gang <gang.chen.5i5j@...il.com>
>>>> ---
>>>>  drivers/target/target_core_alua.c | 3 ++-
>>>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>>>
>>>
>>> FYI, this unsigned long long division in core_alua_state_lba_dependent()
>>> was fixed for 32-bit in linux-next >= 12192013 code.
>>>
>>
>> OK, thanks.
>>
>> The related fix patch changed "start_lba = lba % ..." to "start_lba =
>> lba / ...", and also assumed "segment_size * segment_mult" is still
>> within u32 (can not cause type over flow).
>>
>> I guess the original author already knew about them, and intended to do
>> like that (if not, please let me know, thanks).
>>
> 
> Sorry, your correct that the original code is using modulo division to
> calculate start_lba.
> 

Oh, that's all right, (in fact, don't need sorry), I am not quite
familiar with the details, so need related member help check it.  :-)

> Hannes, can you please double check this below..?
> 

Please help check when have time, thanks.


> Thank you,
> 
> --nab
> 
>>>
>>>> diff --git a/drivers/target/target_core_alua.c b/drivers/target/target_core_alua.c
>>>> index dc0d399..ff2aadc 100644
>>>> --- a/drivers/target/target_core_alua.c
>>>> +++ b/drivers/target/target_core_alua.c
>>>> @@ -489,7 +489,8 @@ static inline int core_alua_state_lba_dependent(
>>>>  			u64 first_lba = map->lba_map_first_lba;
>>>>  
>>>>  			if (segment_mult) {
>>>> -				start_lba = lba % (segment_size * segment_mult);
>>>> +				u64 tmp = (u64)segment_size * segment_mult;
>>>> +				div64_u64_rem(lba, tmp, &start_lba);
>>>>  				last_lba = first_lba + segment_size - 1;
>>>>  				if (start_lba >= first_lba &&
>>>>  				    start_lba <= last_lba) {
>>>
>>>
>>
>>
> 
> 


-- 
Chen Gang

Open, share and attitude like air, water and life which God blessed
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ