lkml.org 
[lkml]   [2016]   [Sep]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] fs/proc/kcore.c: Omit kernel text area for hardened usercopy feature
On Wed, Sep 07, 2016 at 09:58:01AM -0700, Linus Torvalds wrote:
> On Wed, Sep 7, 2016 at 9:38 AM, Andi Kleen <andi@firstfloor.org> wrote:
> >>
> >> - 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.
>
> 'start' and 'tsz' is already chunked to be aligned pages (well, as
> aligned as they can be: the beginning and end obviously won't be).
> Above the loop:
>
> if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
> tsz = buflen;
>
> and then inside the loop:
>
> tsz = (buflen > PAGE_SIZE ? PAGE_SIZE : buflen);
>
> so it's already limited to one page.
>
> That said, it *might* be worth moving the temporary allocation to the
> top, or even to move it to open_kcore(). It used to be a special case
> for just the vmalloc region, now it's always done.
>
> So instead of having two different copies of the same special case for
> the two different cases, why not try to unify them and just have one
> common (page-sized) buffer allocation?

ook, sounds good.. will repost soon

jirka

\
 
 \ /
  Last update: 2016-09-17 09:58    [W:0.124 / U:0.172 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site