tpm: fix parameter order in tpm_getcap()
PATCH 1/1 tpm: fix parameter order in tpm_getcap()
The parameter order mismatches tpm_transmit_cmd().
--- drivers/char/tpm/tpm-interface.c | 14 +++++++------- drivers/char/tpm/tpm-sysfs.c | 33 ++++++++++++++++----------------- drivers/char/tpm/tpm.h | 2 +- 3 files changed, 24 insertions(+), 25 deletions(-)
drivers/char/tpm/tpm-interface.c +7 -7
@@ -478,7 +478,7 @@ static const struct tpm_input_header tpm_getcap_header = { };ssize_t tpm_getcap (struct tpm_chip *chip,u32 subcap_id,cap_t *cap, -const char *desc,size_t min_cap_length) +size_t min_cap_length,const char *desc) {struct tpm_cmd_t tpm_cmd;int rc;
@@ -555,8 +555,8 @@ int tpm_get_timeouts(struct tpm_chip *chip)return 0 ; } - rc =tpm_getcap (chip,TPM_CAP_PROP_TIS_TIMEOUT , &cap,NULL , -sizeof (cap.timeout)); + rc =tpm_getcap (chip,TPM_CAP_PROP_TIS_TIMEOUT , &cap, +sizeof (cap.timeout),NULL );if (rc ==TPM_ERR_INVALID_POSTINIT ) {/* The TPM is not started, we are the first to talk to it. Execute a startup command. */
@@ -565,8 +565,8 @@ int tpm_get_timeouts(struct tpm_chip *chip)return rc; rc =tpm_getcap (chip,TPM_CAP_PROP_TIS_TIMEOUT , &cap, -"attempting to determine the timeouts" , -sizeof (cap.timeout)); +sizeof (cap.timeout), +"attempting to determine the timeouts" ); }if (rc) {
@@ -630,8 +630,8 @@ int tpm_get_timeouts(struct tpm_chip *chip) chip->timeout_d =usecs_to_jiffies (timeout_eff[3 ]); rc =tpm_getcap (chip,TPM_CAP_PROP_TIS_DURATION , &cap, -"attempting to determine the durations" , -sizeof (cap.duration)); +sizeof (cap.duration), +"attempting to determine the durations" );if (rc)return rc;
drivers/char/tpm/tpm-sysfs.c +16 -17
@@ -96,9 +96,8 @@ static ssize_t pcrs_show(struct device *dev, struct device_attribute *attr,char *str = buf;struct tpm_chip *chip =to_tpm_chip (dev); - rc =tpm_getcap (chip,TPM_CAP_PROP_PCR , &cap, -"attempting to determine the number of PCRS" , -sizeof (cap.num_pcrs)); + rc =tpm_getcap (chip,TPM_CAP_PROP_PCR , &cap,sizeof (cap.num_pcrs), +"attempting to determine the number of PCRS" );if (rc)return 0 ;
@@ -123,8 +122,8 @@ static ssize_t enabled_show(struct device *dev, struct device_attribute *attr,ssize_t rc; rc =tpm_getcap (to_tpm_chip (dev),TPM_CAP_FLAG_PERM , &cap, -"attempting to determine the permanent enabled state" , -sizeof (cap.perm_flags)); +sizeof (cap.perm_flags), +"attempting to determine the permanent enabled state" );if (rc)return 0 ;
@@ -140,8 +139,8 @@ static ssize_t active_show(struct device *dev, struct device_attribute *attr,ssize_t rc; rc =tpm_getcap (to_tpm_chip (dev),TPM_CAP_FLAG_PERM , &cap, -"attempting to determine the permanent active state" , -sizeof (cap.perm_flags)); +sizeof (cap.perm_flags), +"attempting to determine the permanent active state" );if (rc)return 0 ;
@@ -157,8 +156,8 @@ static ssize_t owned_show(struct device *dev, struct device_attribute *attr,ssize_t rc; rc =tpm_getcap (to_tpm_chip (dev),TPM_CAP_PROP_OWNER , &cap, -"attempting to determine the owner state" , -sizeof (cap.owned)); +sizeof (cap.owned), +"attempting to determine the owner state" );if (rc)return 0 ;
@@ -174,8 +173,8 @@ static ssize_t temp_deactivated_show(struct device *dev,ssize_t rc; rc =tpm_getcap (to_tpm_chip (dev),TPM_CAP_FLAG_VOL , &cap, -"attempting to determine the temporary state" , -sizeof (cap.stclear_flags)); +sizeof (cap.stclear_flags), +"attempting to determine the temporary state" );if (rc)return 0 ;
@@ -193,8 +192,8 @@ static ssize_t caps_show(struct device *dev, struct device_attribute *attr,char *str = buf; rc =tpm_getcap (chip,TPM_CAP_PROP_MANUFACTURER , &cap, -"attempting to determine the manufacturer" , -sizeof (cap.manufacturer_id)); +sizeof (cap.manufacturer_id), +"attempting to determine the manufacturer" );if (rc)return 0 ; str += sprintf(str, "Manufacturer: 0x%x\n",
@@ -202,8 +201,8 @@ static ssize_t caps_show(struct device *dev, struct device_attribute *attr,/* Try to get a TPM version 1.2 TPM_CAP_VERSION_INFO */ rc =tpm_getcap (chip,TPM_CAP_VERSION_1_2 , &cap, -"attempting to determine the 1.2 version" , -sizeof (cap.tpm_version_1_2)); +sizeof (cap.tpm_version_1_2), +"attempting to determine the 1.2 version" );if (!rc) { str += sprintf(str, "TCG version: %d.%d\nFirmware version: %d.%d\n",
@@ -214,8 +213,8 @@ static ssize_t caps_show(struct device *dev, struct device_attribute *attr, }else {/* Otherwise just use TPM_STRUCT_VER */ rc =tpm_getcap (chip,TPM_CAP_VERSION_1_1 , &cap, -"attempting to determine the 1.1 version" , -sizeof (cap.tpm_version)); +sizeof (cap.tpm_version), +"attempting to determine the 1.1 version" );if (rc)return 0 ; str += sprintf(str,
drivers/char/tpm/tpm.h +1 -1
@@ -499,7 +499,7 @@ ssize_t tpm_transmit_cmd(struct tpm_chip *chip, const void *buf, size_t bufsiz, size_t min_rsp_body_len, unsigned int flags, const char *desc);ssize_t tpm_getcap (struct tpm_chip *chip,u32 subcap_id,cap_t *cap, -const char *desc,size_t min_cap_length); +size_t min_cap_length,const char *desc);int tpm_get_timeouts (struct tpm_chip *);int tpm1_auto_startup (struct tpm_chip *chip);int tpm_do_selftest (struct tpm_chip *chip);
Signature · 6 lines
2.9.3 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot
kbuild test robot
build boturl: https://github.com/0day-ci/linux/commits/Jarkko-Sakkinen/tpm-fix-parameter-order-in-tpm_getcap/20170202-025932 config: x86_64-allyesdebian (attached as .config) compiler: gcc-6 (Debian 6.2.0-3)…
Hi Jarkko,
[auto build test WARNING on next-20170201]
[cannot apply to char-misc/char-misc-testing v4.9-rc8 v4.9-rc7 v4.9-rc6 v4.10-rc6] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Jarkko-Sakkinen/tpm-fix-parameter-order-in-tpm_getcap/20170202-025932
config: x86_64-allyesdebian (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64 All warnings (new ones prefixed by >>):
drivers/char/tpm/tpm_tis_core.c: In function 'tpm_tis_gen_interrupt':
>> drivers/char/tpm/tpm_tis_core.c:561:59: warning: passing argument 4 of 'tpm_getcap' makes integer from pointer without a cast [-Wint-conversion]
return tpm_getcap(chip, TPM_CAP_PROP_TIS_TIMEOUT, &cap, desc,
^~~~
In file included from drivers/char/tpm/tpm_tis_core.c:31:0:
drivers/char/tpm/tpm.h:501:9: note: expected 'size_t {aka long unsigned int}' but argument is of type 'const char *'
ssize_t tpm_getcap(struct tpm_chip *chip, u32 subcap_id, cap_t *cap,
^~~~~~~~~~
vim +/tpm_getcap +561 drivers/char/tpm/tpm_tis_core.c
41a5e1cf1 Christophe Ricard 2016-05-19 545 if (rc < 0)
41a5e1cf1 Christophe Ricard 2016-05-19 546 return IRQ_NONE;
41a5e1cf1 Christophe Ricard 2016-05-19 547
41a5e1cf1 Christophe Ricard 2016-05-19 548 tpm_tis_read32(priv, TPM_INT_STATUS(priv->locality), &interrupt);
41a5e1cf1 Christophe Ricard 2016-05-19 549 return IRQ_HANDLED;
41a5e1cf1 Christophe Ricard 2016-05-19 550 }
41a5e1cf1 Christophe Ricard 2016-05-19 551
eb5854e76 Jarkko Sakkinen 2016-06-12 552 static int tpm_tis_gen_interrupt(struct tpm_chip *chip)
eb5854e76 Jarkko Sakkinen 2016-06-12 553 {
eb5854e76 Jarkko Sakkinen 2016-06-12 554 const char *desc = "attempting to generate an interrupt";
eb5854e76 Jarkko Sakkinen 2016-06-12 555 u32 cap2;
eb5854e76 Jarkko Sakkinen 2016-06-12 556 cap_t cap;
eb5854e76 Jarkko Sakkinen 2016-06-12 557
eb5854e76 Jarkko Sakkinen 2016-06-12 558 if (chip->flags & TPM_CHIP_FLAG_TPM2)
eb5854e76 Jarkko Sakkinen 2016-06-12 559 return tpm2_get_tpm_pt(chip, 0x100, &cap2, desc);
eb5854e76 Jarkko Sakkinen 2016-06-12 560 else
c659af78e Stefan Berger 2017-01-19 @561 return tpm_getcap(chip, TPM_CAP_PROP_TIS_TIMEOUT, &cap, desc,
c659af78e Stefan Berger 2017-01-19 562 0);
eb5854e76 Jarkko Sakkinen 2016-06-12 563 }
eb5854e76 Jarkko Sakkinen 2016-06-12 564
41a5e1cf1 Christophe Ricard 2016-05-19 565 /* Register the IRQ and issue a command that will cause an interrupt. If an
41a5e1cf1 Christophe Ricard 2016-05-19 566 * irq is seen then leave the chip setup for IRQ operation, otherwise reverse
41a5e1cf1 Christophe Ricard 2016-05-19 567 * everything and leave in polling mode. Returns 0 on success.
41a5e1cf1 Christophe Ricard 2016-05-19 568 */
41a5e1cf1 Christophe Ricard 2016-05-19 569 static int tpm_tis_probe_irq_single(struct tpm_chip *chip, u32 intmask,:::::: The code at line 561 was first introduced by commit
:::::: c659af78eb7b7d7be40f23d9d97bde58eb1368ac tpm: Check size of response before accessing data
:::::: TO: Stefan Berger <[email protected]> :::::: CC: Jarkko Sakkinen <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Quoted 4 lines · Jarkko Sakkinen
The parameter order mismatches
tpm_transmit_cmd().Fixes c659af78eb7b ("tpm: Check size of response before accessing data")
Maybe it's better not to rush this into release as it is an cosmetic issue only but spreads around the codebase (saw the kbuld test robot mail).
/Jarkko
Quoted 161 lines
--- drivers/char/tpm/tpm-interface.c | 14 +++++++------- drivers/char/tpm/tpm-sysfs.c | 33 ++++++++++++++++----------------- drivers/char/tpm/tpm.h | 2 +- 3 files changed, 24 insertions(+), 25 deletions(-)drivers/char/tpm/tpm-interface.c +7
-7@@ -478,7 +478,7 @@ static const struct tpm_input_header tpm_getcap_header = { };ssize_t tpm_getcap (struct tpm_chip *chip,u32 subcap_id,cap_t *cap, -const char *desc,size_t min_cap_length) +size_t min_cap_length,const char *desc) {struct tpm_cmd_t tpm_cmd;int rc;@@ -555,8 +555,8 @@ int tpm_get_timeouts(struct tpm_chip *chip)return 0 ; } - rc =tpm_getcap (chip,TPM_CAP_PROP_TIS_TIMEOUT , &cap,NULL , -sizeof (cap.timeout)); + rc =tpm_getcap (chip,TPM_CAP_PROP_TIS_TIMEOUT , &cap, +sizeof (cap.timeout),NULL );if (rc ==TPM_ERR_INVALID_POSTINIT ) {/* The TPM is not started, we are the first to talk to it. Execute a startup command. */ @@ -565,8 +565,8 @@ int tpm_get_timeouts(struct tpm_chip *chip)return rc; rc =tpm_getcap (chip,TPM_CAP_PROP_TIS_TIMEOUT , &cap, -"attempting to determine the timeouts" , -sizeof (cap.timeout)); +sizeof (cap.timeout), +"attempting to determine the timeouts" ); }if (rc) {@@ -630,8 +630,8 @@ int tpm_get_timeouts(struct tpm_chip *chip) chip->timeout_d =usecs_to_jiffies (timeout_eff[3 ]); rc =tpm_getcap (chip,TPM_CAP_PROP_TIS_DURATION , &cap, -"attempting to determine the durations" , -sizeof (cap.duration)); +sizeof (cap.duration), +"attempting to determine the durations" );if (rc)return rc;drivers/char/tpm/tpm-sysfs.c +16
-17@@ -96,9 +96,8 @@ static ssize_t pcrs_show(struct device *dev, struct device_attribute *attr,char *str = buf;struct tpm_chip *chip =to_tpm_chip (dev); - rc =tpm_getcap (chip,TPM_CAP_PROP_PCR , &cap, -"attempting to determine the number of PCRS" , -sizeof (cap.num_pcrs)); + rc =tpm_getcap (chip,TPM_CAP_PROP_PCR , &cap,sizeof (cap.num_pcrs), +"attempting to determine the number of PCRS" );if (rc)return 0 ;@@ -123,8 +122,8 @@ static ssize_t enabled_show(struct device *dev, struct device_attribute *attr,ssize_t rc; rc =tpm_getcap (to_tpm_chip (dev),TPM_CAP_FLAG_PERM , &cap, -"attempting to determine the permanent enabled state" , -sizeof (cap.perm_flags)); +sizeof (cap.perm_flags), +"attempting to determine the permanent enabled state" );if (rc)return 0 ;@@ -140,8 +139,8 @@ static ssize_t active_show(struct device *dev, struct device_attribute *attr,ssize_t rc; rc =tpm_getcap (to_tpm_chip (dev),TPM_CAP_FLAG_PERM , &cap, -"attempting to determine the permanent active state" , -sizeof (cap.perm_flags)); +sizeof (cap.perm_flags), +"attempting to determine the permanent active state" );if (rc)return 0 ;@@ -157,8 +156,8 @@ static ssize_t owned_show(struct device *dev, struct device_attribute *attr,ssize_t rc; rc =tpm_getcap (to_tpm_chip (dev),TPM_CAP_PROP_OWNER , &cap, -"attempting to determine the owner state" , -sizeof (cap.owned)); +sizeof (cap.owned), +"attempting to determine the owner state" );if (rc)return 0 ;@@ -174,8 +173,8 @@ static ssize_t temp_deactivated_show(struct device *dev,ssize_t rc; rc =tpm_getcap (to_tpm_chip (dev),TPM_CAP_FLAG_VOL , &cap, -"attempting to determine the temporary state" , -sizeof (cap.stclear_flags)); +sizeof (cap.stclear_flags), +"attempting to determine the temporary state" );if (rc)return 0 ;@@ -193,8 +192,8 @@ static ssize_t caps_show(struct device *dev, struct device_attribute *attr,char *str = buf; rc =tpm_getcap (chip,TPM_CAP_PROP_MANUFACTURER , &cap, -"attempting to determine the manufacturer" , -sizeof (cap.manufacturer_id)); +sizeof (cap.manufacturer_id), +"attempting to determine the manufacturer" );if (rc)return 0 ; str += sprintf(str, "Manufacturer: 0x%x\n",@@ -202,8 +201,8 @@ static ssize_t caps_show(struct device *dev, struct device_attribute *attr,/* Try to get a TPM version 1.2 TPM_CAP_VERSION_INFO */ rc =tpm_getcap (chip,TPM_CAP_VERSION_1_2 , &cap, -"attempting to determine the 1.2 version" , -sizeof (cap.tpm_version_1_2)); +sizeof (cap.tpm_version_1_2), +"attempting to determine the 1.2 version" );if (!rc) { str += sprintf(str, "TCG version: %d.%d\nFirmware version: %d.%d\n",@@ -214,8 +213,8 @@ static ssize_t caps_show(struct device *dev, struct device_attribute *attr, }else {/* Otherwise just use TPM_STRUCT_VER */ rc =tpm_getcap (chip,TPM_CAP_VERSION_1_1 , &cap, -"attempting to determine the 1.1 version" , -sizeof (cap.tpm_version)); +sizeof (cap.tpm_version), +"attempting to determine the 1.1 version" );if (rc)return 0 ; str += sprintf(str,drivers/char/tpm/tpm.h +1
-1@@ -499,7 +499,7 @@ ssize_t tpm_transmit_cmd(struct tpm_chip *chip, const void *buf, size_t bufsiz, size_t min_rsp_body_len, unsigned int flags, const char *desc);ssize_t tpm_getcap (struct tpm_chip *chip,u32 subcap_id,cap_t *cap, -const char *desc,size_t min_cap_length); +size_t min_cap_length,const char *desc);int tpm_get_timeouts (struct tpm_chip *);int tpm1_auto_startup (struct tpm_chip *chip);int tpm_do_selftest (struct tpm_chip *chip);Signature · 1 line
2.9.3
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot