[PATCH] SIGSEGV instead of -EFAULT

Pavel Machek (pavel@bug.ucw.cz)
Wed, 26 Aug 1998 00:10:51 +0200


Hi!

This patch changes kernel's behaviour a bit: you'll now get SIGSEGV on
read(0,0,1) [even in case of console which is broken and does not
check for errors].

Note that you can _still_ get -EFAULT: in case kernel decides not to
use that address at all. read(0,0xc0001234,1) is an example - kernel
decides that address is too bugy, will not even attempt reading from
it. [in this case broken console will return success :-( ].

This is pretty much to keep 'Re: copy_from_user() fixu' discussion
about anything concrete.

Pavel

--- clean/arch/i386/mm/fault.c Sun Aug 16 22:34:25 1998
+++ linux/arch/i386/mm/fault.c Tue Aug 25 23:36:55 1998
@@ -197,6 +203,11 @@
/* Are we prepared to handle this kernel fault? */
if ((fixup = search_exception_table(regs->eip)) != 0) {
regs->eip = fixup;
+/* For every -EFAULT, you get one SIGSEGV for FREE! */
+ tsk->tss.cr2 = address;
+ tsk->tss.error_code = error_code;
+ tsk->tss.trap_no = 14;
+ force_sig(SIGSEGV, tsk);
return;
}

-- 
I'm really pavel@atrey.karlin.mff.cuni.cz. 	   Pavel
Look at http://atrey.karlin.mff.cuni.cz/~pavel/ ;-).

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html