Deleted Added
full compact
linux_sysvec.c (71039) linux_sysvec.c (71497)
1/*-
2 * Copyright (c) 1994-1996 S�ren Schmidt
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
1/*-
2 * Copyright (c) 1994-1996 S�ren Schmidt
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 11 unchanged lines hidden (view full) ---

20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 *
28 * $FreeBSD: head/sys/i386/linux/linux_sysvec.c 71039 2001-01-14 18:16:01Z des $
28 * $FreeBSD: head/sys/i386/linux/linux_sysvec.c 71497 2001-01-24 00:27:28Z jhb $
29 */
30
31/* XXX we use functions that might not exist. */
32#include "opt_compat.h"
33
34#ifndef COMPAT_43
35#error "Unable to compile Linux-emulator due to missing COMPAT_43 option!"
36#endif

--- 140 unchanged lines hidden (view full) ---

177 }
178 AUXARGS_ENTRY(pos, AT_PHDR, args->phdr);
179 AUXARGS_ENTRY(pos, AT_PHENT, args->phent);
180 AUXARGS_ENTRY(pos, AT_PHNUM, args->phnum);
181 AUXARGS_ENTRY(pos, AT_PAGESZ, args->pagesz);
182 AUXARGS_ENTRY(pos, AT_FLAGS, args->flags);
183 AUXARGS_ENTRY(pos, AT_ENTRY, args->entry);
184 AUXARGS_ENTRY(pos, AT_BASE, args->base);
29 */
30
31/* XXX we use functions that might not exist. */
32#include "opt_compat.h"
33
34#ifndef COMPAT_43
35#error "Unable to compile Linux-emulator due to missing COMPAT_43 option!"
36#endif

--- 140 unchanged lines hidden (view full) ---

177 }
178 AUXARGS_ENTRY(pos, AT_PHDR, args->phdr);
179 AUXARGS_ENTRY(pos, AT_PHENT, args->phent);
180 AUXARGS_ENTRY(pos, AT_PHNUM, args->phnum);
181 AUXARGS_ENTRY(pos, AT_PAGESZ, args->pagesz);
182 AUXARGS_ENTRY(pos, AT_FLAGS, args->flags);
183 AUXARGS_ENTRY(pos, AT_ENTRY, args->entry);
184 AUXARGS_ENTRY(pos, AT_BASE, args->base);
185 PROC_LOCK(imgp->proc);
185 AUXARGS_ENTRY(pos, AT_UID, imgp->proc->p_cred->p_ruid);
186 AUXARGS_ENTRY(pos, AT_EUID, imgp->proc->p_cred->p_svuid);
187 AUXARGS_ENTRY(pos, AT_GID, imgp->proc->p_cred->p_rgid);
188 AUXARGS_ENTRY(pos, AT_EGID, imgp->proc->p_cred->p_svgid);
186 AUXARGS_ENTRY(pos, AT_UID, imgp->proc->p_cred->p_ruid);
187 AUXARGS_ENTRY(pos, AT_EUID, imgp->proc->p_cred->p_svuid);
188 AUXARGS_ENTRY(pos, AT_GID, imgp->proc->p_cred->p_rgid);
189 AUXARGS_ENTRY(pos, AT_EGID, imgp->proc->p_cred->p_svgid);
190 PROC_UNLOCK(imgp->proc);
189 AUXARGS_ENTRY(pos, AT_NULL, 0);
190
191 free(imgp->auxargs, M_TEMP);
192 imgp->auxargs = NULL;
193
194 (*stack_base)--;
195 **stack_base = (long)imgp->argc;
196 return 0;

--- 15 unchanged lines hidden (view full) ---

212
213#ifdef DEBUG
214 printf("Linux-emul(%ld): linux_rt_sendsig(%p, %d, %p, %lu)\n",
215 (long)p->p_pid, catcher, sig, (void*)mask, code);
216#endif
217 /*
218 * Allocate space for the signal handler context.
219 */
191 AUXARGS_ENTRY(pos, AT_NULL, 0);
192
193 free(imgp->auxargs, M_TEMP);
194 imgp->auxargs = NULL;
195
196 (*stack_base)--;
197 **stack_base = (long)imgp->argc;
198 return 0;

--- 15 unchanged lines hidden (view full) ---

