Skip to contentSkip to conversation

tpm: use test_bit() to check TPM2 flag in eventlog and sysfs code

PATCH In review Nayna Jain 3 participants 7 messages Nov 21, 2016 – Nov 22, 2016 2 messages not in the archive TPM device driver

lore
Share & tools
lore

Nayna Jain

author
#0 lore raw

PATCH 1/1 tpm: use test_bit() to check TPM2 flag in eventlog and sysfs code

There is change done to introduce atomic bitops to set and test chip->flags.
This patch fixes tpm_bios_log_setup() and tpm_sysfs_add_device() to use test_bit() to check for TPM_CHIP_FLAG_TPM2 flag.

---
 drivers/char/tpm/tpm-sysfs.c    | 2 +-
 drivers/char/tpm/tpm_eventlog.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/char/tpm/tpm-sysfs.c +1 -1
index 82298e51..9a37c26 100644
@@ -284,7 +284,7 @@ static const struct attribute_group tpm_dev_group = {
 
 void tpm_sysfs_add_device(struct tpm_chip *chip)
 {
-	if (chip->flags & TPM_CHIP_FLAG_TPM2)
+	if (test_bit(TPM_CHIP_FLAG_TPM2, &chip->flags))
 		return;
 
 	/* The sysfs routines rely on an implicit tpm_try_get_ops, device_del
drivers/char/tpm/tpm_eventlog.c +1 -1
index ebec4ac..dede2ec 100644
@@ -391,7 +391,7 @@ int tpm_bios_log_setup(struct tpm_chip *chip)
 	unsigned int cnt;
 	int rc = 0;
 
-	if (chip->flags & TPM_CHIP_FLAG_TPM2)
+	if (test_bit(TPM_CHIP_FLAG_TPM2, &chip->flags))
 		return 0;
 
 	rc = tpm_read_log(chip);
Signature · 1 line
2.5.0
#1 lore raw
Quoted 6 lines · Nayna Jain

There is change done to introduce atomic bitops to set and test chip->flags.
This patch fixes tpm_bios_log_setup() and tpm_sysfs_add_device() to use test_bit() to check for TPM_CHIP_FLAG_TPM2 flag.

I'm bit lost of the purpose of this patch.

/Jarkko

Quoted 38 lines
---
 drivers/char/tpm/tpm-sysfs.c    | 2 +-
 drivers/char/tpm/tpm_eventlog.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/char/tpm/tpm-sysfs.c +1 -1
index 82298e51..9a37c26 100644
@@ -284,7 +284,7 @@ static const struct attribute_group tpm_dev_group = {
 
 void tpm_sysfs_add_device(struct tpm_chip *chip)
 {
-	if (chip->flags & TPM_CHIP_FLAG_TPM2)
+	if (test_bit(TPM_CHIP_FLAG_TPM2, &chip->flags))
 		return;
 
 	/* The sysfs routines rely on an implicit tpm_try_get_ops, device_del
drivers/char/tpm/tpm_eventlog.c +1 -1
index ebec4ac..dede2ec 100644
@@ -391,7 +391,7 @@ int tpm_bios_log_setup(struct tpm_chip *chip)
 	unsigned int cnt;
 	int rc = 0;
 
-	if (chip->flags & TPM_CHIP_FLAG_TPM2)
+	if (test_bit(TPM_CHIP_FLAG_TPM2, &chip->flags))
 		return 0;
 
 	rc = tpm_read_log(chip);
Signature · 6 lines
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
author
#2 lore raw
Quoted 9 lines · Jarkko Sakkinen
Quoted 6 lines · Nayna Jain

There is change done to introduce atomic bitops to set and test chip->flags.
This patch fixes tpm_bios_log_setup() and tpm_sysfs_add_device() to use test_bit() to check for TPM_CHIP_FLAG_TPM2 flag.

I'm bit lost of the purpose of this patch.

I was using tabrm branch which has changes related to using bitops for chip->flags, but it was failing for TPM2 check in tpm_bios_log_setup() with the existing way of checking. Replacing existing one with test_bit() check makes it work. Same in case of tpm_sysfs_add_device().

Thanks & Regards,
- Nayna

Quoted 42 lines

/Jarkko

Quoted 38 lines
---
  drivers/char/tpm/tpm-sysfs.c    | 2 +-
  drivers/char/tpm/tpm_eventlog.c | 2 +-
  2 files changed, 2 insertions(+), 2 deletions(-)
drivers/char/tpm/tpm-sysfs.c +1 -1
index 82298e51..9a37c26 100644
@@ -284,7 +284,7 @@ static const struct attribute_group tpm_dev_group = {
 
  void tpm_sysfs_add_device(struct tpm_chip *chip)
  {
-	if (chip->flags & TPM_CHIP_FLAG_TPM2)
+	if (test_bit(TPM_CHIP_FLAG_TPM2, &chip->flags))
  		return;
 
  	/* The sysfs routines rely on an implicit tpm_try_get_ops, device_del
drivers/char/tpm/tpm_eventlog.c +1 -2
index ebec4ac..dede2ec 100644
@@ -391,7 +391,7 @@ int tpm_bios_log_setup(struct tpm_chip *chip)
  	unsigned int cnt;
  	int rc = 0;
 
-	if (chip->flags & TPM_CHIP_FLAG_TPM2)
+	if (test_bit(TPM_CHIP_FLAG_TPM2, &chip->flags))
  		return 0;
 
  	rc = tpm_read_log(chip);
--

2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-security-module" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): 58340988.9000700-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org

#4 lore raw
Quoted 9 lines · Nayna
Quoted 6 lines · Jarkko Sakkinen
Quoted 5 lines · Nayna Jain

There is change done to introduce atomic bitops to set and test chip->flags.
This patch fixes tpm_bios_log_setup() and tpm_sysfs_add_device() to use test_bit() to check for TPM_CHIP_FLAG_TPM2 flag.

Quoted 8 lines
Quoted 3 lines
Quoted 1 line

I'm bit lost of the purpose of this patch.

I was using tabrm branch which has changes related to using bitops for chip->flags, but it was failing for TPM2 check in tpm_bios_log_setup() with the existing way of checking. Replacing existing one with test_bit() check makes it work. Same in case of tpm_sysfs_add_device().

Why didn't you just response to the thread with a review comment especially as the patch is not applied to the master branch?

/Jarkko

------------------------------------------------------------------------------

author
#5 lore raw
Quoted 14 lines · Jarkko Sakkinen
Quoted 13 lines · Nayna
Quoted 9 lines · Jarkko Sakkinen
Quoted 6 lines · Nayna Jain

There is change done to introduce atomic bitops to set and test chip->flags.
This patch fixes tpm_bios_log_setup() and tpm_sysfs_add_device() to use test_bit() to check for TPM_CHIP_FLAG_TPM2 flag.

I'm bit lost of the purpose of this patch.

Quoted 7 lines
Quoted 4 lines

I was using tabrm branch which has changes related to using bitops for chip->flags, but it was failing for TPM2 check in tpm_bios_log_setup() with the existing way of checking. Replacing existing one with test_bit() check makes it work. Same in case of tpm_sysfs_add_device().

Why didn't you just response to the thread with a review comment especially as the patch is not applied to the master branch?

Oh!! Ok.. Sorry, I should have done that.
Will take care next time.

So basically it needs to be fixed as part of that patch.

Thanks & Regards,
- Nayna

Quoted 3 lines

/Jarkko

A message that is not in the archive (sent off-list or not yet received): [email protected]

#7 lore raw
Quoted 22 lines · Nayna
Quoted 19 lines · Jarkko Sakkinen
Quoted 17 lines · Nayna
Quoted 9 lines · Jarkko Sakkinen
Quoted 6 lines · Nayna Jain

There is change done to introduce atomic bitops to set and test chip->flags.
This patch fixes tpm_bios_log_setup() and tpm_sysfs_add_device() to use test_bit() to check for TPM_CHIP_FLAG_TPM2 flag.

I'm bit lost of the purpose of this patch.

I was using tabrm branch which has changes related to using bitops for chip->flags, but it was failing for TPM2 check in tpm_bios_log_setup() with the existing way of checking. Replacing existing one with test_bit() check makes it work. Same in case of tpm_sysfs_add_device().

Quoted 7 lines
Quoted 2 lines

Why didn't you just response to the thread with a review comment especially as the patch is not applied to the master branch?

Oh!! Ok.. Sorry, I should have done that.
Will take care next time.

So basically it needs to be fixed as part of that patch.

NP. Thanks for reporting the issue!

/Jarkko

------------------------------------------------------------------------------

#8 lore raw
In reply to Jarkko Sakkinen
Quoted 14 lines · Jarkko Sakkinen
Quoted 13 lines · Nayna
Quoted 9 lines · Jarkko Sakkinen
Quoted 6 lines · Nayna Jain

There is change done to introduce atomic bitops to set and test chip->flags.
This patch fixes tpm_bios_log_setup() and tpm_sysfs_add_device() to use test_bit() to check for TPM_CHIP_FLAG_TPM2 flag.

I'm bit lost of the purpose of this patch.

Quoted 7 lines
Quoted 4 lines

I was using tabrm branch which has changes related to using bitops for chip->flags, but it was failing for TPM2 check in tpm_bios_log_setup() with the existing way of checking. Replacing existing one with test_bit() check makes it work. Same in case of tpm_sysfs_add_device().

Why didn't you just response to the thread with a review comment especially as the patch is not applied to the master branch?

Anyway I updated the corresponding patches. Thanks for reporting these issues!

/Jarkko