summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_resource.c
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2007-07-12 18:01:31 +0000
committerjhb <jhb@FreeBSD.org>2007-07-12 18:01:31 +0000
commitef42e8706be34f667d7c85b11f408bec22cb3b77 (patch)
treec78cff16168bf26e653ac32e1c954ba6ed15af12 /sys/kern/kern_resource.c
parent77c677502e8fa12be84a874b37a001e2ee7f53a4 (diff)
downloadFreeBSD-src-ef42e8706be34f667d7c85b11f408bec22cb3b77.zip
FreeBSD-src-ef42e8706be34f667d7c85b11f408bec22cb3b77.tar.gz
Fix a couple of issues with the stack limit for 32-bit processes on 64-bit
kernels exposed by the recent fixes to resource limits for 32-bit processes on 64-bit kernels: - Let ABIs expose their maximum stack size via a new pointer in sysentvec and use that in preference to maxssiz during exec() rather than always using maxssiz for all processses. - Apply the ABI's limit fixup to the previous stack size when adjusting RLIMIT_STACK to determine if the existing mapping for the stack needs to be grown or shrunk (as well as how much it should be grown or shrunk). Approved by: re (kensmith)
Diffstat (limited to 'sys/kern/kern_resource.c')
-rw-r--r--sys/kern/kern_resource.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/sys/kern/kern_resource.c b/sys/kern/kern_resource.c
index 7e161cb..8627a14 100644
--- a/sys/kern/kern_resource.c
+++ b/sys/kern/kern_resource.c
@@ -657,7 +657,7 @@ kern_setrlimit(td, which, limp)
struct plimit *newlim, *oldlim;
struct proc *p;
register struct rlimit *alimp;
- rlim_t oldssiz;
+ struct rlimit oldssiz;
int error;
if (which >= RLIM_NLIMITS)
@@ -671,7 +671,7 @@ kern_setrlimit(td, which, limp)
if (limp->rlim_max < 0)
limp->rlim_max = RLIM_INFINITY;
- oldssiz = 0;
+ oldssiz.rlim_cur = 0;
p = td->td_proc;
newlim = lim_alloc();
PROC_LOCK(p);
@@ -711,7 +711,10 @@ kern_setrlimit(td, which, limp)
limp->rlim_cur = maxssiz;
if (limp->rlim_max > maxssiz)
limp->rlim_max = maxssiz;
- oldssiz = alimp->rlim_cur;
+ oldssiz = *alimp;
+ if (td->td_proc->p_sysent->sv_fixlimit != NULL)
+ td->td_proc->p_sysent->sv_fixlimit(&oldssiz,
+ RLIMIT_STACK);
break;
case RLIMIT_NOFILE:
@@ -745,20 +748,21 @@ kern_setrlimit(td, which, limp)
* "rlim_cur" bytes accessible. If stack limit is going
* up make more accessible, if going down make inaccessible.
*/
- if (limp->rlim_cur != oldssiz) {
+ if (limp->rlim_cur != oldssiz.rlim_cur) {
vm_offset_t addr;
vm_size_t size;
vm_prot_t prot;
- if (limp->rlim_cur > oldssiz) {
+ if (limp->rlim_cur > oldssiz.rlim_cur) {
prot = p->p_sysent->sv_stackprot;
- size = limp->rlim_cur - oldssiz;
+ size = limp->rlim_cur - oldssiz.rlim_cur;
addr = p->p_sysent->sv_usrstack -
limp->rlim_cur;
} else {
prot = VM_PROT_NONE;
- size = oldssiz - limp->rlim_cur;
- addr = p->p_sysent->sv_usrstack - oldssiz;
+ size = oldssiz.rlim_cur - limp->rlim_cur;
+ addr = p->p_sysent->sv_usrstack -
+ oldssiz.rlim_cur;
}
addr = trunc_page(addr);
size = round_page(size);
OpenPOWER on IntegriCloud