[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20160713170048.GA24553@redhat.com>
Date: Wed, 13 Jul 2016 19:00:49 +0200
From: Oleg Nesterov <oleg@...hat.com>
To: Kees Cook <keescook@...omium.org>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
Hector Marco-Gisbert <hecmargi@....es>,
Ismael Ripoll Ripoll <iripoll@....es>,
Alexander Viro <viro@...iv.linux.org.uk>,
"Kirill A. Shutemov" <kirill.shutemov@...ux.intel.com>,
Chen Gang <gang.chen.5i5j@...il.com>,
Michal Hocko <mhocko@...e.com>,
Konstantin Khlebnikov <koct9i@...il.com>,
Andrea Arcangeli <aarcange@...hat.com>,
Andrey Ryabinin <aryabinin@...tuozzo.com>,
"linux-fsdevel@...r.kernel.org" <linux-fsdevel@...r.kernel.org>,
Linux-MM <linux-mm@...ck.org>,
LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 2/2] mm: refuse wrapped vm_brk requests
On 07/12, Kees Cook wrote:
>
> On Tue, Jul 12, 2016 at 9:39 AM, Oleg Nesterov <oleg@...hat.com> wrote:
> >
> > I tried to say that, with or without this change, sys_brk() should check
> > for overflow too, otherwise it looks buggy.
>
> Hmm, it's not clear to me the right way to fix sys_brk(), but it looks
> like my change to do_brk() would catch the problem?
How?
Once again, afaics nothing bad can happen, sys_brk() will silently fail,
just the code looks wrong anyway.
Suppose that newbrk == 0 due to overflow, then both
if (find_vma_intersection(mm, oldbrk, newbrk+PAGE_SIZE))
goto out;
and
if (do_brk(oldbrk, newbrk-oldbrk) < 0)
goto out;
look buggy.
find_vma_intersection(start_addr, end_addr) expects that start_addr < end_addr.
Again, we do not really care if it returns NULL or not, and newbrk == 0 just
means it will certainly return NULL if there is something above oldbrk. Just
looks buggy/confusing.
do_brk(0 - oldbrk) will fail and this is what we want. But not because
your change will catch the problem, PAGE_ALIGNE(-oldbrk) won't necessarily
overflow. However, -oldbrk > TASK_SIZE so get_unmapped_area() should fail.
Nevermind, this is almost off-topic, so let me repeat just in case that
both patches look good to me.
Oleg.
Powered by blists - more mailing lists