EFAULT vs. SIGSEGV [was Re: close return value]

From: Pavel Machek (pavel@elf.ucw.cz)
Date: Thu Jul 25 2002 - 19:06:42 EST


Hi!

> > Returning an error and still doing the operation is slightly awkward.
> > Are there any other syscalls which do similar things?
>
> mmap(MAP_FIXED) may have already unmapped any underlying old area if an
> error occurs.
>
> And EFAULT may have strange behaviour for left-over stuff. If I remember
> correctly, at some point, for example, EFAULT on a write to a TCP socket
> (if the fault happened in the middle) would still send out the full-sized
> packet zero-padded, because not doing so would have screwed up the state
> machine.
>
> (But EFAULT is a special case in general, it's documented to be undefined
> behaviour).

SOme time ago you said you'd agree to doing SIGSEGV in addition to
segfault. What about following patch? It should make difference
between VSYSCALL and normal syscall smaller...

                                                                Pavel

--- clean.2.5/arch/i386/mm/fault.c Thu Jul 25 22:21:08 2002
+++ linux/arch/i386/mm/fault.c Thu Jul 25 22:21:24 2002
@@ -305,6 +305,15 @@
 no_context:
         /* Are we prepared to handle this kernel fault? */
         if ((fixup = search_exception_table(regs->eip)) != 0) {
+ tsk->thread.cr2 = address;
+ tsk->thread.error_code = error_code;
+ tsk->thread.trap_no = 14;
+ info.si_signo = SIGSEGV;
+ info.si_errno = 0;
+ /* info.si_code has been set above */
+ info.si_addr = (void *)address;
+ force_sig_info(SIGSEGV, &info, tsk);
+
                 regs->eip = fixup;
                 return;
         }

-- 
I'm pavel@ucw.cz. "In my country we have almost anarchy and I don't care."
Panos Katsaloulis describing me w.r.t. patents at discuss@linmodems.org
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue Jul 30 2002 - 14:00:23 EST