Skip to contentSkip to conversation

tpm: Fix the type of the return value in calc_tpm2_event_size()

PATCH Applied Jarkko Sakkinen 2 participants 5 messages Apr 17, 2019 – Apr 23, 2019

Subsystems (2)

v1 of 2 Applied Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tpm: Fix the type of the return value in calc_tpm2_event_size()

From: Yue Haibing <[email protected]>

commit 32312418625764cdf740890ac9c78ca26a6a9d24 upstream

calc_tpm2_event_size() has an invalid signature because it returns a 'size_t' where as its signature says that it returns 'int'.

Fixes 4d23cc323cdb ("tpm: add securityfs support for TPM 2.0 firmware event log")

---
backport v5.0.8

 drivers/char/tpm/eventlog/tpm2.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/char/tpm/eventlog/tpm2.c +2 -2
index 1b8fa9de2cac..130c3f227559 100644
@@ -37,8 +37,8 @@
  *
  * Returns size of the event. If it is an invalid event, returns 0.
  */
-static int calc_tpm2_event_size(struct tcg_pcr_event2 *event,
-				struct tcg_pcr_event *event_header)
+static size_t calc_tpm2_event_size(struct tcg_pcr_event2_head *event,
+				   struct tcg_pcr_event *event_header)
 {
 	struct tcg_efi_specid_event *efispecid;
 	struct tcg_event_field *event_field;
Signature · 1 line
2.19.1
maintainer Applied
#1 lore raw
Quoted 3 lines · Jarkko Sakkinen

From: Yue Haibing <[email protected]>

commit 32312418625764cdf740890ac9c78ca26a6a9d24 upstream

This is really commit b9d0a85d6b2e76630cfd4c475ee3af4109bfd87a upstream (looks like James added his S-O-B which changed the commit hash).

Quoted 10 lines

calc_tpm2_event_size() has an invalid signature because it returns a 'size_t' where as its signature says that it returns 'int'.

Fixes 4d23cc323cdb ("tpm: add securityfs support for TPM 2.0 firmware event log")

I've queued it for 5.0, thanks!

--
Thanks,
Sasha

#2 lore raw
Quoted 7 lines · Sasha Levin
Quoted 3 lines · Jarkko Sakkinen

From: Yue Haibing <[email protected]>

commit 32312418625764cdf740890ac9c78ca26a6a9d24 upstream

This is really commit b9d0a85d6b2e76630cfd4c475ee3af4109bfd87a upstream (looks like James added his S-O-B which changed the commit hash).

Oops, thanks, will be more careful next time.

Quoted 5 lines
Quoted 5 lines

calc_tpm2_event_size() has an invalid signature because it returns a 'size_t' where as its signature says that it returns 'int'.

Quoted 8 lines
Quoted 6 lines
Fixes 4d23cc323cdb ("tpm: add securityfs support for TPM 2.0 firmware event log")

I've queued it for 5.0, thanks!

Thank you.

/Jarkko

maintainer
#3 lore raw
In reply to Jarkko Sakkinen
Quoted 24 lines · Jarkko Sakkinen

From: Yue Haibing <[email protected]>

commit 32312418625764cdf740890ac9c78ca26a6a9d24 upstream

calc_tpm2_event_size() has an invalid signature because it returns a 'size_t' where as its signature says that it returns 'int'.

Fixes 4d23cc323cdb ("tpm: add securityfs support for TPM 2.0 firmware event log")

---
backport v5.0.8
drivers/char/tpm/eventlog/tpm2.c | 4 ++--

1 file changed, 2 insertions(+), 2 deletions(-)
drivers/char/tpm/eventlog/tpm2.c +0 -0
index 1b8fa9de2cac..130c3f227559 100644

drivers/char/tpm/eventlog/tpm2.c line 44

Quoted 10 lines
drivers/char/tpm/eventlog/tpm2.c +2 -2
@@ -37,8 +37,8 @@
 *
 * Returns size of the event. If it is an invalid event, returns 0.
 */
-static int calc_tpm2_event_size(struct tcg_pcr_event2 *event,
-				struct tcg_pcr_event *event_header)
+static size_t calc_tpm2_event_size(struct tcg_pcr_event2_head *event,
+				   struct tcg_pcr_event *event_header)
 {
 	struct tcg_efi_specid_event *efispecid;
 	struct tcg_event_field *event_field;

But it seems like it breaks the build:

drivers/char/tpm/eventlog/tpm2.c:40:43: warning: ‘struct tcg_pcr_event2_head’ declared inside parameter list will not be visible outside of this definition or declaration static size_t calc_tpm2_event_size(struct tcg_pcr_event2_head *event,

                                          ^~~~~~~~~~~~~~~~~~~

drivers/char/tpm/eventlog/tpm2.c: In function ‘calc_tpm2_event_size’:
drivers/char/tpm/eventlog/tpm2.c:55:32: error: dereferencing pointer to incomplete type ‘struct tcg_pcr_event2_head’
marker = marker + sizeof(event->pcr_idx) + sizeof(event->event_type)

Probably because c8faabfc6f480 is missing. I've reverted this patch from stable for now.

--
Thanks,
Sasha

#4 lore raw
Quoted 40 lines · Sasha Levin
Quoted 24 lines · Jarkko Sakkinen

From: Yue Haibing <[email protected]>

commit 32312418625764cdf740890ac9c78ca26a6a9d24 upstream

calc_tpm2_event_size() has an invalid signature because it returns a 'size_t' where as its signature says that it returns 'int'.

Fixes 4d23cc323cdb ("tpm: add securityfs support for TPM 2.0 firmware event log")

---
backport v5.0.8
drivers/char/tpm/eventlog/tpm2.c | 4 ++--

1 file changed, 2 insertions(+), 2 deletions(-)
drivers/char/tpm/eventlog/tpm2.c +0 -0
index 1b8fa9de2cac..130c3f227559 100644

drivers/char/tpm/eventlog/tpm2.c line 44

Quoted 10 lines
drivers/char/tpm/eventlog/tpm2.c +2 -2
@@ -37,8 +37,8 @@
 *
 * Returns size of the event. If it is an invalid event, returns 0.
 */
-static int calc_tpm2_event_size(struct tcg_pcr_event2 *event,
-				struct tcg_pcr_event *event_header)
+static size_t calc_tpm2_event_size(struct tcg_pcr_event2_head *event,
+				   struct tcg_pcr_event *event_header)
 {
 	struct tcg_efi_specid_event *efispecid;
 	struct tcg_event_field *event_field;

But it seems like it breaks the build:

drivers/char/tpm/eventlog/tpm2.c:40:43: warning: ‘struct tcg_pcr_event2_head’ declared inside parameter list will not be visible outside of this definition or declaration static size_t calc_tpm2_event_size(struct tcg_pcr_event2_head *event,

Quoted 7 lines
                                          ^~~~~~~~~~~~~~~~~~~

drivers/char/tpm/eventlog/tpm2.c: In function ‘calc_tpm2_event_size’:
drivers/char/tpm/eventlog/tpm2.c:55:32: error: dereferencing pointer to incomplete type ‘struct tcg_pcr_event2_head’
marker = marker + sizeof(event->pcr_idx) + sizeof(event->event_type)

Probably because c8faabfc6f480 is missing. I've reverted this patch from stable for now.

Ugh. I'm for this weekend on leave. Looking this next week. Sorry about wasted time :-(

/Jarkko