qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Liam Merwick <liam.merwick@oracle.com>
To: stefanb@linux.ibm.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] tpm_tis: validate locality values don't overrun array
Date: Wed, 30 Jan 2019 14:45:50 +0000	[thread overview]
Message-ID: <1548859550-32019-1-git-send-email-liam.merwick@oracle.com> (raw)

Assert that various locality values don't exceed TPM_TIS_NUM_LOCALITIES
by adding specific calls to assert(TPM_TIS_NUM_LOCALITIES(l)) in order
to help static code analysis.

Signed-off-by: Liam Merwick <liam.merwick@oracle.com>
---
 hw/tpm/tpm_tis.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/hw/tpm/tpm_tis.c b/hw/tpm/tpm_tis.c
index fd6bb9b59a96..2267bd8c346f 100644
--- a/hw/tpm/tpm_tis.c
+++ b/hw/tpm/tpm_tis.c
@@ -241,6 +241,9 @@ static void tpm_tis_abort(TPMState *s)
 {
     s->rw_offset = 0;
 
+    assert(TPM_TIS_IS_VALID_LOCTY(s->next_locty));
+    assert(TPM_TIS_IS_VALID_LOCTY(s->aborting_locty));
+
     trace_tpm_tis_abort(s->next_locty);
 
     /*
@@ -531,6 +534,8 @@ static void tpm_tis_mmio_write(void *opaque, hwaddr addr,
     uint16_t len;
     uint32_t mask = (size == 1) ? 0xff : ((size == 2) ? 0xffff : ~0);
 
+    assert(TPM_TIS_IS_VALID_LOCTY(locty));
+
     trace_tpm_tis_mmio_write(size, addr, val);
 
     if (locty == 4) {
-- 
1.8.3.1

             reply	other threads:[~2019-01-30 14:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-30 14:45 Liam Merwick [this message]
2019-02-04 18:05 ` [Qemu-devel] [PATCH] tpm_tis: validate locality values don't overrun array Stefan Berger
2019-02-08 20:10   ` Liam Merwick
2019-02-08 20:38     ` Stefan Berger
2019-02-08 21:29       ` Stefan Berger

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=1548859550-32019-1-git-send-email-liam.merwick@oracle.com \
    --to=liam.merwick@oracle.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanb@linux.ibm.com \
    /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;
as well as URLs for NNTP newsgroup(s).