* [Qemu-devel] [PATCH 1/2] tpm: check localities index
@ 2018-11-06 5:21 P J P
2018-11-06 5:21 ` [Qemu-devel] [PATCH 2/2] tpm: use loop iterator to set sts data field P J P
2018-11-06 8:07 ` [Qemu-devel] [PATCH 1/2] tpm: check localities index Marc-André Lureau
0 siblings, 2 replies; 6+ messages in thread
From: P J P @ 2018-11-06 5:21 UTC (permalink / raw)
To: Qemu Developers; +Cc: Stefan Berger, Prasad J Pandit
From: Prasad J Pandit <pjp@fedoraproject.org>
While performing mmio device r/w operations, guest could set 'addr'
parameter such that 'locty' index exceeds TPM_TIS_NUM_LOCALITIES=5.
Add check to avoid OOB access.
Reported-by: Cheng Feng <PSIRT@huawei.com>
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
---
hw/tpm/tpm_tis.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c
index 12f5c9a759..20126dd838 100644
--- a/hw/tpm/tpm_tis.c
+++ b/hw/tpm/tpm_tis.c
@@ -293,6 +293,10 @@ static void tpm_tis_request_completed(TPMIf *ti, int ret)
uint8_t locty = s->cmd.locty;
uint8_t l;
+ if (locty >= TPM_TIS_NUM_LOCALITIES) {
+ return;
+ }
+
if (s->cmd.selftest_done) {
for (l = 0; l < TPM_TIS_NUM_LOCALITIES; l++) {
s->loc[locty].sts |= TPM_TIS_STS_SELFTEST_DONE;
@@ -401,7 +405,8 @@ static uint64_t tpm_tis_mmio_read(void *opaque, hwaddr addr,
uint32_t avail;
uint8_t v;
- if (tpm_backend_had_startup_error(s->be_driver)) {
+ if (tpm_backend_had_startup_error(s->be_driver)
+ || locty >= TPM_TIS_NUM_LOCALITIES) {
return 0;
}
@@ -530,7 +535,8 @@ static void tpm_tis_mmio_write(void *opaque, hwaddr addr,
return;
}
- if (tpm_backend_had_startup_error(s->be_driver)) {
+ if (tpm_backend_had_startup_error(s->be_driver)
+ || locty >= TPM_TIS_NUM_LOCALITIES) {
return;
}
--
2.17.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Qemu-devel] [PATCH 2/2] tpm: use loop iterator to set sts data field
2018-11-06 5:21 [Qemu-devel] [PATCH 1/2] tpm: check localities index P J P
@ 2018-11-06 5:21 ` P J P
2018-11-06 8:13 ` Marc-André Lureau
2018-11-06 14:26 ` Stefan Berger
2018-11-06 8:07 ` [Qemu-devel] [PATCH 1/2] tpm: check localities index Marc-André Lureau
1 sibling, 2 replies; 6+ messages in thread
From: P J P @ 2018-11-06 5:21 UTC (permalink / raw)
To: Qemu Developers; +Cc: Stefan Berger, Prasad J Pandit
From: Prasad J Pandit <pjp@fedoraproject.org>
When TIS request is done, set 'sts' data field across all localities.
Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
---
hw/tpm/tpm_tis.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c
index 20126dd838..58d90645bc 100644
--- a/hw/tpm/tpm_tis.c
+++ b/hw/tpm/tpm_tis.c
@@ -299,7 +299,7 @@ static void tpm_tis_request_completed(TPMIf *ti, int ret)
if (s->cmd.selftest_done) {
for (l = 0; l < TPM_TIS_NUM_LOCALITIES; l++) {
- s->loc[locty].sts |= TPM_TIS_STS_SELFTEST_DONE;
+ s->loc[l].sts |= TPM_TIS_STS_SELFTEST_DONE;
}
}
--
2.17.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH 1/2] tpm: check localities index
2018-11-06 5:21 [Qemu-devel] [PATCH 1/2] tpm: check localities index P J P
2018-11-06 5:21 ` [Qemu-devel] [PATCH 2/2] tpm: use loop iterator to set sts data field P J P
@ 2018-11-06 8:07 ` Marc-André Lureau
1 sibling, 0 replies; 6+ messages in thread
From: Marc-André Lureau @ 2018-11-06 8:07 UTC (permalink / raw)
To: P J P; +Cc: QEMU, Prasad J Pandit, Stefan Berger
Hi
On Tue, Nov 6, 2018 at 9:25 AM P J P <ppandit@redhat.com> wrote:
>
> From: Prasad J Pandit <pjp@fedoraproject.org>
>
> While performing mmio device r/w operations, guest could set 'addr'
> parameter such that 'locty' index exceeds TPM_TIS_NUM_LOCALITIES=5.
> Add check to avoid OOB access.
>
Unless memory_region_init_io() is broken, and the region size is >
TPM_TIS_NUM_LOCALITIES << TPM_TIS_LOCALITY_SHIFT, I don't see how that
could happen. Do you have a reproducer?
Perhaps replace the conditions with an assert instead?
> Reported-by: Cheng Feng <PSIRT@huawei.com>
> Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
> ---
> hw/tpm/tpm_tis.c | 10 ++++++++--
> 1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c
> index 12f5c9a759..20126dd838 100644
> --- a/hw/tpm/tpm_tis.c
> +++ b/hw/tpm/tpm_tis.c
> @@ -293,6 +293,10 @@ static void tpm_tis_request_completed(TPMIf *ti, int ret)
> uint8_t locty = s->cmd.locty;
> uint8_t l;
>
> + if (locty >= TPM_TIS_NUM_LOCALITIES) {
> + return;
> + }
> +
> if (s->cmd.selftest_done) {
> for (l = 0; l < TPM_TIS_NUM_LOCALITIES; l++) {
> s->loc[locty].sts |= TPM_TIS_STS_SELFTEST_DONE;
> @@ -401,7 +405,8 @@ static uint64_t tpm_tis_mmio_read(void *opaque, hwaddr addr,
> uint32_t avail;
> uint8_t v;
>
> - if (tpm_backend_had_startup_error(s->be_driver)) {
> + if (tpm_backend_had_startup_error(s->be_driver)
> + || locty >= TPM_TIS_NUM_LOCALITIES) {
> return 0;
> }
>
> @@ -530,7 +535,8 @@ static void tpm_tis_mmio_write(void *opaque, hwaddr addr,
> return;
> }
>
> - if (tpm_backend_had_startup_error(s->be_driver)) {
> + if (tpm_backend_had_startup_error(s->be_driver)
> + || locty >= TPM_TIS_NUM_LOCALITIES) {
> return;
> }
>
> --
> 2.17.2
>
>
--
Marc-André Lureau
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH 2/2] tpm: use loop iterator to set sts data field
2018-11-06 5:21 ` [Qemu-devel] [PATCH 2/2] tpm: use loop iterator to set sts data field P J P
@ 2018-11-06 8:13 ` Marc-André Lureau
2018-11-06 14:28 ` Stefan Berger
2018-11-06 14:26 ` Stefan Berger
1 sibling, 1 reply; 6+ messages in thread
From: Marc-André Lureau @ 2018-11-06 8:13 UTC (permalink / raw)
To: P J P; +Cc: QEMU, Prasad J Pandit, Stefan Berger
Hi
On Tue, Nov 6, 2018 at 9:24 AM P J P <ppandit@redhat.com> wrote:
>
> From: Prasad J Pandit <pjp@fedoraproject.org>
>
> When TIS request is done, set 'sts' data field across all localities.
The code certainly meant to set the field across all localities.
However I don't see in the "TCG PC Client Specific TPM Interface
Specification (TIS)" where it states that the field should be set
across all localities. Could you quote the relevant part?
thanks
> Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
> ---
> hw/tpm/tpm_tis.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c
> index 20126dd838..58d90645bc 100644
> --- a/hw/tpm/tpm_tis.c
> +++ b/hw/tpm/tpm_tis.c
> @@ -299,7 +299,7 @@ static void tpm_tis_request_completed(TPMIf *ti, int ret)
>
> if (s->cmd.selftest_done) {
> for (l = 0; l < TPM_TIS_NUM_LOCALITIES; l++) {
> - s->loc[locty].sts |= TPM_TIS_STS_SELFTEST_DONE;
> + s->loc[l].sts |= TPM_TIS_STS_SELFTEST_DONE;
> }
> }
>
> --
> 2.17.2
>
>
--
Marc-André Lureau
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH 2/2] tpm: use loop iterator to set sts data field
2018-11-06 5:21 ` [Qemu-devel] [PATCH 2/2] tpm: use loop iterator to set sts data field P J P
2018-11-06 8:13 ` Marc-André Lureau
@ 2018-11-06 14:26 ` Stefan Berger
1 sibling, 0 replies; 6+ messages in thread
From: Stefan Berger @ 2018-11-06 14:26 UTC (permalink / raw)
To: P J P, Qemu Developers; +Cc: Prasad J Pandit, Stefan Berger
On 11/6/18 12:21 AM, P J P wrote:
> From: Prasad J Pandit <pjp@fedoraproject.org>
>
> When TIS request is done, set 'sts' data field across all localities.
>
> Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
Reviewed-by: Stefan Berger <stefanb@linux.ibm.com>
> ---
> hw/tpm/tpm_tis.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c
> index 20126dd838..58d90645bc 100644
> --- a/hw/tpm/tpm_tis.c
> +++ b/hw/tpm/tpm_tis.c
> @@ -299,7 +299,7 @@ static void tpm_tis_request_completed(TPMIf *ti, int ret)
>
> if (s->cmd.selftest_done) {
> for (l = 0; l < TPM_TIS_NUM_LOCALITIES; l++) {
> - s->loc[locty].sts |= TPM_TIS_STS_SELFTEST_DONE;
> + s->loc[l].sts |= TPM_TIS_STS_SELFTEST_DONE;
> }
> }
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH 2/2] tpm: use loop iterator to set sts data field
2018-11-06 8:13 ` Marc-André Lureau
@ 2018-11-06 14:28 ` Stefan Berger
0 siblings, 0 replies; 6+ messages in thread
From: Stefan Berger @ 2018-11-06 14:28 UTC (permalink / raw)
To: Marc-André Lureau, P J P; +Cc: Stefan Berger, QEMU, Prasad J Pandit
On 11/6/18 3:13 AM, Marc-André Lureau wrote:
> Hi
>
> On Tue, Nov 6, 2018 at 9:24 AM P J P <ppandit@redhat.com> wrote:
>> From: Prasad J Pandit <pjp@fedoraproject.org>
>>
>> When TIS request is done, set 'sts' data field across all localities.
> The code certainly meant to set the field across all localities.
> However I don't see in the "TCG PC Client Specific TPM Interface
> Specification (TIS)" where it states that the field should be set
> across all localities. Could you quote the relevant part?
I don't see it explicitly mentioned but would interpret it as being a
flag across all localities.
Stefan
>
> thanks
>
>> Signed-off-by: Prasad J Pandit <pjp@fedoraproject.org>
>> ---
>> hw/tpm/tpm_tis.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c
>> index 20126dd838..58d90645bc 100644
>> --- a/hw/tpm/tpm_tis.c
>> +++ b/hw/tpm/tpm_tis.c
>> @@ -299,7 +299,7 @@ static void tpm_tis_request_completed(TPMIf *ti, int ret)
>>
>> if (s->cmd.selftest_done) {
>> for (l = 0; l < TPM_TIS_NUM_LOCALITIES; l++) {
>> - s->loc[locty].sts |= TPM_TIS_STS_SELFTEST_DONE;
>> + s->loc[l].sts |= TPM_TIS_STS_SELFTEST_DONE;
>> }
>> }
>>
>> --
>> 2.17.2
>>
>>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-11-06 14:28 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-06 5:21 [Qemu-devel] [PATCH 1/2] tpm: check localities index P J P
2018-11-06 5:21 ` [Qemu-devel] [PATCH 2/2] tpm: use loop iterator to set sts data field P J P
2018-11-06 8:13 ` Marc-André Lureau
2018-11-06 14:28 ` Stefan Berger
2018-11-06 14:26 ` Stefan Berger
2018-11-06 8:07 ` [Qemu-devel] [PATCH 1/2] tpm: check localities index Marc-André Lureau
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.