From: Stefan Berger <stefanb@linux.vnet.ibm.com>
To: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
Cc: tpmdd-devel@lists.sourceforge.net,
linux-security-module@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v6] tpm: Check size of response before accessing data
Date: Wed, 18 Jan 2017 08:53:19 -0500 [thread overview]
Message-ID: <33bb28b4-6dd5-8455-de44-12b2980006e1@linux.vnet.ibm.com> (raw)
In-Reply-To: <20170118133646.uvbkt7d4blv2pdbn@intel.com>
On 01/18/2017 08:36 AM, Jarkko Sakkinen wrote:
> On Tue, Jan 17, 2017 at 05:27:47PM -0500, Stefan Berger wrote:
>> On 01/17/2017 09:49 AM, Jarkko Sakkinen wrote:
>>> On Mon, Jan 16, 2017 at 04:41:11PM -0500, Stefan Berger wrote:
>>>
>>>> + * @min_rx_length: minimum expected length of response
>>> Please, rename as min_rsp_body_len and change the description
>>> accordingly.
>>>
>>>> * @flags: tpm transmit flags - bitmap
>>>> * @desc: command description used in the error message
>>>> *
>>>> @@ -434,25 +435,34 @@ ssize_t tpm_transmit(struct tpm_chip *chip, const u8 *buf, size_t bufsiz,
>>>> * A positive number for a TPM error.
>>>> */
>>>> ssize_t tpm_transmit_cmd(struct tpm_chip *chip, const void *cmd,
>>>> - int len, unsigned int flags, const char *desc)
>>>> + size_t cmd_length, size_t min_rx_length,
>>>> + unsigned int flags, const char *desc)
>>>> {
>>>> const struct tpm_output_header *header;
>>>> int err;
>>>> + ssize_t len;
>>>> - len = tpm_transmit(chip, (const u8 *)cmd, len, flags);
>>>> + len = tpm_transmit(chip, (const u8 *)cmd, cmd_length, flags);
>>>> if (len < 0)
>>>> return len;
>>>> else if (len < TPM_HEADER_SIZE)
>>>> return -EFAULT;
>>>> header = cmd;
>>>> + if (len < be32_to_cpu(header->length))
>>>> + return -EFAULT;
>>>> err = be32_to_cpu(header->return_code);
>>>> if (err != 0 && desc)
>>>> dev_err(&chip->dev, "A TPM error (%d) occurred %s\n", err,
>>>> desc);
>>>> + if (err)
>>>> + return err;
>>>> - return err;
>>>> + if (be32_to_cpu(header->length) < min_rx_length)
>>>> + return -EFAULT;
>>>> +
>>>> + return 0;
>>>> }
>>>> #define TPM_DIGEST_SIZE 20
>>>> @@ -468,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)
>>>> + const char *desc, size_t min_cap_length)
>>> tpm_getcap update should be its own commit.
>> tpm_getcap needs to pass something as min_rsp_body_length to
>> tpm_transmit_cmd. What would it pass?
> I do not understand the problem. You are already
>
> TPM_HEADER_SIZE + min_cap_length
When we make this two patches (commits), what would tpm_getcap pass to
tpm_transmit_cmd in the place of the min_rsp_body_length parameter? I
don't think it makes sense to split up this patch.
next prev parent reply other threads:[~2017-01-18 13:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-16 21:41 Stefan Berger
2017-01-17 14:49 ` Jarkko Sakkinen
2017-01-17 22:27 ` Stefan Berger
2017-01-18 13:36 ` Jarkko Sakkinen
2017-01-18 13:53 ` Stefan Berger [this message]
2017-01-19 10:44 ` 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=33bb28b4-6dd5-8455-de44-12b2980006e1@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®