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]
Message-Id: <20170221152405.7552-2-joakim.tjernlund@infinera.com>
Date:   Tue, 21 Feb 2017 16:24:05 +0100
From:   Joakim Tjernlund <joakim.tjernlund@...inera.com>
To:     linux-kernel@...r.kernel.org, stable@...r.kernel.org
Cc:     Joakim Tjernlund <joakim.tjernlund@...inera.com>
Subject: [PATCH 2/2] compiler.h: fix C++ uninitialized const issue

C++ does not like the union { typeof(x) __val; char __c[1]; } __u
construct for const types:
 error: uninitialized const member in
 'union atomic_read(const atomic_t*)::<anonymous>'
Address this by creating a C++ version of READ_ONCE where this union is
initialized: union { void _u(){}; typeof(x) __val; char __c[1]; } __u={0}

To please gcc 6.3.0 also add in a _u(){} as default ctor.

This makes C++ happy enough to build.

Signed-off-by: Joakim Tjernlund <joakim.tjernlund@...inera.com>
---
 include/linux/compiler.h | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index cf0fa5d..0a047fd 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -300,6 +300,7 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
  * required ordering.
  */
 
+#ifndef __cplusplus
 #define __READ_ONCE(x, check)						\
 ({									\
 	union { typeof(x) __val; char __c[1]; } __u;			\
@@ -309,6 +310,17 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s
 		__read_once_size_nocheck(&(x), __u.__c, sizeof(x));	\
 	__u.__val;							\
 })
+#else
+#define __READ_ONCE(x, check)						\
+({									\
+	union { void _u(){}; typeof(x) __val; char __c[1]; } __u={0};	\
+	if (check)							\
+		__read_once_size(&(x), __u.__c, sizeof(x));		\
+	else								\
+		__read_once_size_nocheck(&(x), __u.__c, sizeof(x));	\
+	__u.__val;							\
+})
+#endif
 #define READ_ONCE(x) __READ_ONCE(x, 1)
 
 /*
-- 
2.10.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