Changeset View
Changeset View
Standalone View
Standalone View
sys/vm/vm_mmap.c
Context not available. | |||||
#include "opt_compat.h" | #include "opt_compat.h" | ||||
#include "opt_hwpmc_hooks.h" | #include "opt_hwpmc_hooks.h" | ||||
#include "opt_pax.h" | |||||
#include <sys/param.h> | #include <sys/param.h> | ||||
#include <sys/systm.h> | #include <sys/systm.h> | ||||
Context not available. | |||||
#include <sys/mutex.h> | #include <sys/mutex.h> | ||||
#include <sys/sysproto.h> | #include <sys/sysproto.h> | ||||
#include <sys/filedesc.h> | #include <sys/filedesc.h> | ||||
#include <sys/pax.h> | |||||
#include <sys/priv.h> | #include <sys/priv.h> | ||||
#include <sys/proc.h> | #include <sys/proc.h> | ||||
#include <sys/procctl.h> | #include <sys/procctl.h> | ||||
Context not available. | |||||
struct file *fp; | struct file *fp; | ||||
struct vnode *vp; | struct vnode *vp; | ||||
vm_offset_t addr; | vm_offset_t addr; | ||||
#ifdef PAX_ASLR | |||||
vm_offset_t orig_addr; | |||||
#endif | |||||
vm_size_t size, pageoff; | vm_size_t size, pageoff; | ||||
vm_prot_t cap_maxprot, prot, maxprot; | vm_prot_t cap_maxprot, prot, maxprot; | ||||
void *handle; | void *handle; | ||||
Context not available. | |||||
cap_rights_t rights; | cap_rights_t rights; | ||||
addr = (vm_offset_t) uap->addr; | addr = (vm_offset_t) uap->addr; | ||||
#ifdef PAX_ASLR | |||||
orig_addr = addr; | |||||
#endif | |||||
size = uap->len; | size = uap->len; | ||||
prot = uap->prot & VM_PROT_ALL; | prot = uap->prot & VM_PROT_ALL; | ||||
flags = uap->flags; | flags = uap->flags; | ||||
Context not available. | |||||
* do not bother moving the mapping past the heap (since | * do not bother moving the mapping past the heap (since | ||||
* the heap is usually above 2GB). | * the heap is usually above 2GB). | ||||
*/ | */ | ||||
#ifdef PAX_ASLR | |||||
/* Ugly hack for adding ASLR to 32bit mappings */ | |||||
pax_aslr_mmap(td, &addr, orig_addr, flags); | |||||
if (addr != orig_addr) | |||||
addr = trunc_page(addr & 0x0fffffff); | |||||
#endif | |||||
if (addr + size > MAP_32BIT_MAX_ADDR) | if (addr + size > MAP_32BIT_MAX_ADDR) | ||||
addr = 0; | addr = 0; | ||||
bdrewery: Space missing, addr & 0x0fffffff. | |||||
#endif | #endif | ||||
Context not available. | |||||
* location. | * location. | ||||
*/ | */ | ||||
PROC_LOCK(td->td_proc); | PROC_LOCK(td->td_proc); | ||||
#ifdef PAX_ASLR | |||||
pax_aslr_mmap(td, &addr, orig_addr, flags); | |||||
#endif | |||||
if (addr == 0 || | if (addr == 0 || | ||||
(addr >= round_page((vm_offset_t)vms->vm_taddr) && | (addr >= round_page((vm_offset_t)vms->vm_taddr) && | ||||
addr < round_page((vm_offset_t)vms->vm_daddr + | addr < round_page((vm_offset_t)vms->vm_daddr + | ||||
Context not available. | |||||
Not Done Inline ActionsWas there some other past use for 'orig_addr', or should this really just be rewriting 'addr' in place? rwatson: Was there some other past use for 'orig_addr', or should this really just be rewriting 'addr'… | |||||
Not Done Inline Actionsop: No. The orig_addr is needed.
https://github.com/HardenedBSD/hardenedBSD/commit/190c95d44fb263a… |
Space missing, addr & 0x0fffffff.