Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp4102699pxb; Tue, 17 Nov 2020 11:18:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJy+Hi5MRAVZRtEzQ4KKrw/Oy6FpQnSbGoL/Y7fghJfTmbvas69LT4+EtjxwAQ46BHei45zV X-Received: by 2002:a17:906:40c9:: with SMTP id a9mr20061095ejk.518.1605640724119; Tue, 17 Nov 2020 11:18:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605640724; cv=none; d=google.com; s=arc-20160816; b=viU+ZQoVl/pVQvAZdQMdHHf+Ra2Ey1TPzTg9kcRwG5qTcE70CvZ67VuAa7pUg1MnVo rcTxjtJDYxVGJrJcTX1+HJZgCe72w6nAfcFg3y+9j8hcnGFwKyL7Mf6/yTdElxKG4dZo myiivj9mWcz7sik0j4UK6Y2AuDRHCL0orzLwI4CCX1kcCw/u4ONFtjAIXv4nl0/XVxsT 69T/8M174pVogtrAq82tylYw6cgOdumDxELwmHYQ1YKCpbHruahNRFwV+GObsvSNDFU9 8+jF3rOwNyfssaVluQG7tV9l0Ogdrw6n38IVlouYirEYz/cgtCY/VoZlCA8hjQFz5qhq SEOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=TUPNWn8mjAFJkEgdq8FP1PmZHUDlCNkyWJv7Nvrb+6U=; b=DRbdNifdvoxQWYUt/yEw4E3Ee/nXmnVkybWvh9WqVGxZnXjb1vwoPldVJ3aOD66dBy QKkYo7sBuMF2+9ryVYC9BFMU1kA0WF/h9s+yFS1e9TLRWbG+T2lO88gyUuKzPkqTP086 RA1U5z1KqekVFfKCHQDMfGKYdVYyDE791F6LrQTDMSPUOWMuntOupsyfyGEGUTnB4Z09 UXKS2X3/s6XI1kGC1p0KUeSQZx5RFtpjfr9T9fg931xOu4rfgyJ7ov8XLCJzipIKeWRx 5x+4CoNqJ/QZvBKLdxImVCCYvLTq+v/N8QtFMEgcc2/WphVQ6OkR+WojpAoc0GZXKRs/ zjxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=AxSXaDVS; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z9si1237842ejg.316.2020.11.17.11.18.19; Tue, 17 Nov 2020 11:18:44 -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=@kernel.org header.s=default header.b=AxSXaDVS; 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=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727443AbgKQTPu (ORCPT + 99 others); Tue, 17 Nov 2020 14:15:50 -0500 Received: from mail.kernel.org ([198.145.29.99]:57678 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725730AbgKQTPu (ORCPT ); Tue, 17 Nov 2020 14:15:50 -0500 Received: from kernel.org (83-245-197-237.elisa-laajakaista.fi [83.245.197.237]) (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 E87A924248; Tue, 17 Nov 2020 19:15:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1605640549; bh=qCbF58vgiefZ8VCYS9ofR3cSVoZzEVxnJQJ9R5/mjYA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=AxSXaDVSs9+X8EC5IoAogPm8KBYugk+hG0CvV5NERmDBD26HGnSiqO7qN855ik75o WBLZU7DBN62oQtX/RSvNs3Fuezj/58unPbE/8zZKVltEUQfnnFDJiNVbu6VAlr5GzU RvrxcCoF7GiJY6YRVot03n0h3aZwvOoFm8m/ECOM= Date: Tue, 17 Nov 2020 21:15:40 +0200 From: Jarkko Sakkinen To: Mel Gorman Cc: Dave Hansen , Matthew Wilcox , x86@kernel.org, linux-sgx@vger.kernel.org, linux-kernel@vger.kernel.org, Sean Christopherson , linux-mm@kvack.org, Andrew Morton , Jethro Beekman , andriy.shevchenko@linux.intel.com, asapek@google.com, bp@alien8.de, cedric.xing@intel.com, chenalexchen@google.com, conradparker@google.com, cyhanish@google.com, haitao.huang@intel.com, kai.huang@intel.com, kai.svahn@intel.com, kmoy@google.com, ludloff@google.com, luto@kernel.org, nhorman@redhat.com, npmccallum@redhat.com, puiterwijk@redhat.com, rientjes@google.com, tglx@linutronix.de, yaozhangx@google.com, mikko.ylinen@intel.com Subject: Re: [PATCH v41 10/24] mm: Add 'mprotect' hook to struct vm_operations_struct Message-ID: <20201117191540.GB10393@kernel.org> References: <20201112220135.165028-1-jarkko@kernel.org> <20201112220135.165028-11-jarkko@kernel.org> <20201115173208.GR17076@casper.infradead.org> <96318679-3320-8d7c-d178-7fa34ed11fdf@intel.com> <20201116100957.GM3371@techsingularity.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201116100957.GM3371@techsingularity.net> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 16, 2020 at 10:09:57AM +0000, Mel Gorman wrote: > On Sun, Nov 15, 2020 at 10:36:51AM -0800, Dave Hansen wrote: > > On 11/15/20 9:32 AM, Matthew Wilcox wrote: > > > On Fri, Nov 13, 2020 at 12:01:21AM +0200, Jarkko Sakkinen wrote: > > >> +++ b/include/linux/mm.h > > >> @@ -559,6 +559,13 @@ struct vm_operations_struct { > > >> void (*close)(struct vm_area_struct * area); > > >> int (*split)(struct vm_area_struct * area, unsigned long addr); > > >> int (*mremap)(struct vm_area_struct * area); > > >> + /* > > >> + * Called by mprotect() to make driver-specific permission > > >> + * checks before mprotect() is finalised. The VMA must not > > >> + * be modified. Returns 0 if eprotect() can proceed. > > >> + */ Wonder if this should also document the negative case for the return value, i.e. -EACCES is returned otherwise. > > > > > > This is the wrong place for this documentation, and it's absurdly > > > specific to your implementation. It should be in > > > Documentation/filesystems/locking.rst. > > > > I'll let you and Mel duke that one out: > > > > I suggested placing the comment there to make it clear what the expected > semantics of the hook was to reduce the chances of abuse or surprises. The > hook does not affect locking so Documentation/filesystems/locking.rst > didn't appear appropriate other than maybe adding a note there > that it doesn't affect locks. The hook also is not expecting any > filesystems-specific action that I aware of but a note could be added to > the effect that filesystems should not need to take special action for it. > Protections on the filesystem level are for the inode, I can't imagine what > a filesystem would do with a protection change on the page table level > but maybe I'm not particularly imaginative today. I try to decipher this in generic context. In a permission check of a filesystem, truncated pages should be encapsulated in to the permission decision. It's a just a query. So maybe I'll add something like: "This callback does only a permission query, and thus does never return locked pages." > -- > Mel Gorman > SUSE Labs /Jarkko