Skip to content

Commit

Permalink
[syzkaller] Fix for PR #52658 as suggested by riastradh@
Browse files Browse the repository at this point in the history
The bug was found by Dmitry Vyukov (dvyukov@google.com)
using syzkaller and was tested by me on a VM running
8.99.5
  • Loading branch information
utkarsh009 authored and utkarsh009 committed Oct 27, 2017
1 parent e079ad5 commit 8d45bd6
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions sys/uvm/uvm_mmap.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* $NetBSD: uvm_mmap.c,v 1.166 2017/05/20 07:27:15 chs Exp $ */
/* $NetBSD: uvm_mmap.c,v 1.167 2017/10/27 12:01:08 utkarsh009 Exp $ */

/*
* Copyright (c) 1997 Charles D. Cranor and Washington University.
Expand Down Expand Up @@ -46,7 +46,7 @@
*/

#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: uvm_mmap.c,v 1.166 2017/05/20 07:27:15 chs Exp $");
__KERNEL_RCSID(0, "$NetBSD: uvm_mmap.c,v 1.167 2017/10/27 12:01:08 utkarsh009 Exp $");

#include "opt_compat_netbsd.h"
#include "opt_pax.h"
Expand Down Expand Up @@ -398,10 +398,12 @@ sys_mmap(struct lwp *l, const struct sys_mmap_args *uap, register_t *retval)
}

maxprot = PAX_MPROTECT_MAXPROTECT(l, prot, extraprot, maxprot);
if (((prot | extraprot) & maxprot) != (prot | extraprot))
return EACCES;
if (((prot | extraprot) & maxprot) != (prot | extraprot)) {
error = EACCES;
goto out;
}
if ((error = PAX_MPROTECT_VALIDATE(l, prot)))
return error;
goto out;

pax_aslr_mmap(l, &addr, orig_addr, flags);

Expand Down

0 comments on commit 8d45bd6

Please sign in to comment.