Received: by 10.213.65.68 with SMTP id h4csp859394imn; Wed, 28 Mar 2018 14:22:40 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/UAGUd/GQtTbgAlKzRpLXRvyjJikW93SvANEDQOhvKbzYbM2fKCqP59U9NzLrqC9P67nma X-Received: by 10.101.78.132 with SMTP id b4mr3664857pgs.311.1522272160677; Wed, 28 Mar 2018 14:22:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522272160; cv=none; d=google.com; s=arc-20160816; b=08JSomUhkPvh1zCyvQm1wHWXaY5rkBE8bmZFieuc/brPJtTxhfkQyNDvMzZ6+ZkvrY xS0/0ivqntlReTNw9t9ikEzpR5NA5FswpJEkZRuPkYGkb6wNhsVstzdfEmtvYcNDCTxs 4R6lC8TKJDTAt2nv4SQKUEhISV/7zuqIjYKRdceTPUq8+Mtddi+BuDN2iofFsvOrrXpE pCsDEI5AVcVHiTu+65cq0GHxZQCkvBmda1nO7NlDXcfb/jZHmrmrcaCFx9KsQbHXzXkU vwZrnifl90j16wbPRvAPLHrq4aeiNc17vS3d/uzsxKsa9BNo1e2+Cewydng3VGdSBl5+ Vzzg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=55Ii4OQTtS7T3+8bbmiYzFjY1c18cxZod/Gjww+fKLY=; b=wvuEDrOE1Wwsg24LWPLOMJBr1bCtJXvH/ddhtjhgWRiZjCt4HQu/knr5JermniKBPY V6xiCuTnqo4TOm31HJ3u5G9EhdBCv0psUrm8T2NjCNCxO7/fJkvq2OZzJJnlVh7QWvvX TBNjh9uvm/Rl0zhFF6JsN5c8iNXz75IJrlLO+YpXeB5J5tqH4fz+3V90GyIy2zf3Vq8S jyC/cjx2fYpJi3594sq4H9qGllBANgmDG34948cwxvtuSh8m1tdZDdQwRxwUmfQJ/BMY JrVgQRN/nmZ+BHjp631GlBeBAz1BqkXr9diQP5gnbKM+LvIGs/+YYY6u2Vgp39tOufQz WK6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=g5X5DiO7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b59-v6si4311294plb.530.2018.03.28.14.22.26; Wed, 28 Mar 2018 14:22:40 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=g5X5DiO7; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753134AbeC1VVd (ORCPT + 99 others); Wed, 28 Mar 2018 17:21:33 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:38539 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752694AbeC1VVb (ORCPT ); Wed, 28 Mar 2018 17:21:31 -0400 Received: by mail-pg0-f67.google.com with SMTP id a15so1624975pgn.5 for ; Wed, 28 Mar 2018 14:21:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=55Ii4OQTtS7T3+8bbmiYzFjY1c18cxZod/Gjww+fKLY=; b=g5X5DiO7zLlzs5SroTb+9Zvfstn3u2/kSkq+vHpFdI72Yshyl6hwlEZsABzEXq0mnR gZOX+nZbODN7FqN7Hfl6BJn1CwDw3m5LQbO6JRk9AL5ySfvKb5v7bD+4KU4c/dbsFY8I FtF1SucA73Ja3qZ6CpMc1v5ADcV6zrlRHLtYEzRVxMdPnj0gozczLVOCRKPa41ooMqHe Lv1kfqUszl0xJSURrghqHli5dHyZ/eTtoDdYerRs3PFolyHCnrWsftVbuHMGgC30rJqV J3PDuBpodpKzsGUkWgHHJGeQnceb3iAjGesK3zTIB0FRwZI0srp++NHCfLPx4zI77RWH +/0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=55Ii4OQTtS7T3+8bbmiYzFjY1c18cxZod/Gjww+fKLY=; b=SuvkwFQQrKKLqP5wJQIDy3dBen72DbpNBduK0pSe55X/HPTshNkUJo7ek8ZqkbEAAL FDT1RVOxsXH+7F/mBjHvYMypWcmNy9RCP1jLUdB1jK4hczqMji08sZZ7isH22Bd1D1wl ehlzKFIwnXhuMccYWmdrKPWwN53uiArad8MNWmneTy54Auk5DV5JX5GJdaC7MnpjA5s0 RH/lQQ5vZJYJ7SNS410WCHHxjXnvjpTu7T+nqcnlT7RiaSxFHuvAJItoCqaO0WKITcOp 9lb1hOfKrIGOoh0Fmq4C77OuPXjb6cA8XiXl+w5Dz7btC6yQqAKqFdzZN0RRtvMsjkEu 7cqA== X-Gm-Message-State: AElRT7Fckjq+xIz8o0GxsGnudD2I4WmddxL4NWXA+bCVtggp7p3MXSHS 1fRSh18ISvKDN2d5jZVe92qVCw== X-Received: by 2002:a17:902:a582:: with SMTP id az2-v6mr5467312plb.37.1522272091293; Wed, 28 Mar 2018 14:21:31 -0700 (PDT) Received: from [2620:15c:17:3:3a5:23a7:5e32:4598] ([2620:15c:17:3:3a5:23a7:5e32:4598]) by smtp.gmail.com with ESMTPSA id b13sm8853149pfi.169.2018.03.28.14.21.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Mar 2018 14:21:30 -0700 (PDT) Date: Wed, 28 Mar 2018 14:21:29 -0700 (PDT) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Laurent Dufour cc: paulmck@linux.vnet.ibm.com, peterz@infradead.org, akpm@linux-foundation.org, kirill@shutemov.name, ak@linux.intel.com, mhocko@kernel.org, dave@stgolabs.net, jack@suse.cz, Matthew Wilcox , benh@kernel.crashing.org, mpe@ellerman.id.au, paulus@samba.org, Thomas Gleixner , Ingo Molnar , hpa@zytor.com, Will Deacon , Sergey Senozhatsky , Andrea Arcangeli , Alexei Starovoitov , kemi.wang@intel.com, sergey.senozhatsky.work@gmail.com, Daniel Jordan , linux-kernel@vger.kernel.org, linux-mm@kvack.org, haren@linux.vnet.ibm.com, khandual@linux.vnet.ibm.com, npiggin@gmail.com, bsingharora@gmail.com, Tim Chen , linuxppc-dev@lists.ozlabs.org, x86@kernel.org Subject: Re: [PATCH v9 09/24] mm: protect mremap() against SPF hanlder In-Reply-To: <1fe7529a-947c-fdb2-12d2-b38bdd41bb04@linux.vnet.ibm.com> Message-ID: References: <1520963994-28477-1-git-send-email-ldufour@linux.vnet.ibm.com> <1520963994-28477-10-git-send-email-ldufour@linux.vnet.ibm.com> <1fe7529a-947c-fdb2-12d2-b38bdd41bb04@linux.vnet.ibm.com> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 28 Mar 2018, Laurent Dufour wrote: > >> @@ -326,7 +336,10 @@ static unsigned long move_vma(struct vm_area_struct *vma, > >> mremap_userfaultfd_prep(new_vma, uf); > >> arch_remap(mm, old_addr, old_addr + old_len, > >> new_addr, new_addr + new_len); > >> + if (vma != new_vma) > >> + vm_raw_write_end(vma); > >> } > >> + vm_raw_write_end(new_vma); > > > > Just do > > > > vm_raw_write_end(vma); > > vm_raw_write_end(new_vma); > > > > here. > > Are you sure ? we can have vma = new_vma done if (unlikely(err)) > Sorry, what I meant was do if (vma != new_vma) vm_raw_write_end(vma); vm_raw_write_end(new_vma); after the conditional. Having the locking unnecessarily embedded in the conditional has been an issue in the past with other areas of core code, unless you have a strong reason for it.