Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3193914ybi; Mon, 17 Jun 2019 18:51:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqza224lUFAx9xvmv2ZwBr5fEcbtc5PUj/pVAys4KgoQ3+TROoJlo1SxGoMC15H86SfvCJ65 X-Received: by 2002:a63:5d54:: with SMTP id o20mr281365pgm.97.1560822684402; Mon, 17 Jun 2019 18:51:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560822684; cv=none; d=google.com; s=arc-20160816; b=HLzBXYe0kWDHu9yXsqVPPbSzQxHiBWI9AwjNQNFqdKH7+BYudIPejBKeI0JsigCdyA e3Fge1S5+clMj6pbUaAW+7ey3gP6uKxSfcQXAKzTDvELGkWxKVcMwScP4Uj3GgUWoBEb /yV6X9No+qUhKsG6f6yTnJ5BkUaqjSGqiJQQpk7x97nnXYYh2TMc1qJ7fUZ0zymS0S6T ilrpiYE9Ztvcag8NWNBm8NT3ZpQPkhlLhIO6Ne3vEAzTMHEN2ByrYdaXNVLoGXjZ2Wgm 6TzZ0n90pToRfQ5ma/StF61ipp3nHSl3AotuZHtA4ozihblaK+IDoVD6aWVKoH4JazMQ n2MA== 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=yGUUgP1uKXn/fRTt1KOFlBO2RYvvxLk1PzE3vsueHXw=; b=NUSXnShaK+fKF1Z6OMkwILr4BmYXz5AuBZvq7bBO3B9MdCttazgj7aYlIQvEnG5U25 wJTF1H/8eyzxiC0Nojb64fpznSg8KAG6aGcBMVcdmSYGHQT2w0HUoZ83heLrV0PlUtJT 7I284sLDdiYjti4u1/ptk5iT3g+XsHX8aV4+3huOCfsHi5D1sditiwE09BtYb1SdGCfk RUnUE6a9a4J6Oj8suqpoeSXagNb2eoe+G613IxqXp7bGMd4+8XXL93TH/jrOZYQhyMYA mkkz1Qcm1eeb+mxPezb1Mx+eXFmHUJpuZvbCZ+kmEUK0DEMM7ESWqFA8qum4TuDHqAVK v0+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=aO3C7gus; 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 i17si884362pju.96.2019.06.17.18.51.09; Mon, 17 Jun 2019 18:51:24 -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=aO3C7gus; 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 S1727159AbfFRBvA (ORCPT + 99 others); Mon, 17 Jun 2019 21:51:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:59764 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726023AbfFRBvA (ORCPT ); Mon, 17 Jun 2019 21:51:00 -0400 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (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 7DB96208E4 for ; Tue, 18 Jun 2019 01:50:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560822658; bh=9pADkGP6B9XPZnoSXHTdilPdPV8psk9Fh8iUhTu3lCw=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=aO3C7gusUpRN/F1U4OsRkHAd5bWRjQMfpkle66mvj1CdvoqtH8xKaAKZisXNpFECZ QOlRO1ZyOcvCR5lcG2FzLXrziVwwb7nFPBKZOO+serlPcj/7WLJ2HliilezLLDjCa7 qcRrhJb8zqZ5haKe+GxoCxdEy5Z5yvR95St+9PVQ= Received: by mail-wm1-f48.google.com with SMTP id s15so1349225wmj.3 for ; Mon, 17 Jun 2019 18:50:58 -0700 (PDT) X-Gm-Message-State: APjAAAUpk+KJWuIL0QUCsQbq7+hL9HJ6y3NUiqsXQqEqd32LQYwks2sa Cxx07fcdbGDjxiDpRkgTsMm+XUK6UvWmL0g20mltwA== X-Received: by 2002:a7b:cd84:: with SMTP id y4mr951107wmj.79.1560822657085; Mon, 17 Jun 2019 18:50:57 -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> <1560818931.5187.70.camel@linux.intel.com> In-Reply-To: <1560818931.5187.70.camel@linux.intel.com> From: Andy Lutomirski Date: Mon, 17 Jun 2019 18:50:46 -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: Dave Hansen , Andy Lutomirski , "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:48 PM Kai Huang wrote: > > > > > > > And another silly argument: if we had /dev/mktme, then we could > > > possibly get away with avoiding all the keyring stuff entirely. > > > Instead, you open /dev/mktme and you get your own key under the hook. > > > If you want two keys, you open /dev/mktme twice. If you want some > > > other program to be able to see your memory, you pass it the fd. > > > > We still like the keyring because it's one-stop-shopping as the place > > that *owns* the hardware KeyID slots. Those are global resources and > > scream for a single global place to allocate and manage them. The > > hardware slots also need to be shared between any anonymous and > > file-based users, no matter what the APIs for the anonymous side. > > MKTME driver (who creates /dev/mktme) can also be the one-stop-shopping. I think whether to choose > keyring to manage MKTME key should be based on whether we need/should take advantage of existing key > retention service functionalities. For example, with key retention service we can > revoke/invalidate/set expiry for a key (not sure whether MKTME needs those although), and we have > several keyrings -- thread specific keyring, process specific keyring, user specific keyring, etc, > thus we can control who can/cannot find the key, etc. I think managing MKTME key in MKTME driver > doesn't have those advantages. > Trying to evaluate this with the current proposed code is a bit odd, I think. Suppose you create a thread-specific key and then fork(). The child can presumably still use the key regardless of whether the child can nominally access the key in the keyring because the PTEs are still there. More fundamentally, in some sense, the current code has no semantics. Associating a key with memory and "encrypting" it doesn't actually do anything unless you are attacking the memory bus but you haven't compromised the kernel. There's no protection against a guest that can corrupt its EPT tables, there's no protection against kernel bugs (*especially* if the duplicate direct map design stays), and there isn't even any fd or other object around by which you can only access the data if you can see the key. I'm also wondering whether the kernel will always be able to be a one-stop shop for key allocation -- if the MKTME hardware gains interesting new uses down the road, who knows how key allocation will work?