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] [day] [month] [year] [list]
Date:   Mon, 29 Jul 2019 11:16:42 -0400
From:   Qian Cai <cai@....pw>
To:     David Laight <David.Laight@...LAB.COM>,
        "vyasevich@...il.com" <vyasevich@...il.com>,
        "nhorman@...driver.com" <nhorman@...driver.com>,
        "marcelo.leitner@...il.com" <marcelo.leitner@...il.com>
Cc:     "linux-sctp@...r.kernel.org" <linux-sctp@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] net/sctp: fix GCC8+ -Wpacked-not-aligned warnings

On Mon, 2019-07-29 at 10:39 +0000, David Laight wrote:
> From: Qian Cai
> > Sent: 26 July 2019 21:58
> > 
> > There are a lot of those warnings with GCC8+ 64bit,
> > 
> 
> ...
> > Fix them by aligning the structures and fields to 8 bytes instead.
> 
> ...
> >  struct sctp_setpeerprim {
> >  	sctp_assoc_t            sspp_assoc_id;
> > -	struct sockaddr_storage sspp_addr;
> > -} __attribute__((packed, aligned(4)));
> > +	struct sockaddr_storage sspp_addr __attribute__((aligned(8)));
> > +} __attribute__((packed, aligned(8)));
> 
> What happens to this one if you change both to aligned(4) ?
> Much the same way as:
> 	struct {
> 		int a;
> 		long b __attribute__((aligned(4));
> 	};
> is only 12 bytes on (most) 64bit systems.

No, that won't work. It because that,

#define sockaddr_storage __kernel_sockaddr_storage

struct __kernel_sockaddr_storage {
...
} __attribute__ ((aligned(_K_SS_ALIGNSIZE)))

#define _K_SS_ALIGNSIZE	(__alignof__ (struct sockaddr *))

A pointer is 8-byte on 64-bit systems. If changed "struct
__kernel_sockaddr_storage" to use,

__attribute__ ((aligned((4)))

it then silence the warnings.

Powered by blists - more mailing lists