linux_sysvec.c (81338031c4839351c7f27c04c1e4924751319a88) | linux_sysvec.c (af682d487b6c8ebba4858b2a6578b795c885e15b) |
---|---|
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 --- 195 unchanged lines hidden (view full) --- 204 * means, deal with it here. 205 * 206 * MPSAFE 207 */ 208static int 209translate_traps(int signal, int trap_code) 210{ 211 if (signal != SIGBUS) | 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 --- 195 unchanged lines hidden (view full) --- 204 * means, deal with it here. 205 * 206 * MPSAFE 207 */ 208static int 209translate_traps(int signal, int trap_code) 210{ 211 if (signal != SIGBUS) |
212 return signal; | 212 return (signal); |
213 switch (trap_code) { 214 case T_PROTFLT: 215 case T_TSSFLT: 216 case T_DOUBLEFLT: 217 case T_PAGEFLT: | 213 switch (trap_code) { 214 case T_PROTFLT: 215 case T_TSSFLT: 216 case T_DOUBLEFLT: 217 case T_PAGEFLT: |
218 return SIGSEGV; | 218 return (SIGSEGV); |
219 default: | 219 default: |
220 return signal; | 220 return (signal); |
221 } 222} 223 224static int 225linux_fixup(register_t **stack_base, struct image_params *imgp) 226{ 227 register_t *argv, *envp; 228 --- 451 unchanged lines hidden (view full) --- 680 return (EFAULT); 681 682 /* 683 * Check for security violations. 684 */ 685#define EFLAGS_SECURE(ef, oef) ((((ef) ^ (oef)) & ~PSL_USERCHANGE) == 0) 686 eflags = frame.sf_sc.sc_eflags; 687 if (!EFLAGS_SECURE(eflags, regs->tf_eflags)) | 221 } 222} 223 224static int 225linux_fixup(register_t **stack_base, struct image_params *imgp) 226{ 227 register_t *argv, *envp; 228 --- 451 unchanged lines hidden (view full) --- 680 return (EFAULT); 681 682 /* 683 * Check for security violations. 684 */ 685#define EFLAGS_SECURE(ef, oef) ((((ef) ^ (oef)) & ~PSL_USERCHANGE) == 0) 686 eflags = frame.sf_sc.sc_eflags; 687 if (!EFLAGS_SECURE(eflags, regs->tf_eflags)) |
688 return(EINVAL); | 688 return (EINVAL); |
689 690 /* 691 * Don't allow users to load a valid privileged %cs. Let the 692 * hardware check for invalid selectors, excess privilege in 693 * other selectors, invalid %eip's and invalid %esp's. 694 */ 695#define CS_SECURE(cs) (ISPL(cs) == SEL_UPL) 696 if (!CS_SECURE(frame.sf_sc.sc_cs)) { 697 ksiginfo_init_trap(&ksi); 698 ksi.ksi_signo = SIGBUS; 699 ksi.ksi_code = BUS_OBJERR; 700 ksi.ksi_trapno = T_PROTFLT; 701 ksi.ksi_addr = (void *)regs->tf_eip; 702 trapsignal(td, &ksi); | 689 690 /* 691 * Don't allow users to load a valid privileged %cs. Let the 692 * hardware check for invalid selectors, excess privilege in 693 * other selectors, invalid %eip's and invalid %esp's. 694 */ 695#define CS_SECURE(cs) (ISPL(cs) == SEL_UPL) 696 if (!CS_SECURE(frame.sf_sc.sc_cs)) { 697 ksiginfo_init_trap(&ksi); 698 ksi.ksi_signo = SIGBUS; 699 ksi.ksi_code = BUS_OBJERR; 700 ksi.ksi_trapno = T_PROTFLT; 701 ksi.ksi_addr = (void *)regs->tf_eip; 702 trapsignal(td, &ksi); |
703 return(EINVAL); | 703 return (EINVAL); |
704 } 705 706 lmask.__bits[0] = frame.sf_sc.sc_mask; 707 for (i = 0; i < (LINUX_NSIG_WORDS-1); i++) 708 lmask.__bits[i+1] = frame.sf_extramask[i]; 709 linux_to_bsd_sigset(&lmask, &bmask); 710 kern_sigprocmask(td, SIG_SETMASK, &bmask, NULL, 0); 711 --- 59 unchanged lines hidden (view full) --- 771 context = &uc.uc_mcontext; 772 773 /* 774 * Check for security violations. 775 */ 776#define EFLAGS_SECURE(ef, oef) ((((ef) ^ (oef)) & ~PSL_USERCHANGE) == 0) 777 eflags = context->sc_eflags; 778 if (!EFLAGS_SECURE(eflags, regs->tf_eflags)) | 704 } 705 706 lmask.__bits[0] = frame.sf_sc.sc_mask; 707 for (i = 0; i < (LINUX_NSIG_WORDS-1); i++) 708 lmask.__bits[i+1] = frame.sf_extramask[i]; 709 linux_to_bsd_sigset(&lmask, &bmask); 710 kern_sigprocmask(td, SIG_SETMASK, &bmask, NULL, 0); 711 --- 59 unchanged lines hidden (view full) --- 771 context = &uc.uc_mcontext; 772 773 /* 774 * Check for security violations. 775 */ 776#define EFLAGS_SECURE(ef, oef) ((((ef) ^ (oef)) & ~PSL_USERCHANGE) == 0) 777 eflags = context->sc_eflags; 778 if (!EFLAGS_SECURE(eflags, regs->tf_eflags)) |
779 return(EINVAL); | 779 return (EINVAL); |
780 781 /* 782 * Don't allow users to load a valid privileged %cs. Let the 783 * hardware check for invalid selectors, excess privilege in 784 * other selectors, invalid %eip's and invalid %esp's. 785 */ 786#define CS_SECURE(cs) (ISPL(cs) == SEL_UPL) 787 if (!CS_SECURE(context->sc_cs)) { 788 ksiginfo_init_trap(&ksi); 789 ksi.ksi_signo = SIGBUS; 790 ksi.ksi_code = BUS_OBJERR; 791 ksi.ksi_trapno = T_PROTFLT; 792 ksi.ksi_addr = (void *)regs->tf_eip; 793 trapsignal(td, &ksi); | 780 781 /* 782 * Don't allow users to load a valid privileged %cs. Let the 783 * hardware check for invalid selectors, excess privilege in 784 * other selectors, invalid %eip's and invalid %esp's. 785 */ 786#define CS_SECURE(cs) (ISPL(cs) == SEL_UPL) 787 if (!CS_SECURE(context->sc_cs)) { 788 ksiginfo_init_trap(&ksi); 789 ksi.ksi_signo = SIGBUS; 790 ksi.ksi_code = BUS_OBJERR; 791 ksi.ksi_trapno = T_PROTFLT; 792 ksi.ksi_addr = (void *)regs->tf_eip; 793 trapsignal(td, &ksi); |
794 return(EINVAL); | 794 return (EINVAL); |
795 } 796 797 linux_to_bsd_sigset(&uc.uc_sigmask, &bmask); 798 kern_sigprocmask(td, SIG_SETMASK, &bmask, NULL, 0); 799 800 /* 801 * Restore signal context 802 */ --- 339 unchanged lines hidden (view full) --- 1142 EVENTHANDLER_DEREGISTER(thread_dtor, linux_thread_dtor_tag); 1143 linux_osd_jail_deregister(); 1144 if (bootverbose) 1145 printf("Linux ELF exec handler removed\n"); 1146 } else 1147 printf("Could not deinstall ELF interpreter entry\n"); 1148 break; 1149 default: | 795 } 796 797 linux_to_bsd_sigset(&uc.uc_sigmask, &bmask); 798 kern_sigprocmask(td, SIG_SETMASK, &bmask, NULL, 0); 799 800 /* 801 * Restore signal context 802 */ --- 339 unchanged lines hidden (view full) --- 1142 EVENTHANDLER_DEREGISTER(thread_dtor, linux_thread_dtor_tag); 1143 linux_osd_jail_deregister(); 1144 if (bootverbose) 1145 printf("Linux ELF exec handler removed\n"); 1146 } else 1147 printf("Could not deinstall ELF interpreter entry\n"); 1148 break; 1149 default: |
1150 return EOPNOTSUPP; | 1150 return (EOPNOTSUPP); |
1151 } | 1151 } |
1152 return error; | 1152 return (error); |
1153} 1154 1155static moduledata_t linux_elf_mod = { 1156 "linuxelf", 1157 linux_elf_modevent, 1158 0 1159}; 1160 1161DECLARE_MODULE_TIED(linuxelf, linux_elf_mod, SI_SUB_EXEC, SI_ORDER_ANY); | 1153} 1154 1155static moduledata_t linux_elf_mod = { 1156 "linuxelf", 1157 linux_elf_modevent, 1158 0 1159}; 1160 1161DECLARE_MODULE_TIED(linuxelf, linux_elf_mod, SI_SUB_EXEC, SI_ORDER_ANY); |