summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorps <ps@FreeBSD.org>2005-11-02 21:18:07 +0000
committerps <ps@FreeBSD.org>2005-11-02 21:18:07 +0000
commite0951fe5041ade134381562a4cbf4bc0e2fb7219 (patch)
tree579fb2f2f747602f163048fe8fc4c723adbadd1a /sys
parent830d2103fbe6636ab7adf8d4fb308b9a383be46f (diff)
downloadFreeBSD-src-e0951fe5041ade134381562a4cbf4bc0e2fb7219.zip
FreeBSD-src-e0951fe5041ade134381562a4cbf4bc0e2fb7219.tar.gz
Calling setrlimit from 32bit apps could potentially increase certain
limits beyond what should be capiable in a 32bit process, so we must fixup the limits. Reviewed by: jhb
Diffstat (limited to 'sys')
-rw-r--r--sys/amd64/linux32/linux32_sysvec.c5
-rw-r--r--sys/compat/ia32/ia32_sysvec.c5
-rw-r--r--sys/kern/kern_exec.c2
-rw-r--r--sys/kern/kern_resource.c7
-rw-r--r--sys/sys/sysent.h3
5 files changed, 14 insertions, 8 deletions
diff --git a/sys/amd64/linux32/linux32_sysvec.c b/sys/amd64/linux32/linux32_sysvec.c
index 5cac383..d1b1eed 100644
--- a/sys/amd64/linux32/linux32_sysvec.c
+++ b/sys/amd64/linux32/linux32_sysvec.c
@@ -123,7 +123,7 @@ static void linux_prepsyscall(struct trapframe *tf, int *args, u_int *code,
static void linux_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask);
static void exec_linux_setregs(struct thread *td, u_long entry,
u_long stack, u_long ps_strings);
-static void linux32_fixlimits(struct image_params *imgp);
+static void linux32_fixlimits(struct proc *p);
/*
* Linux syscalls return negative errno's, we do positive and map them
@@ -955,9 +955,8 @@ SYSCTL_ULONG(_compat_linux32, OID_AUTO, maxvmem, CTLFLAG_RW,
* XXX copied from ia32_sysvec.c.
*/
static void
-linux32_fixlimits(struct image_params *imgp)
+linux32_fixlimits(struct proc *p)
{
- struct proc *p = imgp->proc;
struct plimit *oldlim, *newlim;
if (linux32_maxdsiz == 0 && linux32_maxssiz == 0 &&
diff --git a/sys/compat/ia32/ia32_sysvec.c b/sys/compat/ia32/ia32_sysvec.c
index 1052d61..a18163b 100644
--- a/sys/compat/ia32/ia32_sysvec.c
+++ b/sys/compat/ia32/ia32_sysvec.c
@@ -93,7 +93,7 @@ CTASSERT(sizeof(struct ia32_sigframe4) == 408);
#endif
static register_t *ia32_copyout_strings(struct image_params *imgp);
-static void ia32_fixlimits(struct image_params *imgp);
+static void ia32_fixlimits(struct proc *p);
extern struct sysent freebsd32_sysent[];
@@ -278,9 +278,8 @@ static u_long ia32_maxvmem = IA32_MAXVMEM;
SYSCTL_ULONG(_compat_ia32, OID_AUTO, maxvmem, CTLFLAG_RW, &ia32_maxvmem, 0, "");
static void
-ia32_fixlimits(struct image_params *imgp)
+ia32_fixlimits(struct proc *p)
{
- struct proc *p = imgp->proc;
struct plimit *oldlim, *newlim;
if (ia32_maxdsiz == 0 && ia32_maxssiz == 0 && ia32_maxvmem == 0)
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c
index 78b4a04..811bd9f 100644
--- a/sys/kern/kern_exec.c
+++ b/sys/kern/kern_exec.c
@@ -908,7 +908,7 @@ exec_new_vmspace(imgp, sv)
* sense for the 32 bit binary.
*/
if (sv->sv_fixlimits != NULL)
- sv->sv_fixlimits(imgp);
+ sv->sv_fixlimits(p);
/*
* Blow away entire process VM, if address space not shared,
diff --git a/sys/kern/kern_resource.c b/sys/kern/kern_resource.c
index cb5b73d..397a7c5 100644
--- a/sys/kern/kern_resource.c
+++ b/sys/kern/kern_resource.c
@@ -655,6 +655,13 @@ kern_setrlimit(td, which, limp)
addr, addr + size, prot, FALSE);
}
}
+
+ /*
+ * The data size limit may need to be changed to a value
+ * that makes sense for the 32 bit binary.
+ */
+ if (p->p_sysent->sv_fixlimits != NULL)
+ p->p_sysent->sv_fixlimits(p);
return (0);
}
diff --git a/sys/sys/sysent.h b/sys/sys/sysent.h
index 2796660..430b5d6 100644
--- a/sys/sys/sysent.h
+++ b/sys/sys/sysent.h
@@ -34,6 +34,7 @@
#include <bsm/audit.h>
+struct proc;
struct thread;
struct ksiginfo;
@@ -84,7 +85,7 @@ struct sysentvec {
int sv_stackprot; /* vm protection for stack */
register_t *(*sv_copyout_strings)(struct image_params *);
void (*sv_setregs)(struct thread *, u_long, u_long, u_long);
- void (*sv_fixlimits)(struct image_params *);
+ void (*sv_fixlimits)(struct proc *);
};
#ifdef _KERNEL
OpenPOWER on IntegriCloud