Skip to contentSkip to conversation

TPM: integrity fix

PATCH Applied Rajiv Andrade 3 participants 4 messages Feb 5, 2009 TPM device driver

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 TPM: integrity fix

Fix to function which is called by IMA, now tpm_chip_find_get() considers the case in which the machine doesn't have a TPM or, if it has, its TPM isn't enabled.

---
 drivers/char/tpm/tpm.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)
drivers/char/tpm/tpm.c +5 -3
index 0387965..912a473 100644
@@ -666,18 +666,20 @@ EXPORT_SYMBOL_GPL(tpm_show_temp_deactivated);
  */
 static struct tpm_chip *tpm_chip_find_get(int chip_num)
 {
-	struct tpm_chip *pos;
+	struct tpm_chip *pos, *chip = NULL;
 
 	rcu_read_lock();
 	list_for_each_entry_rcu(pos, &tpm_chip_list, list) {
 		if (chip_num != TPM_ANY_NUM && chip_num != pos->dev_num)
 			continue;
 
-		if (try_module_get(pos->dev->driver->owner))
+		if (try_module_get(pos->dev->driver->owner)) {
+			chip = pos;
 			break;
+		}
 	}
 	rcu_read_unlock();
-	return pos;
+	return chip;
 }
 
 #define TPM_ORDINAL_PCRREAD cpu_to_be32(21)
Signature · 1 line
1.5.6.3
Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Rajiv Andrade

Fix to function which is called by IMA, now tpm_chip_find_get() considers the case in which the machine doesn't have a TPM or, if it has, its TPM isn't enabled.

Is this to fix James' problem with IMA on bootup?

Quoted 9 lines
---
 drivers/char/tpm/tpm.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)
drivers/char/tpm/tpm.c +0 -0
index 0387965..912a473 100644

drivers/char/tpm/tpm.c EXPORT_SYMBOL_GPL(tpm_show_temp_deactivated); · line 672

Quoted 8 lines
drivers/char/tpm/tpm.c +1 -1
@@ -666,18 +666,20 @@ EXPORT_SYMBOL_GPL(tpm_show_temp_deactivated);
  */
 static struct tpm_chip *tpm_chip_find_get(int chip_num)
 {
-	struct tpm_chip *pos;
+	struct tpm_chip *pos, *chip = NULL;
 
 	rcu_read_lock();
 	list_for_each_entry_rcu(pos, &tpm_chip_list, list) {

Crap I even paused for a second when I reviewed the original patch. I think the conversation in my head went something like "but will pos be NULL at the end of the loop?" "Oh, it must". gah.

Quoted 17 lines
drivers/char/tpm/tpm.c +4 -2
 		if (chip_num != TPM_ANY_NUM && chip_num != pos->dev_num)
 			continue;
 
-		if (try_module_get(pos->dev->driver->owner))
+		if (try_module_get(pos->dev->driver->owner)) {
+			chip = pos;
 			break;
+		}
 	}
 	rcu_read_unlock();
-	return pos;
+	return chip;
 }
 
 #define TPM_ORDINAL_PCRREAD cpu_to_be32(21)
Signature · 1 line
1.5.6.3
#2 lore raw
Quoted 11 lines · Serge E. Hallyn
Quoted 5 lines · Rajiv Andrade

Fix to function which is called by IMA, now tpm_chip_find_get() considers the case in which the machine doesn't have a TPM or, if it has, its TPM isn't enabled.

Is this to fix James' problem with IMA on bootup?

Yes.

Quoted 18 lines
Quoted 15 lines
---
 drivers/char/tpm/tpm.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)
drivers/char/tpm/tpm.c +1 -1
index 0387965..912a473 100644
@@ -666,18 +666,20 @@ EXPORT_SYMBOL_GPL(tpm_show_temp_deactivated);
  */
 static struct tpm_chip *tpm_chip_find_get(int chip_num)
 {
-	struct tpm_chip *pos;
+	struct tpm_chip *pos, *chip = NULL;
 
Quoted 9 lines

drivers/char/tpm/tpm.c EXPORT_SYMBOL_GPL(tpm_show_temp_deactivated); · line 675

Quoted 3 lines
drivers/char/tpm/tpm.c +0 -0
 	rcu_read_lock();
 	list_for_each_entry_rcu(pos, &tpm_chip_list, list) {
 

Crap I even paused for a second when I reviewed the original patch. I think the conversation in my head went something like "but will pos be NULL at the end of the loop?" "Oh, it must". gah.

Yeah, I thought the same and let it pass by..

Rajiv

Quoted 18 lines
Quoted 18 lines
drivers/char/tpm/tpm.c +4 -2
 		if (chip_num != TPM_ANY_NUM && chip_num != pos->dev_num)
 			continue;
 
-		if (try_module_get(pos->dev->driver->owner))
+		if (try_module_get(pos->dev->driver->owner)) {
+			chip = pos;
 			break;
+		}
 	}
 	rcu_read_unlock();
-	return pos;
+	return chip;
 }
 

#define TPM_ORDINAL_PCRREAD cpu_to_be32(21)

Signature · 1 line
1.5.6.3
Applied
#3 lore raw
In reply to Rajiv Andrade
Quoted 1 line · Rajiv Andrade

Fix to function which is called by IMA, now tpm_chip_find_get() considers the case in which the machine doesn't have a TPM or, if it has, its TPM isn't enabled.

Applied.

Quoted 38 lines
---
 drivers/char/tpm/tpm.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)
drivers/char/tpm/tpm.c +5 -3
index 0387965..912a473 100644
@@ -666,18 +666,20 @@ EXPORT_SYMBOL_GPL(tpm_show_temp_deactivated);
  */
 static struct tpm_chip *tpm_chip_find_get(int chip_num)
 {
-	struct tpm_chip *pos;
+	struct tpm_chip *pos, *chip = NULL;
 
 	rcu_read_lock();
 	list_for_each_entry_rcu(pos, &tpm_chip_list, list) {
 		if (chip_num != TPM_ANY_NUM && chip_num != pos->dev_num)
 			continue;
 
-		if (try_module_get(pos->dev->driver->owner))
+		if (try_module_get(pos->dev->driver->owner)) {
+			chip = pos;
 			break;
+		}
 	}
 	rcu_read_unlock();
-	return pos;
+	return chip;
 }
 
 #define TPM_ORDINAL_PCRREAD cpu_to_be32(21)
Signature · 1 line
1.5.6.3
Signature · 2 lines
James Morris
<[email protected]>