Re: CVE-2014-9900 fix is not upstream

From: Lennart Sorensen
Date: Tue Aug 23 2016 - 16:59:44 EST


On Tue, Aug 23, 2016 at 01:34:05PM -0700, Joe Perches wrote:
> On Tue, 2016-08-23 at 21:09 +0100, Al Viro wrote:
> > On Tue, Aug 23, 2016 at 11:24:06AM -0700, David Miller wrote:
> > ... and then we can file a bug report against the sodding compiler.ÂÂNote
> > that
> > struct ethtool_wolinfo {
> > ÂÂÂÂÂÂÂÂ__u32ÂÂÂcmd;
> > ÂÂÂÂÂÂÂÂ__u32ÂÂÂsupported;
> > ÂÂÂÂÂÂÂÂ__u32ÂÂÂwolopts;
> > ÂÂÂÂÂÂÂÂ__u8ÂÂÂÂsopass[SOPASS_MAX]; // 6, actually
> > };
> > is not going to *have* padding.ÂÂNot on anything even remotely sane.
> > If array of 6 char as member of a struct requires 64bit alignment on some
> > architecture, I would really like some of what the designers of that ABI
> > must have been smoking.
>
> try this on x86-64
>
> $ pahole -C ethtool_wolinfo vmlinux
> struct ethtool_wolinfo {
> __u32ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂcmd;ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ/*ÂÂÂÂÂ0ÂÂÂÂÂ4 */
> __u32ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂsupported;ÂÂÂÂÂÂÂÂÂÂÂÂ/*ÂÂÂÂÂ4ÂÂÂÂÂ4 */
> __u32ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂwolopts;ÂÂÂÂÂÂÂÂÂÂÂÂÂÂ/*ÂÂÂÂÂ8ÂÂÂÂÂ4 */
> __u8ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂsopass[6];ÂÂÂÂÂÂÂÂÂÂÂÂ/*ÂÂÂÂ12ÂÂÂÂÂ6 */
>
> /* size: 20, cachelines: 1, members: 4 */
> /* padding: 2 */
> /* last cacheline: 20 bytes */
> };

That would be padding after the structure elements.

I think what was meant is that it won't add padding in the middle of the
structure due to alignment, ie it isn't doing:

struct ethtool_wolinfo {
__u32ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂcmd;ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ/*ÂÂÂÂÂ0ÂÂÂÂÂ4 */
__u32ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂsupported;ÂÂÂÂÂÂÂÂÂÂÂÂ/*ÂÂÂÂÂ4ÂÂÂÂÂ4 */
__u32ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂwolopts;ÂÂÂÂÂÂÂÂÂÂÂÂÂÂ/*ÂÂÂÂÂ8ÂÂÂÂÂ4 */
<4 bytes padding here>
__u8ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂsopass[6];ÂÂÂÂÂÂÂÂÂÂÂÂ/*ÂÂÂÂ16ÂÂÂÂÂ6 */
};

which would have 4 bytes of padding in the middle between wolopts
and sopass.

I would not think it is the compilers job to worry about what is after
your structure elements, since you shouldn't be going there.

--
Len Sorensen