From patchwork Wed Jan 30 14:45:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liam Merwick X-Patchwork-Id: 10788717 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 596476C2 for ; Wed, 30 Jan 2019 14:46:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 469C82858F for ; Wed, 30 Jan 2019 14:46:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 380C22F155; Wed, 30 Jan 2019 14:46:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DA4012858F for ; Wed, 30 Jan 2019 14:46:38 +0000 (UTC) Received: from localhost ([127.0.0.1]:39283 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gor8P-0001BH-R2 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 30 Jan 2019 09:46:37 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59216) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gor7n-0001B8-D0 for qemu-devel@nongnu.org; Wed, 30 Jan 2019 09:46:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gor7m-0003br-Nv for qemu-devel@nongnu.org; Wed, 30 Jan 2019 09:45:59 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:60300) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gor7m-0003bd-Fp for qemu-devel@nongnu.org; Wed, 30 Jan 2019 09:45:58 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id x0UEjf2i067468; Wed, 30 Jan 2019 14:45:55 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2018-07-02; bh=ZBgqWrSsB3JkrU5gOsr/UB60PNAy0k988Nvm1axHeKI=; b=ihb3OZlebRbWO4vermkAGkCdUvyvqtH/y4IggRG7wMjHYVTJu5ITD7IFt2j5P4aswhvp EZ9hceWPbHojpwzu3oUJJYqbLxVESaMTpmkO1YoNPA0sgVMwyAghTkVgpr/WUi869O9K ulzsvae767kzodbDkT5xXs6DwO03BK1nDPFHk0yECeSug8xInlh1bk5VXN/WkjpdjDK4 iwaoaz1LpNl/7vBzaLp0AmC4Gg5W9qJRLLxdFZF3UygQFA+XfITM7Z2gfxQ0PfHrmORa JKXvuJBelL7dFMBa2Cu0jZYyyUpEWuL7TUY4xSo9wo6SfmfG6tkiZNvM+1JrocM6f2HD Uw== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2120.oracle.com with ESMTP id 2q8g6rauw9-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 30 Jan 2019 14:45:55 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x0UEjsdI017593 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 30 Jan 2019 14:45:54 GMT Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x0UEjrG9007365; Wed, 30 Jan 2019 14:45:53 GMT Received: from ol7.nl.oracle.com (/10.175.63.178) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 30 Jan 2019 06:45:52 -0800 From: Liam Merwick To: stefanb@linux.ibm.com, qemu-devel@nongnu.org Date: Wed, 30 Jan 2019 14:45:50 +0000 Message-Id: <1548859550-32019-1-git-send-email-liam.merwick@oracle.com> X-Mailer: git-send-email 1.8.3.1 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9151 signatures=668682 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=608 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1901300116 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 156.151.31.85 Subject: [Qemu-devel] [PATCH] tpm_tis: validate locality values don't overrun array X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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) {