From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 264DFC2D0E4 for ; Tue, 17 Nov 2020 19:15:53 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9F1832463F for ; Tue, 17 Nov 2020 19:15:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="AxSXaDVS" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9F1832463F Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D86316B005C; Tue, 17 Nov 2020 14:15:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D37006B0068; Tue, 17 Nov 2020 14:15:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BD7906B006C; Tue, 17 Nov 2020 14:15:51 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0111.hostedemail.com [216.40.44.111]) by kanga.kvack.org (Postfix) with ESMTP id 8CACF6B005C for ; Tue, 17 Nov 2020 14:15:51 -0500 (EST) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 3AB69180AD804 for ; Tue, 17 Nov 2020 19:15:51 +0000 (UTC) X-FDA: 77494864902.21.milk88_170ecff27334 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin21.hostedemail.com (Postfix) with ESMTP id 18AC4180442C7 for ; Tue, 17 Nov 2020 19:15:51 +0000 (UTC) X-HE-Tag: milk88_170ecff27334 X-Filterd-Recvd-Size: 4485 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf42.hostedemail.com (Postfix) with ESMTP for ; Tue, 17 Nov 2020 19:15:50 +0000 (UTC) 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> X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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