From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8341A28DC7; Tue, 4 Jun 2024 22:33:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717540418; cv=none; b=DfyDTsi0Ae7lRUVb8UPmYBZlqJ4N+2jWRYGTEcYory4V/6DW93mZVPOrVeUBdY9AodqHMkEz1PohM7hLzP17tF/NDM+5OueDnOp1YyH8SX18MJMMk5iWPkIkOo6mx6iYniunVpp3yZMFYSba2nOncHb34R4IWa4+uM3MQ1DWScM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717540418; c=relaxed/simple; bh=vKk54H5hajLqoyQvgP+yXe9n5V6epR2sgSb7GL/pKD0=; h=Mime-Version:Content-Type:Date:Message-Id:Cc:Subject:From:To: References:In-Reply-To; b=JhbobHZ4nsJ+vulHff510SYYrkLuQuRNhPdmxR5BeWa9z+ZrYL6081UVOQVOPl4/QWHG76+fTwj4DbsnswDRk8rAzn+OwO8f6k+Yf1LqBS76EdX5a4pT5jmGyRKJ0BjHJHO0fbcBKyxoGs/6BR43uSI70iBqPm1TPO4jSBDqA0Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=G/nfl/5c; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="G/nfl/5c" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4AD4AC3277B; Tue, 4 Jun 2024 22:33:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717540417; bh=vKk54H5hajLqoyQvgP+yXe9n5V6epR2sgSb7GL/pKD0=; h=Date:Cc:Subject:From:To:References:In-Reply-To:From; b=G/nfl/5cR0PwMZa8J22uWo0KSFIzBt74P8cN/OEhgB/00aKhX9xMV9qd8jZhHm//G teAehz1lQgqYECpI7jnVW/ck4etFZDkML6JfvX0Py2zN5rt8amp2VC1/cG5MGHCGlq 2hojjdMPUs+seAOX6ZZvyAKv+vOXSbj+WIOqZ10Uhf4PWrzmnTGr+7KvmoPvcDdxqV 7AxsIxMbgqtXMSNHPZ5mlHYXIYYPAtvp8uPjBjmTgZl6P7gMDUPHztTT4BJmgasNko KEBdo7wgfp6PWKv/P3yqQ6I3UyhVdjviylkfGi4XEzuMxN+BqIisBrKAVC7rOpnDwD /6PeY1X9SDS5A== Precedence: bulk X-Mailing-List: linux-security-module@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Wed, 05 Jun 2024 01:33:32 +0300 Message-Id: Cc: , , , "James Prestwood" , "David Woodhouse" , "Eric Biggers" , "James Bottomley" , , "Lennart Poettering" , "David S. Miller" , "open list" , "Mimi Zohar" , "David Howells" , "Paul Moore" , "James Morris" , "Serge E. Hallyn" , "open list:SECURITY SUBSYSTEM" Subject: Re: [PATCH v7 3/5] crypto: tpm2_key: Introduce a TPM2 key type From: "Jarkko Sakkinen" To: "Stefan Berger" , "Herbert Xu" X-Mailer: aerc 0.17.0 References: <20240528210823.28798-1-jarkko@kernel.org> <20240528210823.28798-4-jarkko@kernel.org> <97dd7485-51bf-4e47-83ab-957710fc2182@linux.ibm.com> <6f0e04c2-4602-4407-9af5-f72610021a6a@linux.ibm.com> In-Reply-To: <6f0e04c2-4602-4407-9af5-f72610021a6a@linux.ibm.com> On Tue Jun 4, 2024 at 9:41 PM EEST, Stefan Berger wrote: > > > On 6/4/24 13:23, Jarkko Sakkinen wrote: > > On Fri May 31, 2024 at 3:35 AM EEST, Stefan Berger wrote: > >> > > >>> =20 > >>> - rc =3D tpm2_key_decode(payload, options, &blob); > >>> - if (rc) { > >>> - /* old form */ > >>> + key =3D tpm2_key_decode(payload->blob, payload->blob_len); > >>> + if (IS_ERR(key)) { > >>> + /* Get the error code and reset the pointer to the key: */ > >>> + rc =3D PTR_ERR(key); > >>> + key =3D NULL; > >>> + > >>> + if (rc =3D=3D -ENOMEM) > >>> + return -ENOMEM; > >>> + > >>> + /* A sanity check, as only -EBADMSG or -ENOMEM are expected: */ > >>> + if (rc !=3D -EBADMSG) > >>> + pr_err("tpm2_key_decode(): spurious error code %d\n", rc); > >> > >> tpm2_key_decode seems simple enough that it only returns key, -ENOMEM = or > >> EBADMSG. > >=20 > > So what is your suggestion here? > > You can remove the check resuling in pr_err(). OK, I think so too. Just had to (sanity) check. > > >=20 > > The reasoning here is that asymmetric keys use -EBADMSG not only as > > error but also iterator, when probing which can load a specific key. > >=20 BR, Jarkko