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=-6.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no 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 58AD3C433DB for ; Tue, 2 Feb 2021 18:16:18 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id C9A40601FB for ; Tue, 2 Feb 2021 18:16:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C9A40601FB 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 2C7606B0005; Tue, 2 Feb 2021 13:16:17 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 251386B0070; Tue, 2 Feb 2021 13:16:17 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0F00F6B0071; Tue, 2 Feb 2021 13:16:17 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0057.hostedemail.com [216.40.44.57]) by kanga.kvack.org (Postfix) with ESMTP id DEEFF6B0005 for ; Tue, 2 Feb 2021 13:16:16 -0500 (EST) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id E11D93632 for ; Tue, 2 Feb 2021 18:16:14 +0000 (UTC) X-FDA: 77774132268.12.hole64_250ea47275cc Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin12.hostedemail.com (Postfix) with ESMTP id C39801800F736 for ; Tue, 2 Feb 2021 18:16:13 +0000 (UTC) X-HE-Tag: hole64_250ea47275cc X-Filterd-Recvd-Size: 4996 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by imf13.hostedemail.com (Postfix) with ESMTP for ; Tue, 2 Feb 2021 18:16:12 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 9084864F92; Tue, 2 Feb 2021 18:15:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612289771; bh=jExAi6+S0KhwmLELocI6wMJuzz/tLWY8R7yvg8v3kSM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=EDgDXp2MRosyELVG93hsa2FWpra6U+O1s/wok5z4I/qOXv7rdUmjG2axPtMIvq+YN yBgA8wcWgNGCYn0pW2zVsZsv3wcPZETui3XjKumHzFywKHgYsDnq+d0PEjUY80BQCe IzesvjbDuB+UAqmSCfbvnjKvS7w0UCcntNSHwnveAp/98Y5aklQbVLZ5aIeTMaBtIb Y2S9E4/e0RHCm573D5HvZcykwBcZPsiKWKBYdn9Gm25wRz155OpIc0oI5MY1vEx2Z5 y6k9c5Z7N9NTPpMQGOvaiK4lasHyvoskCgCDKMvmuqHqWSSfiiKO+c0UX4uuveVSEz Bmm6b/PXs32Ig== Date: Tue, 2 Feb 2021 20:15:46 +0200 From: Mike Rapoport To: David Hildenbrand Cc: Michal Hocko , James Bottomley , Andrew Morton , Alexander Viro , Andy Lutomirski , Arnd Bergmann , Borislav Petkov , Catalin Marinas , Christopher Lameter , Dan Williams , Dave Hansen , Elena Reshetova , "H. Peter Anvin" , Ingo Molnar , "Kirill A. Shutemov" , Matthew Wilcox , Mark Rutland , Mike Rapoport , Michael Kerrisk , Palmer Dabbelt , Paul Walmsley , Peter Zijlstra , Rick Edgecombe , Roman Gushchin , Shakeel Butt , Shuah Khan , Thomas Gleixner , Tycho Andersen , Will Deacon , linux-api@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-nvdimm@lists.01.org, linux-riscv@lists.infradead.org, x86@kernel.org, Hagen Paul Pfeifer , Palmer Dabbelt Subject: Re: [PATCH v16 07/11] secretmem: use PMD-size pages to amortize direct map fragmentation Message-ID: <20210202181546.GO242749@kernel.org> References: <6de6b9f9c2d28eecc494e7db6ffbedc262317e11.camel@linux.ibm.com> <20210202124857.GN242749@kernel.org> <6653288a-dd02-f9de-ef6a-e8d567d71d53@redhat.com> <211f0214-1868-a5be-9428-7acfc3b73993@redhat.com> <95625b83-f7e2-b27a-2b99-d231338047fb@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <95625b83-f7e2-b27a-2b99-d231338047fb@redhat.com> 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 Tue, Feb 02, 2021 at 03:34:29PM +0100, David Hildenbrand wrote: > On 02.02.21 15:32, Michal Hocko wrote: > > On Tue 02-02-21 15:26:20, David Hildenbrand wrote: > > > On 02.02.21 15:22, Michal Hocko wrote: > > > > On Tue 02-02-21 15:12:21, David Hildenbrand wrote: > > > > [...] > > > > > I think secretmem behaves much more like longterm GUP right now > > > > > ("unmigratable", "lifetime controlled by user space", "cannot go on > > > > > CMA/ZONE_MOVABLE"). I'd either want to reasonably well control/limit it or > > > > > make it behave more like mlocked pages. > > > > > > > > I thought I have already asked but I must have forgotten. Is there any > > > > actual reason why the memory is not movable? Timing attacks? > > > > > > I think the reason is simple: no direct map, no copying of memory. > > > > This is an implementation detail though and not something terribly hard > > to add on top later on. I was more worried there would be really > > fundamental reason why this is not possible. E.g. security implications. > > I don't remember all the details. Let's see what Mike thinks regarding > migration (e.g., security concerns). Thanks for considering me a security expert :-) Yet, I cannot estimate how dangerous is the temporal exposure of this data to the kernel via the direct map in the simple map/copy/unmap sequence. More secure way would be to map source and destination in a different page table rather than in the direct map, similarly to the way text_poke() on x86 does. I've left the migration callback empty for now because it can be added on top and its implementation would depend on the way we do (or do not do) pooling. -- Sincerely yours, Mike.