From nobody Sat Feb 7 11:31:30 2026 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 CB0FF2F12A5; Sun, 25 Jan 2026 19:25:48 +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=1769369148; cv=none; b=Qy6i4dtbDHljYchZZNbuetIGIGA11Gh+1/E39DvQ//ADxuQnS3DNxwspsMSLhNrauMWd54JMpFexltTyNpplgvFts6Scbfjz13PG6r5u8qB+KtZwxSnc/dlj/MRnMZnoCG176hp/nAsRJ3VpFURezey5E2OR+ILvCpPCHHgN9Oc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769369148; c=relaxed/simple; bh=8pp+fW6JLbhqi+9zPhmUF2VbrqvhQc+UaIFr3qgiAlo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uvtu7bkoVedKirWQEVWEXX0ckzNUa2r5aH0Bx/mKT4T/wEDqGfs12Gyd62/mkaakKwHzQRNj3H0FXSLSx1E9PUCHHkIKDLjBnavkhwwYf+WRhHTdXP/XHrOlE7WMItH3YGDRUapAwOfDtBGkC8FfqcyLQnMXrRjzr4Z7mZtgn/s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QpLG/fV0; 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="QpLG/fV0" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E00E8C4CEF1; Sun, 25 Jan 2026 19:25:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1769369148; bh=8pp+fW6JLbhqi+9zPhmUF2VbrqvhQc+UaIFr3qgiAlo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QpLG/fV07zyT+sqqUhkTdKAGXL4uFH/XW4PSZRgMRPr7aeUaE27UmQLCk8ZyFZuGB TOK3Iu3zc35mGPYpN9pYsA+cSNJkTvkxVHKJUWvdPG6FOkRHyQL2s86ny+ZEYBhURD KxZp9gnV+zyjXg09zftS5MvRzCEoEqKfLEExEd1UAT8ElaSmTVeSJzO9ojcrk3/EM1 6Q8Hh8lUJKocbkTfVAYajh4WWGzzrt5/6ZotNfVn/YrKZlA/knA+SedpeCH3Qy2fOi +ox2CRGcs3jxyuyV+a+pjmRecwg3LPywAqpL8JtXpY5W2PSkvtkWNKEhMHkKsKCVPC FYPKwqcunjPGA== From: Jarkko Sakkinen To: linux-integrity@vger.kernel.org Cc: Jarkko Sakkinen , Jonathan McDowell , James Bottomley , Mimi Zohar , David Howells , Paul Moore , James Morris , "Serge E. Hallyn" , keyrings@vger.kernel.org (open list:KEYS-TRUSTED), linux-security-module@vger.kernel.org (open list:SECURITY SUBSYSTEM), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v9 02/11] KEYS: trusted: Use get_random_bytes_wait() instead of tpm_get_random() Date: Sun, 25 Jan 2026 21:25:12 +0200 Message-ID: <20260125192526.782202-3-jarkko@kernel.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260125192526.782202-1-jarkko@kernel.org> References: <20260125192526.782202-1-jarkko@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@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" Substitute the remaining tpm_get_random() calls in trusted_tpm1.c with get_random_bytes_wait() thus aligning random number generation for TPM 1.2 with the removal of '.get_random' callback. Reviewed-by: Jonathan McDowell Signed-off-by: Jarkko Sakkinen --- security/keys/trusted-keys/trusted_tpm1.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/security/keys/trusted-keys/trusted_tpm1.c b/security/keys/trus= ted-keys/trusted_tpm1.c index 7ce7e31bcdfb..3d75bb6f9689 100644 --- a/security/keys/trusted-keys/trusted_tpm1.c +++ b/security/keys/trusted-keys/trusted_tpm1.c @@ -371,13 +371,10 @@ static int osap(struct tpm_buf *tb, struct osapsess *= s, unsigned char ononce[TPM_NONCE_SIZE]; int ret; =20 - ret =3D tpm_get_random(chip, ononce, TPM_NONCE_SIZE); + ret =3D get_random_bytes_wait(ononce, TPM_NONCE_SIZE); if (ret < 0) return ret; =20 - if (ret !=3D TPM_NONCE_SIZE) - return -EIO; - tpm_buf_reset(tb, TPM_TAG_RQU_COMMAND, TPM_ORD_OSAP); tpm_buf_append_u16(tb, type); tpm_buf_append_u32(tb, handle); @@ -464,15 +461,10 @@ static int tpm_seal(struct tpm_buf *tb, uint16_t keyt= ype, memcpy(td->xorwork + SHA1_DIGEST_SIZE, sess.enonce, SHA1_DIGEST_SIZE); sha1(td->xorwork, SHA1_DIGEST_SIZE * 2, td->xorhash); =20 - ret =3D tpm_get_random(chip, td->nonceodd, TPM_NONCE_SIZE); + ret =3D get_random_bytes_wait(td->nonceodd, TPM_NONCE_SIZE); if (ret < 0) goto out; =20 - if (ret !=3D TPM_NONCE_SIZE) { - ret =3D -EIO; - goto out; - } - ordinal =3D htonl(TPM_ORD_SEAL); datsize =3D htonl(datalen); pcrsize =3D htonl(pcrinfosize); @@ -575,14 +567,10 @@ static int tpm_unseal(struct tpm_buf *tb, } =20 ordinal =3D htonl(TPM_ORD_UNSEAL); - ret =3D tpm_get_random(chip, nonceodd, TPM_NONCE_SIZE); + ret =3D get_random_bytes_wait(nonceodd, TPM_NONCE_SIZE); if (ret < 0) return ret; =20 - if (ret !=3D TPM_NONCE_SIZE) { - pr_info("tpm_get_random failed (%d)\n", ret); - return -EIO; - } ret =3D TSS_authhmac(authdata1, keyauth, TPM_NONCE_SIZE, enonce1, nonceodd, cont, sizeof(uint32_t), &ordinal, bloblen, blob, 0, 0); --=20 2.52.0