Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9461117pxu; Mon, 28 Dec 2020 17:22:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJw2PK9b2lRm3tJgzch2K6HG+LOIlN1Nk8QeZ/bAFr6uUWpd09mbfpMIxakeygKMEMusxSfm X-Received: by 2002:a17:906:af75:: with SMTP id os21mr44327256ejb.330.1609204953482; Mon, 28 Dec 2020 17:22:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609204953; cv=none; d=google.com; s=arc-20160816; b=C41il/41lT0S5rZLynRbWtmBu68ARXnYYXayE9jBfF86xeARWkcsSxPrCLEhqBXhH6 DcBoTsRHqaLBLSiTISQqNuwAOM/y/ORgcWmvHu88u2oZ+kL5qjxhA6xdFTVKFE15ItSu 9RIu1A37WDlHzmFZp/kACi2T6zLBLjBWPv4SoAx3dWCmKEtx/lGHwK8T+Lnsp6k5YPmL 14x+gBfTuYxDD2eF6dpYgLAKi5ZRRZQ3W62muqao/AcpFDE9ew7rhOX7X20lgeiMcxZf lwEhszJqNaeJS/2zhfwl9vzYb2HUCAE/hMUJvaSxqRPp7LsrkEIwJNmayDDMw3aZpt6t T7kA== 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=z2QbH8RGPNV6UCpysofOcmKw2kvcdsWtyhs8XyCCINw=; b=cLNeAYob61ZnabX1zWnMMqHGJ0S4rchoTufpE24YL2bL3YEbQjwXM1jGRtW0hmzWqP 06U0YranD9dqlKjen13fDs9HTlYjx/19GNVxvro2TN+acbtR/W+H5036DAWp+vf8c5Hp VBY3osvcTekEacFavdKQkxLuiL8pqDVeEa/RGIRY2KtZc4m+xGD2P3iFTTXaH83XNhND hXLF4PMcwJKGz5HJodejPVp7E0AP/i897kNqssCF4XOlLB7m2kFPA+WQaZV6ynKcrvz2 RacFpDw9SHwlpEjqaN2NOgFx0Ovd4CQ4bHHRGgfv30ozZc9irDF8QB+w/NP7mu+3Erfb yk6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=oK1bIMFl; 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 cb20si19495500ejb.329.2020.12.28.17.22.11; Mon, 28 Dec 2020 17:22:33 -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=oK1bIMFl; 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 S1728677AbgL1SXR (ORCPT + 99 others); Mon, 28 Dec 2020 13:23:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728405AbgL1SXO (ORCPT ); Mon, 28 Dec 2020 13:23:14 -0500 Received: from mail-ej1-x62b.google.com (mail-ej1-x62b.google.com [IPv6:2a00:1450:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BDD7C061793 for ; Mon, 28 Dec 2020 10:22:33 -0800 (PST) Received: by mail-ej1-x62b.google.com with SMTP id q22so15294017eja.2 for ; Mon, 28 Dec 2020 10:22:33 -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=z2QbH8RGPNV6UCpysofOcmKw2kvcdsWtyhs8XyCCINw=; b=oK1bIMFlk9+9P3yM6IxgC3sGgIIGBKSSzhxKjcmUmJw7zLxWGUG5Z4FT5RjgRhaBPN i7pYF9MtjhuJl7YWB8Sew1jRxwXZSpYdf7aochu1zb+ZWaH/fiz/eL4vSeZrajQE63Mv z8yRPyof9nFuCxMdTOpQKJbsFriOk4ifql5kOVecC6wXCqfH3/TJiCf5HKOIcx3H/IHz eIH4ub0+o/wzo0oEQ22VsKGEYwpVGASXaadXI+DYrBGeTAtjrCS7Bn2U/ZMS4ZMjCFOD I+9SQ2avnuepdBFUxQ4VZoQZyuyE/I1RxB1mpVZUmeo/uUA5VcVuLaaClMMSXkvR+40v RCrA== 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=z2QbH8RGPNV6UCpysofOcmKw2kvcdsWtyhs8XyCCINw=; b=cDOGrlv1np8gULTSK9Q0KQrLMQuKd8ETkgJOSdwKGAkIUHC1kVrVgj2HQjDNI0M70V yh/a+E0SXsvnBIDXuePUTDI9X/+QNymDOjgnunnm3XpmbFZ3qyPQXajmHQXKn3/uYDX+ jjOJHA7VhFKuns7Ho+NwnJEes/wgUgc1uHrsyiKGzI2R9hdDY/9oEAMHFpLiD9eKcsmY KnnTGcytEALQx0XLKgNIVyrEO+wHT5VmLpXNmuw96NiZrGlyCrRnjZDIQbrF785cmUPJ uj9mpZdEvBpcDszKsGklmsY80pOwyQmKANTwxmqPobWpOtzsvKhLGbykFYB13Aw6++VM Zx2w== X-Gm-Message-State: AOAM530Pp72qBNa0j2lvX4yVzBhnO9mVKFrwMgIDqSw+41YlyCq3vNDE RxD/q0/G4ETgr0cEiu2cLbYcUtMfPvNzOmpRY8Gswg== X-Received: by 2002:a17:906:447:: with SMTP id e7mr42157038eja.172.1609179752023; Mon, 28 Dec 2020 10:22:32 -0800 (PST) MIME-Version: 1.0 References: <20201013013416.390574-1-dima@arista.com> <20201013013416.390574-3-dima@arista.com> In-Reply-To: <20201013013416.390574-3-dima@arista.com> From: Brian Geffon Date: Mon, 28 Dec 2020 10:21:56 -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 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.