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] [day] [month] [year] [list]
Date:	Thu, 31 Jan 2013 15:21:14 -0800
From:	"H. Peter Anvin" <hpa@...or.com>
To:	Jon Pry <jonpry@...il.com>
CC:	linux-kernel@...r.kernel.org
Subject: Re: ABI violations eventually caused by short sighted coding style

On 01/31/2013 02:20 PM, Jon Pry wrote:
> 
> I believe changes should be made to the coding style forcing developers to take
> action. There are a couple of solutions I can think of:
> 
> 1. 	Put the unions at the beginning of structures if possible, or at least put
> 	them in a position that would ensure 8 byte offset from the beginning of
> 	the struct. Such as after a u64. Multiple unions should ensure the data[]
> 	of the preceding unions to be a multiple of 8 bytes.
> 2.  Require the data element to be declared as u64[size/8].
> 3.  Pack the ioctl structures
> 
> My preference is for the former since it does not cause any
> unnecessary padding.
> 

"The former" doesn't work when you are talking about a choice of three
elements.

packed structures are *very* expensive to use on some architectures, so
that is not a good solution.

In many, if not most cases, this is actually better handled by having
different ioctl numbers for each version/interface, but if you have to
make it self-contained, it makes most sense to make the common portion a
u64 or explicitly align the union to u64.

Another thing to keep in mind is that it often makes a lot more sense to
have a length member, and skip the problematic union.  That way a future
version of the kernel can simply memset() the part of the structure that
isn't initialized, and doesn't need a huge apparatus to keep track of
each individual version.

	-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