From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1E579C4332F for ; Tue, 20 Dec 2022 14:04:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229690AbiLTOEN (ORCPT ); Tue, 20 Dec 2022 09:04:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36760 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233726AbiLTOD7 (ORCPT ); Tue, 20 Dec 2022 09:03:59 -0500 Received: from bedivere.hansenpartnership.com (bedivere.hansenpartnership.com [IPv6:2607:fcd0:100:8a00::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 568911B1CA for ; Tue, 20 Dec 2022 06:03:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=hansenpartnership.com; s=20151216; t=1671545036; bh=mne194LLKEEWUzgLVwljBQ8IK/w8LLOTkcvQ+P5no3U=; h=Message-ID:Subject:From:To:Date:In-Reply-To:References:From; b=ftsG62FjUwq1a53OpkmdQnVP0e/lXq5WKOy1M6rumQgUYYKFwZoRDxU84xQ7c54Bu 4x8IM29IQsbKfsRRFd+Gd7/AvQdBNR8WjRvkctgEmCQbO/MMqLkT7Je+BkOthKL87/ gC+L+5Cs4E1guXfDiS6TsW6I6QX12OkHdSlT/ZQM= Received: from localhost (localhost [127.0.0.1]) by bedivere.hansenpartnership.com (Postfix) with ESMTP id 130E31281ECC; Tue, 20 Dec 2022 09:03:56 -0500 (EST) Received: from bedivere.hansenpartnership.com ([127.0.0.1]) by localhost (bedivere.hansenpartnership.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 6eWUj8jeFt2R; Tue, 20 Dec 2022 09:03:55 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=hansenpartnership.com; s=20151216; t=1671545035; bh=mne194LLKEEWUzgLVwljBQ8IK/w8LLOTkcvQ+P5no3U=; h=Message-ID:Subject:From:To:Date:In-Reply-To:References:From; b=O+0sQ8LXpJ/dBtK0zqH3qyvLxwVmNqcRjRRMRMRav7RsKvILo+hdoyIf61GiqoUFj 31ticuqpWGzIk4jQWuwI3eZWJr3forHm1qjdFUTUQcj+1X5zPFbn0PFN0aCgzbOkDx TTGNrrnJUyWB5i720TITnx6VPKAV91TBUWBqRUs8= Received: from lingrow.int.hansenpartnership.com (unknown [IPv6:2601:5c4:4302:c21::c14]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature RSA-PSS (2048 bits) server-digest SHA256) (Client did not present a certificate) by bedivere.hansenpartnership.com (Postfix) with ESMTPSA id 71B421281E49; Tue, 20 Dec 2022 09:03:55 -0500 (EST) Message-ID: Subject: Re: Question on loading trusted key with keyctl command From: James Bottomley To: Mimi Zohar , Sughosh Ganu Cc: linux-integrity@vger.kernel.org Date: Tue, 20 Dec 2022 09:03:53 -0500 In-Reply-To: <5e1c8d3bd5742979e328a267522347ad39b483a3.camel@linux.ibm.com> References: <5e1c8d3bd5742979e328a267522347ad39b483a3.camel@linux.ibm.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.4 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-integrity@vger.kernel.org On Tue, 2022-12-20 at 08:54 -0500, Mimi Zohar wrote: > On Tue, 2022-12-20 at 07:50 -0500, James Bottomley wrote: > > On Tue, 2022-12-20 at 12:03 +0530, Sughosh Ganu wrote: [...] > > > I was able to load the key after clearing the keyring. Thanks > > > James and Mimi for your pointers. > > > > Actually, I think this is a bug in trusted keys.  Add on existing > > key is supposed to go through the update path.  If the path doesn't > > exist it returns -EEXIST.  Trusted keys have an update path but > > they return - EINVAL if the trusted key command is anything but > > update (which is used to reseal a key).  Obviously this is > > incorrect and the code should be returning -EEXIST for a key we > > refuse to update to match every other key type. > > Re-loading an existing key was previously permitted.  Obviously this > changed at some point.   Any "fixes" should point out when it > changed. Git history doesn't think so. It thinks when you added trusted keys with d00a1c72f7f4661212299e6cb132dfa58030bcdb the update path already had the -EINVAL return, so reload has always failed this way unless we were doing a reseal update. We could certainly permit overwriting an existing key with load, but that would be a more extensive change. James