From patchwork Fri Dec 9 01:17:04 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 9467337 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 14BA1607D4 for ; Fri, 9 Dec 2016 01:19:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0D69F28618 for ; Fri, 9 Dec 2016 01:19:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F2F6A28631; Fri, 9 Dec 2016 01:19:23 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6355828618 for ; Fri, 9 Dec 2016 01:19:23 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cF9oE-0003J8-HL; Fri, 09 Dec 2016 01:17:10 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cF9oD-0003J2-Q8 for xen-devel@lists.xenproject.org; Fri, 09 Dec 2016 01:17:09 +0000 Received: from [85.158.139.211] by server-6.bemta-5.messagelabs.com id 7C/42-14841-5160A485; Fri, 09 Dec 2016 01:17:09 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrFIsWRWlGSWpSXmKPExsVybKJsh64Im1e EweIGbYvvWyYzOTB6HP5whSWAMYo1My8pvyKBNePpy1b2grMsFb8PnWRvYHzG3MXIxSEkMJVR 4vK9Z4wQzmwmiePH3rJ2MXJysAhoSfy+8IUFxGYTMJT4+2QTWxcjB4cEkL3kMwdIWERASeLeq slMIDazgIHElmc/2EFsYQELib3NW8BaeQW8JXasvMAGYosK6Eoc+veHDSIuKHFy5hMWiF4tie XTt4HZEgIZEvN65rBC2F4Si25cgrLVJK6e28Q8gZF/FpL2WUjaFzAyrWLUKE4tKkst0jU01ks qykzPKMlNzMzRNTQw1ctNLS5OTE/NSUwq1kvOz93ECAw3BiDYwfhvm+chRkkOJiVR3mImrwgh vqT8lMqMxOKM+KLSnNTiQ4wyHBxKEry8rEA5waLU9NSKtMwcYODDpCU4eJREeGWZgdK8xQWJu cWZ6RCpU4y6HAfer3jKJMSSl5+XKiXOe5EFqEgApCijNA9uBCwKLzHKSgnzMgIdJcRTkFqUm1 mCKv+KUZyDUUmYVwPkEp7MvBK4Ta+AjmACOmLeDXeQI0oSEVJSDYz83/h0b6oGBS/2fF67dUe ZsnSnwVbBmn+Hgi2eXL9wvtfpOaOuSNEF+Vsnox4K1edMZVd2WePLclz9n1P42XShYCGrKev+ WmueavP9KK9jl+C8L8Gj/sy+WrezFuEnlPa5nkx8zxySzXpReZKZ6v39SXYbuqrf8DTzCrTV9 Lcra1+MWOXkpsRSnJFoqMVcVJwIAD84XsG9AgAA X-Env-Sender: sstabellini@kernel.org X-Msg-Ref: server-10.tower-206.messagelabs.com!1481246227!57374458!1 X-Originating-IP: [198.145.29.136] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.0.16; banners=-,-,- X-VirusChecked: Checked Received: (qmail 17443 invoked from network); 9 Dec 2016 01:17:08 -0000 Received: from mail.kernel.org (HELO mail.kernel.org) (198.145.29.136) by server-10.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 9 Dec 2016 01:17:08 -0000 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1FB02203AE; Fri, 9 Dec 2016 01:17:06 +0000 (UTC) Received: from [10.1.10.56] (96-82-76-110-static.hfc.comcastbusiness.net [96.82.76.110]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 292A6203AB; Fri, 9 Dec 2016 01:17:05 +0000 (UTC) Date: Thu, 8 Dec 2016 17:17:04 -0800 (PST) From: Stefano Stabellini X-X-Sender: sstabellini@sstabellini-ThinkPad-X260 To: xen-devel@lists.xenproject.org Message-ID: User-Agent: Alpine 2.10 (DEB 1266 2009-07-14) MIME-Version: 1.0 X-Virus-Scanned: ClamAV using ClamSMTP Cc: julien.grall@arm.com, sstabellini@kernel.org Subject: [Xen-devel] [PATCH] fix out of bound access to mode_strings X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP mode == ARRAY_SIZE(mode_strings) causes an out of bound access to the mode_strings array. Coverity-ID: 1381859 Signed-off-by: Stefano Stabellini Reviewed-by: Julien Grall diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index eb85d92..35d8e8b 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -643,7 +643,7 @@ static const char *mode_string(uint32_t cpsr) }; mode = cpsr & PSR_MODE_MASK; - if ( mode > ARRAY_SIZE(mode_strings) ) + if ( mode >= ARRAY_SIZE(mode_strings) ) return "Unknown"; return mode_strings[mode] ? : "Unknown"; }