Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp2653567imm; Thu, 11 Oct 2018 13:56:33 -0700 (PDT) X-Google-Smtp-Source: ACcGV63Gh06IhmHfHkVS5c80qvGo6iKjKX66K7tWvPV0M3W2l89nzFAwu3wKZZYhhML8ZXyqpYqj X-Received: by 2002:a63:5558:: with SMTP id f24-v6mr2891735pgm.37.1539291393031; Thu, 11 Oct 2018 13:56:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539291393; cv=none; d=google.com; s=arc-20160816; b=F/P08ts4sSvD1TP6WEp/R67Inz7cNB5/JxoSAGBXmCfwZadoe2f+JaNbtnj2btUwmV IWRWe2ypLZXvwQXWVHmDYD3p3nRbwAgkDpRJbpMkkBJYm+Kq2sMW3+o7jPrecFr7WBE+ Ho8AcQM8B6Ob+2TXmsXqP4lHvxcpw/LgyCy3CvZW2u3umQjJSaLG1QWLLCxlS5I1SnMe kAKuDJQdvGzinxilbTR3A+EgAnz3pMdZnsMv4ec9U7klag0mXiSurcIXS37fdTkBOBEb K3qKTeVIm57FI/6uySQkn1iuaWj/VKDPGyGpq+qRW8Ru65dAZdGy7DYnzMU1CFSBZLzW tJow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=2KOjYX4ILxhVDuX6J6Xn9Mm3TnCRr6/YJJVFH//h0z0=; b=W349LMvhO4l6pc7VTD9lj+6Mo9Gjy/0pFKT/SvHLKlxiZ1OgfHZ2aIRpUmBJQUw8Po SJEisEt5jsaXwhILP4ELBEerhvjsxLTfi/u9O/8JWZYixwSmpAmU56lyH6KxZJE4oLKa dI/U/4bo+/Epz/+rdZ+Mmrh/lKlasWZ2+dDN90OalUH2MaoKRr32wLrh67YhEStQjap0 VYz5ywyZKSxpbR7KXNmZOU/f/y3/B7oUVboAhq+E54cWyh8ga1E4EaFAfQecXPkLWATo Injkk8LFiXeDipA8mb5XMc3AM6xaVm5hlcaLioXIqYvLF0E2DsVk2xfnRYuOaluPOzy+ IeQw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=qf9Z9hyN; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 14-v6si23702470pgm.488.2018.10.11.13.56.18; Thu, 11 Oct 2018 13:56:32 -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=@amacapital-net.20150623.gappssmtp.com header.s=20150623 header.b=qf9Z9hyN; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726843AbeJLEYj (ORCPT + 99 others); Fri, 12 Oct 2018 00:24:39 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:43412 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725819AbeJLEYi (ORCPT ); Fri, 12 Oct 2018 00:24:38 -0400 Received: by mail-wr1-f66.google.com with SMTP id n1-v6so11152080wrt.10 for ; Thu, 11 Oct 2018 13:55:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amacapital-net.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=2KOjYX4ILxhVDuX6J6Xn9Mm3TnCRr6/YJJVFH//h0z0=; b=qf9Z9hyN2c2yKMz3WdOpddxPJjgvuo0I3a46tr2NvcS7QB39fqUd9gTIS2y4W7PJXq Z7uBYutIYxNO7oi674TDwQwAMRQ3KrRyT2FmiV9yI9fn1qCcYAlJNteiz43pVAICcHP3 yZORwyGV2PWTS1t869CuGydLZqeBHfRMS2818tCCykHx7wVCuZIEF28DwbjpLl9YyA77 ZH24VcEccP8QsYrGWVk3g/YV+kZQ+uQhV5ih8Kda39hgenvbh/lww6lOh651YZfwTNSU DW8J6NAIyUc8NRnu98kIsMc+FbosreYcoJMcd8ql4u582720ioG4sjzP0R46A9mOhqSb 4ynA== 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=2KOjYX4ILxhVDuX6J6Xn9Mm3TnCRr6/YJJVFH//h0z0=; b=s9mKa5Ge4igRBYOJLy8Ig8iao/bV+Ei8bC8DktZl2iDS+Sel4pBBe7M1TvDVxvvFnn Gm2k2MTV7b90dtpvKcjTgZ0OkY4DlQMztrvYMxoDOV1W/tXvJDHfHoGvZg6315xlNTio J+ZzlE74Ao+UNmTsRzZeZYaxvJKs4j/VYVEPr1TqnfHou/qkWatveG/lBpSOhNTxhskg v8oDEYa+ui2Nol1ivXMLkvKuhDXljVUh++k9CAqOOdZu5bQTfrAjXLVqaeSXWFOhq4pO /8rMFi5wx3aknOICmLR0QfvSQlaSlPro3LlCjTLO5Eovcs4cukSBoHi+L+TI6mf+cZBM Kpsw== X-Gm-Message-State: ABuFfoixNqD6dlH4p15cEK3Oo5Zxvyf1IxgseZOtDuaZ/Mll1PD4xnDI 7gDJHrkb6MarxkqIiVhPlrzEPklsLAc0zTeIF3m/Ow== X-Received: by 2002:adf:b188:: with SMTP id q8-v6mr2950881wra.95.1539291338385; Thu, 11 Oct 2018 13:55:38 -0700 (PDT) MIME-Version: 1.0 References: <20181011151523.27101-1-yu-cheng.yu@intel.com> <20181011151523.27101-8-yu-cheng.yu@intel.com> In-Reply-To: From: Andy Lutomirski Date: Thu, 11 Oct 2018 13:55:26 -0700 Message-ID: Subject: Re: [PATCH v5 07/27] mm/mmap: Create a guard area between VMAs To: Jann Horn Cc: Yu-cheng Yu , X86 ML , "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , LKML , linux-doc@vger.kernel.org, Linux-MM , linux-arch , Linux API , Arnd Bergmann , Balbir Singh , Cyrill Gorcunov , Dave Hansen , Eugene Syromiatnikov , Florian Weimer , "H. J. Lu" , Jonathan Corbet , Kees Cook , Mike Kravetz , Nadav Amit , Oleg Nesterov , Pavel Machek , Peter Zijlstra , Randy Dunlap , "Ravi V. Shankar" , "Shanbhogue, Vedvyas" , Daniel Micay Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 11, 2018 at 1:39 PM Jann Horn wrote: > > On Thu, Oct 11, 2018 at 5:20 PM Yu-cheng Yu wrote: > > Create a guard area between VMAs to detect memory corruption. > [...] > > +config VM_AREA_GUARD > > + bool "VM area guard" > > + default n > > + help > > + Create a guard area between VM areas so that access beyond > > + limit can be detected. > > + > > endmenu > > Sorry to bring this up so late, but Daniel Micay pointed out to me > that, given that VMA guards will raise the number of VMAs by > inhibiting vma_merge(), people are more likely to run into > /proc/sys/vm/max_map_count (which limits the number of VMAs to ~65k by > default, and can't easily be raised without risking an overflow of > page->_mapcount on systems with over ~800GiB of RAM, see > https://lore.kernel.org/lkml/20180208021112.GB14918@bombadil.infradead.org/ > and replies) with this change. > > Playing with glibc's memory allocator, it looks like glibc will use > mmap() for 128KB allocations; so at 65530*128KB=8GB of memory usage in > 128KB chunks, an application could run out of VMAs. Ugh. Do we have a free VM flag so we could do VM_GUARD to force a guard page? (And to make sure that, when a new VMA is allocated, it won't be directly adjacent to a VM_GUARD VMA.)