Re: [PATCH v3] powerpc: Do not make the entire heap executable

From: Denys Vlasenko
Date: Wed Aug 10 2016 - 14:56:29 EST


On 08/10/2016 12:43 AM, Kees Cook wrote:
-static int do_brk(unsigned long addr, unsigned long len)
+static int do_brk_flags(unsigned long addr, unsigned long len, unsigned long flags)
{
struct mm_struct *mm = current->mm;
struct vm_area_struct *vma, *prev;
- unsigned long flags;
struct rb_node **rb_link, *rb_parent;
pgoff_t pgoff = addr >> PAGE_SHIFT;
int error;
@@ -2666,7 +2665,7 @@ static int do_brk(unsigned long addr, unsigned long len)
if (!len)
return 0;

- flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
+ flags |= VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;

For sanity's sake, should a mask be applied here? i.e. to be extra
careful about what flags can get passed in?

Maybe... I am leaving it to mm experts.

Otherwise, this looks okay to me:

Reviewed-by: Kees Cook <keescook@xxxxxxxxxxxx>

-Kees