Skip to content

Commit ea33466

Browse files
committed
tpm: fix unsigned/signed mismatch errors related to __calc_tpm2_event_size
JIRA: https://issues.redhat.com/browse/RHEL-72764 Upstream Status: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git commit a066397 Author: Gregory Price <gourry@gourry.net> Date: Fri Sep 13 19:19:53 2024 -0400 tpm: fix unsigned/signed mismatch errors related to __calc_tpm2_event_size __calc_tpm2_event_size returns 0 or a positive length, but return values are often interpreted as ints. Convert everything over to u32 to avoid signed/unsigned logic errors. Signed-off-by: Gregory Price <gourry@gourry.net> Signed-off-by: Ard Biesheuvel <ardb@kernel.org> Signed-off-by: Štěpán Horáček <shoracek@redhat.com>
1 parent 9e8b395 commit ea33466

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

drivers/firmware/efi/libstub/tpm.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ static void efi_retrieve_tcg2_eventlog(int version, efi_physical_addr_t log_loca
5757
struct linux_efi_tpm_eventlog *log_tbl = NULL;
5858
unsigned long first_entry_addr, last_entry_addr;
5959
size_t log_size, last_entry_size;
60-
int final_events_size = 0;
60+
u32 final_events_size = 0;
6161

6262
first_entry_addr = (unsigned long) log_location;
6363

@@ -110,9 +110,9 @@ static void efi_retrieve_tcg2_eventlog(int version, efi_physical_addr_t log_loca
110110
*/
111111
if (final_events_table && final_events_table->nr_events) {
112112
struct tcg_pcr_event2_head *header;
113-
int offset;
113+
u32 offset;
114114
void *data;
115-
int event_size;
115+
u32 event_size;
116116
int i = final_events_table->nr_events;
117117

118118
data = (void *)final_events_table;

drivers/firmware/efi/tpm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ EXPORT_SYMBOL(efi_tpm_final_log_size);
1919
static int __init tpm2_calc_event_log_size(void *data, int count, void *size_info)
2020
{
2121
struct tcg_pcr_event2_head *header;
22-
int event_size, size = 0;
22+
u32 event_size, size = 0;
2323

2424
while (count > 0) {
2525
header = data + size;

include/linux/tpm_eventlog.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ struct tcg_algorithm_info {
157157
* Return: size of the event on success, 0 on failure
158158
*/
159159

160-
static __always_inline int __calc_tpm2_event_size(struct tcg_pcr_event2_head *event,
160+
static __always_inline u32 __calc_tpm2_event_size(struct tcg_pcr_event2_head *event,
161161
struct tcg_pcr_event *event_header,
162162
bool do_mapping)
163163
{

0 commit comments

Comments
 (0)