linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fs/proc/kcore.c: Omit kernel text area for hardened usercopy feature
@ 2016-09-02 12:25 Jiri Olsa
  2016-09-02 15:17 ` Andi Kleen
  0 siblings, 1 reply; 17+ messages in thread
From: Jiri Olsa @ 2016-09-02 12:25 UTC (permalink / raw)
  To: lkml
  Cc: Kees Cook, Ingo Molnar, Adrian Hunter, Andi Kleen,
	KAMEZAWA Hiroyuki, Linus Torvalds

One of the bullets for hardened usercopy feature is:
  - object must not overlap with kernel text

which is what we expose via /proc/kcore. We can hit
this check and crash the system very easily just by
reading the text area in kcore file:

  usercopy: kernel memory exposure attempt detected from ffffffff8179a01f (<kernel text>) (4065 bytes)
  kernel BUG at mm/usercopy.c:75!

Omitting kernel text area from kcore when there's
hardened usercopy feature is enabled.

Fixes: f5509cc18daa ("mm: Hardened usercopy")
Reported-by: Steve Best <sbest@redhat.com>
Cc: Kees Cook <keescook@chromium.org>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
 fs/proc/kcore.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
index a939f5ed7f89..e322d4e0be4d 100644
--- a/fs/proc/kcore.c
+++ b/fs/proc/kcore.c
@@ -629,8 +629,12 @@ static int __init proc_kcore_init(void)
 		pr_err("couldn't create /proc/kcore\n");
 		return 0; /* Always returns 0. */
 	}
+
+#ifndef CONFIG_HARDENED_USERCOPY
 	/* Store text area if it's special */
 	proc_kcore_text_init();
+#endif
+
 	/* Store vmalloc area */
 	kclist_add(&kcore_vmalloc, (void *)VMALLOC_START,
 		VMALLOC_END - VMALLOC_START, KCORE_VMALLOC);
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2016-09-07 22:52 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-02 12:25 [PATCH] fs/proc/kcore.c: Omit kernel text area for hardened usercopy feature Jiri Olsa
2016-09-02 15:17 ` Andi Kleen
2016-09-02 16:15   ` Jiri Olsa
2016-09-05  8:47   ` Jiri Olsa
2016-09-05 16:27     ` Andi Kleen
2016-09-06 17:56     ` Kees Cook
2016-09-06 18:34       ` Linus Torvalds
2016-09-06 19:41         ` Andi Kleen
2016-09-06 19:48           ` Linus Torvalds
2016-09-07 17:17             ` Kees Cook
2016-09-07 17:24               ` Linus Torvalds
2016-09-07  7:32       ` Jiri Olsa
2016-09-07 16:38         ` Andi Kleen
2016-09-07 16:58           ` Linus Torvalds
2016-09-07 19:25             ` Jiri Olsa
2016-09-07 21:24               ` Jiri Olsa
2016-09-07 22:52                 ` Linus Torvalds

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).