214
215#ifdef DEBUG
216 printf("Linux-emul(%ld): linux_rt_sendsig(%p, %d, %p, %lu)\n",
217 (long)p->p_pid, catcher, sig, (void*)mask, code);
218#endif
219 /*
220 * Allocate space for the signal handler context.
221 */
222 PROC_LOCK(p);
220 if ((p->p_flag & P_ALTSTACK) && !oonstack &&
221 SIGISMEMBER(p->p_sigacts->ps_sigonstack, sig)) {
222 fp = (struct linux_rt_sigframe *)(p->p_sigstk.ss_sp +
223 p->p_sigstk.ss_size - sizeof(struct linux_rt_sigframe));
224 } else
225 fp = (struct linux_rt_sigframe *)regs->tf_esp - 1;
223 if ((p->p_flag & P_ALTSTACK) && !oonstack &&
224 SIGISMEMBER(p->p_sigacts->ps_sigonstack, sig)) {
225 fp = (struct linux_rt_sigframe *)(p->p_sigstk.ss_sp +
226 p->p_sigstk.ss_size - sizeof(struct linux_rt_sigframe));
227 } else
228 fp = (struct linux_rt_sigframe *)regs->tf_esp - 1;
229 PROC_UNLOCK(p);
226
227 /*
228 * grow() will return FALSE if the fp will not fit inside the stack
229 * and the stack can not be grown. useracc will return FALSE
230 * if access is denied.
231 */
232 if ((grow_stack (p, (int)fp) == FALSE) ||
233 !useracc((caddr_t)fp, sizeof (struct linux_rt_sigframe),
234 VM_PROT_WRITE)) {
235 /*
236 * Process has trashed its stack; give it an illegal
237 * instruction to halt it in its tracks.
238 */
230
231 /*
232 * grow() will return FALSE if the fp will not fit inside the stack
233 * and the stack can not be grown. useracc will return FALSE
234 * if access is denied.
235 */
236 if ((grow_stack (p, (int)fp) == FALSE) ||
237 !useracc((caddr_t)fp, sizeof (struct linux_rt_sigframe),
238 VM_PROT_WRITE)) {
239 /*
240 * Process has trashed its stack; give it an illegal
241 * instruction to halt it in its tracks.
242 */
243 PROC_LOCK(p);
239 SIGACTION(p, SIGILL) = SIG_DFL;
240 SIGDELSET(p->p_sigignore, SIGILL);
241 SIGDELSET(p->p_sigcatch, SIGILL);
242 SIGDELSET(p->p_sigmask, SIGILL);
244 SIGACTION(p, SIGILL) = SIG_DFL;
245 SIGDELSET(p->p_sigignore, SIGILL);
246 SIGDELSET(p->p_sigcatch, SIGILL);
247 SIGDELSET(p->p_sigmask, SIGILL);
248 PROC_UNLOCK(p);
243#ifdef DEBUG
244 printf("Linux-emul(%ld): linux_rt_sendsig -- bad stack %p, "
245 "oonstack=%x\n", (long)p->p_pid, fp, oonstack);
246#endif
247 psignal(p, SIGILL);
248 return;
249 }
250

--- 15 unchanged lines hidden (view full) ---

266 frame.sf_si.lsi_addr = (void *)regs->tf_err;
267
268 /*
269 * Build the signal context to be used by sigreturn.
270 */
271 frame.sf_sc.uc_flags = 0; /* XXX ??? */
272 frame.sf_sc.uc_link = NULL; /* XXX ??? */
273
249#ifdef DEBUG
250 printf("Linux-emul(%ld): linux_rt_sendsig -- bad stack %p, "
251 "oonstack=%x\n", (long)p->p_pid, fp, oonstack);
252#endif
253 psignal(p, SIGILL);
254 return;
255 }
256

--- 15 unchanged lines hidden (view full) ---

