From patchwork Mon Dec 12 19:22:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 9471109 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 B219B60573 for ; Mon, 12 Dec 2016 19:24:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9A968284D4 for ; Mon, 12 Dec 2016 19:24:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8EA21284F7; Mon, 12 Dec 2016 19:24:51 +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 27672284D4 for ; Mon, 12 Dec 2016 19:24:51 +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 1cGWB2-0004za-0U; Mon, 12 Dec 2016 19:22:20 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cGWB0-0004zN-EJ for xen-devel@lists.xenproject.org; Mon, 12 Dec 2016 19:22:18 +0000 Received: from [85.158.139.211] by server-10.bemta-5.messagelabs.com id 14/31-21400-9E8FE485; Mon, 12 Dec 2016 19:22:17 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrBIsWRWlGSWpSXmKPExsVybKJsh+7LH34 RBv1dbBbft0xmcmD0OPzhCksAYxRrZl5SfkUCa0b7b5+CY+wVZ553szQwLmPrYuTiEBKYyiix +OlMZghnNpPEn/vtTF2MnBwsAtoSn581MILYbAKGEn+fbALq4OCQALKXfOYACYsIKEncWzUZr JxZwEDiWNdKsHJhAWeJe3O+sYPYvALeEtPur2QFsUUFdCUO/fvDBhEXlDg58wkLRK+WxPLp28 BsCYEMiXk9c1ghbC+JRTcuQdlqElfPbWKewMg/C0n7LCTtCxiZVjGqF6cWlaUW6RrqJRVlpme U5CZm5ugaGpjq5aYWFyemp+YkJhXrJefnbmIEhlo9AwPjDsamXudDjJIcTEqivKZv/SKE+JLy UyozEosz4otKc1KLDzHKcHAoSfBu/A6UEyxKTU+tSMvMAQY9TFqCg0dJhHcLSJq3uCAxtzgzH SJ1ilGX48D7FU+ZhFjy8vNSpcR5u0CKBECKMkrz4EbAIvASo6yUMC8jAwODEE9BalFuZgmq/C tGcQ5GJWHenSBTeDLzSuA2vQI6ggnoiOf7vEGOKElESEk1MApvnWefKfJfI8DWvSjX8p1Hj9P L5c7c+voy3Gbh0QJs/ZOnsIp3lWc4nz15e8nm758ePN63cneE9AqjX+J2t7Pv1iS9r2oR71p5 4kqMZ2ODZf2EiwwP/n2Y7eBsG8wn5O6TVBiod9uxmSF8NUuhlc2TtaEyZx69vNwkySfyZN2qm TPEZx3+r8RSnJFoqMVcVJwIAAMixFa7AgAA X-Env-Sender: sstabellini@kernel.org X-Msg-Ref: server-2.tower-206.messagelabs.com!1481570529!54410760!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.1.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 27718 invoked from network); 12 Dec 2016 19:22:10 -0000 Received: from mail.kernel.org (HELO mail.kernel.org) (198.145.29.136) by server-2.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 12 Dec 2016 19:22:10 -0000 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B32942028D; Mon, 12 Dec 2016 19:22:14 +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 ADA3020295; Mon, 12 Dec 2016 19:22:13 +0000 (UTC) Date: Mon, 12 Dec 2016 11:22:12 -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 v3] fix potential pa_range_info out of bound access 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 pa_range_info has only 8 elements and is accessed using pa_range as index. pa_range is initialized to 16, potentially causing out of bound access errors. Fix the issue by checking that pa_range is not greater than the size of the array. Remove the now superfluous pa_range&0x8 check. Coverity-ID: 1381865 Signed-off-by: Stefano Stabellini Reviewed-by: Julien Grall --- Changes in v3: - remove the now superfluous pa_range&0x8 check diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c index e4991df..5d5bb87 100644 --- a/xen/arch/arm/p2m.c +++ b/xen/arch/arm/p2m.c @@ -1639,7 +1639,7 @@ void __init setup_virt_paging(void) } /* pa_range is 4 bits, but the defined encodings are only 3 bits */ - if ( pa_range&0x8 || !pa_range_info[pa_range].pabits ) + if ( pa_range >= ARRAY_SIZE(pa_range_info) || !pa_range_info[pa_range].pabits ) panic("Unknown encoding of ID_AA64MMFR0_EL1.PARange %x\n", pa_range); val |= VTCR_PS(pa_range);