From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 B872643E088; Tue, 21 Jul 2026 22:21:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784672479; cv=none; b=mJkgDwWsb+4d7LSWxWILGX1bWU8FubsWbF7XeEh7VOxIBjRbWPI3D4neiO2I8dx6cZa2SqfFmcv5uToOQPTHnRM5rKG/O5rwcHX9e3eSi55FNZU2qg5G8mNBbUWJzmBCFut1ClT/bb+pjCgrbYZCB7q9zlVtAHpIpDANlQxBV2M= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784672479; c=relaxed/simple; bh=3ExFQdLqF6hnYzjQEkthDz6uZWsPPZA9oQbpbv6au+4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dYW6/W3wdQeVfEsCsnIB8X8sZ8OWzJbrBOwh1znThydOvH83MmRud3bSxXq2IgdLjv0NUpkD2vvtSvfucw90hr2X0dNnH0h7A1z4GrrMwKqogKWCtuIyAHKACEl68fDgdssLmX5MtQQgYk+QvHbQKxfl8dpPv0lm7cD4sl/jFec= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=kYNr1OEs; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="kYNr1OEs" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2AB421F000E9; Tue, 21 Jul 2026 22:21:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784672478; bh=L2TppiGGrRnDaFnqXjBUsxz7yVoi7CgMkvHH+ydH+H0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=kYNr1OEsG7cioTBBhPAkhqDNYpqdJc/5rNQGw39mEd61KcaLVfIGJSph6ViBuoqB1 Sc+4yxSfU4AxMdoC0PL2rRx8gw6qvhG8VuFYgyz6aSpSc9U/VyY4J30J9UA4nlsHOW 32Tu7CyKZBsGQK6fGpmlaYfzC/iCtsjY68sQwKi0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Thorsten Blum , Jarkko Sakkinen Subject: [PATCH 5.15 641/843] tpm: fix event_size output in tpm1_binary_bios_measurements_show Date: Tue, 21 Jul 2026 17:24:36 +0200 Message-ID: <20260721152420.486288240@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152405.946368001@linuxfoundation.org> References: <20260721152405.946368001@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Thorsten Blum commit 1a58f6115bfb34eabcc7de8a3a9745b219179781 upstream. 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 # v5.10+ Signed-off-by: Thorsten Blum Signed-off-by: Jarkko Sakkinen Signed-off-by: Greg Kroah-Hartman --- drivers/char/tpm/eventlog/tpm1.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/char/tpm/eventlog/tpm1.c +++ b/drivers/char/tpm/eventlog/tpm1.c @@ -236,12 +236,12 @@ static int tpm1_binary_bios_measurements temp_ptr = (char *) &temp_event; - for (i = 0; i < (sizeof(struct tcpa_event) - 1) ; i++) + for (i = 0; i < sizeof(struct tcpa_event); i++) seq_putc(m, temp_ptr[i]); temp_ptr = (char *) v; - for (i = (sizeof(struct tcpa_event) - 1); + for (i = sizeof(struct tcpa_event); i < (sizeof(struct tcpa_event) + temp_event.event_size); i++) seq_putc(m, temp_ptr[i]);