272 frame.sf_si.lsi_addr = (void *)regs->tf_err;
273
274 /*
275 * Build the signal context to be used by sigreturn.
276 */
277 frame.sf_sc.uc_flags = 0; /* XXX ??? */
278 frame.sf_sc.uc_link = NULL; /* XXX ??? */
279
280 PROC_LOCK(p);
274 frame.sf_sc.uc_stack.ss_sp = p->p_sigstk.ss_sp;
275 frame.sf_sc.uc_stack.ss_size = p->p_sigstk.ss_size;
276 frame.sf_sc.uc_stack.ss_flags = (p->p_flag & P_ALTSTACK)
277 ? ((oonstack) ? LINUX_SS_ONSTACK : 0) : LINUX_SS_DISABLE;
281 frame.sf_sc.uc_stack.ss_sp = p->p_sigstk.ss_sp;
282 frame.sf_sc.uc_stack.ss_size = p->p_sigstk.ss_size;
283 frame.sf_sc.uc_stack.ss_flags = (p->p_flag & P_ALTSTACK)
284 ? ((oonstack) ? LINUX_SS_ONSTACK : 0) : LINUX_SS_DISABLE;
285 PROC_UNLOCK(p);
278
279 bsd_to_linux_sigset(mask, &frame.sf_sc.uc_sigmask);
280
281 frame.sf_sc.uc_mcontext.sc_mask = frame.sf_sc.uc_sigmask.__bits[0];
282 frame.sf_sc.uc_mcontext.sc_gs = rgs();
283 frame.sf_sc.uc_mcontext.sc_fs = regs->tf_fs;
284 frame.sf_sc.uc_mcontext.sc_es = regs->tf_es;
285 frame.sf_sc.uc_mcontext.sc_ds = regs->tf_ds;

--- 76 unchanged lines hidden (view full) ---

362#ifdef DEBUG
363 printf("Linux-emul(%ld): linux_sendsig(%p, %d, %p, %lu)\n",
364 (long)p->p_pid, catcher, sig, (void*)mask, code);
365#endif
366
367 /*
368 * Allocate space for the signal handler context.
369 */
286
287 bsd_to_linux_sigset(mask, &frame.sf_sc.uc_sigmask);
288
289 frame.sf_sc.uc_mcontext.sc_mask = frame.sf_sc.uc_sigmask.__bits[0];
290 frame.sf_sc.uc_mcontext.sc_gs = rgs();
291 frame.sf_sc.uc_mcontext.sc_fs = regs->tf_fs;
292 frame.sf_sc.uc_mcontext.sc_es = regs->tf_es;
293 frame.sf_sc.uc_mcontext.sc_ds = regs->tf_ds;

--- 76 unchanged lines hidden (view full) ---

370#ifdef DEBUG
371 printf("Linux-emul(%ld): linux_sendsig(%p, %d, %p, %lu)\n",
372 (long)p->p_pid, catcher, sig, (void*)mask, code);
373#endif
374
375 /*
376 * Allocate space for the signal handler context.
377 */
378 PROC_LOCK(p);
370 if ((p->p_flag & P_ALTSTACK) && !oonstack &&
371 SIGISMEMBER(p->p_sigacts->ps_sigonstack, sig)) {
372 fp = (struct linux_sigframe *)(p->p_sigstk.ss_sp +
373 p->p_sigstk.ss_size - sizeof(struct linux_sigframe));
374 } else
375 fp = (struct linux_sigframe *)regs->tf_esp - 1;
379 if ((p->p_flag & P_ALTSTACK) && !oonstack &&
380 SIGISMEMBER(p->p_sigacts->ps_sigonstack, sig)) {
381 fp = (struct linux_sigframe *)(p->p_sigstk.ss_sp +
382 p->p_sigstk.ss_size - sizeof(struct linux_sigframe));
383 } else
384 fp = (struct linux_sigframe *)regs->tf_esp - 1;
385 PROC_UNLOCK(p);
376
377 /*
378 * grow() will return FALSE if the fp will not fit inside the stack
379 * and the stack can not be grown. useracc will return FALSE
380 * if access is denied.
381 */
382 if ((grow_stack (p, (int)fp) == FALSE) ||
383 !useracc((caddr_t)fp, sizeof (struct linux_sigframe),
384 VM_PROT_WRITE)) {
385 /*
386 * Process has trashed its stack; give it an illegal
387 * instruction to halt it in its tracks.
388 */
386
387 /*
388 * grow() will return FALSE if the fp will not fit inside the stack
389 * and the stack can not be grown. useracc will return FALSE
390 * if access is denied.
391 */
392 if ((grow_stack (p, (int)fp) == FALSE) ||
393 !useracc((caddr_t)fp, sizeof (struct linux_sigframe),
394 VM_PROT_WRITE)) {
395 /*
396 * Process has trashed its stack; give it an illegal
397 * instruction to halt it in its tracks.
398 */
399 PROC_LOCK(p);
389 SIGACTION(p, SIGILL) = SIG_DFL;
390 SIGDELSET(p->p_sigignore, SIGILL);
391 SIGDELSET(p->p_sigcatch, SIGILL);
392 SIGDELSET(p->p_sigmask, SIGILL);
400 SIGACTION(p, SIGILL) = SIG_DFL;
401 SIGDELSET(p->p_sigignore, SIGILL);
402 SIGDELSET(p->p_sigcatch, SIGILL);
403 SIGDELSET(p->p_sigmask, SIGILL);
404 PROC_UNLOCK(p);
393 psignal(p, SIGILL);
394 return;
395 }
396
397 /*
398 * Build the argument list for the signal handler.
399 */
400 if (p->p_sysent->sv_sigtbl)

--- 118 unchanged lines hidden (view full) ---

519 if (!CS_SECURE(frame.sf_sc.sc_cs)) {
520 trapsignal(p, SIGBUS, T_PROTFLT);
521 return(EINVAL);
522 }
523
524 lmask.__bits[0] = frame.sf_sc.sc_mask;
525 for (i = 0; i < (LINUX_NSIG_WORDS-1); i++)
526 lmask.__bits[i+1] = frame.sf_extramask[i];
405 psignal(p, SIGILL);
406 return;
407 }
408
409 /*
410 * Build the argument list for the signal handler.
411 */
412 if (p->p_sysent->sv_sigtbl)

