DragonFly kernel List (threaded) for 2007-07
DragonFly BSD
DragonFly kernel List (threaded) for 2007-07
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: link(2) and EFAULT


From: Oliver Fromme <check+jltyok00rsxcmfu5@xxxxxxxxxx>
Date: 27 Jul 2007 09:18:37 GMT

Dave Hayes wrote:
 > Under what conditions does link() return EFAULT? The man
 > page says:
 > 
 >  [EFAULT]  One of the pathnames specified is outside the
 >            process's allocated address space.
 > 
 > However I would think that if I had a (char *) pointing
 > outside the address space that I would get a segfault
 > somewhere before getting this error.

As others have pointed out, only userland applications
can generate a segfault (SIGSEGV).  If an illegal access
happens inside the kernel, it would normally panic the
machine.  Of course that would be undesirable so the
syscalls take precautions and return EFAULT in such cases.

 > How would you even
 > handle this error, should your code get it?

It's clearly an application bug to pass an invalid pointer
to a syscall.  The most sensible thing would be to print
an error message (along the line "internal error, please
report this bug to the author") and abort(2), dropping a
core dump that can be useful for debugging.

However, if the failed syscall is not critical for the
application, it might choose to continue anyway.  But a
warning should still be printed so the bug doesn't stay
unnoticed.

Best regards
   Oliver

-- 
Oliver Fromme,  secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing
Dienstleistungen mit Schwerpunkt FreeBSD: http://www.secnetix.de/bsd

Any opinions expressed in this message may be personal to the author
and may not necessarily reflect the opinions of secnetix in any way.



[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]