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
This commit is contained in:
Paul Saab 2005-11-02 21:18:07 +00:00
parent c7362ff7fb
commit 1471f287e1
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=151980
5 changed files with 14 additions and 8 deletions

View File

@ -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 &&

View File

@ -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)

View File

@ -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,

View File

@ -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);
}

View File

@ -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