All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jarkko Sakkinen <jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
To: Stefan Berger
	<stefanb-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
Cc: linux-security-module-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
	open list <linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: Re: [PATCH RFC v4 1/5] tpm: validate TPM 2.0 commands
Date: Mon, 23 Jan 2017 23:44:35 +0200	[thread overview]
Message-ID: <20170123214435.6aa75rgy6b3gdfpv@intel.com> (raw)
In-Reply-To: <b5837ab8-0edd-86cf-c17d-36d55754219e-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>

On Sun, Jan 22, 2017 at 09:02:17PM -0500, Stefan Berger wrote:
> 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

Thanks. I'll put 9 + 4 * nr_commands as the expected size.

/Jarkko

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot

WARNING: multiple messages have this Message-ID (diff)
From: Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>
To: Stefan Berger <stefanb@linux.vnet.ibm.com>
Cc: tpmdd-devel@lists.sourceforge.net,
	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: Mon, 23 Jan 2017 23:44:35 +0200	[thread overview]
Message-ID: <20170123214435.6aa75rgy6b3gdfpv@intel.com> (raw)
In-Reply-To: <b5837ab8-0edd-86cf-c17d-36d55754219e@linux.vnet.ibm.com>

On Sun, Jan 22, 2017 at 09:02:17PM -0500, Stefan Berger wrote:
> 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

Thanks. I'll put 9 + 4 * nr_commands as the expected size.

/Jarkko

  parent reply	other threads:[~2017-01-23 21:44 UTC|newest]

Thread overview: 34+ 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 ` Jarkko Sakkinen
2017-01-22 23:44 ` [PATCH RFC v4 1/5] tpm: validate TPM 2.0 commands Jarkko Sakkinen
2017-01-22 23:44   ` Jarkko Sakkinen
2017-01-23  2:02   ` [tpmdd-devel] " Stefan Berger
     [not found]     ` <b5837ab8-0edd-86cf-c17d-36d55754219e-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
2017-01-23 21:44       ` Jarkko Sakkinen [this message]
2017-01-23 21:44         ` Jarkko Sakkinen
     [not found] ` <20170122234438.12102-1-jarkko.sakkinen-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2017-01-22 23:44   ` [PATCH RFC v4 2/5] tpm: export tpm2_flush_context_cmd Jarkko Sakkinen
2017-01-22 23:44     ` 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:44     ` Jarkko Sakkinen
2017-01-23 17:01   ` [PATCH RFC v4 0/5] RFC: in-kernel resource manager James Bottomley
2017-01-23 17:01     ` [tpmdd-devel] " James Bottomley
2017-01-24  0:04     ` Jarkko Sakkinen
2017-01-22 23:44 ` [PATCH RFC v4 3/5] tpm: infrastructure for TPM spaces Jarkko Sakkinen
2017-01-22 23:44   ` 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-22 23:44   ` 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
     [not found]                 ` <20170123233028.GA24370-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-01-23 23:45                   ` James Bottomley
2017-01-23 23:45                     ` [tpmdd-devel] " James Bottomley
     [not found]                     ` <1485215158.2534.53.camel-d9PhHud1JfjCXq6kfMZ53/egYHeGw8Jk@public.gmane.org>
2017-01-24  0:04                       ` Jason Gunthorpe
2017-01-24  0:04                         ` [tpmdd-devel] " Jason Gunthorpe
2017-01-24 14:30       ` Jarkko Sakkinen
     [not found]     ` <20170123164754.GA29360-ePGOBjL8dl3ta4EC/59zMFaTQe2KTcn/@public.gmane.org>
2017-01-24 14:28       ` Jarkko Sakkinen
2017-01-24 14:28         ` Jarkko Sakkinen
2017-01-22 23:50 ` [PATCH RFC v4 0/5] RFC: in-kernel resource manager 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=20170123214435.6aa75rgy6b3gdfpv@intel.com \
    --to=jarkko.sakkinen-vuqaysv1563yd54fqh9/ca@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-security-module-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=stefanb-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org \
    --cc=tpmdd-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.