Deleted Added
full compact
ia32_sysvec.c (123423) ia32_sysvec.c (123742)
1/*-
2 * Copyright (c) 2002 Doug Rabson
3 * Copyright (c) 2003 Peter Wemm
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27
28#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 2002 Doug Rabson
3 * Copyright (c) 2003 Peter Wemm
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27
28#include <sys/cdefs.h>
29__FBSDID("$FreeBSD: head/sys/compat/ia32/ia32_sysvec.c 123423 2003-12-11 01:05:09Z peter $");
29__FBSDID("$FreeBSD: head/sys/compat/ia32/ia32_sysvec.c 123742 2003-12-23 02:42:39Z peter $");
30
31#include "opt_compat.h"
32
33#define __ELF_WORD_SIZE 32
34
35#include <sys/param.h>
36#include <sys/exec.h>
37#include <sys/fcntl.h>
38#include <sys/imgact.h>
39#include <sys/kernel.h>
40#include <sys/lock.h>
41#include <sys/malloc.h>
42#include <sys/mutex.h>
43#include <sys/mman.h>
44#include <sys/namei.h>
45#include <sys/pioctl.h>
46#include <sys/proc.h>
47#include <sys/procfs.h>
48#include <sys/resourcevar.h>
49#include <sys/systm.h>
50#include <sys/signalvar.h>
51#include <sys/stat.h>
52#include <sys/sx.h>
53#include <sys/syscall.h>
54#include <sys/sysctl.h>
55#include <sys/sysent.h>
56#include <sys/vnode.h>
57#include <sys/imgact_elf.h>
58
59#include <vm/vm.h>
60#include <vm/vm_kern.h>
61#include <vm/vm_param.h>
62#include <vm/pmap.h>
63#include <vm/vm_map.h>
64#include <vm/vm_object.h>
65#include <vm/vm_extern.h>
66
67#include <compat/freebsd32/freebsd32_util.h>
68#include <compat/freebsd32/freebsd32_proto.h>
69#include <compat/freebsd32/freebsd32_syscall.h>
70#include <compat/ia32/ia32_signal.h>
71#ifdef __amd64__
72#include <machine/psl.h>
73#include <machine/segments.h>
74#include <machine/specialreg.h>
75#else
76#include <i386/include/psl.h>
77#include <i386/include/segments.h>
78#include <i386/include/specialreg.h>
79#endif
80#include <machine/frame.h>
81#include <machine/md_var.h>
82#include <machine/pcb.h>
83#include <machine/cpufunc.h>
84
85CTASSERT(sizeof(struct ia32_mcontext) == 640);
86CTASSERT(sizeof(struct ia32_ucontext) == 704);
87CTASSERT(sizeof(struct ia32_sigframe) == 800);
88CTASSERT(sizeof(struct ia32_siginfo) == 64);
89#ifdef COMPAT_FREEBSD4
90CTASSERT(sizeof(struct ia32_mcontext4) == 260);
91CTASSERT(sizeof(struct ia32_ucontext4) == 324);
92CTASSERT(sizeof(struct ia32_sigframe4) == 408);
93#endif
94
95static register_t *ia32_copyout_strings(struct image_params *imgp);
96static void ia32_fixlimits(struct image_params *imgp);
97
98extern struct sysent freebsd32_sysent[];
99
100SYSCTL_NODE(_compat, OID_AUTO, ia32, CTLFLAG_RW, 0, "ia32 mode");
101
102struct sysentvec ia32_freebsd_sysvec = {
103 FREEBSD32_SYS_MAXSYSCALL,
104 freebsd32_sysent,
105 0,
106 0,
107 NULL,
108 0,
109 NULL,
110 NULL,
111 elf32_freebsd_fixup,
112 ia32_sendsig,
113 ia32_sigcode,
114 &sz_ia32_sigcode,
115 NULL,
116 "FreeBSD ELF32",
117 elf32_coredump,
118 NULL,
119 MINSIGSTKSZ,
120 IA32_PAGE_SIZE,
121 0,
122 FREEBSD32_USRSTACK,
123 FREEBSD32_USRSTACK,
124 FREEBSD32_PS_STRINGS,
125 VM_PROT_ALL,
126 ia32_copyout_strings,
127 ia32_setregs,
128 ia32_fixlimits
129};
130
131
30
31#include "opt_compat.h"
32
33#define __ELF_WORD_SIZE 32
34
35#include <sys/param.h>
36#include <sys/exec.h>
37#include <sys/fcntl.h>
38#include <sys/imgact.h>
39#include <sys/kernel.h>
40#include <sys/lock.h>
41#include <sys/malloc.h>
42#include <sys/mutex.h>
43#include <sys/mman.h>
44#include <sys/namei.h>
45#include <sys/pioctl.h>
46#include <sys/proc.h>
47#include <sys/procfs.h>
48#include <sys/resourcevar.h>
49#include <sys/systm.h>
50#include <sys/signalvar.h>
51#include <sys/stat.h>
52#include <sys/sx.h>
53#include <sys/syscall.h>
54#include <sys/sysctl.h>
55#include <sys/sysent.h>
56#include <sys/vnode.h>
57#include <sys/imgact_elf.h>
58
59#include <vm/vm.h>
60#include <vm/vm_kern.h>
61#include <vm/vm_param.h>
62#include <vm/pmap.h>
63#include <vm/vm_map.h>
64#include <vm/vm_object.h>
65#include <vm/vm_extern.h>
66
67#include <compat/freebsd32/freebsd32_util.h>
68#include <compat/freebsd32/freebsd32_proto.h>
69#include <compat/freebsd32/freebsd32_syscall.h>
70#include <compat/ia32/ia32_signal.h>
71#ifdef __amd64__
72#include <machine/psl.h>
73#include <machine/segments.h>
74#include <machine/specialreg.h>
75#else
76#include <i386/include/psl.h>
77#include <i386/include/segments.h>
78#include <i386/include/specialreg.h>
79#endif
80#include <machine/frame.h>
81#include <machine/md_var.h>
82#include <machine/pcb.h>
83#include <machine/cpufunc.h>
84
85CTASSERT(sizeof(struct ia32_mcontext) == 640);
86CTASSERT(sizeof(struct ia32_ucontext) == 704);
87CTASSERT(sizeof(struct ia32_sigframe) == 800);
88CTASSERT(sizeof(struct ia32_siginfo) == 64);
89#ifdef COMPAT_FREEBSD4
90CTASSERT(sizeof(struct ia32_mcontext4) == 260);
91CTASSERT(sizeof(struct ia32_ucontext4) == 324);
92CTASSERT(sizeof(struct ia32_sigframe4) == 408);
93#endif
94
95static register_t *ia32_copyout_strings(struct image_params *imgp);
96static void ia32_fixlimits(struct image_params *imgp);
97
98extern struct sysent freebsd32_sysent[];
99
100SYSCTL_NODE(_compat, OID_AUTO, ia32, CTLFLAG_RW, 0, "ia32 mode");
101
102struct sysentvec ia32_freebsd_sysvec = {
103 FREEBSD32_SYS_MAXSYSCALL,
104 freebsd32_sysent,
105 0,
106 0,
107 NULL,
108 0,
109 NULL,
110 NULL,
111 elf32_freebsd_fixup,
112 ia32_sendsig,
113 ia32_sigcode,
114 &sz_ia32_sigcode,
115 NULL,
116 "FreeBSD ELF32",
117 elf32_coredump,
118 NULL,
119 MINSIGSTKSZ,
120 IA32_PAGE_SIZE,
121 0,
122 FREEBSD32_USRSTACK,
123 FREEBSD32_USRSTACK,
124 FREEBSD32_PS_STRINGS,
125 VM_PROT_ALL,
126 ia32_copyout_strings,
127 ia32_setregs,
128 ia32_fixlimits
129};
130
131
132const char freebsd32_emul_path[] = "/compat/ia32";
133
134static Elf32_Brandinfo ia32_brand_info = {
135 ELFOSABI_FREEBSD,
136 EM_386,
137 "FreeBSD",
132static Elf32_Brandinfo ia32_brand_info = {
133 ELFOSABI_FREEBSD,
134 EM_386,
135 "FreeBSD",
138 "/compat/ia32",
139 "/usr/libexec/ld-elf.so.1",
140 &ia32_freebsd_sysvec
136 NULL,
137 "/libexec/ld-elf.so.1",
138 &ia32_freebsd_sysvec,
139 "/libexec/ld-elf-32.so.1",
141 };
142
143SYSINIT(ia32, SI_SUB_EXEC, SI_ORDER_ANY,
144 (sysinit_cfunc_t) elf32_insert_brand_entry,
145 &ia32_brand_info);
146
140 };
141
142SYSINIT(ia32, SI_SUB_EXEC, SI_ORDER_ANY,
143 (sysinit_cfunc_t) elf32_insert_brand_entry,
144 &ia32_brand_info);
145
146static Elf32_Brandinfo ia32_brand_oinfo = {
147 ELFOSABI_FREEBSD,
148 EM_386,
149 "FreeBSD",
150 NULL,
151 "/usr/libexec/ld-elf.so.1",
152 &ia32_freebsd_sysvec,
153 "/usr/libexec/ld-elf-32.so.1",
154 };
155
156SYSINIT(oia32, SI_SUB_EXEC, SI_ORDER_ANY,
157 (sysinit_cfunc_t) elf32_insert_brand_entry,
158 &ia32_brand_oinfo);
159
147/* XXX may be freebsd32 MI */
148static register_t *
149ia32_copyout_strings(struct image_params *imgp)
150{
151 int argc, envc;
152 u_int32_t *vectp;
153 char *stringp, *destp;
154 u_int32_t *stack_base;
155 struct freebsd32_ps_strings *arginfo;
156 int szsigcode;
157
158 /*
159 * Calculate string base and vector table pointers.
160 * Also deal with signal trampoline code for this exec type.
161 */
162 arginfo = (struct freebsd32_ps_strings *)FREEBSD32_PS_STRINGS;
163 szsigcode = *(imgp->proc->p_sysent->sv_szsigcode);
164 destp = (caddr_t)arginfo - szsigcode - SPARE_USRSPACE -
165 roundup((ARG_MAX - imgp->stringspace), sizeof(char *));
166
167 /*
168 * install sigcode
169 */
170 if (szsigcode)
171 copyout(imgp->proc->p_sysent->sv_sigcode,
172 ((caddr_t)arginfo - szsigcode), szsigcode);
173
174 /*
175 * If we have a valid auxargs ptr, prepare some room
176 * on the stack.
177 */
178 if (imgp->auxargs) {
179 /*
180 * 'AT_COUNT*2' is size for the ELF Auxargs data. This is for
181 * lower compatibility.
182 */
183 imgp->auxarg_size = (imgp->auxarg_size) ? imgp->auxarg_size
184 : (AT_COUNT * 2);
185 /*
186 * The '+ 2' is for the null pointers at the end of each of
187 * the arg and env vector sets,and imgp->auxarg_size is room
188 * for argument of Runtime loader.
189 */
190 vectp = (u_int32_t *) (destp - (imgp->argc + imgp->envc + 2 +
191 imgp->auxarg_size) * sizeof(u_int32_t));
192
193 } else
194 /*
195 * The '+ 2' is for the null pointers at the end of each of
196 * the arg and env vector sets
197 */
198 vectp = (u_int32_t *)
199 (destp - (imgp->argc + imgp->envc + 2) * sizeof(u_int32_t));
200
201 /*
202 * vectp also becomes our initial stack base
203 */
204 stack_base = vectp;
205
206 stringp = imgp->stringbase;
207 argc = imgp->argc;
208 envc = imgp->envc;
209 /*
210 * Copy out strings - arguments and environment.
211 */
212 copyout(stringp, destp, ARG_MAX - imgp->stringspace);
213
214 /*
215 * Fill in "ps_strings" struct for ps, w, etc.
216 */
217 suword32(&arginfo->ps_argvstr, (u_int32_t)(intptr_t)vectp);
218 suword32(&arginfo->ps_nargvstr, argc);
219
220 /*
221 * Fill in argument portion of vector table.
222 */
223 for (; argc > 0; --argc) {
224 suword32(vectp++, (u_int32_t)(intptr_t)destp);
225 while (*stringp++ != 0)
226 destp++;
227 destp++;
228 }
229
230 /* a null vector table pointer separates the argp's from the envp's */
231 suword32(vectp++, 0);
232
233 suword32(&arginfo->ps_envstr, (u_int32_t)(intptr_t)vectp);
234 suword32(&arginfo->ps_nenvstr, envc);
235
236 /*
237 * Fill in environment portion of vector table.
238 */
239 for (; envc > 0; --envc) {
240 suword32(vectp++, (u_int32_t)(intptr_t)destp);
241 while (*stringp++ != 0)
242 destp++;
243 destp++;
244 }
245
246 /* end of vector table is a null pointer */
247 suword32(vectp, 0);
248
249 return ((register_t *)stack_base);
250}
251
252static u_long ia32_maxdsiz = IA32_MAXDSIZ;
253SYSCTL_ULONG(_compat_ia32, OID_AUTO, maxdsiz, CTLFLAG_RW, &ia32_maxdsiz, 0, "");
254static u_long ia32_maxssiz = IA32_MAXSSIZ;
255SYSCTL_ULONG(_compat_ia32, OID_AUTO, maxssiz, CTLFLAG_RW, &ia32_maxssiz, 0, "");
256static u_long ia32_maxvmem = IA32_MAXVMEM;
257SYSCTL_ULONG(_compat_ia32, OID_AUTO, maxvmem, CTLFLAG_RW, &ia32_maxvmem, 0, "");
258
259static void
260ia32_fixlimits(struct image_params *imgp)
261{
262 struct proc *p = imgp->proc;
263
264 if (ia32_maxdsiz != 0) {
265 if (p->p_rlimit[RLIMIT_DATA].rlim_cur > ia32_maxdsiz ||
266 p->p_rlimit[RLIMIT_DATA].rlim_max > ia32_maxdsiz) {
267 if (p->p_limit->p_refcnt > 1) {
268 p->p_limit->p_refcnt--;
269 p->p_limit = limcopy(p->p_limit);
270 }
271 if (p->p_rlimit[RLIMIT_DATA].rlim_cur > ia32_maxdsiz)
272 p->p_rlimit[RLIMIT_DATA].rlim_cur =
273 ia32_maxdsiz;
274 if (p->p_rlimit[RLIMIT_DATA].rlim_max > ia32_maxdsiz)
275 p->p_rlimit[RLIMIT_DATA].rlim_max =
276 ia32_maxdsiz;
277 }
278 }
279 if (ia32_maxssiz != 0) {
280 if (p->p_rlimit[RLIMIT_STACK].rlim_cur > ia32_maxssiz ||
281 p->p_rlimit[RLIMIT_STACK].rlim_max > ia32_maxssiz) {
282 if (p->p_limit->p_refcnt > 1) {
283 p->p_limit->p_refcnt--;
284 p->p_limit = limcopy(p->p_limit);
285 }
286 if (p->p_rlimit[RLIMIT_STACK].rlim_cur > ia32_maxssiz)
287 p->p_rlimit[RLIMIT_STACK].rlim_cur =
288 ia32_maxssiz;
289 if (p->p_rlimit[RLIMIT_STACK].rlim_max > ia32_maxssiz)
290 p->p_rlimit[RLIMIT_STACK].rlim_max =
291 ia32_maxssiz;
292 }
293 }
294 if (ia32_maxvmem != 0) {
295 if (p->p_rlimit[RLIMIT_VMEM].rlim_cur > ia32_maxvmem ||
296 p->p_rlimit[RLIMIT_VMEM].rlim_max > ia32_maxvmem) {
297 if (p->p_limit->p_refcnt > 1) {
298 p->p_limit->p_refcnt--;
299 p->p_limit = limcopy(p->p_limit);
300 }
301 if (p->p_rlimit[RLIMIT_VMEM].rlim_cur > ia32_maxvmem)
302 p->p_rlimit[RLIMIT_VMEM].rlim_cur =
303 ia32_maxvmem;
304 if (p->p_rlimit[RLIMIT_VMEM].rlim_max > ia32_maxvmem)
305 p->p_rlimit[RLIMIT_VMEM].rlim_max =
306 ia32_maxvmem;
307 }
308 }
309}
160/* XXX may be freebsd32 MI */
161static register_t *
162ia32_copyout_strings(struct image_params *imgp)
163{
164 int argc, envc;
165 u_int32_t *vectp;
166 char *stringp, *destp;
167 u_int32_t *stack_base;
168 struct freebsd32_ps_strings *arginfo;
169 int szsigcode;
170
171 /*
172 * Calculate string base and vector table pointers.
173 * Also deal with signal trampoline code for this exec type.
174 */
175 arginfo = (struct freebsd32_ps_strings *)FREEBSD32_PS_STRINGS;
176 szsigcode = *(imgp->proc->p_sysent->sv_szsigcode);
177 destp = (caddr_t)arginfo - szsigcode - SPARE_USRSPACE -
178 roundup((ARG_MAX - imgp->stringspace), sizeof(char *));
179
180 /*
181 * install sigcode
182 */
183 if (szsigcode)
184 copyout(imgp->proc->p_sysent->sv_sigcode,
185 ((caddr_t)arginfo - szsigcode), szsigcode);
186
187 /*
188 * If we have a valid auxargs ptr, prepare some room
189 * on the stack.
190 */
191 if (imgp->auxargs) {
192 /*
193 * 'AT_COUNT*2' is size for the ELF Auxargs data. This is for
194 * lower compatibility.
195 */
196 imgp->auxarg_size = (imgp->auxarg_size) ? imgp->auxarg_size
197 : (AT_COUNT * 2);
198 /*
199 * The '+ 2' is for the null pointers at the end of each of
200 * the arg and env vector sets,and imgp->auxarg_size is room
201 * for argument of Runtime loader.
202 */
203 vectp = (u_int32_t *) (destp - (imgp->argc + imgp->envc + 2 +
204 imgp->auxarg_size) * sizeof(u_int32_t));
205
206 } else
207 /*
208 * The '+ 2' is for the null pointers at the end of each of
209 * the arg and env vector sets
210 */
211 vectp = (u_int32_t *)
212 (destp - (imgp->argc + imgp->envc + 2) * sizeof(u_int32_t));
213
214 /*
215 * vectp also becomes our initial stack base
216 */
217 stack_base = vectp;
218
219 stringp = imgp->stringbase;
220 argc = imgp->argc;
221 envc = imgp->envc;
222 /*
223 * Copy out strings - arguments and environment.
224 */
225 copyout(stringp, destp, ARG_MAX - imgp->stringspace);
226
227 /*
228 * Fill in "ps_strings" struct for ps, w, etc.
229 */
230 suword32(&arginfo->ps_argvstr, (u_int32_t)(intptr_t)vectp);
231 suword32(&arginfo->ps_nargvstr, argc);
232
233 /*
234 * Fill in argument portion of vector table.
235 */
236 for (; argc > 0; --argc) {
237 suword32(vectp++, (u_int32_t)(intptr_t)destp);
238 while (*stringp++ != 0)
239 destp++;
240 destp++;
241 }
242
243 /* a null vector table pointer separates the argp's from the envp's */
244 suword32(vectp++, 0);
245
246 suword32(&arginfo->ps_envstr, (u_int32_t)(intptr_t)vectp);
247 suword32(&arginfo->ps_nenvstr, envc);
248
249 /*
250 * Fill in environment portion of vector table.
251 */
252 for (; envc > 0; --envc) {
253 suword32(vectp++, (u_int32_t)(intptr_t)destp);
254 while (*stringp++ != 0)
255 destp++;
256 destp++;
257 }
258
259 /* end of vector table is a null pointer */
260 suword32(vectp, 0);
261
262 return ((register_t *)stack_base);
263}
264
265static u_long ia32_maxdsiz = IA32_MAXDSIZ;
266SYSCTL_ULONG(_compat_ia32, OID_AUTO, maxdsiz, CTLFLAG_RW, &ia32_maxdsiz, 0, "");
267static u_long ia32_maxssiz = IA32_MAXSSIZ;
268SYSCTL_ULONG(_compat_ia32, OID_AUTO, maxssiz, CTLFLAG_RW, &ia32_maxssiz, 0, "");
269static u_long ia32_maxvmem = IA32_MAXVMEM;
270SYSCTL_ULONG(_compat_ia32, OID_AUTO, maxvmem, CTLFLAG_RW, &ia32_maxvmem, 0, "");
271
272static void
273ia32_fixlimits(struct image_params *imgp)
274{
275 struct proc *p = imgp->proc;
276
277 if (ia32_maxdsiz != 0) {
278 if (p->p_rlimit[RLIMIT_DATA].rlim_cur > ia32_maxdsiz ||
279 p->p_rlimit[RLIMIT_DATA].rlim_max > ia32_maxdsiz) {
280 if (p->p_limit->p_refcnt > 1) {
281 p->p_limit->p_refcnt--;
282 p->p_limit = limcopy(p->p_limit);
283 }
284 if (p->p_rlimit[RLIMIT_DATA].rlim_cur > ia32_maxdsiz)
285 p->p_rlimit[RLIMIT_DATA].rlim_cur =
286 ia32_maxdsiz;
287 if (p->p_rlimit[RLIMIT_DATA].rlim_max > ia32_maxdsiz)
288 p->p_rlimit[RLIMIT_DATA].rlim_max =
289 ia32_maxdsiz;
290 }
291 }
292 if (ia32_maxssiz != 0) {
293 if (p->p_rlimit[RLIMIT_STACK].rlim_cur > ia32_maxssiz ||
294 p->p_rlimit[RLIMIT_STACK].rlim_max > ia32_maxssiz) {
295 if (p->p_limit->p_refcnt > 1) {
296 p->p_limit->p_refcnt--;
297 p->p_limit = limcopy(p->p_limit);
298 }
299 if (p->p_rlimit[RLIMIT_STACK].rlim_cur > ia32_maxssiz)
300 p->p_rlimit[RLIMIT_STACK].rlim_cur =
301 ia32_maxssiz;
302 if (p->p_rlimit[RLIMIT_STACK].rlim_max > ia32_maxssiz)
303 p->p_rlimit[RLIMIT_STACK].rlim_max =
304 ia32_maxssiz;
305 }
306 }
307 if (ia32_maxvmem != 0) {
308 if (p->p_rlimit[RLIMIT_VMEM].rlim_cur > ia32_maxvmem ||
309 p->p_rlimit[RLIMIT_VMEM].rlim_max > ia32_maxvmem) {
310 if (p->p_limit->p_refcnt > 1) {
311 p->p_limit->p_refcnt--;
312 p->p_limit = limcopy(p->p_limit);
313 }
314 if (p->p_rlimit[RLIMIT_VMEM].rlim_cur > ia32_maxvmem)
315 p->p_rlimit[RLIMIT_VMEM].rlim_cur =
316 ia32_maxvmem;
317 if (p->p_rlimit[RLIMIT_VMEM].rlim_max > ia32_maxvmem)
318 p->p_rlimit[RLIMIT_VMEM].rlim_max =
319 ia32_maxvmem;
320 }
321 }
322}