From patchwork Mon Nov 7 09:25:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 9414551 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 697A36022E for ; Mon, 7 Nov 2016 09:27:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5A0D528BBE for ; Mon, 7 Nov 2016 09:27:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4DE4928BD7; Mon, 7 Nov 2016 09:27:54 +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 D32B228BBE for ; Mon, 7 Nov 2016 09:27:53 +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 1c3gBd-0001Su-Qs; Mon, 07 Nov 2016 09:25:53 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1c3gBc-0001Sm-Uv for xen-devel@lists.xenproject.org; Mon, 07 Nov 2016 09:25:53 +0000 Received: from [193.109.254.147] by server-7.bemta-6.messagelabs.com id F5/3F-21485-0A840285; Mon, 07 Nov 2016 09:25:52 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrAIsWRWlGSWpSXmKPExsXS6fjDS3e+h0K EwZ2zghbft0xmcmD0OPzhCksAYxRrZl5SfkUCa8bZ7UuZCv7yV2zYeJm9gbGPt4uRk0NIIE+i 6cslFhCbV8BOYvrbFjYQW0LAUOLp++tgNouAqsT12/OZQGw2AXWJtmfbWbsYOThEBAwkzh1NA gkzCwRK3Lo/gxHEFhZwkrhy9xUbSAmvgKDE3x3CECV2El+Or2WcwMg1CyEzC0kGwtaSePjrFg uErS2xbOFrZpByZgFpieX/OCDCjhJ32k6wYSrxkZjcFbSAkWMVo0ZxalFZapGuoYFeUlFmekZ JbmJmDpBnppebWlycmJ6ak5hUrJecn7uJERh6DECwg/HesoBDjJIcTEqivJF2ChFCfEn5KZUZ icUZ8UWlOanFhxg1ODgEtu1afYFRiiUvPy9VSYJ3gztQnWBRanpqRVpmDjA6YEolOHiURHitQ dK8xQWJucWZ6RCpU4yKUuK8mSAJAZBERmkeXBssIi8xykoJ8zICHSXEU5BalJtZgir/ilGcg1 FJmPcqyBSezLwSuOmvgBYzAS12C5EBWVySiJCSamBMYtlt/q0ruWF1dXjqxQnOFlk7Go89CP2 5KVRf4fHSBd4/q/x2WqR7PClo/rN5f1ntBGGRnf4/pvjb9Lxwuvif4/p88xfbrB6YLD7nrdqT ZcLzdqPfgxjjQ9LCC86vFuXztP6UUP5lrUp+3+YKrd33NG5ezb1+rdlj2aMNtxauldW+sGTCv SuVSizFGYmGWsxFxYkAmgWFA8MCAAA= X-Env-Sender: JBeulich@suse.com X-Msg-Ref: server-8.tower-27.messagelabs.com!1478510749!59845516!1 X-Originating-IP: [137.65.248.74] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.0.13; banners=-,-,- X-VirusChecked: Checked Received: (qmail 18517 invoked from network); 7 Nov 2016 09:25:50 -0000 Received: from prv-mh.provo.novell.com (HELO prv-mh.provo.novell.com) (137.65.248.74) by server-8.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 7 Nov 2016 09:25:50 -0000 Received: from INET-PRV-MTA by prv-mh.provo.novell.com with Novell_GroupWise; Mon, 07 Nov 2016 02:25:48 -0700 Message-Id: <582056A0020000780011C962@prv-mh.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 14.2.1 Date: Mon, 07 Nov 2016 02:25:36 -0700 From: "Jan Beulich" To: "xen-devel" Mime-Version: 1.0 Cc: Andrew Cooper , Wei Liu Subject: [Xen-devel] [PATCH] x86/traps: replace ASSERT() checking array bounds 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 Avoid out of bounds accesses on non-debug builds. Coverity ID: 1055744 Signed-off-by: Jan Beulich x86/traps: replace ASSERT() checking array bounds Avoid out of bounds accesses on non-debug builds. Coverity ID: 1055744 Signed-off-by: Jan Beulich --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -3764,7 +3764,11 @@ void async_exception_cleanup(struct vcpu if ( (curr->async_exception_mask ^ curr->async_exception_state(trap).old_mask) == (1 << trap) ) break; - ASSERT(trap <= VCPU_TRAP_LAST); + if ( unlikely(trap > VCPU_TRAP_LAST) ) + { + ASSERT_UNREACHABLE(); + return; + } /* Restore previous asynchronous exception mask. */ curr->async_exception_mask = curr->async_exception_state(trap).old_mask; Reviewed-by: Andrew Cooper --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -3764,7 +3764,11 @@ void async_exception_cleanup(struct vcpu if ( (curr->async_exception_mask ^ curr->async_exception_state(trap).old_mask) == (1 << trap) ) break; - ASSERT(trap <= VCPU_TRAP_LAST); + if ( unlikely(trap > VCPU_TRAP_LAST) ) + { + ASSERT_UNREACHABLE(); + return; + } /* Restore previous asynchronous exception mask. */ curr->async_exception_mask = curr->async_exception_state(trap).old_mask;