MADV_FREE and wait4 EFAULT

Konstantin Belousov kostikbel at gmail.com
Wed Apr 17 08:21:48 UTC 2013


On Tue, Apr 16, 2013 at 02:12:54PM -0700, Carl Shapiro wrote:
> I am seeing wait4 system calls failing with an EFAULT and I am trying to
> understand what might be going wrong.
> 
> An inspection of the wait4 implementation suggests the  opportunity for
> EFAULT is within its invocations of copyout.  In my situation, the status
> and rusage pointer arguments contain addresses to mmaped pages which have
> been madvised as MADV_FREE.
> 
> Is it permissible to pass pages which have been madvised MADV_FREE to wait4
> or any other system call for that matter?  Might there be another
> opportunity for a wait4 to EFAULT?

Did you ensured with e.g. ktrace and procstat -v that your assumptions
hold, i.e. the addresses supplied as wait4(2) arguments are valid ?
Please provide the minimal test case demonstrating the behaviour.

MADV_FREE should only result in the possible lost of the previous
content of the page, not in the faulting of the page access. From the
inspection of the code, I do not see how MADV_FREE could result in
the memory address becoming invalid.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 834 bytes
Desc: not available
URL: <http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20130417/8e3e33fd/attachment.sig>


More information about the freebsd-hackers mailing list