Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp3509424ybv; Sat, 15 Feb 2020 22:51:44 -0800 (PST) X-Google-Smtp-Source: APXvYqw1bjySirZsuibq3BscF4YRPwrzwfSQRy8p0180ur7F6EQ3HZGLnf/zjR1CEUiOPN3Gg5BI X-Received: by 2002:a9d:6a53:: with SMTP id h19mr8423337otn.120.1581835904229; Sat, 15 Feb 2020 22:51:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581835904; cv=none; d=google.com; s=arc-20160816; b=SCphhi045YkDX/aAgsyww7DJGwtxGEwKfdX7CeY9BDB7s0Wjiicd72x+a+eA2Bo376 bPLO/4X4MusP7X0S+o3AW8pImXVKSDtfxHoRWdKhI2AO4Fq5VwgZyrj3ECcU4PhBEYMo u6MuSpndajjf+g62kBLTr3H1SYFfiIKkAyhQ8pu7oNKrn05rB//CXdwAYAKfONZgR07/ 0efbXK4tC6qNXJvezNgYyk6xNJtBgLWgCyz73nN/AoDf6ALT8HBROHfIefUb/Tuysx4z ms2pm4ChQg4o0h/8GJuwlmdS8XvTCPhx6Fr2Ern6ILEOZfj33LJhL7U84HeT8eLjluIL sRJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=XhivVxUaJKZGcxbGfXY7exHNyuV/0xlXzx3tyHY4poI=; b=f8BmQp1oNgJVwHiYnFpX8IwqVXoSwews8Bi/JMhTjKASZPcxqP4M5bEW6TSJ2fRvTm ++36AIFZQKEaHkOC08iyq6dPCCCr4UcDrHSyQ0jBMauHLni2FKOT3ydnKY0e8oo+72zN +D/rQRJpiwQhRs5Q6GrirpLR1VSlcyR25bOij7iwb2lKek4AfuqIuHARaQVIx2Hb3fDo YkyINceLsj0F8or5qvKJaeR5y/ohpd3HMD1LpN8YVfvA4Of4K7iK/s86PFdj4VvuJG3H pbya0ztHR9vsoodpNgDKJa5UdJjdSbzXvJE5r8AtLsz4pvIRPZggeKqcDbeozzpcFQbJ FDfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FeIN6dVV; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v25si5519636oth.274.2020.02.15.22.51.06; Sat, 15 Feb 2020 22:51:44 -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=pass header.i=@kernel.org header.s=default header.b=FeIN6dVV; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726020AbgBPGq7 (ORCPT + 99 others); Sun, 16 Feb 2020 01:46:59 -0500 Received: from mail.kernel.org ([198.145.29.99]:46282 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725866AbgBPGq7 (ORCPT ); Sun, 16 Feb 2020 01:46:59 -0500 Received: from hump.haifa.ibm.com (nesher1.haifa.il.ibm.com [195.110.40.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 400CF20659; Sun, 16 Feb 2020 06:46:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581835618; bh=0Glmy2rHz9Nf2Jk6JgoRKqRnT6KMFXNB47KY1ashgzA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=FeIN6dVVEIRThZ2RgK/fA7L8n90zXVh6xftACf3uAvtFfHrlNAPq66yQ1RfEX3fJT XEbXDLFzjWyFXbnapOP1OCC3WbScqsUtAPrQi5qvRmLQscnMJO1AWyavFd4VwQi5/L 51D+zQAcS/gs6QwAQIZBdOE9r22m+xCJtA/hvX7w= Date: Sun, 16 Feb 2020 08:46:50 +0200 From: Mike Rapoport To: Jonathan Corbet 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: <20200216064650.GB22092@hump.haifa.ibm.com> References: <20200130162340.GA14232@rapoport-lnx> <20200212141029.7b89acee@lwn.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200212141029.7b89acee@lwn.net> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 12, 2020 at 02:10:29PM -0700, Jonathan Corbet wrote: > 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? Indeed, it's possible to lock down RLIMIT_MEMLOCK * RLIMIT_NOFILE of RAM with this implementation, thanks for catching this. I'll surely update the resource limiting once we've settle on the API selection :) > Thanks, > > jon > -- Sincerely yours, Mike.