From patchwork Tue Aug 14 02:05:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alison Schofield X-Patchwork-Id: 10564987 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BB9FC15A6 for ; Tue, 14 Aug 2018 02:04:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A8A19295A1 for ; Tue, 14 Aug 2018 02:04:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9C8A0295A9; Tue, 14 Aug 2018 02:04:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 24436295A1 for ; Tue, 14 Aug 2018 02:04:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729459AbeHNEs7 (ORCPT ); Tue, 14 Aug 2018 00:48:59 -0400 Received: from mga02.intel.com ([134.134.136.20]:10362 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725829AbeHNEs7 (ORCPT ); Tue, 14 Aug 2018 00:48:59 -0400 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Aug 2018 19:04:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,236,1531810800"; d="scan'208";a="224405328" Received: from alison-desk.jf.intel.com ([10.54.74.53]) by orsmga004.jf.intel.com with ESMTP; 13 Aug 2018 19:04:03 -0700 Date: Mon, 13 Aug 2018 19:05:38 -0700 From: Alison Schofield To: dhowells@redhat.com Cc: jmorris@namei.org, serge@hallyn.com, keyrings@vger.kernel.org, linux-security-module@vger.kernel.org, Dave Hansen , Kirill Shutemov , Kai Huang , Jun Nakajima Subject: [RFC] KEYS: inject an MKTME specific safety check in the keyctl revoke path Message-ID: <20180814020538.GA18424@alison-desk.jf.intel.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: X-Virus-Scanned: ClamAV using ClamSMTP This RFC is asking for feedback on a problem I'm running into using the Kernel Key Service for MKTME (MultiKey Total Memory Encryption). I previously posted an RFC with the proposal to create a new key type "mktme" to support MKTME (Multi-Key Total Memory Encryption). https://www.spinics.net/lists/keyrings/msg03702.html The MKTME key service maps userspace keys to hardware keyids. Those keys are used in a new system call that encrypts memory. The keys need to be tightly controlled. One example is that userspace keys should not be revoked while the hardware keyid slot is still in use. The KEY_FLAG_KEEP bit offers good control. The mktme service uses that bit to prevent userspace keys from disappearing without the service being notified. Problem is that we need a safe and synchronous way to revoke keys. The way .revoke methods function now, the key service type is called late in the revoke process. The mktme key service has no means to reject the request. So, even if the mktme service sanity checks the request in its .revoke method, it's too late to do anything about it. This proposal inserts an MKTME specific check earlier into the existing keyctl path. If it is safe to revoke the key, mktme key service will turn off KEY_FLAG_KEEP and let the revoke continue (and succeed). Otherwise, not safe, KEY_FLAG_KEEP stays on, and the revoke continues (and fails). I considered proposing a new keyctl