Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3128090ybi; Mon, 17 Jun 2019 17:15:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqxjjxyGNzRxEj5tq6LFb+VFWmcElaiWOGbMoDu14OrgsD6qy8kY/5KbHgsGQD6iNuthCaxa X-Received: by 2002:a63:306:: with SMTP id 6mr1735pgd.263.1560816937823; Mon, 17 Jun 2019 17:15:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560816937; cv=none; d=google.com; s=arc-20160816; b=KaMkS84oixW7NToeX6IkxW9q4uoJ0j9DLGIG3+N73b4aQMOnukiACFVkjc/4fzIGxF oFyEwy6X6RI4tDLXoSTP6mRE9cbaVG74GtV+PqM6WvTzL0U8Ypoje2+YX8/cV64WrdCE RlM5IWkfR33bWNW7Z8Y2HJ5xOpFAlag8PtLUKN/f0zpotnRp8i9lOJGjhJh5HDqJYF7b TatdpUixS+dSiluVQxcVFG3l1Jd/zcoRbKcr0pivTPHZMSjut83h3JIYoJigc0BTMtMr N78lhPFCK7br1AoDb1o1JYA8huwUqWVHgj/ZY5gKddjG7diTGNnR1c7dAP1L2vzlrzj/ aKmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=J4ERNaAOi1Sm06NQyxiHs/joERhtwrCsfmkXb7NeUCI=; b=MjlPCQHwtrJmT6b9c1K7UWiZ3Up5LXRADqrTahcz7QrQEV5VN93NhzU5lnQPDAr2TX PPPIRqXE4M6NScsk1BVEV2yNAfzkB40CA24tqzdbXMp7pVErYvdGsTP8Ncqf99jmQxoA RgCyQigRQAFM7QTksdia8+PnItn0abK+novry/r8czJr++8mRK1iB6y07k+pwcmuwinQ 0mzBk6+W1V3bGjiSaqzdYBecKJ0fZHdvJqG0+ebC5gJBMn62JJNBZsMvZ5Q6S/JV2TCE myL5vdvy3R/wQK5NJyPZxWJ88GHIObNjUgnRXDoSxPEVJDUt6Uv8GMtCxBG3YlP+keBS N6qQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KufUXcCH; 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 w5si10923420pll.36.2019.06.17.17.15.22; Mon, 17 Jun 2019 17:15:37 -0700 (PDT) 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=KufUXcCH; 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 S1727731AbfFRAPS (ORCPT + 99 others); Mon, 17 Jun 2019 20:15:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:54456 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726568AbfFRAPS (ORCPT ); Mon, 17 Jun 2019 20:15:18 -0400 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4743C21670 for ; Tue, 18 Jun 2019 00:15:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560816917; bh=bQszpKKtRqay8BXy5xoZqczKSmcgkXxEdS7CWQ4wvic=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=KufUXcCHguV/MZBfdJ1UgPyRTW3eCKtSrfxLxy9i+UBAiIazGMrltN+iFYxFVl62s IdEC552KDjlEdIDwV6nsWtxB0Hz2z7RrknFPD/knhdNuEJYm9q3wE83tea6VtQK6hq voYk6nrOcb65/pVTvsckV8vOkNjw4TXXRvXpe+tA= Received: by mail-wr1-f43.google.com with SMTP id f9so11853595wre.12 for ; Mon, 17 Jun 2019 17:15:17 -0700 (PDT) X-Gm-Message-State: APjAAAUHOUp24/BHnkC5omi3hp4BBse/NOI3DdZbbsbPhQ50RXz6P+Hg XmkxCO7U4evnDKDSXTUjYeQCI8e1P6rU64PMBO1nHw== X-Received: by 2002:adf:f28a:: with SMTP id k10mr11743806wro.343.1560816915741; Mon, 17 Jun 2019 17:15:15 -0700 (PDT) MIME-Version: 1.0 References: <20190508144422.13171-1-kirill.shutemov@linux.intel.com> <20190508144422.13171-46-kirill.shutemov@linux.intel.com> <3c658cce-7b7e-7d45-59a0-e17dae986713@intel.com> <5cbfa2da-ba2e-ed91-d0e8-add67753fc12@intel.com> <1560816342.5187.63.camel@linux.intel.com> In-Reply-To: <1560816342.5187.63.camel@linux.intel.com> From: Andy Lutomirski Date: Mon, 17 Jun 2019 17:15:04 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH, RFC 45/62] mm: Add the encrypt_mprotect() system call for MKTME To: Kai Huang Cc: Andy Lutomirski , Dave Hansen , "Kirill A. Shutemov" , Andrew Morton , X86 ML , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , Borislav Petkov , Peter Zijlstra , David Howells , Kees Cook , Jacob Pan , Alison Schofield , Linux-MM , kvm list , keyrings@vger.kernel.org, LKML , Tom Lendacky Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 17, 2019 at 5:05 PM Kai Huang wrote: > > On Mon, 2019-06-17 at 12:12 -0700, Andy Lutomirski wrote: > > On Mon, Jun 17, 2019 at 11:37 AM Dave Hansen wrote: > > > > > > Tom Lendacky, could you take a look down in the message to the talk of > > > SEV? I want to make sure I'm not misrepresenting what it does today. > > > ... > > > > > > > > > > > I actually don't care all that much which one we end up with. It's not > > > > > like the extra syscall in the second options means much. > > > > > > > > The benefit of the second one is that, if sys_encrypt is absent, it > > > > just works. In the first model, programs need a fallback because > > > > they'll segfault of mprotect_encrypt() gets ENOSYS. > > > > > > Well, by the time they get here, they would have already had to allocate > > > and set up the encryption key. I don't think this would really be the > > > "normal" malloc() path, for instance. > > > > > > > > How do we > > > > > eventually stack it on top of persistent memory filesystems or Device > > > > > DAX? > > > > > > > > How do we stack anonymous memory on top of persistent memory or Device > > > > DAX? I'm confused. > > > > > > If our interface to MKTME is: > > > > > > fd = open("/dev/mktme"); > > > ptr = mmap(fd); > > > > > > Then it's hard to combine with an interface which is: > > > > > > fd = open("/dev/dax123"); > > > ptr = mmap(fd); > > > > > > Where if we have something like mprotect() (or madvise() or something > > > else taking pointer), we can just do: > > > > > > fd = open("/dev/anything987"); > > > ptr = mmap(fd); > > > sys_encrypt(ptr); > > > > I'm having a hard time imagining that ever working -- wouldn't it blow > > up if someone did: > > > > fd = open("/dev/anything987"); > > ptr1 = mmap(fd); > > ptr2 = mmap(fd); > > sys_encrypt(ptr1); > > > > So I think it really has to be: > > fd = open("/dev/anything987"); > > ioctl(fd, ENCRYPT_ME); > > mmap(fd); > > This requires "/dev/anything987" to support ENCRYPT_ME ioctl, right? > > So to support NVDIMM (DAX), we need to add ENCRYPT_ME ioctl to DAX? Yes and yes, or we do it with layers -- see below. I don't see how we can credibly avoid this. If we try to do MKTME behind the DAX driver's back, aren't we going to end up with cache coherence problems? > > > > > But I really expect that the encryption of a DAX device will actually > > be a block device setting and won't look like this at all. It'll be > > more like dm-crypt except without device mapper. > > Are you suggesting not to support MKTME for DAX, or adding MKTME support to dm-crypt? I'm proposing exposing it by an interface that looks somewhat like dm-crypt. Either we could have a way to create a device layered on top of the DAX devices that exposes a decrypted view or we add a way to tell the DAX device to kindly use MKTME with such-and-such key. If there is demand for a way to have an fscrypt-like thing on top of DAX where different files use different keys, I suppose that could be done too, but it will need filesystem or VFS help.