Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9462611pxu; Mon, 28 Dec 2020 17:26:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJx45Xc+2AWtVuRwYrSStwUJOo8erSis5+4MgG57+xqd6pIlvKAVi+nzPwamvh2yZPkPylk8 X-Received: by 2002:a05:6402:50cf:: with SMTP id h15mr34929618edb.149.1609205161427; Mon, 28 Dec 2020 17:26:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609205161; cv=none; d=google.com; s=arc-20160816; b=t6MdtHUfZkwwxtUP/S5Qtv5A+kugqwOy6Bwrx2MDHhWGYTzufJJXrq1LfjwbTp63Kf lrUKp+koffQDJnz3rt3Z+XKGdbTewB0ks+fm7z/3kq6uePHpoXd8z6HU6F1mocsIAuav 17nktW8whR7NdEiabULwmbEpjNqjl1jvw/VuFZCsAt5kt7nhsjtPgWtKYJZYNl4WG0CX xiKLBozBWDyG5NWEs19/CJOd5ogHEYQjLCnQbUxZ5nJFc/LaI8EkZpFYnTiytC9um77P QHZXBrF7qFGTeSbxm26C3obSJAFhplbp7Nb+XZXIFMfL3fJp3Bn1RrZOo2N5zJXffMeY bI7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=m/Wglbh+lTgBxyPrtUFRzs3rkWrSwjCdxL8lF/PAxdg=; b=Uw5ZQHGdr25Ph5OZlD51Inj8iU8veuQdat2t3nJ8XnRBZEJE4DI4wA32cKPCZeNuJ7 vhoosWSoxkRvTSPI4l9J1JGjUNRk0lRXma0kP1IR2j4Pdo+f2AN2xfZ87B/A2a4gjiQD gm+OAv9OwC8HdyGdgDpl4GVo1zptmjhe+Jr4+X/i+QQs3hWs1xlJH/xie4DHDPlYux/f kJIkuOxi4QApf1TEabMY4DhaBnHMpO8KYGrGOGduGiybLi0761qMbyTzd8ypnoaElWlY 5J8FwVvCLGe4DX4tu4FIfICt4++L/1CodUTPCNw+ZixsRato2D6mCAvkGiBGu6bm1AbQ dIvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arista.com header.s=googlenew header.b=KHzYIWd4; 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=arista.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a17si21392285edb.389.2020.12.28.17.25.39; Mon, 28 Dec 2020 17:26:01 -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=@arista.com header.s=googlenew header.b=KHzYIWd4; 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=arista.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729099AbgL1TNH (ORCPT + 99 others); Mon, 28 Dec 2020 14:13:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50050 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729075AbgL1TNG (ORCPT ); Mon, 28 Dec 2020 14:13:06 -0500 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA3E9C061796 for ; Mon, 28 Dec 2020 11:12:25 -0800 (PST) Received: by mail-wr1-x431.google.com with SMTP id t16so12302790wra.3 for ; Mon, 28 Dec 2020 11:12:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arista.com; s=googlenew; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=m/Wglbh+lTgBxyPrtUFRzs3rkWrSwjCdxL8lF/PAxdg=; b=KHzYIWd41lKdXti3O/ypHc8S0tMeIsfWLC/Bj7B0SzjA8vucJTYN7bHDQbPOIgg+4F fZD18Yty8GCok3qJf1fO63aT/4yXv5IpQqs4zCHs6V8c/hTJ3jaQBAZgI1nNOXy4naTF ahJeKtRt8Pj9o4utY+Oij4Ku95ArtGy+QiPl1IdezaUwqXgj7zMzTDihrmBFRPhv697s bXngRr1a7rkXrFhKxJYOOgbczrc3pA2FODIFky5l5upMPG9SMmchnVyAwlPmjBKrztxo RaTE0yITbMFc9Tl43W6lAhyGoZZ8DqUbKdkwj5EfXs0er0oc6+0O81LxacbGaxM/kkSZ KMhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=m/Wglbh+lTgBxyPrtUFRzs3rkWrSwjCdxL8lF/PAxdg=; b=QhGj+WwWWRLTdKnbHllenFFX0OPQlz4n6jd4Hq4Ajw6N9DVgjLR4udWnr+5Qnk1hJJ xiSRYxjVlXdxZVzolu6QKEzfmeXoAPfJdaYTL0ALi7rL4HVi+ZEI2PpKOJb0Q5oph/2I zsKLwgUxmWioDDhMsVuMNEmlMHBtQt0AknVt/FG1vpPBamBDTc3lY/yJ6Iax9bYorBKI sMvUNE6Zue8GBjvlYClWLIyQgao9/MoGBR6U1TjHJGBad60dY7rfM8FD3hyOKWaBXRZL oLW6C72U78pOtq5lssP1echXQdhg03FrHc/XEISMaIoypofZb59V+5yEOsJoqWlr/zrT KjqQ== X-Gm-Message-State: AOAM533T8Jz2b/qLoejFxx2uvnfYCophEUFB3Mt5XuRPNIQh+xL9I0NV OuZvT4JCxb3GfOCd//VOvjZXug== X-Received: by 2002:a5d:4ccb:: with SMTP id c11mr50075979wrt.324.1609182744412; Mon, 28 Dec 2020 11:12:24 -0800 (PST) Received: from ?IPv6:2a02:8084:e84:2480:228:f8ff:fe6f:83a8? ([2a02:8084:e84:2480:228:f8ff:fe6f:83a8]) by smtp.gmail.com with ESMTPSA id s3sm258209wmc.44.2020.12.28.11.12.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 28 Dec 2020 11:12:23 -0800 (PST) Subject: Re: [PATCH 2/6] mm/mremap: For MREMAP_DONTUNMAP check security_vm_enough_memory_mm() To: Brian Geffon 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 References: <20201013013416.390574-1-dima@arista.com> <20201013013416.390574-3-dima@arista.com> From: Dmitry Safonov Message-ID: Date: Mon, 28 Dec 2020 19:12:21 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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