From patchwork Tue Mar 15 17:56:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Konrad Rzeszutek Wilk X-Patchwork-Id: 8591261 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A37EC9F294 for ; Tue, 15 Mar 2016 18:03:03 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B9CF620122 for ; Tue, 15 Mar 2016 18:03:01 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id 896E620357 for ; Tue, 15 Mar 2016 18:02:59 +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 1aftGi-0001Dd-22; Tue, 15 Mar 2016 18:00:32 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aftGf-00019g-LQ for xen-devel@lists.xenproject.org; Tue, 15 Mar 2016 18:00:29 +0000 Received: from [85.158.139.211] by server-1.bemta-5.messagelabs.com id D9/61-29419-CBD48E65; Tue, 15 Mar 2016 18:00:28 +0000 X-Env-Sender: konrad@char.us.oracle.com X-Msg-Ref: server-7.tower-206.messagelabs.com!1458064826!28980032!1 X-Originating-IP: [141.146.126.69] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTQxLjE0Ni4xMjYuNjkgPT4gMjc3MjE4\n X-StarScan-Received: X-StarScan-Version: 8.11; banners=-,-,- X-VirusChecked: Checked Received: (qmail 6502 invoked from network); 15 Mar 2016 18:00:28 -0000 Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by server-7.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 15 Mar 2016 18:00:28 -0000 Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u2FI0J9t026648 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 15 Mar 2016 18:00:19 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0022.oracle.com (8.14.4/8.13.8) with ESMTP id u2FI0JRZ003591 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL); Tue, 15 Mar 2016 18:00:19 GMT Received: from abhmp0016.oracle.com (abhmp0016.oracle.com [141.146.116.22]) by userv0121.oracle.com (8.13.8/8.13.8) with ESMTP id u2FI0IZR005999; Tue, 15 Mar 2016 18:00:18 GMT Received: from char.us.oracle.com (/10.137.176.158) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 15 Mar 2016 11:00:18 -0700 Received: by char.us.oracle.com (Postfix, from userid 1000) id 7CD5C6A00D1; Tue, 15 Mar 2016 13:59:10 -0400 (EDT) From: Konrad Rzeszutek Wilk To: xen-devel@lists.xenproject.org, ross.lagerwall@citrix.com, konrad@kernel.org, andrew.cooper3@citrix.com, mpohlack@amazon.de, sasha.levin@oracle.com Date: Tue, 15 Mar 2016 13:56:31 -0400 Message-Id: <1458064616-23101-10-git-send-email-konrad.wilk@oracle.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1458064616-23101-1-git-send-email-konrad.wilk@oracle.com> References: <1458064616-23101-1-git-send-email-konrad.wilk@oracle.com> X-Source-IP: userv0022.oracle.com [156.151.31.74] Cc: Keir Fraser , Tim Deegan , Ian Jackson , Jan Beulich , Konrad Rzeszutek Wilk Subject: [Xen-devel] [PATCH v4 09/34] vmap: ASSERT on NULL. 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: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The vmap_to_page macro (three levels deep!) can come up with a NULL pointer. Lets add the proper ASSERT to catch this errant behavior. Signed-off-by: Konrad Rzeszutek Wilk --- Cc: Ian Jackson Cc: Jan Beulich Cc: Keir Fraser Cc: Tim Deegan --- --- xen/common/vmap.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/xen/common/vmap.c b/xen/common/vmap.c index be01285..1f1da1b 100644 --- a/xen/common/vmap.c +++ b/xen/common/vmap.c @@ -279,8 +279,12 @@ void vfree(void *va) ASSERT(pages); for ( i = 0; i < pages; i++ ) - page_list_add(vmap_to_page(va + i * PAGE_SIZE), &pg_list); + { + struct page_info *page = vmap_to_page(va + i * PAGE_SIZE); + ASSERT(page); + page_list_add(page, &pg_list); + } vunmap(va); while ( (pg = page_list_remove_head(&pg_list)) != NULL )