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, 28 May 2014 08:45:52 +0000
From:	David Laight <David.Laight@...LAB.COM>
To:	'Cody P Schafer' <dev@...yps.com>,
	LKML <linux-kernel@...r.kernel.org>,
	Linux PPC <linuxppc-dev@...ts.ozlabs.org>
CC:	Sukadev Bhattiprolu <sukadev@...ux.vnet.ibm.com>
Subject: RE: [PATCH 11/16] byteorder: provide a linux/byteorder.h with {be,
 le}_to_cpu() and cpu_to_{be, le}() macros

From: Cody P Schafer
> Rather manually specifying the size of the integer to be converted, key
> off of the type size. Reduces duplicate size info and the occurance of
> certain types of bugs (using the wrong sized conversion).
...
> +#define be_to_cpu(v) \
> +	__builtin_choose_expr(sizeof(v) == sizeof(uint8_t) , v,	\
> +	__builtin_choose_expr(sizeof(v) == sizeof(uint16_t), be16_to_cpu(v), \
> +	__builtin_choose_expr(sizeof(v) == sizeof(uint32_t), be32_to_cpu(v), \
> +	__builtin_choose_expr(sizeof(v) == sizeof(uint64_t), be64_to_cpu(v), \
> +		(void)0))))
...

I'm not at all sure that using the 'size' of the constant will reduce
the number of bugs - it just introduces a whole new category of bugs.

Using the size of the destination might help, but that makes the code
ugly.

Getting one of the static analysers to find the obvious errors is
probably more appropriate.

	David

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