Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp6484489ybv; Wed, 12 Feb 2020 13:11:54 -0800 (PST) X-Google-Smtp-Source: APXvYqy78WY6P+hvlnRq51ysr7VwDW2UxY/HehhicsximE/gfXOrSMlgsOqnmY3u9mWnp8OHeY5W X-Received: by 2002:a54:468b:: with SMTP id k11mr721902oic.134.1581541914386; Wed, 12 Feb 2020 13:11:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581541914; cv=none; d=google.com; s=arc-20160816; b=K6GN1C4KMuEcoLMrzbm6NnhQJj3bHZRd7WsaMmEFmtyLHLJ8mtYno4WArzE+WiSHF7 fLhNSbGTJeivFtnyjI9wdD9e8afVtfgOubZoRPifWJN3RZ4snlFpBLCa9V3hxtTajzEH GESGPSQe/SSpvnN8T4nlzCF48EzKpRuxpia4r3qCRSnf1FCp0xtH8/r3Zav+QEAu5gWO 9oEEfLjTJfmS3zQubRRvWZWYUwrKphC/JnGgxt0LjmUMrnaSe8034SaFLO2qEVihwsGX HTU6RadZ424upEqK+x/FnOHrhxPoCH6tzAgQnjz6zzC8DBvdgReaDXlGkW5hsV36AdUS 2yoQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=mAJ/EZebb+k0RpKEtvebGFj+iWn5Yiqx0aKLmlmXmkg=; b=JkbVpZyNMYhBOc8ymvaJrZK3qiTXJnHvvUrImCuzS+AprT4KJfKkR9aiQ6dh9qQ0ru KkYKYYaD3S6dbPIy+q8fEOh+BZSG1Ebl1AAxAZ3ZXYhN8QwdchA4l0y3IQ3My997GgIK Bwi4+N0yxVHycIyQ6z0uHeDwcoLoGYgJx8WaMTtOuvbsJH7QB5BPMZYYgXEBaQibI21m EQ6VsP2dq0iYt049yPmuGFJZKZyHMFeBYVyRD2dwE180KuhP8LLAGKDCvtAXQ0zlAGrD oU27JebFUIJOKiCGKytImh7XUMqtEp+jBve/KNqrn32aeQ3B1C4j6fXyk2EInfz9y0Qj L/BQ== ARC-Authentication-Results: i=1; mx.google.com; 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 a20si771203otf.271.2020.02.12.13.11.41; Wed, 12 Feb 2020 13:11:54 -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; 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 S1728447AbgBLVKc (ORCPT + 99 others); Wed, 12 Feb 2020 16:10:32 -0500 Received: from ms.lwn.net ([45.79.88.28]:59066 "EHLO ms.lwn.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727420AbgBLVKb (ORCPT ); Wed, 12 Feb 2020 16:10:31 -0500 Received: from lwn.net (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ms.lwn.net (Postfix) with ESMTPSA id 94C40740; Wed, 12 Feb 2020 21:10:30 +0000 (UTC) Date: Wed, 12 Feb 2020 14:10:29 -0700 From: Jonathan Corbet To: Mike Rapoport Cc: linux-kernel@vger.kernel.org, Alan Cox , Andrew Morton , Andy Lutomirski , Christopher Lameter , Dave Hansen , James Bottomley , "Kirill A. Shutemov" , Matthew Wilcox , Peter Zijlstra , "Reshetova, Elena" , Thomas Gleixner , Tycho Andersen , linux-api@vger.kernel.org, linux-mm@kvack.org Subject: Re: [RFC PATCH] mm: extend memfd with ability to create "secret" memory areas Message-ID: <20200212141029.7b89acee@lwn.net> In-Reply-To: <20200130162340.GA14232@rapoport-lnx> References: <20200130162340.GA14232@rapoport-lnx> Organization: LWN.net MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 30 Jan 2020 18:23:41 +0200 Mike Rapoport wrote: > Hi, > > This is essentially a resend of my attempt to implement "secret" mappings > using a file descriptor [1]. So one little thing I was curious about as I read through the patch... > +static int secretmem_check_limits(struct vm_fault *vmf) > +{ > + struct secretmem_state *state = vmf->vma->vm_file->private_data; > + struct inode *inode = file_inode(vmf->vma->vm_file); > + unsigned long limit; > + > + if (((loff_t)vmf->pgoff << PAGE_SHIFT) >= i_size_read(inode)) > + return -EINVAL; > + > + limit = rlimit(RLIMIT_MEMLOCK) >> PAGE_SHIFT; > + if (state->nr_pages + 1 >= limit) > + return -EPERM; > + > + return 0; > +} If I'm not mistaken, this means each memfd can be RLIMIT_MEMLOCK in length, with no global limit on the number of locked pages. What's keeping me from creating 1000 of these things and locking down lots of RAM? Thanks, jon