Skip to content

Commit

Permalink
Merge tag 'tpmdd-next-20190925' of git://git.infradead.org/users/jjs/…
Browse files Browse the repository at this point in the history
…linux-tpmdd

Pull tpm fixes from Jarkko Sakkinen.

* tag 'tpmdd-next-20190925' of git://git.infradead.org/users/jjs/linux-tpmdd:
  tpm: Wrap the buffer from the caller to tpm_buf in tpm_send()
  MAINTAINERS: keys: Update path to trusted.h
  KEYS: trusted: correctly initialize digests and fix locking issue
  selftests/tpm2: Add log and *.pyc to .gitignore
  selftests/tpm2: Add the missing TEST_FILES assignment
  • Loading branch information
Linus Torvalds committed Sep 25, 2019
2 parents 4ef5b13 + e13cd21 commit 301310c
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 13 deletions.
2 changes: 1 addition & 1 deletion MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -9056,7 +9056,7 @@ S: Supported
F: Documentation/security/keys/trusted-encrypted.rst
F: include/keys/trusted-type.h
F: security/keys/trusted.c
F: security/keys/trusted.h
F: include/keys/trusted.h

KEYS/KEYRINGS:
M: David Howells <dhowells@redhat.com>
Expand Down
23 changes: 11 additions & 12 deletions drivers/char/tpm/tpm-interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -320,18 +320,22 @@ int tpm_pcr_extend(struct tpm_chip *chip, u32 pcr_idx,
if (!chip)
return -ENODEV;

for (i = 0; i < chip->nr_allocated_banks; i++)
if (digests[i].alg_id != chip->allocated_banks[i].alg_id)
return -EINVAL;
for (i = 0; i < chip->nr_allocated_banks; i++) {
if (digests[i].alg_id != chip->allocated_banks[i].alg_id) {
rc = EINVAL;
goto out;
}
}

if (chip->flags & TPM_CHIP_FLAG_TPM2) {
rc = tpm2_pcr_extend(chip, pcr_idx, digests);
tpm_put_ops(chip);
return rc;
goto out;
}

rc = tpm1_pcr_extend(chip, pcr_idx, digests[0].digest,
"attempting extend a PCR value");

out:
tpm_put_ops(chip);
return rc;
}
Expand All @@ -354,14 +358,9 @@ int tpm_send(struct tpm_chip *chip, void *cmd, size_t buflen)
if (!chip)
return -ENODEV;

rc = tpm_buf_init(&buf, 0, 0);
if (rc)
goto out;

memcpy(buf.data, cmd, buflen);
buf.data = cmd;
rc = tpm_transmit_cmd(chip, &buf, 0, "attempting to a send a command");
tpm_buf_destroy(&buf);
out:

tpm_put_ops(chip);
return rc;
}
Expand Down
5 changes: 5 additions & 0 deletions security/keys/trusted.c
Original file line number Diff line number Diff line change
Expand Up @@ -1228,11 +1228,16 @@ static int __init trusted_shash_alloc(void)

static int __init init_digests(void)
{
int i;

digests = kcalloc(chip->nr_allocated_banks, sizeof(*digests),
GFP_KERNEL);
if (!digests)
return -ENOMEM;

for (i = 0; i < chip->nr_allocated_banks; i++)
digests[i].alg_id = chip->allocated_banks[i].alg_id;

return 0;
}

Expand Down
2 changes: 2 additions & 0 deletions tools/testing/selftests/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ gpiogpio-event-mon
gpiogpio-hammer
gpioinclude/
gpiolsgpio
tpm2/SpaceTest.log
tpm2/*.pyc
1 change: 1 addition & 0 deletions tools/testing/selftests/tpm2/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
include ../lib.mk

TEST_PROGS := test_smoke.sh test_space.sh
TEST_FILES := tpm2.py tpm2_tests.py

0 comments on commit 301310c

Please sign in to comment.