Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 31 Jan 2017 12:24:20 -0800
From: Kees Cook <keescook@...omium.org>
To: linux-kernel@...r.kernel.org
Cc: Kees Cook <keescook@...omium.org>,
	Emese Revfy <re.emese@...il.com>,
	Arnd Bergmann <arnd@...db.de>,
	Josh Triplett <josh@...htriplett.org>,
	pageexec@...email.hu,
	yamada.masahiro@...ionext.com,
	minipli@...linux.so,
	linux@...linux.org.uk,
	catalin.marinas@....com,
	linux@...musvillemoes.dk,
	david.brown@...aro.org,
	benh@...nel.crashing.org,
	tglx@...utronix.de,
	akpm@...ux-foundation.org,
	jlayton@...chiereds.net,
	sam@...nborg.org,
	kernel-hardening@...ts.openwall.com
Subject: [PATCH v5 2/4] util: Move type casts into is_kernel_rodata

From: Emese Revfy <re.emese@...il.com>

This moves type casts into the is_kernel_rodata() function itself so that
parameters can be marked as "nocapture" in the coming initify gcc plugin.

Signed-off-by: Emese Revfy <re.emese@...il.com>
[kees: expanded commit message]
Signed-off-by: Kees Cook <keescook@...omium.org>
---
 mm/util.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/mm/util.c b/mm/util.c
index 3cb2164f4099..a700e3fb1587 100644
--- a/mm/util.c
+++ b/mm/util.c
@@ -17,10 +17,10 @@
 
 #include "internal.h"
 
-static inline int is_kernel_rodata(unsigned long addr)
+static inline int is_kernel_rodata(const void *addr)
 {
-	return addr >= (unsigned long)__start_rodata &&
-		addr < (unsigned long)__end_rodata;
+	return (unsigned long)addr >= (unsigned long)__start_rodata &&
+		(unsigned long)addr < (unsigned long)__end_rodata;
 }
 
 /**
@@ -31,7 +31,7 @@ static inline int is_kernel_rodata(unsigned long addr)
  */
 void kfree_const(const void *x)
 {
-	if (!is_kernel_rodata((unsigned long)x))
+	if (!is_kernel_rodata(x))
 		kfree(x);
 }
 EXPORT_SYMBOL(kfree_const);
@@ -68,7 +68,7 @@ EXPORT_SYMBOL(kstrdup);
  */
 const char *kstrdup_const(const char *s, gfp_t gfp)
 {
-	if (is_kernel_rodata((unsigned long)s))
+	if (is_kernel_rodata(s))
 		return s;
 
 	return kstrdup(s, gfp);
-- 
2.7.4

Powered by blists - more mailing lists

Your e-mail address:

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.