--- 118 unchanged lines hidden (view full) ---

531 if (!CS_SECURE(frame.sf_sc.sc_cs)) {
532 trapsignal(p, SIGBUS, T_PROTFLT);
533 return(EINVAL);
534 }
535
536 lmask.__bits[0] = frame.sf_sc.sc_mask;
537 for (i = 0; i < (LINUX_NSIG_WORDS-1); i++)
538 lmask.__bits[i+1] = frame.sf_extramask[i];
539 PROC_LOCK(p);
527 linux_to_bsd_sigset(&lmask, &p->p_sigmask);
528 SIG_CANTMASK(p->p_sigmask);
540 linux_to_bsd_sigset(&lmask, &p->p_sigmask);
541 SIG_CANTMASK(p->p_sigmask);
542 PROC_UNLOCK(p);
529
530 /*
531 * Restore signal context.
532 */
533 /* %gs was restored by the trampoline. */
534 regs->tf_fs = frame.sf_sc.sc_fs;
535 regs->tf_es = frame.sf_sc.sc_es;
536 regs->tf_ds = frame.sf_sc.sc_ds;

--- 78 unchanged lines hidden (view full) ---

615 * other selectors, invalid %eip's and invalid %esp's.
616 */
617#define CS_SECURE(cs) (ISPL(cs) == SEL_UPL)
618 if (!CS_SECURE(context->sc_cs)) {
619 trapsignal(p, SIGBUS, T_PROTFLT);
620 return(EINVAL);
621 }
622
543
544 /*
545 * Restore signal context.
546 */
547 /* %gs was restored by the trampoline. */
548 regs->tf_fs = frame.sf_sc.sc_fs;
549 regs->tf_es = frame.sf_sc.sc_es;
550 regs->tf_ds = frame.sf_sc.sc_ds;

--- 78 unchanged lines hidden (view full) ---

629 * other selectors, invalid %eip's and invalid %esp's.
630 */
631#define CS_SECURE(cs) (ISPL(cs) == SEL_UPL)
632 if (!CS_SECURE(context->sc_cs)) {
633 trapsignal(p, SIGBUS, T_PROTFLT);
634 return(EINVAL);
635 }
636
637 PROC_LOCK(p);
623 linux_to_bsd_sigset(&uc.uc_sigmask, &p->p_sigmask);
624 SIG_CANTMASK(p->p_sigmask);
638 linux_to_bsd_sigset(&uc.uc_sigmask, &p->p_sigmask);
639 SIG_CANTMASK(p->p_sigmask);
640 PROC_UNLOCK(p);
625
626 /*
627 * Restore signal context
628 */
629 /* %gs was restored by the trampoline. */
630 regs->tf_fs = context->sc_fs;
631 regs->tf_es = context->sc_es;
632 regs->tf_ds = context->sc_ds;

--- 202 unchanged lines hidden ---
641
642 /*
643 * Restore signal context
644 */
645 /* %gs was restored by the trampoline. */
646 regs->tf_fs = context->sc_fs;
647 regs->tf_es = context->sc_es;
648 regs->tf_ds = context->sc_ds;

--- 202 unchanged lines hidden ---