Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp719533pxb; Tue, 2 Feb 2021 16:37:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJxFAJ+8qy6ZX6BZ0ErBqKi63J5Z29mgWuixaJ+Yt9zgSL9WXC27Wr5Wzf996ElCD2LBHqtm X-Received: by 2002:a17:906:225a:: with SMTP id 26mr567682ejr.477.1612312633919; Tue, 02 Feb 2021 16:37:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612312633; cv=none; d=google.com; s=arc-20160816; b=ZQNBikZ204rhwb/+1MvreBcVpH6hBCmkIfXqPFZJG/xv/VCFMy0Rir+mIZLR/JAPGW bT6KEpUvBgXGiYIAjBLPHa3w1DsLZsuyk2GU9kLKqLdNFkevKICvOq9JlKL3vgQ2IWZo nQGQSh7aOOw1wCgqyKgz8AsuOlcN2m2qswlNjKKGUoqS6uZZbBoOqUzgyWQHKrUUk1O8 AGz1il6oac/hGZXjttI00ORttAupDUpiOs52m3BwYWpI1dKhtfFC7KIwWcoTApCwRFgq ShrcZ5LHNn2NleKW8+6IAIRbiVn4NEYklyTmVCdkQ1MHYl99UEsjzrkYDjmA16Ocu7Kq O5vg== 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=MQ6JfJNaq3fXiMp+xxIsLbCNfqgJPyA+vfYz6dBkPzo=; b=TRNxF3YRhWCbiGD4cOJqONyKLothnMDjEGUPXW9/ieEBD19AZnYB2EH19XXuKXvfod 1iGmS2viNEAC+H0JtW4Lb5B1h7unJCkMHc426qn5IYgIZgoibcocHDbWG8B1s974gE3E tKmep47m+HAviSjcL7nIZPFno2vFK7rjhpUOCkMUWAirEAhPc6OVKNW9LmkBcBJMjPBm 0zZ7Pf2T39DDTwE0Ox0oIL0tbvgFaoBw24RD3XGq2q+D1OylGZlLpbtfZxRbDjVSiQCs q9tHR8jG7qVYOKwzZpcR/mVGZY/vn+p3UZixGgkfzvjQ99uB1JBtZasJOyt2gQkK+YmN Poog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=EDgDXp2M; 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 f17si196579eds.588.2021.02.02.16.36.50; Tue, 02 Feb 2021 16:37:13 -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=k20201202 header.b=EDgDXp2M; 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 S238415AbhBBSUf (ORCPT + 99 others); Tue, 2 Feb 2021 13:20:35 -0500 Received: from mail.kernel.org ([198.145.29.99]:57624 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238384AbhBBSQ5 (ORCPT ); Tue, 2 Feb 2021 13:16:57 -0500 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> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.