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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 03 Dec 2007 10:26:29 +0100
From:	Johannes Berg <johannes@...solutions.net>
To:	Daniel Drake <dsd@...too.org>
Cc:	linux-kernel@...r.kernel.org, avuton@...il.com, hancockr@...w.ca,
	alan@...rguk.ukuu.org.uk, andi@...stfloor.org, mrmacman_g4@....com,
	dean@...tic.org, argggh@...phinics.no, jengelh@...putergmbh.de,
	shdl@...alwe.fi, vlobanov@...akeasy.net, drzeus-list@...eus.cx,
	strange@....no-ip.org, dm.n9107@...il.com
Subject: Re: [RFC v2] Documentation about unaligned memory access


> 	void myfunc(u8 *data, u32 value)
> 	{
> 		[...]
> 		value = cpu_to_le32(value);
> 		put_unaligned(value, data);

> 	u32 value = get_unaligned(data);

Actually, this is wrong. put_unaligned and get_unaligned use the type of
the "data" pointer, e.g. on powerpc get_unaligned does just "*data".

Hence, here you'll want to use

	put_unaligned(value, (u32 *)data);

and

	u32 value = get_unaligned((u32 *)data);

or you end up with a single-byte store/load.

johannes

Download attachment "signature.asc" of type "application/pgp-signature" (829 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