linux_sysvec.c (69073) | linux_sysvec.c (69081) |
---|---|
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 69073 2000-11-23 03:21:58Z marcel $ | 28 * $FreeBSD: head/sys/i386/linux/linux_sysvec.c 69081 2000-11-23 08:55:30Z marcel $ |
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 --- 160 unchanged lines hidden (view full) --- 197extern unsigned long _linux_sznonrtsigcode; 198 199static void 200linux_rt_sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code) 201{ 202 register struct proc *p = curproc; 203 register struct trapframe *regs; 204 struct linux_rt_sigframe *fp, frame; | 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 --- 160 unchanged lines hidden (view full) --- 197extern unsigned long _linux_sznonrtsigcode; 198 199static void 200linux_rt_sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code) 201{ 202 register struct proc *p = curproc; 203 register struct trapframe *regs; 204 struct linux_rt_sigframe *fp, frame; |
205 struct sigacts *psp = p->p_sigacts; | |
206 int oonstack; 207 208 regs = p->p_md.md_regs; 209 oonstack = p->p_sigstk.ss_flags & SS_ONSTACK; 210 211#ifdef DEBUG 212 printf("Linux-emul(%ld): linux_rt_sendsig(%p, %d, %p, %lu)\n", 213 (long)p->p_pid, catcher, sig, (void*)mask, code); 214#endif 215 /* 216 * Allocate space for the signal handler context. 217 */ 218 if ((p->p_flag & P_ALTSTACK) && !oonstack && | 205 int oonstack; 206 207 regs = p->p_md.md_regs; 208 oonstack = p->p_sigstk.ss_flags & SS_ONSTACK; 209 210#ifdef DEBUG 211 printf("Linux-emul(%ld): linux_rt_sendsig(%p, %d, %p, %lu)\n", 212 (long)p->p_pid, catcher, sig, (void*)mask, code); 213#endif 214 /* 215 * Allocate space for the signal handler context. 216 */ 217 if ((p->p_flag & P_ALTSTACK) && !oonstack && |
219 SIGISMEMBER(psp->ps_sigonstack, sig)) { | 218 SIGISMEMBER(p->p_sigacts->ps_sigonstack, sig)) { |
220 fp = (struct linux_rt_sigframe *)(p->p_sigstk.ss_sp + 221 p->p_sigstk.ss_size - sizeof(struct linux_rt_sigframe)); 222 p->p_sigstk.ss_flags |= SS_ONSTACK; 223 } else { 224 fp = (struct linux_rt_sigframe *)regs->tf_esp - 1; 225 } 226 227 /* --- 24 unchanged lines hidden (view full) --- 252 * Build the argument list for the signal handler. 253 */ 254 if (p->p_sysent->sv_sigtbl) 255 if (sig <= p->p_sysent->sv_sigsize) 256 sig = p->p_sysent->sv_sigtbl[_SIG_IDX(sig)]; 257 258 frame.sf_handler = catcher; 259 frame.sf_sig = sig; | 219 fp = (struct linux_rt_sigframe *)(p->p_sigstk.ss_sp + 220 p->p_sigstk.ss_size - sizeof(struct linux_rt_sigframe)); 221 p->p_sigstk.ss_flags |= SS_ONSTACK; 222 } else { 223 fp = (struct linux_rt_sigframe *)regs->tf_esp - 1; 224 } 225 226 /* --- 24 unchanged lines hidden (view full) --- 251 * Build the argument list for the signal handler. 252 */ 253 if (p->p_sysent->sv_sigtbl) 254 if (sig <= p->p_sysent->sv_sigsize) 255 sig = p->p_sysent->sv_sigtbl[_SIG_IDX(sig)]; 256 257 frame.sf_handler = catcher; 258 frame.sf_sig = sig; |
260 | |
261 frame.sf_siginfo = &fp->sf_si; 262 frame.sf_ucontext = &fp->sf_sc; | 259 frame.sf_siginfo = &fp->sf_si; 260 frame.sf_ucontext = &fp->sf_sc; |
261 |
|
263 /* Fill siginfo structure. */ 264 frame.sf_si.lsi_signo = sig; 265 frame.sf_si.lsi_code = code; 266 frame.sf_si.lsi_addr = (void *)regs->tf_err; | 262 /* Fill siginfo structure. */ 263 frame.sf_si.lsi_signo = sig; 264 frame.sf_si.lsi_code = code; 265 frame.sf_si.lsi_addr = (void *)regs->tf_err; |
266 |
|
267 /* 268 * Build the signal context to be used by sigreturn. 269 */ | 267 /* 268 * Build the signal context to be used by sigreturn. 269 */ |
270 frame.sf_sc.uc_mcontext.sc_mask = mask->__bits[0]; | 270 frame.sf_sc.uc_flags = 0; /* XXX ??? */ 271 frame.sf_sc.uc_link = NULL; /* XXX ??? */ 272 273 frame.sf_sc.uc_stack.ss_sp = p->p_sigstk.ss_sp; 274 frame.sf_sc.uc_stack.ss_flags = 275 bsd_to_linux_sigaltstack(p->p_sigstk.ss_flags); 276 frame.sf_sc.uc_stack.ss_size = p->p_sigstk.ss_size; 277 278 bsd_to_linux_sigset(mask, &frame.sf_sc.uc_sigmask); 279 280 frame.sf_sc.uc_mcontext.sc_mask = frame.sf_sc.uc_sigmask.__bits[0]; |
271 frame.sf_sc.uc_mcontext.sc_gs = rgs(); 272 frame.sf_sc.uc_mcontext.sc_fs = regs->tf_fs; 273 frame.sf_sc.uc_mcontext.sc_es = regs->tf_es; 274 frame.sf_sc.uc_mcontext.sc_ds = regs->tf_ds; 275 frame.sf_sc.uc_mcontext.sc_edi = regs->tf_edi; 276 frame.sf_sc.uc_mcontext.sc_esi = regs->tf_esi; 277 frame.sf_sc.uc_mcontext.sc_ebp = regs->tf_ebp; 278 frame.sf_sc.uc_mcontext.sc_ebx = regs->tf_ebx; 279 frame.sf_sc.uc_mcontext.sc_edx = regs->tf_edx; 280 frame.sf_sc.uc_mcontext.sc_ecx = regs->tf_ecx; 281 frame.sf_sc.uc_mcontext.sc_eax = regs->tf_eax; 282 frame.sf_sc.uc_mcontext.sc_eip = regs->tf_eip; 283 frame.sf_sc.uc_mcontext.sc_cs = regs->tf_cs; 284 frame.sf_sc.uc_mcontext.sc_eflags = regs->tf_eflags; 285 frame.sf_sc.uc_mcontext.sc_esp_at_signal = regs->tf_esp; 286 frame.sf_sc.uc_mcontext.sc_ss = regs->tf_ss; 287 frame.sf_sc.uc_mcontext.sc_err = regs->tf_err; 288 frame.sf_sc.uc_mcontext.sc_trapno = code; /* XXX ???? */ 289 | 281 frame.sf_sc.uc_mcontext.sc_gs = rgs(); 282 frame.sf_sc.uc_mcontext.sc_fs = regs->tf_fs; 283 frame.sf_sc.uc_mcontext.sc_es = regs->tf_es; 284 frame.sf_sc.uc_mcontext.sc_ds = regs->tf_ds; 285 frame.sf_sc.uc_mcontext.sc_edi = regs->tf_edi; 286 frame.sf_sc.uc_mcontext.sc_esi = regs->tf_esi; 287 frame.sf_sc.uc_mcontext.sc_ebp = regs->tf_ebp; 288 frame.sf_sc.uc_mcontext.sc_ebx = regs->tf_ebx; 289 frame.sf_sc.uc_mcontext.sc_edx = regs->tf_edx; 290 frame.sf_sc.uc_mcontext.sc_ecx = regs->tf_ecx; 291 frame.sf_sc.uc_mcontext.sc_eax = regs->tf_eax; 292 frame.sf_sc.uc_mcontext.sc_eip = regs->tf_eip; 293 frame.sf_sc.uc_mcontext.sc_cs = regs->tf_cs; 294 frame.sf_sc.uc_mcontext.sc_eflags = regs->tf_eflags; 295 frame.sf_sc.uc_mcontext.sc_esp_at_signal = regs->tf_esp; 296 frame.sf_sc.uc_mcontext.sc_ss = regs->tf_ss; 297 frame.sf_sc.uc_mcontext.sc_err = regs->tf_err; 298 frame.sf_sc.uc_mcontext.sc_trapno = code; /* XXX ???? */ 299 |
290 /* 291 * Build the remainder of the ucontext struct to be used by sigreturn. 292 */ 293 frame.sf_sc.uc_flags = 0; /* XXX ??? */ 294 frame.sf_sc.uc_link = NULL; /* XXX ??? */ 295 frame.sf_sc.uc_stack.ss_sp = p->p_sigstk.ss_sp; 296 frame.sf_sc.uc_stack.ss_flags = 297 bsd_to_linux_sigaltstack(p->p_sigstk.ss_flags); 298 frame.sf_sc.uc_stack.ss_size = p->p_sigstk.ss_size; | |
299#ifdef DEBUG 300 printf("Linux-emul(%ld): rt_sendsig flags: 0x%x, sp: %p, ss: 0x%x, mask: 0x%x\n", 301 (long)p->p_pid, frame.sf_sc.uc_stack.ss_flags, p->p_sigstk.ss_sp, 302 p->p_sigstk.ss_size, frame.sf_sc.uc_mcontext.sc_mask); 303#endif | 300#ifdef DEBUG 301 printf("Linux-emul(%ld): rt_sendsig flags: 0x%x, sp: %p, ss: 0x%x, mask: 0x%x\n", 302 (long)p->p_pid, frame.sf_sc.uc_stack.ss_flags, p->p_sigstk.ss_sp, 303 p->p_sigstk.ss_size, frame.sf_sc.uc_mcontext.sc_mask); 304#endif |
304 bsd_to_linux_sigset(mask, &frame.sf_sc.uc_sigmask); | |
305 306 if (copyout(&frame, fp, sizeof(frame)) != 0) { 307 /* 308 * Process has trashed its stack; give it an illegal 309 * instruction to halt it in its tracks. 310 */ 311 sigexit(p, SIGILL); 312 /* NOTREACHED */ --- 27 unchanged lines hidden (view full) --- 340 */ 341 342static void 343linux_sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code) 344{ 345 register struct proc *p = curproc; 346 register struct trapframe *regs; 347 struct linux_sigframe *fp, frame; | 305 306 if (copyout(&frame, fp, sizeof(frame)) != 0) { 307 /* 308 * Process has trashed its stack; give it an illegal 309 * instruction to halt it in its tracks. 310 */ 311 sigexit(p, SIGILL); 312 /* NOTREACHED */ --- 27 unchanged lines hidden (view full) --- 340 */ 341 342static void 343linux_sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code) 344{ 345 register struct proc *p = curproc; 346 register struct trapframe *regs; 347 struct linux_sigframe *fp, frame; |
348 struct sigacts *psp = p->p_sigacts; | 348 linux_sigset_t lmask; |
349 int oonstack, i; 350 | 349 int oonstack, i; 350 |
351 if (SIGISMEMBER(p->p_sigacts->ps_siginfo, sig)) { 352 /* Signal handler installed with SA_SIGINFO. */ 353 linux_rt_sendsig(catcher, sig, mask, code); 354 return; 355 } 356 |
|
351 regs = p->p_md.md_regs; 352 oonstack = p->p_sigstk.ss_flags & SS_ONSTACK; 353 354#ifdef DEBUG 355 printf("Linux-emul(%ld): linux_sendsig(%p, %d, %p, %lu)\n", 356 (long)p->p_pid, catcher, sig, (void*)mask, code); 357#endif 358 | 357 regs = p->p_md.md_regs; 358 oonstack = p->p_sigstk.ss_flags & SS_ONSTACK; 359 360#ifdef DEBUG 361 printf("Linux-emul(%ld): linux_sendsig(%p, %d, %p, %lu)\n", 362 (long)p->p_pid, catcher, sig, (void*)mask, code); 363#endif 364 |
359 if (SIGISMEMBER(p->p_sigacts->ps_siginfo, sig)) { 360 /* Signal handler installed with SA_SIGINFO. */ 361 linux_rt_sendsig(catcher, sig, mask, code); 362 return; 363 } 364 | |
365 /* 366 * Allocate space for the signal handler context. 367 */ 368 if ((p->p_flag & P_ALTSTACK) && !oonstack && | 365 /* 366 * Allocate space for the signal handler context. 367 */ 368 if ((p->p_flag & P_ALTSTACK) && !oonstack && |
369 SIGISMEMBER(psp->ps_sigonstack, sig)) { | 369 SIGISMEMBER(p->p_sigacts->ps_sigonstack, sig)) { |
370 fp = (struct linux_sigframe *)(p->p_sigstk.ss_sp + 371 p->p_sigstk.ss_size - sizeof(struct linux_sigframe)); 372 p->p_sigstk.ss_flags |= SS_ONSTACK; 373 } else { 374 fp = (struct linux_sigframe *)regs->tf_esp - 1; 375 } 376 377 /* --- 21 unchanged lines hidden (view full) --- 399 */ 400 if (p->p_sysent->sv_sigtbl) 401 if (sig <= p->p_sysent->sv_sigsize) 402 sig = p->p_sysent->sv_sigtbl[_SIG_IDX(sig)]; 403 404 frame.sf_handler = catcher; 405 frame.sf_sig = sig; 406 | 370 fp = (struct linux_sigframe *)(p->p_sigstk.ss_sp + 371 p->p_sigstk.ss_size - sizeof(struct linux_sigframe)); 372 p->p_sigstk.ss_flags |= SS_ONSTACK; 373 } else { 374 fp = (struct linux_sigframe *)regs->tf_esp - 1; 375 } 376 377 /* --- 21 unchanged lines hidden (view full) --- 399 */ 400 if (p->p_sysent->sv_sigtbl) 401 if (sig <= p->p_sysent->sv_sigsize) 402 sig = p->p_sysent->sv_sigtbl[_SIG_IDX(sig)]; 403 404 frame.sf_handler = catcher; 405 frame.sf_sig = sig; 406 |
407 bsd_to_linux_sigset(mask, &lmask); 408 |
|
407 /* 408 * Build the signal context to be used by sigreturn. 409 */ | 409 /* 410 * Build the signal context to be used by sigreturn. 411 */ |
410 frame.sf_sc.sc_mask = mask->__bits[0]; | 412 frame.sf_sc.sc_mask = lmask.__bits[0]; |
411 frame.sf_sc.sc_gs = rgs(); 412 frame.sf_sc.sc_fs = regs->tf_fs; 413 frame.sf_sc.sc_es = regs->tf_es; 414 frame.sf_sc.sc_ds = regs->tf_ds; 415 frame.sf_sc.sc_edi = regs->tf_edi; 416 frame.sf_sc.sc_esi = regs->tf_esi; 417 frame.sf_sc.sc_ebp = regs->tf_ebp; 418 frame.sf_sc.sc_ebx = regs->tf_ebx; 419 frame.sf_sc.sc_edx = regs->tf_edx; 420 frame.sf_sc.sc_ecx = regs->tf_ecx; 421 frame.sf_sc.sc_eax = regs->tf_eax; 422 frame.sf_sc.sc_eip = regs->tf_eip; 423 frame.sf_sc.sc_cs = regs->tf_cs; 424 frame.sf_sc.sc_eflags = regs->tf_eflags; 425 frame.sf_sc.sc_esp_at_signal = regs->tf_esp; 426 frame.sf_sc.sc_ss = regs->tf_ss; 427 frame.sf_sc.sc_err = regs->tf_err; 428 frame.sf_sc.sc_trapno = code; /* XXX ???? */ | 413 frame.sf_sc.sc_gs = rgs(); 414 frame.sf_sc.sc_fs = regs->tf_fs; 415 frame.sf_sc.sc_es = regs->tf_es; 416 frame.sf_sc.sc_ds = regs->tf_ds; 417 frame.sf_sc.sc_edi = regs->tf_edi; 418 frame.sf_sc.sc_esi = regs->tf_esi; 419 frame.sf_sc.sc_ebp = regs->tf_ebp; 420 frame.sf_sc.sc_ebx = regs->tf_ebx; 421 frame.sf_sc.sc_edx = regs->tf_edx; 422 frame.sf_sc.sc_ecx = regs->tf_ecx; 423 frame.sf_sc.sc_eax = regs->tf_eax; 424 frame.sf_sc.sc_eip = regs->tf_eip; 425 frame.sf_sc.sc_cs = regs->tf_cs; 426 frame.sf_sc.sc_eflags = regs->tf_eflags; 427 frame.sf_sc.sc_esp_at_signal = regs->tf_esp; 428 frame.sf_sc.sc_ss = regs->tf_ss; 429 frame.sf_sc.sc_err = regs->tf_err; 430 frame.sf_sc.sc_trapno = code; /* XXX ???? */ |
429 bzero(&frame.fpstate, sizeof(struct linux_fpstate)); | 431 432 bzero(&frame.sf_fpstate, sizeof(struct linux_fpstate)); 433 |
430 for (i = 0; i < (LINUX_NSIG_WORDS-1); i++) | 434 for (i = 0; i < (LINUX_NSIG_WORDS-1); i++) |
431 frame.extramask[i] = mask->__bits[i+1]; 432 | 435 frame.sf_extramask[i] = lmask.__bits[i+1]; 436 |
433 if (copyout(&frame, fp, sizeof(frame)) != 0) { 434 /* 435 * Process has trashed its stack; give it an illegal 436 * instruction to halt it in its tracks. 437 */ 438 sigexit(p, SIGILL); 439 /* NOTREACHED */ 440 } --- 22 unchanged lines hidden (view full) --- 463 * psl to gain improper privileges or to cause 464 * a machine fault. 465 */ 466int 467linux_sigreturn(p, args) 468 struct proc *p; 469 struct linux_sigreturn_args *args; 470{ | 437 if (copyout(&frame, fp, sizeof(frame)) != 0) { 438 /* 439 * Process has trashed its stack; give it an illegal 440 * instruction to halt it in its tracks. 441 */ 442 sigexit(p, SIGILL); 443 /* NOTREACHED */ 444 } --- 22 unchanged lines hidden (view full) --- 467 * psl to gain improper privileges or to cause 468 * a machine fault. 469 */ 470int 471linux_sigreturn(p, args) 472 struct proc *p; 473 struct linux_sigreturn_args *args; 474{ |
471 struct linux_sigcontext context; | 475 struct linux_sigframe frame; |
472 register struct trapframe *regs; | 476 register struct trapframe *regs; |
473 u_int extramask[LINUX_NSIG_WORDS-1]; 474 u_int *emp; | 477 linux_sigset_t lmask; |
475 int eflags, i; 476 477 regs = p->p_md.md_regs; 478 479#ifdef DEBUG 480 printf("Linux-emul(%ld): linux_sigreturn(%p)\n", 481 (long)p->p_pid, (void *)args->scp); 482#endif 483 /* | 478 int eflags, i; 479 480 regs = p->p_md.md_regs; 481 482#ifdef DEBUG 483 printf("Linux-emul(%ld): linux_sigreturn(%p)\n", 484 (long)p->p_pid, (void *)args->scp); 485#endif 486 /* |
484 * The trampoline code hands us the context. | 487 * The trampoline code hands us the sigframe. |
485 * It is unsafe to keep track of it ourselves, in the event that a 486 * program jumps out of a signal handler. 487 */ | 488 * It is unsafe to keep track of it ourselves, in the event that a 489 * program jumps out of a signal handler. 490 */ |
488 if (copyin((caddr_t)args->scp, &context, sizeof(context)) != 0) | 491 if (copyin((caddr_t)args->sfp, &frame, sizeof(frame)) != 0) |
489 return (EFAULT); 490 491 /* 492 * Check for security violations. 493 */ 494#define EFLAGS_SECURE(ef, oef) ((((ef) ^ (oef)) & ~PSL_USERCHANGE) == 0) | 492 return (EFAULT); 493 494 /* 495 * Check for security violations. 496 */ 497#define EFLAGS_SECURE(ef, oef) ((((ef) ^ (oef)) & ~PSL_USERCHANGE) == 0) |
495 eflags = context.sc_eflags; | 498 eflags = frame.sf_sc.sc_eflags; |
496 /* 497 * XXX do allow users to change the privileged flag PSL_RF. The 498 * cpu sets PSL_RF in tf_eflags for faults. Debuggers should 499 * sometimes set it there too. tf_eflags is kept in the signal 500 * context during signal handling and there is no other place 501 * to remember it, so the PSL_RF bit may be corrupted by the 502 * signal handler without us knowing. Corruption of the PSL_RF 503 * bit at worst causes one more or one less debugger trap, so --- 4 unchanged lines hidden (view full) --- 508 } 509 510 /* 511 * Don't allow users to load a valid privileged %cs. Let the 512 * hardware check for invalid selectors, excess privilege in 513 * other selectors, invalid %eip's and invalid %esp's. 514 */ 515#define CS_SECURE(cs) (ISPL(cs) == SEL_UPL) | 499 /* 500 * XXX do allow users to change the privileged flag PSL_RF. The 501 * cpu sets PSL_RF in tf_eflags for faults. Debuggers should 502 * sometimes set it there too. tf_eflags is kept in the signal 503 * context during signal handling and there is no other place 504 * to remember it, so the PSL_RF bit may be corrupted by the 505 * signal handler without us knowing. Corruption of the PSL_RF 506 * bit at worst causes one more or one less debugger trap, so --- 4 unchanged lines hidden (view full) --- 511 } 512 513 /* 514 * Don't allow users to load a valid privileged %cs. Let the 515 * hardware check for invalid selectors, excess privilege in 516 * other selectors, invalid %eip's and invalid %esp's. 517 */ 518#define CS_SECURE(cs) (ISPL(cs) == SEL_UPL) |
516 if (!CS_SECURE(context.sc_cs)) { | 519 if (!CS_SECURE(frame.sf_sc.sc_cs)) { |
517 trapsignal(p, SIGBUS, T_PROTFLT); 518 return(EINVAL); 519 } 520 521 p->p_sigstk.ss_flags &= ~SS_ONSTACK; | 520 trapsignal(p, SIGBUS, T_PROTFLT); 521 return(EINVAL); 522 } 523 524 p->p_sigstk.ss_flags &= ~SS_ONSTACK; |
522 emp = (u_int *)((caddr_t)args->scp + sizeof(context) + 523 sizeof(struct linux_fpstate)); 524 if (copyin((caddr_t)emp, extramask, sizeof(extramask)) == 0) 525 for (i = 0; i < (LINUX_NSIG_WORDS-1); i++) 526 p->p_sigmask.__bits[i+1] = extramask[i]; 527 528 SIGSETOLD(p->p_sigmask, context.sc_mask); | 525 lmask.__bits[0] = frame.sf_sc.sc_mask; 526 for (i = 0; i < (LINUX_NSIG_WORDS-1); i++) 527 lmask.__bits[i+1] = frame.sf_extramask[i]; 528 linux_to_bsd_sigset(&lmask, &p->p_sigmask); |
529 SIG_CANTMASK(p->p_sigmask); 530 531 /* 532 * Restore signal context. 533 */ 534 /* %gs was restored by the trampoline. */ | 529 SIG_CANTMASK(p->p_sigmask); 530 531 /* 532 * Restore signal context. 533 */ 534 /* %gs was restored by the trampoline. */ |
535 regs->tf_fs = context.sc_fs; 536 regs->tf_es = context.sc_es; 537 regs->tf_ds = context.sc_ds; 538 regs->tf_edi = context.sc_edi; 539 regs->tf_esi = context.sc_esi; 540 regs->tf_ebp = context.sc_ebp; 541 regs->tf_ebx = context.sc_ebx; 542 regs->tf_edx = context.sc_edx; 543 regs->tf_ecx = context.sc_ecx; 544 regs->tf_eax = context.sc_eax; 545 regs->tf_eip = context.sc_eip; 546 regs->tf_cs = context.sc_cs; | 535 regs->tf_fs = frame.sf_sc.sc_fs; 536 regs->tf_es = frame.sf_sc.sc_es; 537 regs->tf_ds = frame.sf_sc.sc_ds; 538 regs->tf_edi = frame.sf_sc.sc_edi; 539 regs->tf_esi = frame.sf_sc.sc_esi; 540 regs->tf_ebp = frame.sf_sc.sc_ebp; 541 regs->tf_ebx = frame.sf_sc.sc_ebx; 542 regs->tf_edx = frame.sf_sc.sc_edx; 543 regs->tf_ecx = frame.sf_sc.sc_ecx; 544 regs->tf_eax = frame.sf_sc.sc_eax; 545 regs->tf_eip = frame.sf_sc.sc_eip; 546 regs->tf_cs = frame.sf_sc.sc_cs; |
547 regs->tf_eflags = eflags; | 547 regs->tf_eflags = eflags; |
548 regs->tf_esp = context.sc_esp_at_signal; 549 regs->tf_ss = context.sc_ss; | 548 regs->tf_esp = frame.sf_sc.sc_esp_at_signal; 549 regs->tf_ss = frame.sf_sc.sc_ss; |
550 551 return (EJUSTRETURN); 552} 553 554/* 555 * System call to cleanup state after a signal 556 * has been taken. Reset signal mask and 557 * stack state from context left by rt_sendsig (above). --- 19 unchanged lines hidden (view full) --- 577 578 regs = p->p_md.md_regs; 579 580#ifdef DEBUG 581 printf("Linux-emul(%ld): linux_rt_sigreturn(%p)\n", 582 (long)p->p_pid, (void *)args->ucp); 583#endif 584 /* | 550 551 return (EJUSTRETURN); 552} 553 554/* 555 * System call to cleanup state after a signal 556 * has been taken. Reset signal mask and 557 * stack state from context left by rt_sendsig (above). --- 19 unchanged lines hidden (view full) --- 577 578 regs = p->p_md.md_regs; 579 580#ifdef DEBUG 581 printf("Linux-emul(%ld): linux_rt_sigreturn(%p)\n", 582 (long)p->p_pid, (void *)args->ucp); 583#endif 584 /* |
585 * The trampoline code hands us the u_context. | 585 * The trampoline code hands us the ucontext. |
586 * It is unsafe to keep track of it ourselves, in the event that a 587 * program jumps out of a signal handler. 588 */ 589 if (copyin((caddr_t)args->ucp, &uc, sizeof(uc)) != 0) 590 return (EFAULT); 591 592 context = &uc.uc_mcontext; 593 --- 27 unchanged lines hidden (view full) --- 621 return(EINVAL); 622 } 623 624 p->p_sigstk.ss_flags &= ~SS_ONSTACK; 625 linux_to_bsd_sigset(&uc.uc_sigmask, &p->p_sigmask); 626 SIG_CANTMASK(p->p_sigmask); 627 628 /* | 586 * It is unsafe to keep track of it ourselves, in the event that a 587 * program jumps out of a signal handler. 588 */ 589 if (copyin((caddr_t)args->ucp, &uc, sizeof(uc)) != 0) 590 return (EFAULT); 591 592 context = &uc.uc_mcontext; 593 --- 27 unchanged lines hidden (view full) --- 621 return(EINVAL); 622 } 623 624 p->p_sigstk.ss_flags &= ~SS_ONSTACK; 625 linux_to_bsd_sigset(&uc.uc_sigmask, &p->p_sigmask); 626 SIG_CANTMASK(p->p_sigmask); 627 628 /* |
629 * Restore signal context-> | 629 * Restore signal context |
630 */ 631 /* %gs was restored by the trampoline. */ 632 regs->tf_fs = context->sc_fs; 633 regs->tf_es = context->sc_es; 634 regs->tf_ds = context->sc_ds; 635 regs->tf_edi = context->sc_edi; 636 regs->tf_esi = context->sc_esi; 637 regs->tf_ebp = context->sc_ebp; --- 199 unchanged lines hidden --- | 630 */ 631 /* %gs was restored by the trampoline. */ 632 regs->tf_fs = context->sc_fs; 633 regs->tf_es = context->sc_es; 634 regs->tf_ds = context->sc_ds; 635 regs->tf_edi = context->sc_edi; 636 regs->tf_esi = context->sc_esi; 637 regs->tf_ebp = context->sc_ebp; --- 199 unchanged lines hidden --- |