public inbox for kernel-hardening@lists.openwall.com
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: kernel-hardening@lists.openwall.com
Cc: Kees Cook <keescook@chromium.org>,
	Emese Revfy <re.emese@gmail.com>,
	linux-kernel@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>,
	Josh Triplett <josh@joshtriplett.org>,
	pageexec@freemail.hu, spender@grsecurity.net, mmarek@suse.com,
	yamada.masahiro@socionext.com, linux-kbuild@vger.kernel.org,
	minipli@ld-linux.so, linux@armlinux.org.uk,
	catalin.marinas@arm.com, linux@rasmusvillemoes.dk,
	david.brown@linaro.org, benh@kernel.crashing.org,
	tglx@linutronix.de, akpm@linux-foundation.org,
	jlayton@poochiereds.net, sam@ravnborg.org
Subject: [kernel-hardening] [PATCH v4 2/4] util: Move type casts into is_kernel_rodata
Date: Fri, 16 Dec 2016 14:06:22 -0800	[thread overview]
Message-ID: <1481925984-98605-3-git-send-email-keescook@chromium.org> (raw)
In-Reply-To: <1481925984-98605-1-git-send-email-keescook@chromium.org>

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

diff --git a/mm/util.c b/mm/util.c
index 1a41553db866..5606c6b74eee 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

  parent reply	other threads:[~2016-12-16 22:06 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-16 22:06 [kernel-hardening] [PATCH v4 0/4] Introduce the initify gcc plugin Kees Cook
2016-12-16 22:06 ` [kernel-hardening] [PATCH v4 1/4] gcc-plugins: Add " Kees Cook
2016-12-16 22:45   ` [kernel-hardening] " PaX Team
2016-12-16 23:02     ` Kees Cook
2016-12-16 23:15       ` PaX Team
2016-12-16 22:06 ` Kees Cook [this message]
2016-12-16 22:06 ` [kernel-hardening] [PATCH v4 3/4] initify: Mark functions with the __nocapture attribute Kees Cook
2016-12-16 22:06 ` [kernel-hardening] [PATCH v4 4/4] initify: Mark functions with the __unverified_nocapture attribute Kees Cook
2016-12-16 22:19 ` [kernel-hardening] Re: [PATCH v4 0/4] Introduce the initify gcc plugin Kees Cook
2016-12-19 11:10   ` Emese Revfy
2017-01-04  0:23     ` Kees Cook
2017-01-11  0:24       ` Emese Revfy
2017-01-11  1:09         ` Kees Cook
2017-01-12 21:41           ` Emese Revfy
2017-01-12 23:27             ` Kees Cook
2017-01-12 23:40               ` Kees Cook
2017-01-17 20:31                 ` Emese Revfy
2017-01-19  1:22                   ` Kees Cook
2017-02-15  0:23                 ` Emese Revfy
2017-02-15 19:27                   ` Kees Cook
2017-02-20 21:42                     ` Emese Revfy
2016-12-19 18:24 ` Laura Abbott
2017-01-04  0:23   ` Kees Cook

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1481925984-98605-3-git-send-email-keescook@chromium.org \
    --to=keescook@chromium.org \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=benh@kernel.crashing.org \
    --cc=catalin.marinas@arm.com \
    --cc=david.brown@linaro.org \
    --cc=jlayton@poochiereds.net \
    --cc=josh@joshtriplett.org \
    --cc=kernel-hardening@lists.openwall.com \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=linux@rasmusvillemoes.dk \
    --cc=minipli@ld-linux.so \
    --cc=mmarek@suse.com \
    --cc=pageexec@freemail.hu \
    --cc=re.emese@gmail.com \
    --cc=sam@ravnborg.org \
    --cc=spender@grsecurity.net \
    --cc=tglx@linutronix.de \
    --cc=yamada.masahiro@socionext.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox