From: Stefan Berger <stefanb@linux.vnet.ibm.com>
To: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>,
tpmdd-devel@lists.sourceforge.net
Cc: open list <linux-kernel@vger.kernel.org>,
linux-security-module@vger.kernel.org
Subject: Re: [tpmdd-devel] [PATCH RFC v4 1/5] tpm: validate TPM 2.0 commands
Date: Sun, 22 Jan 2017 21:02:17 -0500 [thread overview]
Message-ID: <b5837ab8-0edd-86cf-c17d-36d55754219e@linux.vnet.ibm.com> (raw)
In-Reply-To: <20170122234438.12102-2-jarkko.sakkinen@linux.intel.com>
On 01/22/2017 06:44 PM, Jarkko Sakkinen wrote:
> @@ -1025,8 +1029,60 @@ int tpm2_auto_startup(struct tpm_chip *chip)
> }
> }
>
> + rc = tpm2_get_tpm_pt(chip, TPM_PT_TOTAL_COMMANDS, &nr_commands, NULL);
> + if (rc)
> + goto out;
> +
> + /* sanity check */
> + if (nr_commands > INT_MAX) {
> + rc = -E2BIG;
> + goto out;
> + }
> +
> + chip->cc_attrs_tbl = devm_kzalloc(&chip->dev, 4 * nr_commands,
> + GFP_KERNEL);
> +
> + rc = tpm_buf_init(&buf, TPM2_ST_NO_SESSIONS, TPM2_CC_GET_CAPABILITY);
> + if (rc)
> + goto out;
> +
> + tpm_buf_append_u32(&buf, TPM2_CAP_COMMANDS);
> + tpm_buf_append_u32(&buf, TPM2_CC_FIRST);
> + tpm_buf_append_u32(&buf, nr_commands);
> +
> + rc = tpm_transmit_cmd(chip, buf.data, PAGE_SIZE, 0, 0, NULL);
You should probably pass the min_rsp_body_size as 5 + 4 + nr_commands * 4
> + if (rc < 0) {
> + tpm_buf_destroy(&buf);
> + goto out;
> + }
> +
> + if (nr_commands !=
> + be32_to_cpup((__be32 *)&buf.data[TPM_HEADER_SIZE + 5])) {
> + tpm_buf_destroy(&buf);
> + goto out;
> + }
> +
> + chip->nr_commands = nr_commands;
> +
> + attrs = (u32 *)&buf.data[TPM_HEADER_SIZE + 9];
> + for (i = 0; i < nr_commands; i++, attrs++)
> + chip->cc_attrs_tbl[i] = be32_to_cpup(attrs);
> +
> + tpm_buf_destroy(&buf);
> +
> out:
> if (rc > 0)
> rc = -ENODEV;
> return rc;
> }
> +
> +int tpm2_find_cc(struct tpm_chip *chip, u32 cc)
> +{
> + int i;
> +
> + for (i = 0; i < chip->nr_commands; i++)
> + if (cc == (chip->cc_attrs_tbl[i] & GENMASK(15, 0)))
> + return i;
> +
> + return -1;
> +}
next prev parent reply other threads:[~2017-01-23 2:02 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-22 23:44 [PATCH RFC v4 0/5] RFC: in-kernel resource manager Jarkko Sakkinen
2017-01-22 23:44 ` [PATCH RFC v4 1/5] tpm: validate TPM 2.0 commands Jarkko Sakkinen
2017-01-23 2:02 ` Stefan Berger [this message]
2017-01-23 21:44 ` [tpmdd-devel] " Jarkko Sakkinen
2017-01-22 23:44 ` [PATCH RFC v4 2/5] tpm: export tpm2_flush_context_cmd Jarkko Sakkinen
2017-01-22 23:44 ` [PATCH RFC v4 3/5] tpm: infrastructure for TPM spaces Jarkko Sakkinen
2017-01-23 0:00 ` Jarkko Sakkinen
2017-01-22 23:44 ` [PATCH RFC v4 4/5] tpm: split out tpm-dev.c into tpm-dev.c and tpm-common-dev.c Jarkko Sakkinen
2017-01-23 16:47 ` Jason Gunthorpe
2017-01-23 22:28 ` [tpmdd-devel] " James Bottomley
2017-01-23 22:49 ` Jason Gunthorpe
2017-01-23 22:57 ` James Bottomley
2017-01-23 23:04 ` Jason Gunthorpe
2017-01-23 23:20 ` James Bottomley
2017-01-23 23:30 ` Jason Gunthorpe
2017-01-23 23:45 ` James Bottomley
2017-01-24 0:04 ` Jason Gunthorpe
2017-01-24 14:30 ` Jarkko Sakkinen
2017-01-24 14:28 ` Jarkko Sakkinen
2017-01-22 23:44 ` [PATCH RFC v4 5/5] tpm2: expose spaces via a device link /dev/tpms<n> Jarkko Sakkinen
2017-01-22 23:50 ` [PATCH RFC v4 0/5] RFC: in-kernel resource manager Jarkko Sakkinen
2017-01-23 17:01 ` [tpmdd-devel] " James Bottomley
2017-01-24 0:04 ` Jarkko Sakkinen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=b5837ab8-0edd-86cf-c17d-36d55754219e@linux.vnet.ibm.com \
--to=stefanb@linux.vnet.ibm.com \
--cc=jarkko.sakkinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=tpmdd-devel@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®