Received: by 10.223.185.116 with SMTP id b49csp706676wrg; Wed, 14 Feb 2018 05:52:49 -0800 (PST) X-Google-Smtp-Source: AH8x227NbNNAOfx4fovwUho2JI+MtAkVQ1whmyhdbPccZ32eGUKb21waoln/LcVfyd8flsjVqsR0 X-Received: by 2002:a17:902:540f:: with SMTP id d15-v6mr234340pli.224.1518616369737; Wed, 14 Feb 2018 05:52:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518616369; cv=none; d=google.com; s=arc-20160816; b=q6IGKgqV2LWzbuQibigqlF3yuNn5FbKfVNVlAG6H4qB6OdS96Rn+Yi3jZui/CwL0c9 dPkpD9yhI2b8rQCKPqOUuP4bYfTVsAOxX9vrKUqRK6ZLMsZvD8LamV+b9z9/rjr+RTRa nFfeYA/Cc7q10yr9zB23aEGftyRcAqz+pj8f5UdrkgQ5kzl8Z8pkOOCbpPlCjLCKi1tS +91vPLj5U/hNPVJkWgS47ZMv40mqYG1AoqLCkoYbY8yGCd4BfOn29XzzzvJc9xlpmQrk u9IHe29e4UPwh/yMQGfpR0u7VD8curF3Fk+YPz792CHf6yaONp7zvj6bAHvMAvMSbLA/ wQTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=GtzsWCwvSpEp7ccXruLU7xTKk0SP5pFXszMhBVd60Ds=; b=0O6dm5FD7f+pKl5WNnrmQfBNrOK8F8bMA3leIlo/8ylMp776m1gbOFJiF7gT74xd3Y 3R2sDV1Tyqm8Jb+8/AvMmSrFedCDYGb3NCdaIBkf/R0f7U88iBcUapk6SWsK615YUCqU M+Jkbcy1ogaltBwMBWVqPLbZqP5dz2oCWY6KF9cmInwcqn4vcj5jiNyd8Aubrymwe22J uLnhxFUW2m5HFPw/CXi3MrKIr3nstdJjzXdNwLW7OKscWfh7uv4MKQQm+yWEgb+ynu0m jFFwmVvhsGBDOqy1/PuRc/M1B0z0gejy0lPrUdTsO3dVcOuuUu3BkHBULHt2eoTJNeY6 I6Tw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=CdUqsTC0; 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 p12-v6si483485pll.191.2018.02.14.05.52.34; Wed, 14 Feb 2018 05:52:49 -0800 (PST) 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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=CdUqsTC0; 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 S1030381AbeBNNvr (ORCPT + 99 others); Wed, 14 Feb 2018 08:51:47 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:40896 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030221AbeBNNvq (ORCPT ); Wed, 14 Feb 2018 08:51:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=GtzsWCwvSpEp7ccXruLU7xTKk0SP5pFXszMhBVd60Ds=; b=CdUqsTC0Gi55jkvhcmQ1un2KB 8kaUGtDd7BHRkygPtYTnNjcXF9DX3Hc/rKSGwqPxaJK1Pnmtf9yha1xNKUvrXvS4g2x0xw3CB1gKg ZJw6DGHT64/TkjqqODLmVWd29Lupert0VyIVqm0Gl8+3VfT8NX9wHVeYLrYt5mEaozquPVf+AT4BP YBl2dCY7YqvmuJiMq6qUGSxQM5EMqP/QEHYY1PGbMbwWoQ8MZh//VQYoy9uW+TO4HESyq7d9n0zXb xkFM8zgAY7+5OXdhCvxYVsG6BinIgOMzFZrNJgmvp2qVbBNXtX+i2mBdBuOcfG4iMh3ww9dMLM1Kw HOsX8VuNQ==; Received: from willy by bombadil.infradead.org with local (Exim 4.89 #1 (Red Hat Linux)) id 1elxTK-0008Up-6s; Wed, 14 Feb 2018 13:51:42 +0000 Date: Wed, 14 Feb 2018 05:51:41 -0800 From: Matthew Wilcox To: "Kirill A. Shutemov" Cc: Daniel Micay , Jann Horn , linux-mm@kvack.org, Kernel Hardening , kernel list , "Kirill A. Shutemov" Subject: Re: [RFC] Limit mappings to ten per page per process Message-ID: <20180214135141.GA16215@bombadil.infradead.org> References: <20180208021112.GB14918@bombadil.infradead.org> <20180208185648.GB9524@bombadil.infradead.org> <20180208194235.GA3424@bombadil.infradead.org> <20180208202100.GB3424@bombadil.infradead.org> <20180208213743.GC3424@bombadil.infradead.org> <20180209042609.wi6zho24wmmdkg6i@node.shutemov.name> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180209042609.wi6zho24wmmdkg6i@node.shutemov.name> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 09, 2018 at 07:26:09AM +0300, Kirill A. Shutemov wrote: > On Thu, Feb 08, 2018 at 01:37:43PM -0800, Matthew Wilcox wrote: > > On Thu, Feb 08, 2018 at 12:21:00PM -0800, Matthew Wilcox wrote: > > > Now that I think about it, though, perhaps the simplest solution is not > > > to worry about checking whether _mapcount has saturated, and instead when > > > adding a new mmap, check whether this task already has it mapped 10 times. > > > If so, refuse the mapping. > > > > That turns out to be quite easy. Comments on this approach? > > This *may* break some remap_file_pages() users. We have some?! ;-) I don't understand the use case where they want to map the same page of a file multiple times into the same process. I mean, yes, of course, they might ask for it, but I don't understand why they would. Do you have any insight here? > And it may be rather costly for popular binaries. Consider libc.so. We already walk this tree to insert the mapping; this just adds a second walk of the tree to check which overlapping mappings exist. I would expect it to just make the tree cache-hot.