From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753402AbcIBMZu (ORCPT ); Fri, 2 Sep 2016 08:25:50 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46798 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752414AbcIBMZs (ORCPT ); Fri, 2 Sep 2016 08:25:48 -0400 From: Jiri Olsa To: lkml Cc: Kees Cook , Ingo Molnar , Adrian Hunter , Andi Kleen , KAMEZAWA Hiroyuki , Linus Torvalds Subject: [PATCH] fs/proc/kcore.c: Omit kernel text area for hardened usercopy feature Date: Fri, 2 Sep 2016 14:25:45 +0200 Message-Id: <1472819145-27260-1-git-send-email-jolsa@kernel.org> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 02 Sep 2016 12:25:47 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 () (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 Cc: Kees Cook Signed-off-by: Jiri Olsa --- 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