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>] [day] [month] [year] [list]
Message-Id: <1226979552.6150.270.camel@brick>
Date:	Mon, 17 Nov 2008 19:39:12 -0800
From:	Harvey Harrison <harvey.harrison@...il.com>
To:	Andrew Morton <akpm@...ux-foundation.org>
Cc:	Linus Torvalds <torvalds@...ux-foundation.org>,
	Will Newton <will.newton@...il.com>,
	LKML <linux-kernel@...r.kernel.org>,
	Russell King <rmk@....linux.org.uk>,
	Hirokazu Takata <takata@...ux-m32r.org>,
	Yoshinori Sato <ysato@...rs.sourceforge.jp>
Subject: [PATCH-mm 5/7] unaligned: pack the struct, not the struct members

This is safe for the arches that currently use this as gcc says that
defining a struct as packed is equivalent to putting packed on each struct
member.

The reason this is needed is that there are some arches that define structs
to be aligned to something greater than a byte...so even if the first member
of the struct is marked as packed, gcc will still treat it as having the
default stuct alignment which will allow it to choose _builtin_memcpy...
see the comments in the memmove-using arches.  This also turned out to be
the issue with ARM (needs confirmation) because _some_ ARM compilers
have this alignment set to 4 bytes.

If the struct _itself_ is marked as packed, the compiler cannot assume this default
alignment and _must_ do the bytewise access in whatever way the arch does it.  By
making this change, the last 3 arches could move to the new asm-generic version
and the bits in linux/unaligned/ can be removed.

Signed-off-by: Harvey Harrison <harvey.harrison@...il.com>
---
 include/asm-generic/unaligned.h |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/include/asm-generic/unaligned.h b/include/asm-generic/unaligned.h
index 8dfca50..ac23e04 100644
--- a/include/asm-generic/unaligned.h
+++ b/include/asm-generic/unaligned.h
@@ -68,9 +68,9 @@ static inline void put_unaligned_be64(u64 val, void *p)
 
 #else /* _UNALIGNED_ACCESS_OK */
 
-struct __una_u16 { u16 x __attribute__((packed)); };
-struct __una_u32 { u32 x __attribute__((packed)); };
-struct __una_u64 { u64 x __attribute__((packed)); };
+struct __una_u16 { u16 x; } __attribute__((packed));
+struct __una_u32 { u32 x; } __attribute__((packed));
+struct __una_u64 { u64 x; } __attribute__((packed));
 
 static inline u16 __get_le16_noalign(const u8 *p)
 {
-- 
1.6.0.4.994.g16bd3e


--
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