From owner-freebsd-hackers@FreeBSD.ORG Tue Apr 16 23:28:34 2013 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 4124928B for ; Tue, 16 Apr 2013 23:28:34 +0000 (UTC) (envelope-from rwmaillists@googlemail.com) Received: from mail-wi0-x231.google.com (mail-wi0-x231.google.com [IPv6:2a00:1450:400c:c05::231]) by mx1.freebsd.org (Postfix) with ESMTP id CFCD21E30 for ; Tue, 16 Apr 2013 23:28:33 +0000 (UTC) Received: by mail-wi0-f177.google.com with SMTP id hm14so1002540wib.4 for ; Tue, 16 Apr 2013 16:28:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=x-received:date:from:to:subject:message-id:in-reply-to:references :x-mailer:mime-version:content-type:content-transfer-encoding; bh=FsUABFXg3iEsZaM60fYuSZFlnPdc5ZNzPLspwq2Cb/I=; b=n9VHViOc65CU84l5tLaLtrTC5rSiUcY06WblCPX+bqgMT23ycZu9dglg44A7h9zFB5 XKtBmLqBoJW+7iq2k5M32zuZBfIiAEBx+rzDeppMzH0W1GsmdRnFOV6plxxO3qrRwOeb nXVxMuJYGSePUXtpLPziPTXNN+wAN0rfWFsZ5gjmqrPSsQkXsB1tcznDAYEhTjt8/d2V qSe3rZnDyjQX0U91KfmSQK/lO+3SD8VAv5AOpQmNi9z8Oua+OHIbnaulz9JZSCBF2lnS BhLb08rSaWq0OAoOE83ufmDMBk6z8HvzTRaN2P/5uVEakRMQn84feHHlNNZw6Q0OKIfo MrRw== X-Received: by 10.194.242.163 with SMTP id wr3mr7279333wjc.35.1366154912931; Tue, 16 Apr 2013 16:28:32 -0700 (PDT) Received: from gumby.homeunix.com (87-194-105-247.bethere.co.uk. [87.194.105.247]) by mx.google.com with ESMTPS id k5sm6111727wiy.5.2013.04.16.16.28.30 (version=SSLv3 cipher=RC4-SHA bits=128/128); Tue, 16 Apr 2013 16:28:32 -0700 (PDT) Date: Wed, 17 Apr 2013 00:28:28 +0100 From: RW To: freebsd-hackers@freebsd.org Subject: Re: MADV_FREE and wait4 EFAULT Message-ID: <20130417002828.2f5a0896@gumby.homeunix.com> In-Reply-To: References: X-Mailer: Claws Mail 3.9.0 (GTK+ 2.24.17; amd64-portbld-freebsd9.1) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Apr 2013 23:28:34 -0000 On Tue, 16 Apr 2013 14:12:54 -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? IIRC MADV_FREE pages are marked clean and placed on the end of the inactive queue as "low hanging fruit" for the page daemon. AFAIK they're no different to any other clean page. Malloc'ed memory pages are commonly in that state.