Page MenuHomeFreeBSD

D31516.id94233.diff
No OneTemporary

D31516.id94233.diff

Index: sys/kern/imgact_elf.c
===================================================================
--- sys/kern/imgact_elf.c
+++ sys/kern/imgact_elf.c
@@ -2695,5 +2695,6 @@
arc4rand(&rbase, sizeof(rbase), 0);
gap = rbase % range;
gap &= ~(sizeof(u_long) - 1);
+ imgp->proc->p_vmspace->vm_stkgap = (vm_offset_t)gap;
*stack_base -= gap;
}
Index: sys/kern/kern_exec.c
===================================================================
--- sys/kern/kern_exec.c
+++ sys/kern/kern_exec.c
@@ -1155,6 +1155,7 @@
stack_prot, error, vm_mmap_to_errno(error));
return (vm_mmap_to_errno(error));
}
+ vmspace->vm_stkgap = 0;
/*
* vm_ssize and vm_maxsaddr are somewhat antiquated concepts, but they
@@ -1568,8 +1569,10 @@
if (imgp->sysent->sv_stackgap == NULL ||
(imgp->proc->p_fctl0 & (NT_FREEBSD_FCTL_ASLR_DISABLE |
NT_FREEBSD_FCTL_ASG_DISABLE)) != 0 ||
- (imgp->map_flags & MAP_ASLR) == 0)
+ (imgp->map_flags & MAP_ASLR) == 0) {
+ imgp->proc->p_vmspace->vm_stkgap = 0;
return;
+ }
imgp->sysent->sv_stackgap(imgp, dp);
}
Index: sys/kern/kern_resource.c
===================================================================
--- sys/kern/kern_resource.c
+++ sys/kern/kern_resource.c
@@ -671,6 +671,9 @@
if (limp->rlim_max < 0)
limp->rlim_max = RLIM_INFINITY;
+ if (which == RLIMIT_STACK && limp->rlim_cur != RLIM_INFINITY)
+ limp->rlim_cur += p->p_vmspace->vm_stkgap;
+
oldssiz.rlim_cur = 0;
newlim = lim_alloc();
PROC_LOCK(p);
Index: sys/vm/vm_map.h
===================================================================
--- sys/vm/vm_map.h
+++ sys/vm/vm_map.h
@@ -293,6 +293,7 @@
caddr_t vm_taddr; /* (c) user virtual address of text */
caddr_t vm_daddr; /* (c) user virtual address of data */
caddr_t vm_maxsaddr; /* user VA at max stack growth */
+ vm_offset_t vm_stkgap; /* stack gap size */
u_int vm_refcnt; /* number of references */
/*
* Keep the PMAP last, so that CPU-specific variations of that
Index: sys/vm/vm_map.c
===================================================================
--- sys/vm/vm_map.c
+++ sys/vm/vm_map.c
@@ -343,6 +343,7 @@
vm->vm_taddr = 0;
vm->vm_daddr = 0;
vm->vm_maxsaddr = 0;
+ vm->vm_stkgap = 0;
return (vm);
}
@@ -4265,6 +4266,7 @@
vm2->vm_taddr = vm1->vm_taddr;
vm2->vm_daddr = vm1->vm_daddr;
vm2->vm_maxsaddr = vm1->vm_maxsaddr;
+ vm2->vm_stkgap = vm1->vm_stkgap;
vm_map_lock(old_map);
if (old_map->busy)
vm_map_wait_busy(old_map);

File Metadata

Mime Type
text/plain
Expires
Thu, Mar 12, 9:51 AM (17 h, 57 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
29576087
Default Alt Text
D31516.id94233.diff (2 KB)

Event Timeline