Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1628602pxb; Thu, 4 Mar 2021 16:54:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJwHmxS7uersY+z9B6Z3y2gI+Ukvq33HYc0P/BjeEUp3VfvK9xOy3kjb702jy1kqo+aagUV0 X-Received: by 2002:a02:9663:: with SMTP id c90mr7136062jai.16.1614905680058; Thu, 04 Mar 2021 16:54:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614905680; cv=none; d=google.com; s=arc-20160816; b=cJAC31r8kN9xr3yIh68rERl+ro5o39aZnJvdRWH2UyVOcC57xWdNWTQsVgjRcI0kt7 lPvM+50oST/kNuMXuE+rXF7NwBWIfR2aKg0RF/AIeehcyVPlm7GUc/qz3srLlY07OwJH EtMk7f9N3w9DIZJcL7yDQYDtoTFl98M0IESc+8YatrO3Jc0MU3qU7Wu4UvdTkHoiWIpK pYKkGOvhWJA72q+afZRGDCMBjiLVtEtpAsEhLCxHWFovgThhjIH8M7KK0AF9PO/oUYH8 HJaZTaTamRXae5vC5QthAUmJuff9ia7jbGJwxfl22JMEMqQCZVqSr+knorEo/yLl/Q5+ 4asg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:in-reply-to:date:subject:cc:to:from:user-agent :references:dkim-signature; bh=8R7Ifb0lG6B9vvUmi1oPee7NhyKlrhTZle2Mf9WBYdQ=; b=ienPyrSCVJvPB4AimR343lXV8lOjR8BoykgF6HO7jgJXfU6wwVxVGlMBScbn+KQrsh 4mmEI8tOTV6fFsXfXvU/eoqVLy286QuLY5JcGLLw93I5Ks2NyY3ChYWSb8Z0BeRF79NH hzZyCZaz4K8w3vJLSD7v3wJ5CKa3cJQ3Ljv2Uk8oTv1QngtDrti/Nkr263E+ZyJXvOXZ pw7825qfDFiziqu0yPfkNHk2HbmiFL7qnO6GdQBFsvZ7WHTFmT2A5fs9Jxnp97y2o4+l h7GirtWHdZ7R4h8NgyW8HdfmSMKzdELcMwO7OqV7O+sIEJ8nn5/AV/7xCQYLAFOxUDM0 cYpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xsl1yZ6g; 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 h2si908835iov.19.2021.03.04.16.54.26; Thu, 04 Mar 2021 16:54:40 -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=xsl1yZ6g; 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 S232535AbhCDSBs (ORCPT + 99 others); Thu, 4 Mar 2021 13:01:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232321AbhCDSBR (ORCPT ); Thu, 4 Mar 2021 13:01:17 -0500 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0494C061756 for ; Thu, 4 Mar 2021 10:00:36 -0800 (PST) Received: by mail-wr1-x436.google.com with SMTP id a18so20449389wrc.13 for ; Thu, 04 Mar 2021 10:00:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=references:user-agent:from:to:cc:subject:date:in-reply-to :message-id:mime-version:content-transfer-encoding; bh=8R7Ifb0lG6B9vvUmi1oPee7NhyKlrhTZle2Mf9WBYdQ=; b=xsl1yZ6gGZXAoEu02jhqZeM0rHDiFWFH/3g3Kq+bb5AL3RAImOHMR2VPDce9buhUs5 wgXVWxcIDm9seZmzGULizGtbzfErxlddmAsquXMb40FHvDKf8fo6y7v+HGes/L8Iu2mq 9k5QhKMJfYOo5VqfsPP//nDxQiT68+5sO9lG6aYhXIvdl3m4dihgCZOElKMozwREOaGD I85a/Sgq+RxIR2SAVRmMwpKXeghOUj/PyjpayUbjN4I6l47bJReBrH4pYk6cq3qygw1g QuqdlirqO7QM7NxQg4BEOH0ozHE5EMpcX+HEBKztSiZHe48YNFB1km4pJKkNcVApJwk1 P8ww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:cc:subject:date :in-reply-to:message-id:mime-version:content-transfer-encoding; bh=8R7Ifb0lG6B9vvUmi1oPee7NhyKlrhTZle2Mf9WBYdQ=; b=FbnXR/WmgFUpIfD7jqgBmVPVOzkQaiPTkEcDMNsHytpmBy/2xjIWyqHveu4UYTQPAc VwCU1O45O2gRRBy7uRaBPOezTh9iEuNLX79uHsA52f7pyMBc+sEDDmOUpPFJF81xRC7n mLXLo8ZYYmGV3aXtv4upBUnTU6sjsxwRm7a6eqNeQbeB3v9OtxEyVCyNnuPm37ARIS0E HVOSI8DCJLzVoq+ssGM8E+3w7qBq01BUjhcaL/E5qS4pYa4lL9+PdpxzK8QTUATRzEi5 F4Iuq4d911Sc66sZbNZ0ecXWDWqu3I6LN4rv5OXY16bhMRtdywxAC4lQpqODv/sH8XXU tfwA== X-Gm-Message-State: AOAM530Cdt6sYJZxS+4RN2BcRNVVgEf8kG/csQsmsW0PYOVa5TMIf/aC WFttKs1uGLFC1wQIweEa9jIF6w== X-Received: by 2002:adf:dd4f:: with SMTP id u15mr5426860wrm.260.1614880835435; Thu, 04 Mar 2021 10:00:35 -0800 (PST) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id o20sm322634wmq.5.2021.03.04.10.00.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Mar 2021 10:00:34 -0800 (PST) Received: from zen (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 9CC271FF7E; Thu, 4 Mar 2021 18:00:33 +0000 (GMT) References: <20210303135500.24673-1-alex.bennee@linaro.org> <20210303135500.24673-3-alex.bennee@linaro.org> <87eegvgr0w.fsf@linaro.org> <590e0157d6c44d55aa166ccad6355db5@intel.com> User-agent: mu4e 1.5.8; emacs 28.0.50 From: Alex =?utf-8?Q?Benn=C3=A9e?= To: "Winkler, Tomas" Cc: "linux-kernel@vger.kernel.org" , "maxim.uvarov@linaro.org" , "joakim.bech@linaro.org" , "ilias.apalodimas@linaro.org" , "arnd@linaro.org" , "ruchika.gupta@linaro.org" , "Huang, Yang" , "Zhu, Bing" , "Matti.Moell@opensynergy.com" , "hmo@opensynergy.com" , "linux-mmc@vger.kernel.org" , "linux-scsi@vger.kernel.org" , linux-nvme@lists.infradead.org, Ulf Hansson , "Linus Walleij" , Arnd Bergmann , "Usyskin, Alexander" , Avri Altman Subject: Re: [RFC PATCH 2/5] char: rpmb: provide a user space interface Date: Thu, 04 Mar 2021 17:52:01 +0000 In-reply-to: <590e0157d6c44d55aa166ccad6355db5@intel.com> Message-ID: <87wnumg5oe.fsf@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Winkler, Tomas writes: >> "Winkler, Tomas" writes: >>=20 >> >> The user space API is achieved via a number of synchronous IOCTLs. >> >> >> >> * RPMB_IOC_VER_CMD - simple versioning API >> >> * RPMB_IOC_CAP_CMD - query of underlying capabilities >> >> * RPMB_IOC_PKEY_CMD - one time programming of access key >> >> * RPMB_IOC_COUNTER_CMD - query the write counter >> >> * RPMB_IOC_WBLOCKS_CMD - write blocks to device >> >> * RPMB_IOC_RBLOCKS_CMD - read blocks from device >> >> >> >> The keys used for programming and writing blocks to the device are >> >> key_serial_t handles as provided by the keyctl() interface. >> >> >> >> [AJB: here there are two key differences between this and the >> >> original proposal. The first is the dropping of the sequence of >> >> preformated frames in favour of explicit actions. The second is the >> >> introduction of key_serial_t and the keyring API for referencing the >> >> key to use] >> > >> > Putting it gently I'm not sure this is good idea, from the security po= int of >> view. >> > The key has to be possession of the one that signs the frames as they = are, >> it doesn't mean it is linux kernel keyring, it can be other party on dif= ferent >> system. >> > With this approach you will make the other usecases not applicable. It >> > is less then trivial to move key securely from one system to another. >>=20 >> OK I can understand the desire for such a use-case but it does constrain= the >> interface on the kernel with access to the hardware to purely providing a >> pipe to the raw hardware while also having to expose the details of the = HW >> to userspace.=20 > This is the use case in Android. The key is in the "trusty" which > different os running in a virtual environment. The file storage > abstraction is implemented there. I'm not sure the point of > constraining the kernel, can you please elaborate on that. Well the kernel is all about abstracting differences not baking in assumptions. However can I ask a bit more about this security model? Is the secure enclave just a separate userspace process or is it in a separate virtual machine? Is it accessible at all by the kernel running the driver? The fact that key id is passed down into the kernel doesn't have to imply the kernel does the final cryptographic operation. In the ARM world you could make a call to the secure world to do the operation for you. I note the keyctl() interface already has support for going to userspace to make queries of the keyring. Maybe what is really needed is an abstraction for the kernel to delegate the MAC calculation to some other trusted process that also understands the keyid. > > Also doesn't this break down after a PROGRAM_KEY event as >> the key will have had to traverse into the "untrusted" kernel? > > This is one in a life event of the card happening on the manufacturing > floor, maybe even not performed on Linux. In an off list conversation it was suggested that maybe the PROGRAM_KEY ioctl should be disabled for locked down kernels to dissuade production use of the facility (it is handy for testing though!). >> I wonder if virtio-rpmb may be of help here? You could wrap up up the fr= ont- >> end in the security domain that has the keys although I don't know how e= asy >> it would be for a backend to work with real hardware? > > I'm open to see any proposal, not sure I can wrap may head about it right= now.=20 > > Anyway I was about to send the new round of my code, but let's come to c= ommon ground first.=20 > OK - I'll see what the others say. --=20 Alex Benn=C3=A9e