tpm: Check for parent device being NULL
PATCH 1/2 tpm: Check for parent device being NULL
Check for the parent device being NULL before accessing it. This prevents crashed with the vtpm_proxy driver, since this driver does not have a parent device.
--- drivers/char/tpm/tpm_of.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/tpm/tpm_of.c +1 -1
@@ -29,7 +29,7 @@ int tpm_read_log_of(struct tpm_chip *chip)struct tpm_bios_log *log; log = &chip->log; -if (chip->dev.parent->of_node) +if (chip->dev.parent && chip->dev.parent->of_node) np = chip->dev.parent->of_node;else return -ENODEV ;
Signature · 4 lines
2.4.3 ------------------------------------------------------------------------------
A message that is not in the archive (sent off-list or not yet received): 1479429004-7962-1-git-send-email-stefanb-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org
PATCH 2/2 tpm: Fix error code handling after tpm_bios_log_setup
tpm_bios_log_setup() may return -ENODEV in case no log was found. In this case we do not need to fail the device.
--- drivers/char/tpm/tpm-chip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/char/tpm/tpm-chip.c +1 -1
@@ -346,7 +346,7 @@ int tpm_chip_register(struct tpm_chip *chip)tpm_sysfs_add_device (chip); rc =tpm_bios_log_setup (chip); -if (rc == -ENODEV ) +if (rc != -ENODEV )return rc;tpm_add_ppi (chip);
Signature · 4 lines
2.4.3 ------------------------------------------------------------------------------
A message that is not in the archive (sent off-list or not yet received): 1479429004-7962-2-git-send-email-stefanb-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org
Re: [PATCH 2/2] tpm: Fix error code handling after tpm_bios_log_setup
Quoted 13 lines · Stefan Berger
tpm_bios_log_setup()may return-ENODEVin case no log was found. In this case we do not need to fail the device.Signed-off-by Stefan Berger <[email protected]>--- drivers/char/tpm/tpm-chip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/char/tpm/tpm-chip.c +0
-0
drivers/char/tpm/tpm-chip.c int tpm_chip_register(struct tpm_chip *chip) · line 350
Quoted 6 lines
drivers/char/tpm/tpm-chip.c +1
-1@@ -346,7 +346,7 @@ int tpm_chip_register(struct tpm_chip *chip)tpm_sysfs_add_device (chip); rc =tpm_bios_log_setup (chip); -if (rc == -ENODEV ) +if (rc != -ENODEV )return rc;
This will return even for (rc == 0).
Thanks & Regards,
- Nayna
drivers/char/tpm/tpm-chip.c int tpm_chip_register(struct tpm_chip *chip) · line 352
Quoted 3 lines
drivers/char/tpm/tpm-chip.c +0
-0tpm_add_ppi (chip);
------------------------------------------------------------------------------
Re: [PATCH 2/2] tpm: Fix error code handling after tpm_bios_log_setup
In reply to Stefan BergerQuoted 23 lines · Stefan Berger
tpm_bios_log_setup()may return-ENODEVin case no log was found. In this case we do not need to fail the device.Signed-off-by Stefan Berger <[email protected]>--- drivers/char/tpm/tpm-chip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/char/tpm/tpm-chip.c +1
-1@@ -346,7 +346,7 @@ int tpm_chip_register(struct tpm_chip *chip)tpm_sysfs_add_device (chip); rc =tpm_bios_log_setup (chip); -if (rc == -ENODEV ) +if (rc != -ENODEV )return rc;tpm_add_ppi (chip);Signature · 1 line
2.4.3
CC to linux-security-module
LGTM
/Jarkko
Re: [PATCH 2/2] tpm: Fix error code handling after tpm_bios_log_setup
Quoted 19 lines · Jarkko Sakkinen
Quoted 18 lines · Stefan Berger
tpm_bios_log_setup()may return-ENODEVin case no log was found. In this case we do not need to fail the device.Signed-off-by Stefan Berger <[email protected]>drivers/char/tpm/tpm-chip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/char/tpm/tpm-chip.c +2
-1+++ b/drivers/char/tpm/tpm-chip.c@@ -346,7 +346,7 @@ int tpm_chip_register(struct tpm_chip *chip)tpm_sysfs_add_device (chip); rc =tpm_bios_log_setup (chip); -if (rc == -ENODEV ) +if (rc != -ENODEV )return rc;
Quoted 7 lines
drivers/char/tpm/tpm-chip.c int tpm_chip_register(struct tpm_chip *chip) · line 352
Quoted 1 line
drivers/char/tpm/tpm-chip.c +0
-0tpm_add_ppi (chip);CC to linux-security-module
LGTM
Reviewed-by Jarkko Sakkinen <[email protected]>
Erm, what about rc == 0? And all the other problems?
Here, use this (untested) should take care of everything on this topic..
The two things I haven't seen explained are the sysfs unregister crash and the acpi iounmap crash :/
Quoted 1 line
From
8768bcb8cd2a5a17cc4d811a9298b20c3a2c0884Mon Sep 17 00:00:00 2001
From: Jason Gunthorpe <[email protected]>
Date: Sat, 19 Nov 2016 11:18:28 -0700
Subject: [PATCH] tpm: Fix handling of missing event log
The event log is an optional firmware feature, if the firmware does not support it then the securityfs files should not be created and no other notification given.
- Uniformly return -ENODEV from the tpm_bios_log_setup cone if no event log is detected.
- Check in ACPI if this node was discovered via ACPI.
- Improve the check in OF to make sure there is a parent and to fail detection if the two log properties are not declared
- Pass through all other error codes instead of filtering just some
--- drivers/char/tpm/tpm-chip.c | 2 +- drivers/char/tpm/tpm_acpi.c | 8 +++++++- drivers/char/tpm/tpm_eventlog.c | 26 +++++++++++++------------- drivers/char/tpm/tpm_of.c | 11 +++++------ 4 files changed, 26 insertions(+), 21 deletions(-)
drivers/char/tpm/tpm-chip.c +1 -1
@@ -346,7 +346,7 @@ int tpm_chip_register(struct tpm_chip *chip)tpm_sysfs_add_device (chip); rc =tpm_bios_log_setup (chip); -if (rc == -ENODEV ) +if (rc !=0 && rc != -ENODEV )return rc;tpm_add_ppi (chip);
drivers/char/tpm/tpm_acpi.c +7 -1
@@ -56,12 +56,18 @@ int tpm_read_log_acpi(struct tpm_chip *chip) log = &chip->log; +/* Unfortuntely ACPI does not associate the event log with a specific +* TPM, like PPI. Thus all ACPI TPMs will read the same log. +*/ +if (!chip->acpi_dev_handle) +return -ENODEV ; +/* Find TCPA entry in RSDT (ACPI_LOGICAL_ADDRESSING) */ status =acpi_get_table (ACPI_SIG_TCPA ,1 , (struct acpi_table_header **)&buff);if (ACPI_FAILURE (status)) -return -EIO ; +return -ENODEV ;switch (buff->platform_class) {case BIOS_SERVER :
drivers/char/tpm/tpm_eventlog.c +13 -13
@@ -377,14 +377,21 @@ static int tpm_read_log(struct tpm_chip *chip) } rc =tpm_read_log_acpi (chip); -if ((rc ==0 ) || (rc == -ENOMEM )) +if (rc != -ENODEV )return rc; - rc =tpm_read_log_of (chip); - -return rc; +return tpm_read_log_of (chip); } +/* +* tpm_bios_log_setup() - Read the event log from the firmware +* @chip: TPM chip to use. +* +* If an event log is found then the securityfs files are setup to +* export it to userspace, otherwise nothing is done. +* +* Returns -ENODEV if the firmware has no event log. +*/ int tpm_bios_log_setup (struct tpm_chip *chip) {const char *name =dev_name (&chip->dev);
@@ -395,15 +402,8 @@ int tpm_bios_log_setup(struct tpm_chip *chip)return 0 ; rc =tpm_read_log (chip); -/* -* read_log failure means event log is not supported except for ENOMEM. -*/ -if (rc <0 ) { -if (rc == -ENOMEM ) -return -ENODEV ; -else -return rc; - } +if (rc) +return rc; cnt =0 ; chip->bios_dir[cnt] =securityfs_create_dir (name,NULL );
drivers/char/tpm/tpm_of.c +5 -6
@@ -29,13 +29,16 @@ int tpm_read_log_of(struct tpm_chip *chip)struct tpm_bios_log *log; log = &chip->log; -if (chip->dev.parent->of_node) +if (chip->dev.parent && chip->dev.parent->of_node) np = chip->dev.parent->of_node;else return -ENODEV ; sizep =of_get_property (np,"linux,sml-size" ,NULL ); -if (sizep ==NULL ) + basep =of_get_property (np,"linux,sml-base" ,NULL ); +if (sizep ==NULL && basep ==NULL ) +return -ENODEV ; +if (sizep ==NULL || basep ==NULL )return -EIO ;if (*sizep ==0 ) {
@@ -43,10 +46,6 @@ int tpm_read_log_of(struct tpm_chip *chip)return -EIO ; } - basep =of_get_property (np,"linux,sml-base" ,NULL ); -if (basep ==NULL ) -return -EIO ; - log->bios_event_log =kmalloc (*sizep,GFP_KERNEL );if (!log->bios_event_log)return -ENOMEM ;
Signature · 1 line
2.7.4
Re: [PATCH 2/2] tpm: Fix error code handling after tpm_bios_log_setup
Quoted 24 lines · Jason Gunthorpe
Quoted 23 lines · Jarkko Sakkinen
Quoted 11 lines · Stefan Berger
tpm_bios_log_setup()may return-ENODEVin case no log was found. In this case we do not need to fail the device.Signed-off-by Stefan Berger <[email protected]>drivers/char/tpm/tpm-chip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/char/tpm/tpm-chip.c +1
-0+++ b/drivers/char/tpm/tpm-chip.cdrivers/char/tpm/tpm-chip.c int tpm_chip_register(struct tpm_chip *chip) · line 352
Quoted 8 lines
drivers/char/tpm/tpm-chip.c +1
-1@@ -346,7 +346,7 @@ int tpm_chip_register(struct tpm_chip *chip)tpm_sysfs_add_device (chip); rc =tpm_bios_log_setup (chip); -if (rc == -ENODEV ) +if (rc != -ENODEV )return rc;tpm_add_ppi (chip);CC to linux-security-module
Quoted 5 lines
Quoted 3 lines
LGTM
Reviewed-by Jarkko Sakkinen <[email protected]>Erm, what about rc == 0? And all the other problems?
Sorry my bad. I was not thinking clearly.
This whole situation looks like a mess. I gave a lot of thought on this during my plane trips.
Quoted 5 lines
Here, use this (untested) should take care of everything on this topic..
The two things I haven't seen explained are the sysfs unregister crash and the acpi iounmap crash :/
Yup. The reason I'm not weighting that yet so much is that I do not know the environment.
Quoted 95 lines
From
8768bcb8cd2a5a17cc4d811a9298b20c3a2c0884Mon Sep 17 00:00:00 2001
From: Jason Gunthorpe <[email protected]>
Date: Sat, 19 Nov 2016 11:18:28 -0700
Subject: [PATCH] tpm: Fix handling of missing event logThe event log is an optional firmware feature, if the firmware does not support it then the securityfs files should not be created and no other notification given.
- Uniformly return
-ENODEVfrom thetpm_bios_log_setupcone if no event log is detected.
- Check in ACPI if this node was discovered via ACPI.
- Improve the check in OF to make sure there is a parent and to fail detection if the two log properties are not declared
- Pass through all other error codes instead of filtering just someSigned-off-by Jason Gunthorpe <[email protected]>--- drivers/char/tpm/tpm-chip.c | 2 +- drivers/char/tpm/tpm_acpi.c | 8 +++++++- drivers/char/tpm/tpm_eventlog.c | 26 +++++++++++++------------- drivers/char/tpm/tpm_of.c | 11 +++++------ 4 files changed, 26 insertions(+), 21 deletions(-)drivers/char/tpm/tpm-chip.c +1
-1@@ -346,7 +346,7 @@ int tpm_chip_register(struct tpm_chip *chip)tpm_sysfs_add_device (chip); rc =tpm_bios_log_setup (chip); -if (rc == -ENODEV ) +if (rc !=0 && rc != -ENODEV )return rc;tpm_add_ppi (chip);drivers/char/tpm/tpm_acpi.c +7
-1@@ -56,12 +56,18 @@ int tpm_read_log_acpi(struct tpm_chip *chip) log = &chip->log; +/* Unfortuntely ACPI does not associate the event log with a specific +* TPM, like PPI. Thus all ACPI TPMs will read the same log. +*/ +if (!chip->acpi_dev_handle) +return -ENODEV ; +/* Find TCPA entry in RSDT (ACPI_LOGICAL_ADDRESSING) */ status =acpi_get_table (ACPI_SIG_TCPA ,1 , (struct acpi_table_header **)&buff);if (ACPI_FAILURE (status)) -return -EIO ; +return -ENODEV ;switch (buff->platform_class) {case BIOS_SERVER :drivers/char/tpm/tpm_eventlog.c +11
-4@@ -377,14 +377,21 @@ static int tpm_read_log(struct tpm_chip *chip) } rc =tpm_read_log_acpi (chip); -if ((rc ==0 ) || (rc == -ENOMEM )) +if (rc != -ENODEV )return rc; - rc =tpm_read_log_of (chip); - -return rc; +return tpm_read_log_of (chip); } +/* +* tpm_bios_log_setup() - Read the event log from the firmware +* @chip: TPM chip to use. +* +* If an event log is found then the securityfs files are setup to +* export it to userspace, otherwise nothing is done. +* +* Returns -ENODEV if the firmware has no event log. +*/ int tpm_bios_log_setup (struct tpm_chip *chip) {const char *name =dev_name (&chip->dev);@@ -395,15 +402,8 @@ int tpm_bios_log_setup(struct tpm_chip *chip)return 0 ;
drivers/char/tpm/tpm_eventlog.c int tpm_bios_log_setup(struct tpm_chip *chip) · line 406
Quoted 10 lines
drivers/char/tpm/tpm_eventlog.c +0
-9rc =tpm_read_log (chip); -/* -* read_log failure means event log is not supported except for ENOMEM. -*/ -if (rc <0 ) { -if (rc == -ENOMEM ) -return -ENODEV ; -else -return rc; - }
WTF. I really have to be much more focused when I looked this. That is more than wrong... Too much multitasking last couple of weeks. That's my excuse...
I can consider putting the patch set to the next release but I really would want yet another version with change log what fixes were done and why.
/Jarkko
Re: [PATCH 2/2] tpm: Fix error code handling after tpm_bios_log_setup
Quoted 155 lines · Jarkko Sakkinen
Quoted 24 lines · Jason Gunthorpe
Quoted 23 lines · Jarkko Sakkinen
Quoted 11 lines · Stefan Berger
tpm_bios_log_setup()may return-ENODEVin case no log was found. In this case we do not need to fail the device.Signed-off-by Stefan Berger <[email protected]>drivers/char/tpm/tpm-chip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/char/tpm/tpm-chip.c +1
-0+++ b/drivers/char/tpm/tpm-chip.cdrivers/char/tpm/tpm-chip.c int tpm_chip_register(struct tpm_chip *chip) · line 352
Quoted 8 lines
drivers/char/tpm/tpm-chip.c +1
-1@@ -346,7 +346,7 @@ int tpm_chip_register(struct tpm_chip *chip)tpm_sysfs_add_device (chip); rc =tpm_bios_log_setup (chip); -if (rc == -ENODEV ) +if (rc != -ENODEV )return rc;tpm_add_ppi (chip);CC to linux-security-module
Quoted 5 lines
Quoted 3 lines
LGTM
Reviewed-by Jarkko Sakkinen <[email protected]>Erm, what about rc == 0? And all the other problems?
Sorry my bad. I was not thinking clearly.
This whole situation looks like a mess. I gave a lot of thought on this during my plane trips.
Quoted 5 lines
Here, use this (untested) should take care of everything on this topic..
The two things I haven't seen explained are the sysfs unregister crash and the acpi iounmap crash :/
Yup. The reason I'm not weighting that yet so much is that I do not know the environment.
Quoted 95 lines
From
8768bcb8cd2a5a17cc4d811a9298b20c3a2c0884Mon Sep 17 00:00:00 2001
From: Jason Gunthorpe <[email protected]>
Date: Sat, 19 Nov 2016 11:18:28 -0700
Subject: [PATCH] tpm: Fix handling of missing event logThe event log is an optional firmware feature, if the firmware does not support it then the securityfs files should not be created and no other notification given.
- Uniformly return
-ENODEVfrom thetpm_bios_log_setupcone if no event log is detected.
- Check in ACPI if this node was discovered via ACPI.
- Improve the check in OF to make sure there is a parent and to fail detection if the two log properties are not declared
- Pass through all other error codes instead of filtering just someSigned-off-by Jason Gunthorpe <[email protected]>--- drivers/char/tpm/tpm-chip.c | 2 +- drivers/char/tpm/tpm_acpi.c | 8 +++++++- drivers/char/tpm/tpm_eventlog.c | 26 +++++++++++++------------- drivers/char/tpm/tpm_of.c | 11 +++++------ 4 files changed, 26 insertions(+), 21 deletions(-)drivers/char/tpm/tpm-chip.c +1
-1@@ -346,7 +346,7 @@ int tpm_chip_register(struct tpm_chip *chip)tpm_sysfs_add_device (chip); rc =tpm_bios_log_setup (chip); -if (rc == -ENODEV ) +if (rc !=0 && rc != -ENODEV )return rc;tpm_add_ppi (chip);drivers/char/tpm/tpm_acpi.c +7
-1@@ -56,12 +56,18 @@ int tpm_read_log_acpi(struct tpm_chip *chip) log = &chip->log; +/* Unfortuntely ACPI does not associate the event log with a specific +* TPM, like PPI. Thus all ACPI TPMs will read the same log. +*/ +if (!chip->acpi_dev_handle) +return -ENODEV ; +/* Find TCPA entry in RSDT (ACPI_LOGICAL_ADDRESSING) */ status =acpi_get_table (ACPI_SIG_TCPA ,1 , (struct acpi_table_header **)&buff);if (ACPI_FAILURE (status)) -return -EIO ; +return -ENODEV ;switch (buff->platform_class) {case BIOS_SERVER :drivers/char/tpm/tpm_eventlog.c +11
-4@@ -377,14 +377,21 @@ static int tpm_read_log(struct tpm_chip *chip) } rc =tpm_read_log_acpi (chip); -if ((rc ==0 ) || (rc == -ENOMEM )) +if (rc != -ENODEV )return rc; - rc =tpm_read_log_of (chip); - -return rc; +return tpm_read_log_of (chip); } +/* +* tpm_bios_log_setup() - Read the event log from the firmware +* @chip: TPM chip to use. +* +* If an event log is found then the securityfs files are setup to +* export it to userspace, otherwise nothing is done. +* +* Returns -ENODEV if the firmware has no event log. +*/ int tpm_bios_log_setup (struct tpm_chip *chip) {const char *name =dev_name (&chip->dev);@@ -395,15 +402,8 @@ int tpm_bios_log_setup(struct tpm_chip *chip)return 0 ;drivers/char/tpm/tpm_eventlog.c int tpm_bios_log_setup(struct tpm_chip *chip) · line 406
Quoted 10 lines
drivers/char/tpm/tpm_eventlog.c +0
-9rc =tpm_read_log (chip); -/* -* read_log failure means event log is not supported except for ENOMEM. -*/ -if (rc <0 ) { -if (rc == -ENOMEM ) -return -ENODEV ; -else -return rc; - }WTF. I really have to be much more focused when I looked this. That is more than wrong... Too much multitasking last couple of weeks. That's my excuse...
Quoted 3 lines
I can consider putting the patch set to the next release but I really would want yet another version with change log what fixes were done and why.
I mean one more version of the patch set. Otherwise, I probably just postpone the whole patch set to 4.10.
/Jarkko
Re: [PATCH 2/2] tpm: Fix error code handling after tpm_bios_log_setup
In reply to Jason GunthorpeI was able to apply the patch after manually editing the mbox file. Not nice. It'd be better to send these things with git-send-email to simplify the mgmt (like getting them into patchwork for starters) especially in a situation that is bit chaotic to begin with :-/
It's there. I'm not yet sure what to do with these changes. I'll probably move my pull request towards late next week. Lets see if things stabilize. Too early to decide.
In any case I won't squash the fixes to existing series even if I include them to the pull request. I'll add new tested-by's only to the fixes.
/Jarkko
Quoted 182 lines · Jason Gunthorpe
Quoted 19 lines · Jarkko Sakkinen
Quoted 18 lines · Stefan Berger
tpm_bios_log_setup()may return-ENODEVin case no log was found. In this case we do not need to fail the device.Signed-off-by Stefan Berger <[email protected]>drivers/char/tpm/tpm-chip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/char/tpm/tpm-chip.c +2
-1+++ b/drivers/char/tpm/tpm-chip.c@@ -346,7 +346,7 @@ int tpm_chip_register(struct tpm_chip *chip)tpm_sysfs_add_device (chip); rc =tpm_bios_log_setup (chip); -if (rc == -ENODEV ) +if (rc != -ENODEV )return rc;Quoted 7 lines
drivers/char/tpm/tpm-chip.c int tpm_chip_register(struct tpm_chip *chip) · line 352
Quoted 1 line
drivers/char/tpm/tpm-chip.c +0
-0tpm_add_ppi (chip);CC to linux-security-module
LGTM
Reviewed-by Jarkko Sakkinen <[email protected]>Erm, what about rc == 0? And all the other problems?
Here, use this (untested) should take care of everything on this topic..
The two things I haven't seen explained are the sysfs unregister crash and the acpi iounmap crash :/
From
8768bcb8cd2a5a17cc4d811a9298b20c3a2c0884Mon Sep 17 00:00:00 2001
From: Jason Gunthorpe <[email protected]>
Date: Sat, 19 Nov 2016 11:18:28 -0700
Subject: [PATCH] tpm: Fix handling of missing event logThe event log is an optional firmware feature, if the firmware does not support it then the securityfs files should not be created and no other notification given.
- Uniformly return
-ENODEVfrom thetpm_bios_log_setupcone if no event log is detected.
- Check in ACPI if this node was discovered via ACPI.
- Improve the check in OF to make sure there is a parent and to fail detection if the two log properties are not declared
- Pass through all other error codes instead of filtering just someSigned-off-by Jason Gunthorpe <[email protected]>--- drivers/char/tpm/tpm-chip.c | 2 +- drivers/char/tpm/tpm_acpi.c | 8 +++++++- drivers/char/tpm/tpm_eventlog.c | 26 +++++++++++++------------- drivers/char/tpm/tpm_of.c | 11 +++++------ 4 files changed, 26 insertions(+), 21 deletions(-)drivers/char/tpm/tpm-chip.c +1
-1@@ -346,7 +346,7 @@ int tpm_chip_register(struct tpm_chip *chip)tpm_sysfs_add_device (chip); rc =tpm_bios_log_setup (chip); -if (rc == -ENODEV ) +if (rc !=0 && rc != -ENODEV )return rc;tpm_add_ppi (chip);drivers/char/tpm/tpm_acpi.c +7
-1@@ -56,12 +56,18 @@ int tpm_read_log_acpi(struct tpm_chip *chip) log = &chip->log; +/* Unfortuntely ACPI does not associate the event log with a specific +* TPM, like PPI. Thus all ACPI TPMs will read the same log. +*/ +if (!chip->acpi_dev_handle) +return -ENODEV ; +/* Find TCPA entry in RSDT (ACPI_LOGICAL_ADDRESSING) */ status =acpi_get_table (ACPI_SIG_TCPA ,1 , (struct acpi_table_header **)&buff);if (ACPI_FAILURE (status)) -return -EIO ; +return -ENODEV ;switch (buff->platform_class) {case BIOS_SERVER :drivers/char/tpm/tpm_eventlog.c +13
-13@@ -377,14 +377,21 @@ static int tpm_read_log(struct tpm_chip *chip) } rc =tpm_read_log_acpi (chip); -if ((rc ==0 ) || (rc == -ENOMEM )) +if (rc != -ENODEV )return rc; - rc =tpm_read_log_of (chip); - -return rc; +return tpm_read_log_of (chip); } +/* +* tpm_bios_log_setup() - Read the event log from the firmware +* @chip: TPM chip to use. +* +* If an event log is found then the securityfs files are setup to +* export it to userspace, otherwise nothing is done. +* +* Returns -ENODEV if the firmware has no event log. +*/ int tpm_bios_log_setup (struct tpm_chip *chip) {const char *name =dev_name (&chip->dev);@@ -395,15 +402,8 @@ int tpm_bios_log_setup(struct tpm_chip *chip)return 0 ; rc =tpm_read_log (chip); -/* -* read_log failure means event log is not supported except for ENOMEM. -*/ -if (rc <0 ) { -if (rc == -ENOMEM ) -return -ENODEV ; -else -return rc; - } +if (rc) +return rc; cnt =0 ; chip->bios_dir[cnt] =securityfs_create_dir (name,NULL );drivers/char/tpm/tpm_of.c +5
-6@@ -29,13 +29,16 @@ int tpm_read_log_of(struct tpm_chip *chip)struct tpm_bios_log *log; log = &chip->log; -if (chip->dev.parent->of_node) +if (chip->dev.parent && chip->dev.parent->of_node) np = chip->dev.parent->of_node;else return -ENODEV ; sizep =of_get_property (np,"linux,sml-size" ,NULL ); -if (sizep ==NULL ) + basep =of_get_property (np,"linux,sml-base" ,NULL ); +if (sizep ==NULL && basep ==NULL ) +return -ENODEV ; +if (sizep ==NULL || basep ==NULL )return -EIO ;if (*sizep ==0 ) {@@ -43,10 +46,6 @@ int tpm_read_log_of(struct tpm_chip *chip)return -EIO ; } - basep =of_get_property (np,"linux,sml-base" ,NULL ); -if (basep ==NULL ) -return -EIO ; - log->bios_event_log =kmalloc (*sizep,GFP_KERNEL );if (!log->bios_event_log)return -ENOMEM ;Signature · 1 line
2.7.4
A message that is not in the archive (sent off-list or not yet received): 20161120121451.awcraondhcvzpbig-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org
Jason Gunthorpe
Tested-by Stefan BergerRe: [PATCH 2/2] tpm: Fix error code handling after tpm_bios_log_setup
Quoted 4 lines · Jarkko Sakkinen
I was able to apply the patch after manually editing the mbox file. Not nice. It'd be better to send these things with git-send-email to simplify the mgmt (like getting them into patchwork for starters) especially in a situation that is bit chaotic to begin with :-/
It is in patchwork just fine:
https://patchwork.kernel.org/patch/9438323/
git am is unfortunately much more limited than patchwork, but you can apply right out of patchwork.
You forgot to add your signed-off-by though.
And this one fixes the sysfs problem
https://patchwork.kernel.org/patch/9438331/
Here is a commit message:
tpm: Do not call tpm_chip_unregister if register has not succeeded
This is no longer allowed, vtpm was relying on the check inside the tpm core which was removed. Fixes an oops during error unwind.
That just leaves the ACPI thing..
Jason
------------------------------------------------------------------------------
Re: [PATCH 2/2] tpm: Fix error code handling after tpm_bios_log_setup
Quoted 6 lines · Jason Gunthorpe
Quoted 4 lines · Jarkko Sakkinen
I was able to apply the patch after manually editing the mbox file. Not nice. It'd be better to send these things with git-send-email to simplify the mgmt (like getting them into patchwork for starters) especially in a situation that is bit chaotic to begin with :-/
Quoted 8 lines
It is in patchwork just fine:
https://patchwork.kernel.org/patch/9438323/
git am is unfortunately much more limited than patchwork, but you can apply right out of patchwork.
You forgot to add your signed-off-by though.
It's not forgotten. I'm yet to test it properly. I just quickly wanted to make it available...
/Jarkko
Quoted 19 lines
And this one fixes the sysfs problem
https://patchwork.kernel.org/patch/9438331/
Here is a commit message:
tpm: Do not call
tpm_chip_unregisterif register has not succeededThis is no longer allowed, vtpm was relying on the check inside the tpm core which was removed. Fixes an oops during error unwind.
Fixes a8ed92219a04 ("tpm: Get rid of TPM_CHIP_FLAG_REGISTERED")Signed-off-by Jason Gunthorpe <[email protected]>Tested-by Stefan Berger <[email protected]>That just leaves the ACPI thing..
Jason
A message that is not in the archive (sent off-list or not yet received): 20161121175520.GA24191-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org
Re: [PATCH 2/2] tpm: Fix error code handling after tpm_bios_log_setup
Quoted 23 lines · Jason Gunthorpe
Quoted 4 lines · Jarkko Sakkinen
I was able to apply the patch after manually editing the mbox file. Not nice. It'd be better to send these things with git-send-email to simplify the mgmt (like getting them into patchwork for starters) especially in a situation that is bit chaotic to begin with :-/
It is in patchwork just fine:
https://patchwork.kernel.org/patch/9438323/
git am is unfortunately much more limited than patchwork, but you can apply right out of patchwork.
You forgot to add your signed-off-by though.
And this one fixes the sysfs problem
https://patchwork.kernel.org/patch/9438331/
Here is a commit message:
tpm: Do not call
tpm_chip_unregisterif register has not succeeded
Quoted 8 lines
This is no longer allowed, vtpm was relying on the check inside the tpm core which was removed. Fixes an oops during error unwind.
Fixes a8ed92219a04 ("tpm: Get rid of TPM_CHIP_FLAG_REGISTERED")Tested-by Stefan Berger <[email protected]>That just leaves the ACPI thing..
I like the original commit message more. It documents the change.
/Jarkko
Quoted 2 lines
Jason
------------------------------------------------------------------------------
Re: [PATCH 2/2] tpm: Fix error code handling after tpm_bios_log_setup
Quoted 27 lines · Jarkko Sakkinen
Quoted 26 lines · Jason Gunthorpe
Quoted 4 lines · Jarkko Sakkinen
I was able to apply the patch after manually editing the mbox file. Not nice. It'd be better to send these things with git-send-email to simplify the mgmt (like getting them into patchwork for starters) especially in a situation that is bit chaotic to begin with :-/
It is in patchwork just fine:
https://patchwork.kernel.org/patch/9438323/
git am is unfortunately much more limited than patchwork, but you can apply right out of patchwork.
You forgot to add your signed-off-by though.
And this one fixes the sysfs problem
https://patchwork.kernel.org/patch/9438331/
Here is a commit message:
tpm: Do not call
tpm_chip_unregisterif register has not succeededThis is no longer allowed, vtpm was relying on the check inside the tpm core which was removed. Fixes an oops during error unwind.
Quoted 7 lines
Quoted 5 lines
Fixes a8ed92219a04 ("tpm: Get rid of TPM_CHIP_FLAG_REGISTERED")Signed-off-by Jason Gunthorpe <[email protected]>Tested-by Stefan Berger <[email protected]>That just leaves the ACPI thing..
I like the original commit message more. It documents the change.
I added to the commits reviewed-by's and signed-off-by's as I agree on the correctness of the changes. I'll do more formal testing before adding testd-by...
/Jarkko
Re: [PATCH 2/2] tpm: Fix error code handling after tpm_bios_log_setup
In reply to Jarkko SakkinenQuoted 11 lines · Jarkko Sakkinen
Quoted 11 lines
And this one fixes the sysfs problem
https://patchwork.kernel.org/patch/9438331/
Here is a commit message:
tpm: Do not call
tpm_chip_unregisterif register has not succeededThis is no longer allowed, vtpm was relying on the check inside the tpm core which was removed. Fixes an oops during error unwind.
Quoted 7 lines
Quoted 5 lines
Fixes a8ed92219a04 ("tpm: Get rid of TPM_CHIP_FLAG_REGISTERED")Signed-off-by Jason Gunthorpe <[email protected]>Tested-by Stefan Berger <[email protected]>That just leaves the ACPI thing..
I like the original commit message more. It documents the change.
??
This is for https://patchwork.kernel.org/patch/9438331/ which didn't have a message yet.
Jason
A message that is not in the archive (sent off-list or not yet received): 20161121203708.GA7294-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org
Re: [PATCH 2/2] tpm: Fix error code handling after tpm_bios_log_setup
Quoted 17 lines · Jason Gunthorpe
Quoted 15 lines · Jarkko Sakkinen
Quoted 15 lines
And this one fixes the sysfs problem
https://patchwork.kernel.org/patch/9438331/
Here is a commit message:
tpm: Do not call
tpm_chip_unregisterif register has not succeededThis is no longer allowed, vtpm was relying on the check inside the tpm core which was removed. Fixes an oops during error unwind.
Fixes a8ed92219a04 ("tpm: Get rid of TPM_CHIP_FLAG_REGISTERED")Tested-by Stefan Berger <[email protected]>
Quoted 8 lines
Quoted 3 lines
Quoted 1 line
That just leaves the ACPI thing..
I like the original commit message more. It documents the change.
??
This is for https://patchwork.kernel.org/patch/9438331/ which didn't have a message yet.
This was the commit message when I did git am:
tpm: vtpm_proxy: Do not access host's event log
On Thu, Nov 17, 2016 at 06:15:20PM -0500, Stefan Berger wrote:
> >>Further, I had the impression that the error unwinding following -ENODEV has > >>an issue related to sysfs.
> >I don't follow this comment..
>
> I have encountered this error here, which gets masked when applying the > previously shown patch.
If tpm_chip_register fails vtpm must not call tpm_chip_unregister:
> [ 58.271017] [<ffffffff8155bd32>] dpm_sysfs_remove+0x22/0x60
> [ 58.271017] [<ffffffff8154e438>] device_del+0x58/0x280
> [ 58.271017] [<ffffffffa024c020>] tpm_chip_unregister+0x40/0xb0 [tpm]
> [ 58.271017] [<ffffffffa0292360>] vtpm_proxy_fops_release+0x40/0x60 [tpm_vtpm_proxy]
So, this is a vtpm thing I missed for 'tpm: Get rid of TPM_CHIP_FLAG_REGISTERED'
Does this do the trick?
/Jarkko
------------------------------------------------------------------------------
Re: [PATCH 2/2] tpm: Fix error code handling after tpm_bios_log_setup
Quoted 20 lines · Jarkko Sakkinen
Quoted 19 lines · Jason Gunthorpe
Quoted 17 lines · Jarkko Sakkinen
Quoted 16 lines
And this one fixes the sysfs problem
https://patchwork.kernel.org/patch/9438331/
Here is a commit message:
tpm: Do not call
tpm_chip_unregisterif register has not succeededThis is no longer allowed, vtpm was relying on the check inside the tpm core which was removed. Fixes an oops during error unwind.
Fixes a8ed92219a04 ("tpm: Get rid of TPM_CHIP_FLAG_REGISTERED")Signed-off-by Jason Gunthorpe <[email protected]>Tested-by Stefan Berger <[email protected]>That just leaves the ACPI thing..
Quoted 8 lines
Quoted 6 lines
Quoted 1 line
I like the original commit message more. It documents the change.
??
This is for https://patchwork.kernel.org/patch/9438331/ which didn't have a message yet.
This was the commit message when I did git am:
Well, that is just a conversation from email, not a commit message, you need to edit it. The above I gave you is much better.
Jason
Re: [PATCH 2/2] tpm: Fix error code handling after tpm_bios_log_setup
In reply to Jason GunthorpeQuoted 65 lines · Jason Gunthorpe
Quoted 19 lines · Jarkko Sakkinen
Quoted 18 lines · Stefan Berger
tpm_bios_log_setup()may return-ENODEVin case no log was found. In this case we do not need to fail the device.Signed-off-by Stefan Berger <[email protected]>drivers/char/tpm/tpm-chip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/char/tpm/tpm-chip.c +2
-1+++ b/drivers/char/tpm/tpm-chip.c@@ -346,7 +346,7 @@ int tpm_chip_register(struct tpm_chip *chip)tpm_sysfs_add_device (chip); rc =tpm_bios_log_setup (chip); -if (rc == -ENODEV ) +if (rc != -ENODEV )return rc;Quoted 7 lines
drivers/char/tpm/tpm-chip.c int tpm_chip_register(struct tpm_chip *chip) · line 352
Quoted 1 line
drivers/char/tpm/tpm-chip.c +0
-0tpm_add_ppi (chip);CC to linux-security-module
LGTM
Reviewed-by Jarkko Sakkinen <[email protected]>Erm, what about rc == 0? And all the other problems?
Here, use this (untested) should take care of everything on this topic..
The two things I haven't seen explained are the sysfs unregister crash and the acpi iounmap crash :/
From
8768bcb8cd2a5a17cc4d811a9298b20c3a2c0884Mon Sep 17 00:00:00 2001
From: Jason Gunthorpe <[email protected]>
Date: Sat, 19 Nov 2016 11:18:28 -0700
Subject: [PATCH] tpm: Fix handling of missing event logThe event log is an optional firmware feature, if the firmware does not support it then the securityfs files should not be created and no other notification given.
- Uniformly return
-ENODEVfrom thetpm_bios_log_setupcone if no event log is detected.
- Check in ACPI if this node was discovered via ACPI.
- Improve the check in OF to make sure there is a parent and to fail detection if the two log properties are not declared
- Pass through all other error codes instead of filtering just someSigned-off-by Jason Gunthorpe <[email protected]>--- drivers/char/tpm/tpm-chip.c | 2 +- drivers/char/tpm/tpm_acpi.c | 8 +++++++- drivers/char/tpm/tpm_eventlog.c | 26 +++++++++++++------------- drivers/char/tpm/tpm_of.c | 11 +++++------ 4 files changed, 26 insertions(+), 21 deletions(-)drivers/char/tpm/tpm-chip.c +0
-0
drivers/char/tpm/tpm-chip.c int tpm_chip_register(struct tpm_chip *chip) · line 350
Quoted 6 lines
drivers/char/tpm/tpm-chip.c +1
-1@@ -346,7 +346,7 @@ int tpm_chip_register(struct tpm_chip *chip)tpm_sysfs_add_device (chip); rc =tpm_bios_log_setup (chip); -if (rc == -ENODEV ) +if (rc !=0 && rc != -ENODEV )return rc;
This will return in case of -EFAULT as well, where the check is that log is already initialized. Do we want to fail the probe here as well ?
-EFAULT is returned from tpm_read_log() as below:
tpm_read_log() has
if (chip->log.bios_event_log != NULL) {
dev_dbg(&chip->dev,
"%s: ERROR - event log already initialized\n",
__func__);
return -EFAULT;
}Quoted 31 lines
drivers/char/tpm/tpm-chip.c +0
-0tpm_add_ppi (chip);drivers/char/tpm/tpm_acpi.c +7
-1@@ -56,12 +56,18 @@ int tpm_read_log_acpi(struct tpm_chip *chip) log = &chip->log; +/* Unfortuntely ACPI does not associate the event log with a specific +* TPM, like PPI. Thus all ACPI TPMs will read the same log. +*/ +if (!chip->acpi_dev_handle) +return -ENODEV ; +/* Find TCPA entry in RSDT (ACPI_LOGICAL_ADDRESSING) */ status =acpi_get_table (ACPI_SIG_TCPA ,1 , (struct acpi_table_header **)&buff);if (ACPI_FAILURE (status)) -return -EIO ; +return -ENODEV ;switch (buff->platform_class) {case BIOS_SERVER :drivers/char/tpm/tpm_eventlog.c +0
-0
drivers/char/tpm/tpm_eventlog.c static int tpm_read_log(struct tpm_chip *chip) · line 379
Quoted 3 lines
drivers/char/tpm/tpm_eventlog.c +0
-0@@ -377,14 +377,21 @@ static int tpm_read_log(struct tpm_chip *chip) } rc =tpm_read_log_acpi (chip);
This is to understand..
It can return -ENOMEM error here, contd below...
drivers/char/tpm/tpm_eventlog.c static int tpm_read_log(struct tpm_chip *chip) · line 383
Quoted 8 lines
drivers/char/tpm/tpm_eventlog.c +2
-4-if ((rc ==0 ) || (rc == -ENOMEM )) +if (rc != -ENODEV )return rc; - rc =tpm_read_log_of (chip); - -return rc; +return tpm_read_log_of (chip);
So, in ACPI if -ENOMEM error is returned, it will continue to tpm_read_log_of(chip), which will return -ENODEV. So, -ENOMEM error is now masked with -ENODEV error.
Next, in tpm_chip_register(), this will be considered as -ENODEV
drivers/char/tpm/tpm_eventlog.c static int tpm_read_log(struct tpm_chip *chip) · line 385
Quoted 2 lines
drivers/char/tpm/tpm_eventlog.c +1
-0+if (rc !=0 && rc != -ENODEV )return rc;
and so will not fail the probe.
It doesn't create securityfs files, but also does not fail the probe for memory error. Is it the expected behavior ?
Quoted 43 lines
drivers/char/tpm/tpm_eventlog.c +11
-9} +/* +* tpm_bios_log_setup() - Read the event log from the firmware +* @chip: TPM chip to use. +* +* If an event log is found then the securityfs files are setup to +* export it to userspace, otherwise nothing is done. +* +* Returns -ENODEV if the firmware has no event log. +*/ int tpm_bios_log_setup (struct tpm_chip *chip) {const char *name =dev_name (&chip->dev);@@ -395,15 +402,8 @@ int tpm_bios_log_setup(struct tpm_chip *chip)return 0 ; rc =tpm_read_log (chip); -/* -* read_log failure means event log is not supported except for ENOMEM. -*/ -if (rc <0 ) { -if (rc == -ENOMEM ) -return -ENODEV ; -else -return rc; - } +if (rc) +return rc; cnt =0 ; chip->bios_dir[cnt] =securityfs_create_dir (name,NULL );drivers/char/tpm/tpm_of.c +1
-1@@ -29,13 +29,16 @@ int tpm_read_log_of(struct tpm_chip *chip)struct tpm_bios_log *log; log = &chip->log; -if (chip->dev.parent->of_node) +if (chip->dev.parent && chip->dev.parent->of_node) np = chip->dev.parent->of_node;
drivers/char/tpm/tpm_of.c int tpm_read_log_of(struct tpm_chip *chip) · line 42
Quoted 10 lines
drivers/char/tpm/tpm_of.c +4
-1else return -ENODEV ; sizep =of_get_property (np,"linux,sml-size" ,NULL ); -if (sizep ==NULL ) + basep =of_get_property (np,"linux,sml-base" ,NULL ); +if (sizep ==NULL && basep ==NULL ) +return -ENODEV ; +if (sizep ==NULL || basep ==NULL )return -EIO ;
To confirm my understanding,
For -ENODEV, it means that both properties are not supported, so event log is not supported.
For -EIO , it means that event log is supported but there is some failure in getting one of them, so should fail the probe. Is my understanding right ?
Thanks & Regards,
- Nayna
Quoted 14 lines
drivers/char/tpm/tpm_of.c +0
-4if (*sizep ==0 ) {@@ -43,10 +46,6 @@ int tpm_read_log_of(struct tpm_chip *chip)return -EIO ; } - basep =of_get_property (np,"linux,sml-base" ,NULL ); -if (basep ==NULL ) -return -EIO ; - log->bios_event_log =kmalloc (*sizep,GFP_KERNEL );if (!log->bios_event_log)return -ENOMEM ;
Re: [PATCH 2/2] tpm: Fix error code handling after tpm_bios_log_setup
Quoted 9 lines · Nayna
drivers/char/tpm/tpm-chip.c int tpm_chip_register(struct tpm_chip *chip) · line 350
Quoted 4 lines
drivers/char/tpm/tpm-chip.c +1
-1rc =tpm_bios_log_setup (chip); -if (rc == -ENODEV ) +if (rc !=0 && rc != -ENODEV )return rc;This will return in case of
-EFAULTas well, where the check is that log is already initialized. Do we want to fail the probe here as well ?
-EFAULTis returned fromtpm_read_log()as below:
That is fine, we should never read the log twice.
Quoted 14 lines
drivers/char/tpm/tpm_eventlog.c static int tpm_read_log(struct tpm_chip *chip) · line 379
Quoted 6 lines
index
fb603a74cbd29e..2a15b866ac257a100644
+++b/drivers/char/tpm/tpm_eventlog.cdrivers/char/tpm/tpm_eventlog.c +0
-0@@ -377,14 +377,21 @@ static int tpm_read_log(struct tpm_chip *chip) } rc =tpm_read_log_acpi (chip);This is to understand..
It can return-ENOMEMerror here, contd below...Quoted 4 lines
drivers/char/tpm/tpm_eventlog.c +1
-1-if ((rc ==0 ) || (rc == -ENOMEM )) +if (rc != -ENODEV )return rc;
Quoted 8 lines
drivers/char/tpm/tpm_eventlog.c static int tpm_read_log(struct tpm_chip *chip) · line 383
Quoted 4 lines
drivers/char/tpm/tpm_eventlog.c +1
-3- rc =tpm_read_log_of (chip); - -return rc; +return tpm_read_log_of (chip);So, in ACPI if
-ENOMEMerror is returned, it will continue totpm_read_log_of(chip), which will return-ENODEV. So,-ENOMEMerror is now masked with-ENODEVerror.
No, if acpi is -ENOMEM then 'if (rc != -ENODEV)' is true and it returns -ENOMEM.
Quoted 10 lines
drivers/char/tpm/tpm_of.c int tpm_read_log_of(struct tpm_chip *chip) · line 42
Quoted 7 lines
drivers/char/tpm/tpm_of.c +4
-1sizep =of_get_property (np,"linux,sml-size" ,NULL ); -if (sizep ==NULL ) + basep =of_get_property (np,"linux,sml-base" ,NULL ); +if (sizep ==NULL && basep ==NULL ) +return -ENODEV ; +if (sizep ==NULL || basep ==NULL )return -EIO ;To confirm my understanding,
Quoted 2 lines
For
-ENODEV, it means that both properties are not supported, so event log is not supported.
Yes
Quoted 3 lines
For
-EIO, it means that event log is supported but there is some failure in getting one of them, so should fail the probe.
Is my understanding right ?
Yes
Jason
Re: [PATCH 2/2] tpm: Fix error code handling after tpm_bios_log_setup
Quoted 9 lines · Jason Gunthorpe
Quoted 8 lines · Nayna
drivers/char/tpm/tpm-chip.c int tpm_chip_register(struct tpm_chip *chip) · line 350
Quoted 4 lines
drivers/char/tpm/tpm-chip.c +1
-1rc =tpm_bios_log_setup (chip); -if (rc == -ENODEV ) +if (rc !=0 && rc != -ENODEV )return rc;This will return in case of
-EFAULTas well, where the check is that log is already initialized. Do we want to fail the probe here as well ?
Quoted 3 lines
Quoted 1 line
-EFAULTis returned fromtpm_read_log()as below:That is fine, we should never read the log twice.
I just went through tpm_bios_log_setup(), tpm_read_log_of() and tpm_read_log_acpi(). The error handling is sound now but the condition should be in tpm_bios_log_setup(). Not in tpm_chip_register().
It is applied but if you don't mind I would like make a small commit that moves the condition to that function.
I think tpm_chip_register() should only care when something went wrong.
/Jarkko
Re: [PATCH 2/2] tpm: Fix error code handling after tpm_bios_log_setup
Quoted 6 lines · Jarkko Sakkinen
I just went through
tpm_bios_log_setup(),tpm_read_log_of()andtpm_read_log_acpi(). The error handling is sound now but the condition should be intpm_bios_log_setup(). Not intpm_chip_register().It is applied but if you don't mind I would like make a small commit that moves the condition to that function.
I'm not particularly concerned where the check lives..
Jason
A message that is not in the archive (sent off-list or not yet received): 20161122163720.GB3956-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org
Re: [PATCH 2/2] tpm: Fix error code handling after tpm_bios_log_setup
Quoted 10 lines · Jason Gunthorpe
Quoted 6 lines · Jarkko Sakkinen
I just went through
tpm_bios_log_setup(),tpm_read_log_of()andtpm_read_log_acpi(). The error handling is sound now but the condition should be intpm_bios_log_setup(). Not intpm_chip_register().It is applied but if you don't mind I would like make a small commit that moves the condition to that function.
I'm not particularly concerned where the check lives..
It's just a minor glitch but still an obvious inconsistency. Maybe I'll ignore for th moment as everything is well tested.
There is still two commits in the series that are untested and unreviewed.
/Jarkko
------------------------------------------------------------------------------
Re: [PATCH 2/2] tpm: Fix error code handling after tpm_bios_log_setup
In reply to Jason GunthorpeQuoted 36 lines · Jason Gunthorpe
Quoted 9 lines · Nayna
drivers/char/tpm/tpm-chip.c int tpm_chip_register(struct tpm_chip *chip) · line 350
Quoted 4 lines
rc = tpm_bios_log_setup(chip);drivers/char/tpm/tpm-chip.c +1
-1-if (rc == -ENODEV ) +if (rc !=0 && rc != -ENODEV )return rc;This will return in case of
-EFAULTas well, where the check is that log is already initialized. Do we want to fail the probe here as well ?
-EFAULTis returned fromtpm_read_log()as below:That is fine, we should never read the log twice.
Quoted 14 lines
drivers/char/tpm/tpm_eventlog.c static int tpm_read_log(struct tpm_chip *chip) · line 379
Quoted 6 lines
index
fb603a74cbd29e..2a15b866ac257a100644
+++b/drivers/char/tpm/tpm_eventlog.cdrivers/char/tpm/tpm_eventlog.c +0
-0@@ -377,14 +377,21 @@ static int tpm_read_log(struct tpm_chip *chip) } rc =tpm_read_log_acpi (chip);This is to understand..
It can return-ENOMEMerror here, contd below...Quoted 4 lines
drivers/char/tpm/tpm_eventlog.c +1
-1-if ((rc ==0 ) || (rc == -ENOMEM )) +if (rc != -ENODEV )return rc;Quoted 8 lines
drivers/char/tpm/tpm_eventlog.c static int tpm_read_log(struct tpm_chip *chip) · line 383
Quoted 4 lines
drivers/char/tpm/tpm_eventlog.c +1
-3- rc =tpm_read_log_of (chip); - -return rc; +return tpm_read_log_of (chip);So, in ACPI if
-ENOMEMerror is returned, it will continue totpm_read_log_of(chip), which will return-ENODEV. So,-ENOMEMerror is now masked with-ENODEVerror.
Quoted 2 lines
No, if acpi is
-ENOMEMthen 'if (rc !=-ENODEV)' is true and it returns-ENOMEM.
Yeah, I missed it. Sorry.
Quoted 14 lines
Quoted 11 lines
drivers/char/tpm/tpm_of.c int tpm_read_log_of(struct tpm_chip *chip) · line 42
Quoted 8 lines
drivers/char/tpm/tpm_of.c +4
-1sizep =of_get_property (np,"linux,sml-size" ,NULL ); -if (sizep ==NULL ) + basep =of_get_property (np,"linux,sml-base" ,NULL ); +if (sizep ==NULL && basep ==NULL ) +return -ENODEV ; +if (sizep ==NULL || basep ==NULL )return -EIO ;To confirm my understanding,
Quoted 2 lines
For
-ENODEV, it means that both properties are not supported, so event log is not supported.
Quoted 7 lines
Yes
Quoted 3 lines
For
-EIO, it means that event log is supported but there is some failure in getting one of them, so should fail the probe.
Is my understanding right ?Yes
Thanks for explaining. Looks good now.
Thanks & Regards,
- Nayna
Quoted 3 lines
Jason
Jarkko Sakkinen
Reviewed-byQuoted 24 lines · Stefan Berger
Check for the parent device being NULL before accessing it. This prevents crashed with the
vtpm_proxydriver, since this driver does not have a parent device.Signed-off-by Stefan Berger <[email protected]>--- drivers/char/tpm/tpm_of.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/char/tpm/tpm_of.c +1
-1@@ -29,7 +29,7 @@ int tpm_read_log_of(struct tpm_chip *chip)struct tpm_bios_log *log; log = &chip->log; -if (chip->dev.parent->of_node) +if (chip->dev.parent && chip->dev.parent->of_node) np = chip->dev.parent->of_node;else return -ENODEV ;Signature · 1 line
2.4.3
CC to linux-security-module
LGTM
/Jarkko
------------------------------------------------------------------------------