public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] TPM: integrity fix
@ 2009-02-05 15:06 Rajiv Andrade
  2009-02-05 15:26 ` Serge E. Hallyn
  2009-02-05 22:37 ` James Morris
  0 siblings, 2 replies; 4+ messages in thread
From: Rajiv Andrade @ 2009-02-05 15:06 UTC (permalink / raw)
  To: linux-kernel; +Cc: jmorris, akpm, serue, safford, Mimi Zohar

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.

Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
Signed-off-by: Rajiv Andrade <srajiv@linux.vnet.ibm.com>
---
 drivers/char/tpm/tpm.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
index 0387965..912a473 100644
--- a/drivers/char/tpm/tpm.c
+++ b/drivers/char/tpm/tpm.c
@@ -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)
-- 
1.5.6.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] TPM: integrity fix
  2009-02-05 15:06 [PATCH] TPM: integrity fix Rajiv Andrade
@ 2009-02-05 15:26 ` Serge E. Hallyn
  2009-02-05 16:05   ` Rajiv Andrade
  2009-02-05 22:37 ` James Morris
  1 sibling, 1 reply; 4+ messages in thread
From: Serge E. Hallyn @ 2009-02-05 15:26 UTC (permalink / raw)
  To: Rajiv Andrade; +Cc: linux-kernel, jmorris, akpm, safford, Mimi Zohar

Quoting Rajiv Andrade (srajiv@linux.vnet.ibm.com):
> 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.
> 
> Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
> Signed-off-by: Rajiv Andrade <srajiv@linux.vnet.ibm.com>

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

Acked-by: Serge Hallyn <serue@us.ibm.com>

> ---
>  drivers/char/tpm/tpm.c |    8 +++++---
>  1 files changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
> index 0387965..912a473 100644
> --- a/drivers/char/tpm/tpm.c
> +++ b/drivers/char/tpm/tpm.c
> @@ -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.

>  		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)
> -- 
> 1.5.6.3

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] TPM: integrity fix
  2009-02-05 15:26 ` Serge E. Hallyn
@ 2009-02-05 16:05   ` Rajiv Andrade
  0 siblings, 0 replies; 4+ messages in thread
From: Rajiv Andrade @ 2009-02-05 16:05 UTC (permalink / raw)
  To: Serge E. Hallyn; +Cc: linux-kernel, jmorris, akpm, safford, Mimi Zohar

Serge E. Hallyn wrote:
> Quoting Rajiv Andrade (srajiv@linux.vnet.ibm.com):
>   
>> 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.
>>
>> Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
>> Signed-off-by: Rajiv Andrade <srajiv@linux.vnet.ibm.com>
>>     
>
> Is this to fix James' problem with IMA on bootup?
>
>   
Yes.
> Acked-by: Serge Hallyn <serue@us.ibm.com>
>
>   
>> ---
>>  drivers/char/tpm/tpm.c |    8 +++++---
>>  1 files changed, 5 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
>> index 0387965..912a473 100644
>> --- a/drivers/char/tpm/tpm.c
>> +++ b/drivers/char/tpm/tpm.c
>> @@ -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.
>
>   
Yeah, I thought the same and let it pass by..

Rajiv
>>  		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)
>> -- 
>> 1.5.6.3
>>     


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] TPM: integrity fix
  2009-02-05 15:06 [PATCH] TPM: integrity fix Rajiv Andrade
  2009-02-05 15:26 ` Serge E. Hallyn
@ 2009-02-05 22:37 ` James Morris
  1 sibling, 0 replies; 4+ messages in thread
From: James Morris @ 2009-02-05 22:37 UTC (permalink / raw)
  To: Rajiv Andrade; +Cc: linux-kernel, akpm, serue, safford, Mimi Zohar

On Thu, 5 Feb 2009, Rajiv Andrade wrote:

> 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.

> 
> Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
> Signed-off-by: Rajiv Andrade <srajiv@linux.vnet.ibm.com>
> ---
>  drivers/char/tpm/tpm.c |    8 +++++---
>  1 files changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/char/tpm/tpm.c b/drivers/char/tpm/tpm.c
> index 0387965..912a473 100644
> --- a/drivers/char/tpm/tpm.c
> +++ b/drivers/char/tpm/tpm.c
> @@ -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)
> -- 
> 1.5.6.3
> 

-- 
James Morris
<jmorris@namei.org>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-02-05 22:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-05 15:06 [PATCH] TPM: integrity fix Rajiv Andrade
2009-02-05 15:26 ` Serge E. Hallyn
2009-02-05 16:05   ` Rajiv Andrade
2009-02-05 22:37 ` James Morris

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox