From patchwork Tue Feb 13 18:26:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Moriarty X-Patchwork-Id: 10217321 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 0DA3460467 for ; Tue, 13 Feb 2018 19:01:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EEA0028F05 for ; Tue, 13 Feb 2018 19:01:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E2D9D28EFA; Tue, 13 Feb 2018 19:01:20 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6008D28EFA for ; Tue, 13 Feb 2018 19:01:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965508AbeBMTBS (ORCPT ); Tue, 13 Feb 2018 14:01:18 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:60302 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965477AbeBMTBR (ORCPT ); Tue, 13 Feb 2018 14:01:17 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w1DIn5cq050062; Tue, 13 Feb 2018 19:01:14 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2017-10-26; bh=RgE84OwpYgHyJsQCB8QTk1VFzQYP6jQ0P4av7aFelA4=; b=JOWI/Ga+BWmnuqkiuLomPbRm6YeZMnzimkHIdLgbRQPDU41xy6D7JxDdyMC3+DYKdaPg sHqFaWoS0YrJB+aRPua5Vz4yipJzwCOFI5An1rf2YLIJ/+7OcXuS35HqQ6mXbDGjt4me nTEwYPXT81daXU+s0pybafqqaa3qGre6xBIz9x3IEIGGzk/lLxpeLXk+U4DYR9hbUFV9 1EWdWad+sAJaPuE3kH2prrTNqTOvl41Q8u0LI3FnDSJJIqTPjKUiBh85TTweGLFWiiox Ndou22upIIEYbPCBTkh2w0PY6Ajt2ta8gI8+/G0SihmbBvOBVS8w8xlh7McfIxQWZf36 vA== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2120.oracle.com with ESMTP id 2g45mqg1r2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 Feb 2018 19:01:14 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w1DIQrTq019683 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 13 Feb 2018 18:26:53 GMT Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w1DIQr5V026056; Tue, 13 Feb 2018 18:26:53 GMT Received: from localhost.us.oracle.com (/10.153.52.84) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 13 Feb 2018 10:26:52 -0800 From: Joe Moriarty To: pbonzini@redhat.com, rkrcmar@redhat.com, kvm@vger.kernel.org Cc: joe.moriarty@oracle.com Subject: [PATCH v1 1/1] KVM: X86: NULL pointer dereference [null-pointer-deref] (CWE 476) problem Date: Tue, 13 Feb 2018 13:26:40 -0500 Message-Id: <20180213182640.10646-2-joe.moriarty@oracle.com> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20180213182640.10646-1-joe.moriarty@oracle.com> References: <20180213182640.10646-1-joe.moriarty@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8804 signatures=668670 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=808 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1802130225 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The Parfait (version 2.1.0) static code analysis tool found the following NULL pointer dereference problem. - arch/x86/kvm/mmu.c There is a possibility that the call to __gfn_to_rmap() can happen with a NULL pointer given for the slot argument. This can happen if the slot information cannot be determined from a previous call to __gfn_to_memslot(). The base_gfn will be passed in as 0 to gfn_to_index if no valid slot information can be obtained from a call to __gfn_to_memslot(). Signed-off-by: Joe Moriarty --- arch/x86/kvm/mmu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 8eca1d04aeb8..69d41b5d0948 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -1239,7 +1239,7 @@ static struct kvm_rmap_head *__gfn_to_rmap(gfn_t gfn, int level, { unsigned long idx; - idx = gfn_to_index(gfn, slot->base_gfn, level); + idx = gfn_to_index(gfn, slot ? slot->base_gfn : 0, level); return &slot->arch.rmap[level - PT_PAGE_TABLE_LEVEL][idx]; }