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:	Fri, 21 Jan 2011 16:05:03 -0800 (PST)
From:	David Miller <davem@...emloft.net>
To:	mathieu.desnoyers@...icios.com
Cc:	linux-kernel@...r.kernel.org, rostedt@...dmis.org,
	fweisbec@...il.com, mingo@...e.hu, richm@...elvet.org.uk,
	ben@...adent.org.uk, sparclinux@...r.kernel.org
Subject: Re: [patch 1/3] introduce __u64_aligned and U64_ALIGN() for
 structure alignment in custom sections (v3)

From: Mathieu Desnoyers <mathieu.desnoyers@...icios.com>
Date: Fri, 21 Jan 2011 15:36:31 -0500

> Problem description:
> 
> gcc happily align on 32-byte structures defined statically. Ftrace trace events
> and Tracepoints both statically define structures into custom sections (using
> the "section" attribute), to then assign these to symbols with the linker
> scripts to iterate the these sections as an array.
> 
> However, gcc uses different alignments for these structures when they are
> defined statically than when they are globally visible and/or in an array.
> Therefore iteration on these arrays sees "holes" of padding. gcc is within its
> rights to increase the alignment of the statically defined structures because,
> normally, there should be no other accesses to them than in the local object. We
> are actually iterating on the generated structures as if they were an array
> without letting gcc knowing anything about it.
> 
> This patch introduces __u64_aligned to force gcc to use the u64 type and
> variable alignment, up-aligning or down-aligning the target type if necessary.
> The memory accesses to the target structure are efficient (does not require
> bytewise memory accesses) and the atomic pointer update guarantees required by
> RCU are kept. u64 is considered as the largest type that can generate a trap for
> unaligned accesses (u64 on sparc32 needs to be aligned on 64-bit).
> 
> This alignment should be used for both structure definitions and declarations
> (as *both* the type and variable attribute) when using the "section"
> attribute to generate arrays of structures. Given that gcc only uses the type
> attribute "aligned" as a lower-bound for alignment, the structures should not
> contain types which require alignment larger than that of u64. The "aligned"
> variable attribute, on the other hand, forces gcc to use exactly the specified
> alignment.
> 
> Also introduce the linker script U64_ALIGN() macro for specification of custom
> section alignment that matches that of __u64_aligned.
> 
> Changelog since v2:
> - Drop the "packed" type attribute, because it causes gcc to drop the padding
>   between consecutive "int" and "pointer"/"long" fields, which leads to
>   unaligned accesses on sparc64.
> 
> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@...icios.com>

Acked-by: David S. Miller <davem@...emloft.net>
--
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