Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'for-next-tpm-7.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jarkko/linux-tpmdd

Pull tpm updates from Jarkko Sakkinen:
"Here are the accumulated fixes for 7.1-rc1 and a single structural
change worth mentioning separately: Rafael's commit converting tpm_crb
from ACPI driver to a platform driver"

* tag 'for-next-tpm-7.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/jarkko/linux-tpmdd:
tpm: tpm_tis: stop transmit if retries are exhausted
tpm: tpm_tis: add error logging for data transfer
tpm: avoid -Wunused-but-set-variable
tpm: Use kfree_sensitive() to free auth session in tpm_dev_release()
tpm2-sessions: Fix missing tpm_buf_destroy() in tpm2_read_public()
tpm: Fix auth session leak in tpm2_get_random() error path
tpm: i2c: atmel: fix block comment formatting
tpm_crb: Convert ACPI driver to a platform one
tpm: Make tcpci_pm_ops variable static const

+64 -40
+1 -1
drivers/char/tpm/tpm-chip.c
··· 247 247 kfree(chip->work_space.context_buf); 248 248 kfree(chip->work_space.session_buf); 249 249 #ifdef CONFIG_TCG_TPM2_HMAC 250 - kfree(chip->auth); 250 + kfree_sensitive(chip->auth); 251 251 #endif 252 252 kfree(chip); 253 253 }
+3 -5
drivers/char/tpm/tpm2-cmd.c
··· 21 21 module_param(disable_pcr_integrity, bool, 0444); 22 22 MODULE_PARM_DESC(disable_pcr_integrity, "Disable integrity protection of TPM2_PCR_Extend"); 23 23 24 - struct tpm2_hash tpm2_hash_map[] = { 24 + static const struct tpm2_hash tpm2_hash_map[] = { 25 25 {HASH_ALGO_SHA1, TPM_ALG_SHA1}, 26 26 {HASH_ALGO_SHA256, TPM_ALG_SHA256}, 27 27 {HASH_ALGO_SHA384, TPM_ALG_SHA384}, ··· 295 295 } 296 296 tpm_buf_append_u16(&buf, num_bytes); 297 297 err = tpm_buf_fill_hmac_session(chip, &buf); 298 - if (err) { 299 - tpm_buf_destroy(&buf); 300 - return err; 301 - } 298 + if (err) 299 + goto out; 302 300 303 301 err = tpm_transmit_cmd(chip, &buf, 304 302 offsetof(struct tpm2_get_random_out,
+4 -1
drivers/char/tpm/tpm2-sessions.c
··· 203 203 rc = tpm_buf_read_u16(&buf, &offset); 204 204 name_size_alg = name_size(&buf.data[offset]); 205 205 206 - if (name_size_alg < 0) 206 + if (name_size_alg < 0) { 207 + tpm_buf_destroy(&buf); 207 208 return name_size_alg; 209 + } 208 210 209 211 if (rc != name_size_alg) { 210 212 tpm_buf_destroy(&buf); ··· 219 217 } 220 218 221 219 memcpy(name, &buf.data[offset], rc); 220 + tpm_buf_destroy(&buf); 222 221 return name_size_alg; 223 222 } 224 223 #endif /* CONFIG_TCG_TPM2_HMAC */
+16 -19
drivers/char/tpm/tpm_crb.c
··· 15 15 #include <linux/highmem.h> 16 16 #include <linux/rculist.h> 17 17 #include <linux/module.h> 18 + #include <linux/platform_device.h> 18 19 #include <linux/pm_runtime.h> 19 20 #ifdef CONFIG_ARM64 20 21 #include <linux/arm-smccc.h> ··· 603 602 return io_res->end - start + 1; 604 603 } 605 604 606 - static int crb_map_io(struct acpi_device *device, struct crb_priv *priv, 605 + static int crb_map_io(struct device *dev, struct crb_priv *priv, 607 606 struct acpi_table_tpm2 *buf) 608 607 { 608 + struct acpi_device *device = ACPI_COMPANION(dev); 609 609 struct list_head acpi_resource_list; 610 610 struct resource iores_array[TPM_CRB_MAX_RESOURCES + 1] = { {0} }; 611 611 void __iomem *iobase_array[TPM_CRB_MAX_RESOURCES] = {NULL}; 612 - struct device *dev = &device->dev; 613 612 struct resource *iores; 614 613 void __iomem **iobase_ptr; 615 614 int i; ··· 783 782 return 0; 784 783 } 785 784 786 - static int crb_acpi_add(struct acpi_device *device) 785 + static int crb_acpi_probe(struct platform_device *pdev) 787 786 { 787 + struct device *dev = &pdev->dev; 788 + struct acpi_device *device = ACPI_COMPANION(dev); 788 789 struct acpi_table_tpm2 *buf; 789 790 struct crb_priv *priv; 790 791 struct tpm_chip *chip; 791 - struct device *dev = &device->dev; 792 792 struct tpm2_crb_smc *crb_smc; 793 793 struct tpm2_crb_ffa *crb_ffa; 794 794 struct tpm2_crb_pluton *crb_pluton; ··· 869 867 priv->sm = sm; 870 868 priv->hid = acpi_device_hid(device); 871 869 872 - rc = crb_map_io(device, priv, buf); 870 + rc = crb_map_io(dev, priv, buf); 873 871 if (rc) 874 872 goto out; 875 873 ··· 903 901 return rc; 904 902 } 905 903 906 - static void crb_acpi_remove(struct acpi_device *device) 904 + static void crb_acpi_remove(struct platform_device *pdev) 907 905 { 908 - struct device *dev = &device->dev; 909 - struct tpm_chip *chip = dev_get_drvdata(dev); 910 - 911 - tpm_chip_unregister(chip); 906 + tpm_chip_unregister(platform_get_drvdata(pdev)); 912 907 } 913 908 914 909 static const struct dev_pm_ops crb_pm = { ··· 918 919 }; 919 920 MODULE_DEVICE_TABLE(acpi, crb_device_ids); 920 921 921 - static struct acpi_driver crb_acpi_driver = { 922 - .name = "tpm_crb", 923 - .ids = crb_device_ids, 924 - .ops = { 925 - .add = crb_acpi_add, 926 - .remove = crb_acpi_remove, 927 - }, 928 - .drv = { 922 + static struct platform_driver crb_acpi_driver = { 923 + .probe = crb_acpi_probe, 924 + .remove = crb_acpi_remove, 925 + .driver = { 926 + .name = "tpm_crb_acpi", 927 + .acpi_match_table = crb_device_ids, 929 928 .pm = &crb_pm, 930 929 }, 931 930 }; 932 931 933 - module_acpi_driver(crb_acpi_driver); 932 + module_platform_driver(crb_acpi_driver); 934 933 MODULE_AUTHOR("Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>"); 935 934 MODULE_DESCRIPTION("TPM2 Driver"); 936 935 MODULE_VERSION("0.1");
+23 -11
drivers/char/tpm/tpm_i2c_atmel.c
··· 31 31 32 32 struct priv_data { 33 33 size_t len; 34 - /* This is the amount we read on the first try. 25 was chosen to fit a 34 + /* 35 + * This is the amount we read on the first try. 25 was chosen to fit a 35 36 * fair number of read responses in the buffer so a 2nd retry can be 36 - * avoided in small message cases. */ 37 + * avoided in small message cases. 38 + */ 37 39 u8 buffer[sizeof(struct tpm_header) + 25]; 38 40 }; 39 41 ··· 60 58 if (status < 0) 61 59 return status; 62 60 63 - /* The upper layer does not support incomplete sends. */ 61 + /* 62 + * The upper layer does not support incomplete sends. 63 + */ 64 64 if (status != len) 65 65 return -E2BIG; 66 66 ··· 80 76 if (priv->len == 0) 81 77 return -EIO; 82 78 83 - /* Get the message size from the message header, if we didn't get the 79 + /* 80 + * Get the message size from the message header, if we didn't get the 84 81 * whole message in read_status then we need to re-read the 85 - * message. */ 82 + * message. 83 + */ 86 84 expected_len = be32_to_cpu(hdr->length); 87 85 if (expected_len > count) 88 86 return -ENOMEM; ··· 117 111 struct i2c_client *client = to_i2c_client(chip->dev.parent); 118 112 int rc; 119 113 120 - /* The TPM fails the I2C read until it is ready, so we do the entire 114 + /* 115 + * The TPM fails the I2C read until it is ready, so we do the entire 121 116 * transfer here and buffer it locally. This way the common code can 122 - * properly handle the timeouts. */ 117 + * properly handle the timeouts. 118 + */ 123 119 priv->len = 0; 124 120 memset(priv->buffer, 0, sizeof(priv->buffer)); 125 121 126 122 127 - /* Once the TPM has completed the command the command remains readable 128 - * until another command is issued. */ 123 + /* 124 + * Once the TPM has completed the command the command remains readable 125 + * until another command is issued. 126 + */ 129 127 rc = i2c_master_recv(client, priv->buffer, sizeof(priv->buffer)); 130 128 dev_dbg(&chip->dev, 131 129 "%s: sts=%d", __func__, rc); ··· 182 172 183 173 dev_set_drvdata(&chip->dev, priv); 184 174 185 - /* There is no known way to probe for this device, and all version 175 + /* 176 + * There is no known way to probe for this device, and all version 186 177 * information seems to be read via TPM commands. Thus we rely on the 187 - * TPM startup process in the common code to detect the device. */ 178 + * TPM startup process in the common code to detect the device. 179 + */ 188 180 189 181 return tpm_chip_register(chip); 190 182 }
+10 -1
drivers/char/tpm/tpm_tis_core.c
··· 471 471 status = tpm_tis_status(chip); 472 472 if (!itpm && (status & TPM_STS_DATA_EXPECT) == 0) { 473 473 rc = -EIO; 474 + dev_err(&chip->dev, "TPM_STS_DATA_EXPECT should be set. sts = 0x%08x\n", 475 + status); 474 476 goto out_err; 475 477 } 476 478 } ··· 493 491 status = tpm_tis_status(chip); 494 492 if (!itpm && (status & TPM_STS_DATA_EXPECT) != 0) { 495 493 rc = -EIO; 494 + dev_err(&chip->dev, "TPM_STS_DATA_EXPECT should be unset. sts = 0x%08x\n", 495 + status); 496 496 goto out_err; 497 497 } 498 498 ··· 556 552 break; 557 553 else if (rc != -EAGAIN && rc != -EIO) 558 554 /* Data transfer failed, not recoverable */ 559 - return rc; 555 + goto out_err; 560 556 561 557 usleep_range(priv->timeout_min, priv->timeout_max); 558 + } 559 + 560 + if (rc == -EAGAIN || rc == -EIO) { 561 + dev_err(&chip->dev, "Exhausted %d tpm_tis_send_data retries\n", TPM_RETRY); 562 + goto out_err; 562 563 } 563 564 564 565 /* go and do it */
+7 -2
include/linux/tpm_eventlog.h
··· 131 131 }; 132 132 133 133 #ifndef TPM_MEMREMAP 134 - #define TPM_MEMREMAP(start, size) NULL 134 + static inline void *TPM_MEMREMAP(unsigned long start, size_t size) 135 + { 136 + return NULL; 137 + } 135 138 #endif 136 139 137 140 #ifndef TPM_MEMUNMAP 138 - #define TPM_MEMUNMAP(start, size) do{} while(0) 141 + static inline void TPM_MEMUNMAP(void *mapping, size_t size) 142 + { 143 + } 139 144 #endif 140 145 141 146 /**