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.

Attachment: pgprDGMZd7Ffy.pgp
Description: PGP signature

Reply via email to