From patchwork Tue Jun 11 01:12:10 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 17750 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-gg0-f197.google.com (mail-gg0-f197.google.com [209.85.161.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5E08F25DFB for ; Tue, 11 Jun 2013 01:12:39 +0000 (UTC) Received: by mail-gg0-f197.google.com with SMTP id x14sf6837944ggx.4 for ; Mon, 10 Jun 2013 18:12:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-beenthere:x-forwarded-to:x-forwarded-for :delivered-to:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe; bh=3Ut71jAsYmrSxIJq73YeAcFNuS5sglbUX/LUXfYCCGQ=; b=Xmu5lpfRaOaWhoYeVxoavbZ+x7/9lpNXmtvCcP/SfrVGdtRfRqf7A2fKQbgFkHON4r 0BKgoTk7bMyyy64E/zk5L/a+PmWPOmRltJQYRh9uzN8pex5GchVizC6DJp05hSB5Xe9K MGDKuu9q5VPStHUBG3XkVFWVqWz2nGMQ5Fruu8rqWg5OU0SgrSwIqO4KN0NX8zrpYgoS 1sPV3oY4nHEmMM9J76diNOwJDuTFiBeVMXfuYBLEb7EsQk/6fsSjPeeRpXvjwaW1jUn9 Hm4jjDjDAX22jvPkXc9lLcpzXoilCOs3b19Z9oiQFgLxEcOLeoZAV24eAROA8kbhLsXA ofOQ== X-Received: by 10.224.59.205 with SMTP id m13mr9717468qah.7.1370913158997; Mon, 10 Jun 2013 18:12:38 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.64.74 with SMTP id m10ls304545qes.44.gmail; Mon, 10 Jun 2013 18:12:38 -0700 (PDT) X-Received: by 10.58.133.81 with SMTP id pa17mr7195969veb.37.1370913158720; Mon, 10 Jun 2013 18:12:38 -0700 (PDT) Received: from mail-ve0-x22b.google.com (mail-ve0-x22b.google.com [2607:f8b0:400c:c01::22b]) by mx.google.com with ESMTPS id sc6si6132823vdc.125.2013.06.10.18.12.38 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 10 Jun 2013 18:12:38 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c01::22b is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c01::22b; Received: by mail-ve0-f171.google.com with SMTP id b10so5310142vea.2 for ; Mon, 10 Jun 2013 18:12:38 -0700 (PDT) X-Received: by 10.52.155.67 with SMTP id vu3mr6111605vdb.94.1370913158565; Mon, 10 Jun 2013 18:12:38 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.221.10.206 with SMTP id pb14csp89598vcb; Mon, 10 Jun 2013 18:12:38 -0700 (PDT) X-Received: by 10.66.154.225 with SMTP id vr1mr16676429pab.85.1370913157672; Mon, 10 Jun 2013 18:12:37 -0700 (PDT) Received: from mail-pd0-f182.google.com (mail-pd0-f182.google.com [209.85.192.182]) by mx.google.com with ESMTPS id wn4si5791445pbc.355.2013.06.10.18.12.37 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 10 Jun 2013 18:12:37 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.192.182 is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) client-ip=209.85.192.182; Received: by mail-pd0-f182.google.com with SMTP id r10so1893562pdi.41 for ; Mon, 10 Jun 2013 18:12:37 -0700 (PDT) X-Received: by 10.68.212.106 with SMTP id nj10mr392370pbc.74.1370913157250; Mon, 10 Jun 2013 18:12:37 -0700 (PDT) Received: from localhost.localdomain (c-67-170-153-23.hsd1.or.comcast.net. [67.170.153.23]) by mx.google.com with ESMTPSA id qe10sm9802489pbb.2.2013.06.10.18.12.35 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 10 Jun 2013 18:12:36 -0700 (PDT) From: John Stultz To: minchan@kernel.org Cc: dgiani@mozilla.com, John Stultz Subject: [PATCH 04/13] vrange: Clear volatility on new mmaps Date: Mon, 10 Jun 2013 18:12:10 -0700 Message-Id: <1370913139-9320-5-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1370913139-9320-1-git-send-email-john.stultz@linaro.org> References: <1370913139-9320-1-git-send-email-john.stultz@linaro.org> X-Gm-Message-State: ALoCoQmxqBHu67/M2iCgIr8gz1B7yosjVRAOQoXuU0wk/ba4dTSQWganeoIzYP7U1f9FoOARQbby X-Original-Sender: john.stultz@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c01::22b is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , At lsf-mm, the issue was brought up that there is a precedence with interfaces like mlock, such that new mappings in a pre-existing range do no inherit the mlock state. This is mostly because mlock only modifies the existing vmas, and so any new mmaps create new vmas, which won't be mlocked. Since volatility is not stored in the vma (for good cause, specfically as we'd have to have manage file volatility differently from anonymous), this patch clears volatilty on new mappings, to ensure that we don't inherit volatility if memory in an existing volatile range is unmapped and then re-mapped with something else. Thus, this patch forces any volatility to be cleared on mmap. XXX - Minchan would like to see this issue addressed differently. Signed-off-by: John Stultz --- include/linux/vrange.h | 2 ++ mm/mmap.c | 5 +++++ mm/vrange.c | 8 ++++++++ 3 files changed, 15 insertions(+) diff --git a/include/linux/vrange.h b/include/linux/vrange.h index 13f4887..a97ac25 100644 --- a/include/linux/vrange.h +++ b/include/linux/vrange.h @@ -32,6 +32,8 @@ static inline int vrange_type(struct vrange *vrange) } void vrange_init(void); +extern int vrange_clear(struct vrange_root *vroot, + unsigned long start, unsigned long end); extern void vrange_root_cleanup(struct vrange_root *vroot); extern int vrange_fork(struct mm_struct *new, struct mm_struct *old); diff --git a/mm/mmap.c b/mm/mmap.c index f681e18..80d3676 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -1500,6 +1501,10 @@ unsigned long mmap_region(struct file *file, unsigned long addr, /* Clear old maps */ error = -ENOMEM; munmap_back: + + /* zap any volatile ranges */ + vrange_clear(&mm->vroot, addr, addr + len); + if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) { if (do_munmap(mm, addr, len)) return -ENOMEM; diff --git a/mm/vrange.c b/mm/vrange.c index bbaa184..5ca8853 100644 --- a/mm/vrange.c +++ b/mm/vrange.c @@ -164,6 +164,14 @@ static int vrange_remove(struct vrange_root *vroot, return 0; } +int vrange_clear(struct vrange_root *vroot, + unsigned long start, unsigned long end) +{ + int purged; + + return vrange_remove(vroot, start, end-1, &purged); +} + void vrange_root_cleanup(struct vrange_root *vroot) { struct vrange *range;