From 403b2266db205fedd91befbb16fddd581245ae35 Mon Sep 17 00:00:00 2001 From: deraadt Date: Fri, 12 Jan 1996 16:45:00 +0000 Subject: [PATCH] SIGBUS is an alignment fault. SIGSEGV is an access violation --- sys/arch/alpha/alpha/trap.c | 2 +- sys/arch/amiga/amiga/trap.c | 2 +- sys/arch/atari/atari/trap.c | 2 +- sys/arch/hp300/hp300/trap.c | 20 ++++---------------- sys/arch/i386/i386/locore.s | 2 +- sys/arch/i386/i386/trap.c | 3 +-- sys/arch/mac68k/mac68k/trap.c | 20 ++++---------------- sys/arch/mvme68k/mvme68k/trap.c | 22 +++++----------------- sys/arch/mvme88k/mvme88k/trap.c | 2 +- sys/arch/pc532/pc532/trap.c | 4 ++-- sys/arch/pica/pica/trap.c | 6 +++--- sys/arch/pmax/pmax/trap.c | 4 ++-- sys/arch/sun3/sun3/trap.c | 2 +- 13 files changed, 27 insertions(+), 64 deletions(-) diff --git a/sys/arch/alpha/alpha/trap.c b/sys/arch/alpha/alpha/trap.c index fcea4840ca4..e1ec691761a 100644 --- a/sys/arch/alpha/alpha/trap.c +++ b/sys/arch/alpha/alpha/trap.c @@ -295,7 +295,7 @@ sigfpe: i = SIGFPE; goto dopanic; } ucode = v; - i = (rv == KERN_PROTECTION_FAILURE) ? SIGBUS : SIGSEGV; + i = SIGSEGV; break; } diff --git a/sys/arch/amiga/amiga/trap.c b/sys/arch/amiga/amiga/trap.c index ee104684fde..cd6f281691c 100644 --- a/sys/arch/amiga/amiga/trap.c +++ b/sys/arch/amiga/amiga/trap.c @@ -455,7 +455,7 @@ nogo: type, code); panictrap(type, code, v, fp); } - trapsignal(p, (rv == KERN_PROTECTION_FAILURE) ? SIGBUS : SIGSEGV, v); + trapsignal(p, SIGSEGV, v); if ((type & T_USER) == 0) return; userret(p, fp->f_pc, sticks); diff --git a/sys/arch/atari/atari/trap.c b/sys/arch/atari/atari/trap.c index 9ccb593926c..7d6858d1933 100644 --- a/sys/arch/atari/atari/trap.c +++ b/sys/arch/atari/atari/trap.c @@ -440,7 +440,7 @@ nogo: type, code); panictrap(type, code, v, fp); } - trapsignal(p, (rv == KERN_PROTECTION_FAILURE) ? SIGBUS : SIGSEGV, v); + trapsignal(p, SIGSEGV, v); if ((type & T_USER) == 0) return; userret(p, fp->f_pc, sticks); diff --git a/sys/arch/hp300/hp300/trap.c b/sys/arch/hp300/hp300/trap.c index eb33b83aeb4..ebc9a5dac3b 100644 --- a/sys/arch/hp300/hp300/trap.c +++ b/sys/arch/hp300/hp300/trap.c @@ -564,7 +564,7 @@ copyfault: goto dopanic; } ucode = v; - i = (rv == KERN_PROTECTION_FAILURE) ? SIGBUS : SIGSEGV; + i = SIGSEGV; break; } } @@ -819,22 +819,10 @@ writeback(fp, docachepush) } p->p_addr->u_pcb.pcb_onfault = oonfault; /* - * Determine the cause of the failure if any translating to - * a signal. If the corresponding VA is valid and RO it is - * a protection fault (SIGBUS) otherwise consider it an - * illegal reference (SIGSEGV). + * Any problems are SIGSEGV's */ - if (err) { - if (vm_map_check_protection(&p->p_vmspace->vm_map, - trunc_page(fa), round_page(fa), - VM_PROT_READ) && - !vm_map_check_protection(&p->p_vmspace->vm_map, - trunc_page(fa), round_page(fa), - VM_PROT_WRITE)) - err = SIGBUS; - else - err = SIGSEGV; - } + if (err) + err = SIGSEGV; return(err); } diff --git a/sys/arch/i386/i386/locore.s b/sys/arch/i386/i386/locore.s index 3fe77734a0e..97e36ba250f 100644 --- a/sys/arch/i386/i386/locore.s +++ b/sys/arch/i386/i386/locore.s @@ -1887,7 +1887,7 @@ IDTVEC(align) * If an error is detected during trap, syscall, or interrupt exit, trap() will * change %eip to point to one of these labels. We clean up the stack, if * necessary, and resume as if we were handling a general protection fault. - * This will cause the process to get a SIGBUS. + * This will cause the process to get a SIGSEGV. */ ENTRY(resume_iret) ZTRAP(T_PROTFLT) diff --git a/sys/arch/i386/i386/trap.c b/sys/arch/i386/i386/trap.c index f6feb3f1faf..c929d7eb178 100644 --- a/sys/arch/i386/i386/trap.c +++ b/sys/arch/i386/i386/trap.c @@ -412,8 +412,7 @@ trap(frame) map, va, ftype, rv); goto we_re_toast; } - trapsignal(p, (rv == KERN_PROTECTION_FAILURE) - ? SIGBUS : SIGSEGV, T_PAGEFLT); + trapsignal(p, SIGSEGV, T_PAGEFLT); break; } diff --git a/sys/arch/mac68k/mac68k/trap.c b/sys/arch/mac68k/mac68k/trap.c index 97496cbaf5a..9798285fb7e 100644 --- a/sys/arch/mac68k/mac68k/trap.c +++ b/sys/arch/mac68k/mac68k/trap.c @@ -548,7 +548,7 @@ copyfault: goto dopanic; } ucode = v; - i = (rv == KERN_PROTECTION_FAILURE) ? SIGBUS : SIGSEGV; + i = SIGSEGV; break; } } @@ -803,22 +803,10 @@ writeback(fp, docachepush) } p->p_addr->u_pcb.pcb_onfault = oonfault; /* - * Determine the cause of the failure if any translating to - * a signal. If the corresponding VA is valid and RO it is - * a protection fault (SIGBUS) otherwise consider it an - * illegal reference (SIGSEGV). + * Any problems are SIGSEGV's */ - if (err) { - if (vm_map_check_protection(&p->p_vmspace->vm_map, - trunc_page(fa), round_page(fa), - VM_PROT_READ) && - !vm_map_check_protection(&p->p_vmspace->vm_map, - trunc_page(fa), round_page(fa), - VM_PROT_WRITE)) - err = SIGBUS; - else - err = SIGSEGV; - } + if (err) + err = SIGSEGV; return(err); } diff --git a/sys/arch/mvme68k/mvme68k/trap.c b/sys/arch/mvme68k/mvme68k/trap.c index 3c81ef7b474..2b0e8fcd1f9 100644 --- a/sys/arch/mvme68k/mvme68k/trap.c +++ b/sys/arch/mvme68k/mvme68k/trap.c @@ -1,4 +1,4 @@ -/* $Id: trap.c,v 1.4 1995/11/23 13:14:31 deraadt Exp $ */ +/* $Id: trap.c,v 1.5 1996/01/12 16:45:14 deraadt Exp $ */ /* * Copyright (c) 1995 Theo de Raadt @@ -611,7 +611,7 @@ copyfault: goto dopanic; } ucode = v; - i = (rv == KERN_PROTECTION_FAILURE) ? SIGBUS : SIGSEGV; + i = SIGSEGV; break; } } @@ -867,22 +867,10 @@ writeback(fp, docachepush) } p->p_addr->u_pcb.pcb_onfault = oonfault; /* - * Determine the cause of the failure if any translating to - * a signal. If the corresponding VA is valid and RO it is - * a protection fault (SIGBUS) otherwise consider it an - * illegal reference (SIGSEGV). + * Any problems are SIGSEGV's */ - if (err) { - if (vm_map_check_protection(&p->p_vmspace->vm_map, - trunc_page(fa), round_page(fa), - VM_PROT_READ) && - !vm_map_check_protection(&p->p_vmspace->vm_map, - trunc_page(fa), round_page(fa), - VM_PROT_WRITE)) - err = SIGBUS; - else - err = SIGSEGV; - } + if (err) + err = SIGSEGV; return(err); } diff --git a/sys/arch/mvme88k/mvme88k/trap.c b/sys/arch/mvme88k/mvme88k/trap.c index ebdf5288c81..d399c351661 100644 --- a/sys/arch/mvme88k/mvme88k/trap.c +++ b/sys/arch/mvme88k/mvme88k/trap.c @@ -348,7 +348,7 @@ trap(unsigned type, struct m88100_saved_state *frame) frame->snip = frame->sxip & ~NIP_E; } } else { - sig = result == KERN_PROTECTION_FAILURE ? SIGBUS : SIGSEGV; + sig = result == SIGSEGV; } break; diff --git a/sys/arch/pc532/pc532/trap.c b/sys/arch/pc532/pc532/trap.c index d72213d7d48..300ff782d5b 100644 --- a/sys/arch/pc532/pc532/trap.c +++ b/sys/arch/pc532/pc532/trap.c @@ -176,7 +176,7 @@ copyfault: * APDEpde (or there may be no problem with APDEpde). */ if (va > 0xFEBFF000) { - v = KERN_FAILURE; /* becomes SIGBUS */ + v = KERN_FAILURE; /* becomes SIGSEGV */ goto nogo; } /* @@ -253,7 +253,7 @@ nogo: type, tear, msr); goto we_re_toast; } - i = (rv == KERN_PROTECTION_FAILURE) ? SIGBUS : SIGSEGV; + i = SIGSEGV; break; } diff --git a/sys/arch/pica/pica/trap.c b/sys/arch/pica/pica/trap.c index bf210a3053e..ce3e1641db5 100644 --- a/sys/arch/pica/pica/trap.c +++ b/sys/arch/pica/pica/trap.c @@ -38,7 +38,7 @@ * from: Utah Hdr: trap.c 1.32 91/04/06 * * from: @(#)trap.c 8.5 (Berkeley) 1/11/94 - * $Id: trap.c,v 1.3 1995/10/29 00:46:10 deraadt Exp $ + * $Id: trap.c,v 1.4 1996/01/12 16:45:19 deraadt Exp $ */ #include @@ -429,7 +429,7 @@ trap(statusReg, causeReg, vadr, pc, args) goto err; } ucode = vadr; - i = (rv == KERN_PROTECTION_FAILURE) ? SIGBUS : SIGSEGV; + i = SIGSEGV; break; } @@ -437,7 +437,7 @@ trap(statusReg, causeReg, vadr, pc, args) case T_ADDR_ERR_ST+T_USER: /* misaligned or kseg access */ case T_BUS_ERR_IFETCH+T_USER: /* BERR asserted to cpu */ case T_BUS_ERR_LD_ST+T_USER: /* BERR asserted to cpu */ - i = SIGSEGV; + i = SIGBUS; break; case T_SYSCALL+T_USER: diff --git a/sys/arch/pmax/pmax/trap.c b/sys/arch/pmax/pmax/trap.c index d4b3cf1a3ec..50f6b029d72 100644 --- a/sys/arch/pmax/pmax/trap.c +++ b/sys/arch/pmax/pmax/trap.c @@ -438,7 +438,7 @@ trap(statusReg, causeReg, vadr, pc, args) goto err; } ucode = vadr; - i = (rv == KERN_PROTECTION_FAILURE) ? SIGBUS : SIGSEGV; + i = SIGSEGV; break; } @@ -446,7 +446,7 @@ trap(statusReg, causeReg, vadr, pc, args) case T_ADDR_ERR_ST+T_USER: /* misaligned or kseg access */ case T_BUS_ERR_IFETCH+T_USER: /* BERR asserted to cpu */ case T_BUS_ERR_LD_ST+T_USER: /* BERR asserted to cpu */ - i = SIGSEGV; + i = SIGBUS; break; case T_SYSCALL+T_USER: diff --git a/sys/arch/sun3/sun3/trap.c b/sys/arch/sun3/sun3/trap.c index c2d6e2c2cf7..24702194758 100644 --- a/sys/arch/sun3/sun3/trap.c +++ b/sys/arch/sun3/sun3/trap.c @@ -522,7 +522,7 @@ trap(type, code, v, frame) goto dopanic; } ucode = v; - sig = (rv == KERN_PROTECTION_FAILURE) ? SIGBUS : SIGSEGV; + sig = SIGSEGV; break; } /* T_MMUFLT */ } /* switch */ -- 2.20.1