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 $
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 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);
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 */
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;
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 */
239 SIGACTION(p, SIGILL) = SIG_DFL;
240 SIGDELSET(p->p_sigignore, SIGILL);
241 SIGDELSET(p->p_sigcatch, SIGILL);
242 SIGDELSET(p->p_sigmask, SIGILL);
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
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;
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 */
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;
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 */
389 SIGACTION(p, SIGILL) = SIG_DFL;
390 SIGDELSET(p->p_sigignore, SIGILL);
391 SIGDELSET(p->p_sigcatch, SIGILL);
392 SIGDELSET(p->p_sigmask, SIGILL);
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];
527 linux_to_bsd_sigset(&lmask, &p->p_sigmask);
528 SIG_CANTMASK(p->p_sigmask);
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
623 linux_to_bsd_sigset(&uc.uc_sigmask, &p->p_sigmask);
624 SIG_CANTMASK(p->p_sigmask);
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 ---
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 $
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 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);
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 */
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;
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 */
239 SIGACTION(p, SIGILL) = SIG_DFL;
240 SIGDELSET(p->p_sigignore, SIGILL);
241 SIGDELSET(p->p_sigcatch, SIGILL);
242 SIGDELSET(p->p_sigmask, SIGILL);
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
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;
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 */
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;
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 */
389 SIGACTION(p, SIGILL) = SIG_DFL;
390 SIGDELSET(p->p_sigignore, SIGILL);
391 SIGDELSET(p->p_sigcatch, SIGILL);
392 SIGDELSET(p->p_sigmask, SIGILL);
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];
527 linux_to_bsd_sigset(&lmask, &p->p_sigmask);
528 SIG_CANTMASK(p->p_sigmask);
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
623 linux_to_bsd_sigset(&uc.uc_sigmask, &p->p_sigmask);
624 SIG_CANTMASK(p->p_sigmask);
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 ---