From nobody Sun May 24 19:32:55 2026 Received: from out-178.mta1.migadu.com (out-178.mta1.migadu.com [95.215.58.178]) (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 895673B95F6 for ; Fri, 22 May 2026 09:45:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779443139; cv=none; b=E3DWJL1OqGjMpWqXQgLgHP4rii6EcOFCEep7TwGgvu2KTOhTysCe0q2S5N0uy9Ke6bOflWCp0nag3kkHjysV/2b4eh6XlAGtCtVvAvWlFhPEhL09WQM7rR7JvzDChaMRlcKQ4vu9NqjJw/l4qwHvb67M6Mc3ntaHjlaFTRbv1eE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779443139; c=relaxed/simple; bh=DfWpdJcRaZ53yrjDsoyNnfVJq6RrxKAt61FGJUKZ72E=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=GzeySI2cOE+WZEbQHp2NQqlVsKOlLwV7ToyvQQ8YvIPbKeEaxZINVQl5n1lRN9uujTTcOhdQmLMu9DIqsB/lEYIqhenmkGacWjJtnW1J4oLY508y9t36gsJgYEKJB2J8mylarhvkuhBX9z5SLK8RSGHH//dPwneQelelGCMTmk0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=B7+4qIOH; arc=none smtp.client-ip=95.215.58.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="B7+4qIOH" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1779443124; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=g5agdTFGEfWZbLCwQ4kJJjc5gZ15gxHIdT5eE3Z8E90=; b=B7+4qIOHzP+1/A75WlMe+Zkio3GKTzFX6fm6Ygv7/RAqNAh/HS1aOJFUL7gU5wFaGQzKFn Te8XsC2TH70tqTIQty8Vof9T/HD5o6bo1pCM+dK9jrrSi69Tj0Cfvrg2sRGdYOj8OMjL71 E71mYDXqFAFpyvY1qRweJatSH80WP1w= From: Thorsten Blum To: Peter Huewe , Jarkko Sakkinen , Jason Gunthorpe , Colin Ian King , Harald Hoyer Cc: Thorsten Blum , stable@vger.kernel.org, linux-integrity@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] tpm: fix event_size output in tpm1_binary_bios_measurements_show Date: Fri, 22 May 2026 11:44:38 +0200 Message-ID: <20260522094440.583766-2-thorsten.blum@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1855; i=thorsten.blum@linux.dev; h=from:subject; bh=DfWpdJcRaZ53yrjDsoyNnfVJq6RrxKAt61FGJUKZ72E=; b=owGbwMvMwCUWt7pQ4caZUj3G02pJDFkCqh06e55KKjhuaJCRWXhN1bmd60VV4+lL15a/0LeVy GIK+362o5SFQYyLQVZMkeXBrB8zfEtrKjeZROyEmcPKBDKEgYtTACYy9x0jw/Hc74d1dR9nabhs e+GYmuGpIJ3z6Yb4+79H523Lnxz+R52RYWX1lUdTL+wxDnnBcunio83nr4TsmCZamxBQ/OegYKm cCgMA X-Developer-Key: i=thorsten.blum@linux.dev; a=openpgp; fpr=1D60735E8AEF3BE473B69D84733678FD8DFEEAD4 Content-Transfer-Encoding: quoted-printable X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset="utf-8" Commit 186d124f07da ("tpm_eventlog.c: fix binary_bios_measurements") split the output to write the endian-converted event header first and then the variable-length event data. However, the split was at sizeof(struct tcpa_event) - 1, even though event_data was a zero-length array, and later a flexible array member, both of which already excluded the event data. Therefore, the current code writes the first three bytes of event_size from the endian-converted header and then the last byte from the raw header, which can emit a corrupted event_size on PPC64, where do_endian_conversion() maps to be32_to_cpu(). Split one byte later to write the full endian-converted header first, followed by the variable-length event->event_data. Fixes: 186d124f07da ("tpm_eventlog.c: fix binary_bios_measurements") Cc: stable@vger.kernel.org Signed-off-by: Thorsten Blum --- Changes in v2: - Minimal fix without using seq_write() - v1: https://lore.kernel.org/lkml/20260521093639.162095-3-thorsten.blum@li= nux.dev/ --- drivers/char/tpm/eventlog/tpm1.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/char/tpm/eventlog/tpm1.c b/drivers/char/tpm/eventlog/t= pm1.c index e7913b2853d5..0397e3361020 100644 --- a/drivers/char/tpm/eventlog/tpm1.c +++ b/drivers/char/tpm/eventlog/tpm1.c @@ -236,12 +236,12 @@ static int tpm1_binary_bios_measurements_show(struct = seq_file *m, void *v) =20 temp_ptr =3D (char *) &temp_event; =20 - for (i =3D 0; i < (sizeof(struct tcpa_event) - 1) ; i++) + for (i =3D 0; i < sizeof(struct tcpa_event); i++) seq_putc(m, temp_ptr[i]); =20 temp_ptr =3D (char *) v; =20 - for (i =3D (sizeof(struct tcpa_event) - 1); + for (i =3D sizeof(struct tcpa_event); i < (sizeof(struct tcpa_event) + temp_event.event_size); i++) seq_putc(m, temp_ptr[i]);