Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp5133553pxb; Wed, 19 Jan 2022 11:45:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJyJBgb4Kl1ryBieMiaNHQSHzmZm05xeWKNEv1jO2vAZr9hMv4gGQv/GdGScrW3vpG+mqP2c X-Received: by 2002:a63:e805:: with SMTP id s5mr18864191pgh.369.1642621520411; Wed, 19 Jan 2022 11:45:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1642621520; cv=none; d=google.com; s=arc-20160816; b=lwOkRPaxGFnRZOiZFM3+K9eEGcQjUWynSt4EwO/kW8+qbj5k8EcK1a+Vg2nSUxsrdV mU1MOqs7h0WkJsX6aUBbG0xHB1tx1BsigRqKuk2KbyoRtkNr5Cg9Yd+IMoAH2EBYnCFS mrNq3hxDSweX73nQRBGoYQkQ1e4LC1tj4zHCqPVH4V83BZgfYL4409A3x9yxqHeaKese yBBMRGARwniGLbgLePLY82TMWAuoo6TClF5zMibuIotg6J1Mf+LHq3yz8FlgOi0+ap+w mHQsS9s6Rh78Z1E8cGos5GxXOxmt1K4vzFROWkBLKLB37XgkK12qgCE5+ojMr8Ce1Jdh b6Rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=ndRmdqMdJ9799j8PWgE96Wh//o3D2hfldSG13u5SeAM=; b=gm16pnX1r7+2ggk3Uh/pdHduKuZ8kr5npbQUtbiecr04Whp1d1By6cbfUuOFUsGZZP CHy6bL8oR+iLc+2i/ZiPddAwiPmGb6IqKLJeqlUSxqDQ6H0h4ZPgYFoWVJJz2vkfNngC N6LV0/AJxzLdzjuLyGqe0b8SBK8zEGA08/9rpl32f31NL30Evmr7fuGvq/I9f9zOXcKN D/Xs8+tAjaZhFWRwfFYReM28YKW+NsFNB9L2iU3lx5qS9prkbEBd9b+VwzcTS8746gZQ 7eceaZxv2THRF+di2HNScdBkmOglMpE+uOKYQ7jdWbiZUiWujBwqoMoIn3LQQbOQWojQ cKAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=YB+Kge9l; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q5si873426pgh.121.2022.01.19.11.45.08; Wed, 19 Jan 2022 11:45:20 -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=@linaro.org header.s=google header.b=YB+Kge9l; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240013AbiARGrN (ORCPT + 99 others); Tue, 18 Jan 2022 01:47:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231146AbiARGrK (ORCPT ); Tue, 18 Jan 2022 01:47:10 -0500 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42A57C06161C for ; Mon, 17 Jan 2022 22:47:10 -0800 (PST) Received: by mail-lf1-x134.google.com with SMTP id p27so55005157lfa.1 for ; Mon, 17 Jan 2022 22:47:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ndRmdqMdJ9799j8PWgE96Wh//o3D2hfldSG13u5SeAM=; b=YB+Kge9lFu1w7LVUa5FlGUi7PZaLnS8FNV8sMwK0FPqqG0Lk2PUL7PRgao61YZQSU8 3/JPbrKoffRa3xJh3qPEuFRzwkbTeYnhZK0i3jHv7Q7X2waL25oHJU1p6im42FbswCSs Ug69yVzHk9/Wmztwy3F8QTh8w2X6tZjB36qmOuzjwqEg4ZdDg1m2wZWDLniLM00kGvDN 7tTN5RWg6e9J+S9w5Cc2SEcm7/jA6zzRdoUnhJNiSN7hO/EyjynW9TVag9qAp2VVtfE4 wj4QBzzIlAqEZb63Nh++4Y9PPsElMmAn3PShGpukX0PibdcmJlXUdOqIb9oLyi9WcFXd 5T0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ndRmdqMdJ9799j8PWgE96Wh//o3D2hfldSG13u5SeAM=; b=hepMAVRixRPzg9yEsGLJQBRByETQKU6y01OtcYD2Usv7tU0aNHr3+xWVx2X70twBaR 5Qpw2IfAreVo165CpDlZZnwJlpZE4BBD94SjKWAp49YiH7Zx2878cv0sEDDPeUaKcvfE shh0EOVE8Kln0GgvduGWG4zejh96hHQkpcqYM3ptXa1gGup310HQRY/UgdXsDy0yTmVK sWZ9NpI4K6kKfqX9195uC3IPtSe2wNtbhwxTSC+2vWwkRfvoDYq1E7kYbA9Jx3iYzDHV ZcgdN/WRckinIWsOdautV6jdwyLPCXuMqmzmrItKG5Mga6zcYDujigR/1q9ACrL2EXfF K32w== X-Gm-Message-State: AOAM5334jV7UJ+nEJrV6kENZWcyUhFtKCknCBZnZFvj+8j3VpxbRDb4A CAdEme3FUTM/MNbyggDlU9jwELYRHCCBAs8DJOIs/g== X-Received: by 2002:a2e:bf01:: with SMTP id c1mr18353250ljr.511.1642488428506; Mon, 17 Jan 2022 22:47:08 -0800 (PST) MIME-Version: 1.0 References: <20211229215330.4134835-1-yaelt@google.com> <5a38824152eeee0fc9ba0a4fd2308bb6e0970059.camel@linux.ibm.com> In-Reply-To: From: Sumit Garg Date: Tue, 18 Jan 2022 12:16:56 +0530 Message-ID: Subject: Re: [PATCH v4] KEYS: encrypted: Instantiate key with user-provided decrypted data To: Yael Tiomkin Cc: Mimi Zohar , linux-integrity@vger.kernel.org, jejb@linux.ibm.com, Jarkko Sakkinen , corbet@lwn.net, dhowells@redhat.com, jmorris@namei.org, serge@hallyn.com, keyrings@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-security-module , =?UTF-8?Q?Jan_L=C3=BCbbe?= , Ahmad Fatoum Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 14 Jan 2022 at 00:45, Yael Tiomkin wrote: > > On Fri, Jan 7, 2022 at 8:32 AM Sumit Garg wrote: > > > > On Fri, 7 Jan 2022 at 18:23, Yael Tiomkin wrote: > > > > > > Hi Sumit, > > > > > > On Fri, Jan 7, 2022 at 12:15 AM Sumit Garg wrote: > > > > > > > > Hi Yael, > > > > > > > > On Thu, 6 Jan 2022 at 01:48, Yael Tiomkin wrote: > > > > > > > > > > Hi Sumit, > > > > > > > > > > On Mon, Jan 3, 2022 at 1:51 AM Sumit Garg wrote: > > > > > > > > > > > > Hi Mimi, > > > > > > > > > > > > Apologies for the delayed reply as I was on leave for a long new year weekend. > > > > > > > > > > > > On Thu, 30 Dec 2021 at 18:59, Mimi Zohar wrote: > > > > > > > > > > > > > > Hi Sumit, > > > > > > > > > > > > > > On Thu, 2021-12-30 at 15:37 +0530, Sumit Garg wrote: > > > > > > > > + Jan, Ahmad > > > > > > > > > > > > > > > > On Thu, 30 Dec 2021 at 03:24, Yael Tiomkin wrote: > > > > > > > > > > > > > > > > > > The encrypted.c class supports instantiation of encrypted keys with > > > > > > > > > either an already-encrypted key material, or by generating new key > > > > > > > > > material based on random numbers. This patch defines a new datablob > > > > > > > > > format: [] > > > > > > > > > that allows to instantiate encrypted keys using > > > > > > > > > user-provided decrypted data, and therefore allows to perform key > > > > > > > > > encryption from userspace. The decrypted key material will be > > > > > > > > > inaccessible from userspace. > > > > > > > > > > > > > > > > This type of user-space key import feature has already been discussed > > > > > > > > at large in the context of trusted keys here [1]. So what makes it > > > > > > > > special in case of encrypted keys such that it isn't a "UNSAFE_IMPORT" > > > > > > > > or "DEBUGGING_IMPORT" or "DEVELOPMENT_IMPORT", ...? > > > > > > > > > > > > > > > > [1] https://lore.kernel.org/linux-integrity/74830d4f-5a76-8ba8-aad0-0d79f7c01af9@pengutronix.de/ > > > > > > > > > > > > > > > > -Sumit > > > > > > > > > > > > > > > > > > > > > > > > > > Reviewed-by: Mimi Zohar > > > > > > > > > Signed-off-by: Yael Tiomkin > > > > > > > > > > > > > > There is a difference between trusted and encrypted keys. > > > > > > > > > > > > Yeah I understand the implementation differences. > > > > > > > > > > > > > So in > > > > > > > addition to pointing to the rather long discussion thread, please > > > > > > > summarize the conclusion and, assuming you agree, include why in once > > > > > > > case it was acceptable and in the other it wasn't to provide userspace > > > > > > > key data. > > > > > > > > > > > > My major concern with importing user-space key data in *plain* format > > > > > > is that if import is *not* done in a safe (manufacturing or > > > > > > production) environment then the plain key data is susceptible to > > > > > > user-space compromises when the device is in the field. > > > > > > > > > > I agree this can happen. Key distribution in any scenario needs to be > > > > > secure and this could also potentially be an issue if the key is first > > > > > encrypted and then imported. > > > > > > > > Currently its not the case with encrypted keys. These are random keys > > > > generated within the kernel and encrypted with master key within the > > > > kernel and then exposed to user-space as encrypted blob only. > > > > > > > > > There are two different ways to create encrypted keys. One is to have > > > them generated within the kernel using random numbers, and the other > > > is by importing them in their encrypted form from user-space. > > > I was referring to the latter in my previous statement. > > > > > > > So, from a key distribution security point of view, encrypted key > > user-space import is **not equal to** plain key user-space import. > > That's why we need to have a separate compile time option as every > > device may come with its own threat model and may choose to enable or > > disable this user-space plain key import feature. > > > > -Sumit > > > > > > > > > > > We can make sure the documentation > > > > > highlights the safety requirement. > > > > > > > > > > > > > IMO, you should enable this feature as a compile time option. The help > > > > text for that config option should highlight the use-case along with a > > > > safety warning. > > > > > > > > -Sumit > > > > > > > > > > > > > > > > And it sounds like we are diverting from basic definition [1] of encrypted keys: > > > > > > > > > > > > "Trusted and Encrypted Keys are two new key types added to the > > > > > > existing kernel key ring service. Both of these new types are variable > > > > > > length symmetric keys, and in both cases all keys are created in the > > > > > > kernel, and **user space sees, stores, and loads** only encrypted > > > > > > blobs." > > > > > > > > > > > > Also, as Jarrko mentioned earlier the use-case is still not clear to > > > > > > me as well. Isn't user logon keys an alternative option for > > > > > > non-readable user-space keys? > > > > > > > > > > The goal in this change is to allow key encryption from userspace, > > > > > using user-provided decrypted data. This cannot be achieved in logon > > > > > keys, which as you mentioned, are simply non-readable user type keys. > > > > > > > > > > > > > > > > > > > > > > [1] https://www.kernel.org/doc/html/v4.13/security/keys/trusted-encrypted.html > > > > > > > > > > > > -Sumit > > > > > > > > > > > > > > > > > > > > thanks, > > > > > > > > > > > > > > Mimi > > > > > > > > > > > > > > > > > Yael > > Hi Sumit, > The encrypted-keys module is already controlled by the > CONFIG_ENCRYPTED_KEYS option, which I think might give sufficient > granularity to control the behavior. Do you still think a feature > dedicated option is needed? > Since this feature will change security properties for encrypted keys which can be considered as a regression for existing users during uprev. So it needs to be an optional key import feature with a clear user visible warning. Thinking more about this, you can even have a module param to turn it on with a runtime warning as well. -Sumit > Yael