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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 23 Jan 2014 14:32:35 -0500
From:	Richard Guy Briggs <rgb@...hat.com>
To:	linux-audit@...hat.com, linux-kernel@...r.kernel.org
Cc:	Richard Guy Briggs <rgb@...hat.com>, eparis@...hat.com,
	sgrubb@...hat.com, akpm@...ux-foundation.org, peterz@...radead.org,
	oleg@...hat.com
Subject: [PATCH 2/7] compiler: CONST_CAST makes writing const vars easier and obvious

There are vars that would benefit from making it more difficult or obvious to
overwrite by setting them to const.  This macro makes it easier to do so
avoiding typos while making it easier to find such instances.

Oleg Nesterov deserves full credit for this patch.

Cc: Oleg Nesterov <oleg@...hat.com>
Cc: Peter Zijlstra <peterz@...radead.org>
Signed-off-by: Richard Guy Briggs <rgb@...hat.com>
---
 include/linux/compiler.h |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index 92669cd..eaaf273 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -357,4 +357,12 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
 #else
 # define __kprobes
 #endif
+
+/* Make it easier to find and get right making a const writable */
+#define CONST_CAST(type, lval)			\
+	(*({					\
+		(void)((type *)0 == &(lval));	\
+		(type *)&(lval);		\
+	}))
+
 #endif /* __LINUX_COMPILER_H */
-- 
1.7.1

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