Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp10642577pxu; Wed, 30 Dec 2020 07:47:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJxG6szEN39CL5yEhbF6Ce8P204Ds85oTKrG955Xu8KNu2PO6soKKxTRs6FB4yzdfmc0k7Sp X-Received: by 2002:a17:906:c2ca:: with SMTP id ch10mr2305691ejb.157.1609343264988; Wed, 30 Dec 2020 07:47:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609343264; cv=none; d=google.com; s=arc-20160816; b=sMjchdBvELj/b9ffSD9d3L0YS+Oq04EaCm4I7GBBbA8M5npEhA+BDjTm4GvCbhUqUY Fr0EOeAvCTteU7qU32424nkNky+dVYSDcZXcx3GhC9tNLFwsAS1TyE7jmJG7zqjyVdaA OhyZ/MgFBjx5oYL2Kk6JalqnhaoA1bncERaHwlmegbVTzTOsrqrUItdYPsX6te/6zu2O 8dX062UD+GyKJaU4b43VWNfP02qtYC7V/U4mXqP0FHS4L8nH4qGvQePHpbemXzcOqA+Y JXWdln2J98kBcr32Zon1ij2i+4FKmOimjMIpQmGNGckBMvBOFMo29qRmuH8TDEbyEaW+ IS0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=5hBnQDw081gPYRJZ5sSOQpvtWrIndiY9aAJP6hoGoCI=; b=vSREq1pm9IaTJkmrdQoqEhNn9woFYObfVJle6ajYEhjo4w/zSpllyeQ/t5igm2Iwf7 cI58Mi4fPVzC6ScJqpXFR886XNzcIFCTBPAb2CLxQqmB2aLD7LEXMuIZ/zRg1hHRoi9n EG3ers3kAD38+enF6F6bYUpY/M2C8k1ov7EXXfbuFsZa5YagBLkJ8Wgja3lN+3Dp/zf3 oys2D1JFfzIkMSSWiFAtQKM+6hMZ0Ec9keLGTyPYQtVNBtbeJQmid3mutyC8aYZ2b/z7 I++iqV0FLolzO89GhQA5HL3lC2tiOzEfWjoTv3WNogijvJeBEsn5Oc/dHRLJTXXBdJUU 5iAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=jF9zBs3u; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id n22si16479795ejr.464.2020.12.30.07.47.22; Wed, 30 Dec 2020 07:47:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=jF9zBs3u; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1726588AbgL3PpA (ORCPT + 99 others); Wed, 30 Dec 2020 10:45:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726533AbgL3PpA (ORCPT ); Wed, 30 Dec 2020 10:45:00 -0500 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F70CC061799 for ; Wed, 30 Dec 2020 07:44:19 -0800 (PST) Received: by mail-ed1-x52e.google.com with SMTP id h16so15747510edt.7 for ; Wed, 30 Dec 2020 07:44:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=5hBnQDw081gPYRJZ5sSOQpvtWrIndiY9aAJP6hoGoCI=; b=jF9zBs3u6j4Qo5O+462fi/y8Z3H2Rg/kS494qsVJ1AZwXnP4CZKBWtNfWVC4M+XY2L a4QSfGMk/T0BX8WKgAXjGmwlhjMR7jUfuM2MJMUhMMzVoz9BLvH3vgISA3wl+9ipOCg7 0Qetw+q4d2hE88fpkR4idIMOjFu7r0tivYhG8TVkhRtIgbM86B8C7RpW5EP6KPEYDHtC vItSy1oO9aljOyRk1izLO06eG2w4wHJ+0sSw2J77SK31m7y6YeOFi1L64eSfXn/5DXnp hbTTEwqrK98bNoVh9B93pHxvRkTOtAv++3QeaGy3wk9I8XYNKJVnZC34WbIzngDe6Wgn Is7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=5hBnQDw081gPYRJZ5sSOQpvtWrIndiY9aAJP6hoGoCI=; b=ePPDZjqUO2nF2h/1GU3Z1l8Xbu9Okx4bkhmVt2BhiXEMJ/yqhIrLpGejRymUv87/MF YzFyc86PoxABJvTpj/ntQUm/JEhHyeBwSYssHstlDNvSRyHCcPQbtFWqVdBmom/R+hS3 ZslRUhP16Dommgcb2AeI8ZNWviyjzrixMhSpMitI1td6h0AzDj+k5fLsf4zdqRDPlqe6 SwnmWgkNhnAOA4vhCkApDwz04XDcATLwNi5FZji6qgBXdUKkqPxWq+3dbkfR5GrQll0t 21ACTzA2oQp25pd4vFYEByTFQYtvlxdVp8bpRxxAzLPPLtqhhWTqcnqUJzqQUs7hd7YU w7nw== X-Gm-Message-State: AOAM532X4NvVpq2OqoLg9tHwQANT41bXMI4STuZHAKLPgEZpnzQVuRIK ydPvsXcY9pbmpOGCOqSVeRvpaXg+sLf7WBH83BmVKzKBu9Y= X-Received: by 2002:a50:b5c5:: with SMTP id a63mr50773533ede.227.1609343058152; Wed, 30 Dec 2020 07:44:18 -0800 (PST) MIME-Version: 1.0 References: <20201013013416.390574-1-dima@arista.com> <20201013013416.390574-3-dima@arista.com> In-Reply-To: From: Brian Geffon Date: Wed, 30 Dec 2020 07:43:42 -0800 Message-ID: Subject: Re: [PATCH 2/6] mm/mremap: For MREMAP_DONTUNMAP check security_vm_enough_memory_mm() To: Dmitry Safonov Cc: LKML , Dmitry Safonov <0x7f454c46@gmail.com>, Alexander Viro , Andrew Morton , Andy Lutomirski , Catalin Marinas , Dan Williams , Dave Jiang , Hugh Dickins , Ingo Molnar , "Kirill A. Shutemov" , Mike Kravetz , Minchan Kim , Russell King , Thomas Bogendoerfer , Thomas Gleixner , Vishal Verma , Vlastimil Babka , Will Deacon , linux-aio@kvack.org, linux-fsdevel@vger.kernel.org, linux-mm Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Ah, you're right. This individual patch looks good to me. Brian On Mon, Dec 28, 2020 at 11:12 AM Dmitry Safonov wrote: > > On 12/28/20 6:21 PM, Brian Geffon wrote: > > This looks good to me with a small comment. > > > >> if (do_munmap(mm, old_addr, old_len, uf_unmap) < 0) { > >> /* OOM: unable to split vma, just get accounts right */ > >> - if (vm_flags & VM_ACCOUNT) > >> + if (vm_flags & VM_ACCOUNT && !(flags & MREMAP_DONTUNMAP)) > >> vm_acct_memory(new_len >> PAGE_SHIFT); > > > > Checking MREMAP_DONTUNMAP in the do_munmap path is unnecessary as > > MREMAP_DONTUNMAP will have already returned by this point. > > In this code it is also used as err-path. In case move_page_tables() > fails to move all page tables or .mremap() callback fails, the new VMA > is unmapped. > > IOW, MREMAP_DONTUNMAP returns under: > : if (unlikely(!err && (flags & MREMAP_DONTUNMAP))) { > > -- > Dima