From patchwork Tue Dec 12 04:15:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Prasad Pandit X-Patchwork-Id: 10106187 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6D152602B3 for ; Tue, 12 Dec 2017 04:16:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 60EB82950F for ; Tue, 12 Dec 2017 04:16:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 544AC28700; Tue, 12 Dec 2017 04:16:44 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 129EA28700 for ; Tue, 12 Dec 2017 04:16:42 +0000 (UTC) Received: from localhost ([::1]:56593 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eObzk-0005va-Rf for patchwork-qemu-devel@patchwork.kernel.org; Mon, 11 Dec 2017 23:16:40 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37912) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eObyz-0005Vx-TJ for qemu-devel@nongnu.org; Mon, 11 Dec 2017 23:15:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eObyy-00081U-V7 for qemu-devel@nongnu.org; Mon, 11 Dec 2017 23:15:53 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44750) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eObyt-0007xt-7u; Mon, 11 Dec 2017 23:15:47 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 25F997E42C; Tue, 12 Dec 2017 04:15:46 +0000 (UTC) Received: from localhost.localdomain (ovpn-116-106.sin2.redhat.com [10.67.116.106]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E2C2617B94; Tue, 12 Dec 2017 04:15:43 +0000 (UTC) From: P J P To: Qemu Developers Date: Tue, 12 Dec 2017 09:45:39 +0530 Message-Id: <20171212041539.25700-1-ppandit@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 12 Dec 2017 04:15:46 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v1] display: limit irq handler index to TC6393XB_GPIOS 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: , Cc: Peter Maydell , qemu-arm@nongnu.org, Moguofang , Prasad J Pandit Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Prasad J Pandit The ctz32() routine could return value greater than TC6393XB_GPIOS=16. This could lead to an OOB array access. Mask 'level' to avoid it. Reported-by: Moguofang Signed-off-by: Prasad J Pandit --- hw/display/tc6393xb.c | 1 + 1 file changed, 1 insertion(+) Update: mask 'level' value to TC6393XB_GPIOS=16 -> https://lists.gnu.org/archive/html/qemu-devel/2017-12/msg01685.html diff --git a/hw/display/tc6393xb.c b/hw/display/tc6393xb.c index 74d10af3d4..0ae63605f0 100644 --- a/hw/display/tc6393xb.c +++ b/hw/display/tc6393xb.c @@ -172,6 +172,7 @@ static void tc6393xb_gpio_handler_update(TC6393xbState *s) int bit; level = s->gpio_level & s->gpio_dir; + level &= MAKE_64BIT_MASK(0, TC6393XB_GPIOS); for (diff = s->prev_level ^ level; diff; diff ^= 1 << bit) { bit = ctz32(diff);