From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758045AbcIGQi5 (ORCPT ); Wed, 7 Sep 2016 12:38:57 -0400 Received: from one.firstfloor.org ([193.170.194.197]:57317 "EHLO one.firstfloor.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756223AbcIGQiz (ORCPT ); Wed, 7 Sep 2016 12:38:55 -0400 Date: Wed, 7 Sep 2016 09:38:52 -0700 From: Andi Kleen To: Jiri Olsa Cc: Kees Cook , Andi Kleen , Jiri Olsa , lkml , Ingo Molnar , Adrian Hunter , KAMEZAWA Hiroyuki , Linus Torvalds Subject: Re: [PATCH] fs/proc/kcore.c: Omit kernel text area for hardened usercopy feature Message-ID: <20160907163852.GQ5871@two.firstfloor.org> References: <1472819145-27260-1-git-send-email-jolsa@kernel.org> <20160902151713.GM5871@two.firstfloor.org> <20160905084722.GA3134@krava> <20160907073257.GB8619@krava> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160907073257.GB8619@krava> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > --- > diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c > index a939f5ed7f89..de07c273f725 100644 > --- a/fs/proc/kcore.c > +++ b/fs/proc/kcore.c > @@ -515,8 +515,20 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos) > } else { > if (kern_addr_valid(start)) { > unsigned long n; > + char *buf; > > - n = copy_to_user(buffer, (char *)start, tsz); > + buf = kzalloc(tsz, GFP_KERNEL); You have to add some limit and a loop, otherwise a user can eat all kernel memory, or copies > KMALLOC_MAX wouldn't work. Probably only get a single page. Also don't need kzalloc, kmalloc is sufficient. -Andi