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]
Message-ID: <477304C3.9060409@zytor.com>
Date:	Wed, 26 Dec 2007 17:49:55 -0800
From:	"H. Peter Anvin" <hpa@...or.com>
To:	Jan Engelhardt <jengelh@...putergmbh.de>
CC:	Pavel Machek <pavel@....cz>, Julia Lawall <julia@...u.dk>,
	tglx@...utronix.de, viro@....linux.org.uk,
	linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org
Subject: Re: [PATCH 1/3] arch/x86: Use offsetof

Jan Engelhardt wrote:
> On Dec 26 2007 17:01, H. Peter Anvin wrote:
>>>> @@ -215,7 +215,9 @@ asmlinkage int sys_vm86old(struct pt_reg
>>>>   ret = -EFAULT;
>>>>   if (tmp)
>>>> 		goto out;
>>>> -	memset(&info.vm86plus, 0, (int)&info.regs32 - (int)&info.vm86plus);
>>>> +	memset(&info.vm86plus, 0,
>>>> +	       offsetof(struct kernel_vm86_struct, regs32) -
>>>> +	       offsetof(struct kernel_vm86_struct, vm86plus));
>>> I do not think this makes it more readable... (int) -> (char *) would
>>> make it portable and readable, AFAICT.
>>>         Pavel
>> The right way to do it is:
>>
>> 	memset(&info.vm86plus, 0, sizeof info.vm86plus);
> 
> Either way, downcasting a pointer to (int) is dangerous,
> even if this one occurrence happens to be in 32-bit-only code.

Actually, it would be safe (although stupid) in this case since the 
difference would still be 32 bits or less.

Doesn't make it any less wrong.

	-hpa
--
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