Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp2050727pxb; Mon, 23 Aug 2021 10:51:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzdL5IZUlWVgOqyuDFmjlSKWtIWFappH++oQzBxZHrYuGgjDp3IWJvHDlX1vKzpTi3gcBmD X-Received: by 2002:a50:fd87:: with SMTP id o7mr39163160edt.289.1629741100222; Mon, 23 Aug 2021 10:51:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629741100; cv=none; d=google.com; s=arc-20160816; b=PWbSseIThYG7phnCi8ZUQEUzUESMaPxDSwb1yqc6Kv+V4uyVDQM2ImCe8vJcWuQSbb 3IG62gJ/uuHKYQL0nlREA4Zg7optPVz7PW0McT2MJGXBejk4YEJ/5XsT44BAVodDYLEz 1VwwIhU9HGZBXy6OrqClZgdy5nbPL75kSnlRZXxgQo3Epwwkaz+dQITpWPQCv8Xdf+mU +aLeeyZ7sy0DFF4XZicchdKuBdMSVkWC+YWlL/J4HY3X3xT4M7MyFym/qx/ih1/XpNMc ok/E65Yhw8sMZPueh1Yxej4ch29r7TZfeSShgluD5CR46qr6OIXBwqjFTOtspkBNnmIi GHRg== 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=plb0F7/zgK9URg+TVDPgTOY+zfqlB9v4coJEI8iSXGQ=; b=AVAqwbjPAV0SKyoaOVi1Ck5kjH31KC/Im6zehBdv6KRUDwtKKYEugIXS2gv1T5jW0/ laFXOMUSvDU8Tkx/I5DjQRqc/1ENaJ9lpZihCHFUJk5Inm+k/Oz3F9BDRicgegqKAFwN 7MI+IMkM4Zn7WmUs6wj9sBinHGJcorJzCrbr20j43q98j/9pVEwhoTk8jb6tcRVQJEHE kQaErNzRocBIRVTdl7Bv6IytX0Ku3P1ydpQtrDNsGvkDatDQ89RLK0clTdmauQez4UF1 W+tUy3H/6L0DaBZONeowzCx5RHI5O1x80hpP7agSL5en+CnNVWgOzMlslBJgIHh8nS3H 35zQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gateworks-com.20150623.gappssmtp.com header.s=20150623 header.b=sK+PNdpy; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id eg4si3479830edb.102.2021.08.23.10.51.15; Mon, 23 Aug 2021 10:51:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-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=@gateworks-com.20150623.gappssmtp.com header.s=20150623 header.b=sK+PNdpy; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231877AbhHWRvz (ORCPT + 99 others); Mon, 23 Aug 2021 13:51:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229746AbhHWRvy (ORCPT ); Mon, 23 Aug 2021 13:51:54 -0400 Received: from mail-pj1-x102c.google.com (mail-pj1-x102c.google.com [IPv6:2607:f8b0:4864:20::102c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBAB3C06175F for ; Mon, 23 Aug 2021 10:51:11 -0700 (PDT) Received: by mail-pj1-x102c.google.com with SMTP id qe12-20020a17090b4f8c00b00179321cbae7so493514pjb.2 for ; Mon, 23 Aug 2021 10:51:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gateworks-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=plb0F7/zgK9URg+TVDPgTOY+zfqlB9v4coJEI8iSXGQ=; b=sK+PNdpyJ9XMyiKYWAu4TIqV+1vRFwSaoOZRmbF+Skj6cP4PrU4PZdYKf5AajUCIea wGK1OHqe7oUdD/Zo+RKwiNdc9i/UqPMiQ0DT+qEMhAe6APYpLpOTQm8Lk41gSbaZkSaY jTs3jHS5v9nHua9DqauQ65P50OIYqT7C8dd0Fja6L0ZnLdc7rtZvy+qZ/mQr5a3wGIdq ur3WeoHlxl0uzl1F9sxQZm+wUvURGJibgLoRaGwP9bMBHhmI+gzVCmXkZgbIQN0wcWfd 2X6edx6I85LU3jXjYoOxRgNIIY/HECn5clRVQ7vzmBUxKCqTZfc0YFZ8TQPAR+DkDg9R DO8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=plb0F7/zgK9URg+TVDPgTOY+zfqlB9v4coJEI8iSXGQ=; b=FnFP67l0WZdT+3crWviYLAITMkN/pFu+0Kt6Ur4luSWtRWvlPBEji45otVP2f8KHHs nOGJi3/JWZbT0bEHr+JxxZmrHj/6+Qu7XPa9zPJlnq6TlbGg6gdXIb1x6uuKt6zvb4N2 oNQxLXOgBRP1HWBdS6/FZuAVcSWJ7CNy1rWKZVi68CGI98d2oW3tSwpSskMTIjWY7Aiy 5lNgFjigv5aN7J8cb1u9bvCS2cAhQeRcRprYq8+7P7zyFINx036nD9Tws4ztUespLgXn 0Fuv6gbyMj6Qsfw3S64LzUZqAok7rxriZtWEgK4hOZjSzgs+PIALa0rt6ZcMJb42pruL N0Rg== X-Gm-Message-State: AOAM531xyIffVrNqSj/4urPKLwfrmHcQuDizkXAtCJzkugOndVdFsutN jqoKkh6TiVJLKwhfQ+/hBNL99WgKQ1gmGMyNqGOzWA== X-Received: by 2002:a17:902:a9c7:b029:12b:349:b318 with SMTP id b7-20020a170902a9c7b029012b0349b318mr29742335plr.13.1629741071409; Mon, 23 Aug 2021 10:51:11 -0700 (PDT) MIME-Version: 1.0 References: <2b48a848-d70b-9c43-5ca0-9ab72622ed12@pengutronix.de> <9200d46d-94a2-befd-e9b0-93036e56eb8a@pengutronix.de> In-Reply-To: From: Tim Harvey Date: Mon, 23 Aug 2021 10:50:59 -0700 Message-ID: Subject: Re: [PATCH 0/4] KEYS: trusted: Introduce support for NXP CAAM-based trusted keys To: Ahmad Fatoum Cc: David Gstir , Aymen Sghaier , Mimi Zohar , Jan Luebbe , keyrings@vger.kernel.org, Steffen Trumtrar , linux-security-module@vger.kernel.org, Udit Agarwal , Herbert Xu , =?UTF-8?Q?Horia_Geant=C4=83?= , Richard Weinberger , James Morris , Eric Biggers , "Serge E. Hallyn" , Sumit Garg , James Bottomley , Franck LENORMAND , David Howells , open list , Jarkko Sakkinen , linux-crypto@vger.kernel.org, Sascha Hauer , linux-integrity@vger.kernel.org, "David S. Miller" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Mon, Aug 23, 2021 at 6:29 AM Ahmad Fatoum wrote: > > Hello Tim, > > On 20.08.21 23:19, Tim Harvey wrote: > > On Fri, Aug 20, 2021 at 1:36 PM Ahmad Fatoum wrote: > >> > >> On 20.08.21 22:20, Tim Harvey wrote: > >>> On Fri, Aug 20, 2021 at 9:20 AM Ahmad Fatoum wrote: > >>>> On 20.08.21 17:39, Tim Harvey wrote: > >>>>> Thanks for your work! > >>>>> > >>>>> I've been asked to integrate the capability of using CAAM to > >>>>> blob/deblob data to an older 5.4 kernel such as NXP's downstream > >>>>> vendor kernel does [1] and I'm trying to understand how your series > >>>>> works. I'm not at all familiar with the Linux Key Management API's or > >>>>> trusted keys. Can you provide an example of how this can be used for > >>>>> such a thing? > >>>> > >>>> Here's an example with dm-crypt: > >>>> > >>>> https://lore.kernel.org/linux-integrity/5d44e50e-4309-830b-79f6-f5d888b1ef69@pengutronix.de/ > >>>> > >>>> dm-crypt is a bit special at the moment, because it has direct support for > >>>> trusted keys. For interfacing with other parts of the kernel like ecryptfs > >>>> or EVM, you have to create encrypted keys rooted to the trusted keys and use > >>>> those. The kernel documentation has an example: > >>>> > >>>> https://www.kernel.org/doc/html/v5.13/security/keys/trusted-encrypted.html > >>>> > >>>> If you backport this series, you can include the typo fix spotted by David. > >>>> > >>>> I'll send out a revised series, but given that a regression fix I want to > >>>> rebase on hasn't been picked up for 3 weeks now, I am not in a hurry. > >>>> > >>> Thanks for the reference. > >>> > >>> I'm still trying to understand the keyctl integration with caam. For > >>> the 'data' param to keyctl you are using tings like 'new ' and > >>> 'load '. Where are these 'commands' identified? > >> > >> Search for match_table_t in security/keys/trusted-keys/trusted_core.c > >> > >>> I may still be missing something. I'm using 4.14-rc6 with your series > >>> and seeing the following: > >> > >> That's an odd version to backport stuff to.. > >> > >>> # cat /proc/cmdline > >>> trusted.source=caam > >>> # keyctl add trusted mykey 'new 32' @s)# create new trusted key named > >>> 'mykey' of 32 bytes in the session keyring > >>> 480104283 > >>> # keyctl print 480104283 # dump the key > >>> keyctl_read_alloc: Unknown error 126 > >>> ^^^ not clear what this is > >> > >> Not sure what returns -ENOKEY for you. I haven't been using trusted > >> keys on v4.14, but you can try tracing the keyctl syscall. > > > > yikes... that would be painful. I typo'd and meant 5.14-rc6 :) > > ^^ > > > I'm working with mainline first to make sure I understand everything. If I > > backport this it would be to 5.4 but that looks to be extremely > > painful. It looks like there was a lot of activity around trusted keys > > in 5.13. > > Ye. It used to be limited to TPM before that. > > > It works for a user keyring but not a session keyring... does that > > explain anything? > > # keyctl add trusted mykey 'new 32' @u > > 941210782 > > # keyctl print 941210782 > > 83b7845cb45216496aead9ee2c6a406f587d64aad47bddc539d8947a247e618798d9306b36398b5dc2722a4c3f220a3a763ee175f6bd64758fdd49ca4db597e8ce328121b60edbba9b8d8d55056be896 > > # keyctl add trusted mykey 'new 32' @s > > 310571960 > > # keyctl print 310571960 > > keyctl_read_alloc: Unknown error 126 > > Both sequences work for me. > > My getty is started by systemd. I think systemd allocates a new session > keyring for the getty that's inherited by the shell and the commands I run > it in. If you don't do that, each command will get its own session key. > > > Sorry, I'm still trying to wrap my head around the differences in > > keyrings and trusted vs user keys. > > No problem. HTH. Ahmad, Ok that explains it - my testing is using a very basic buildroot ramdisk rootfs. If I do a 'keyctl new_session' first I can use the system keyring fine as well. Thanks - hoping to see this merged soon! Tim