From patchwork Mon Nov 26 15:28:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Roman Kagan X-Patchwork-Id: 10698507 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2E16F13AD for ; Mon, 26 Nov 2018 15:29:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1E86D29C68 for ; Mon, 26 Nov 2018 15:29:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 12AED29E8D; Mon, 26 Nov 2018 15:29:36 +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.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4ADE029E86 for ; Mon, 26 Nov 2018 15:29:35 +0000 (UTC) Received: from localhost ([::1]:37293 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRIpK-00089j-3V for patchwork-qemu-devel@patchwork.kernel.org; Mon, 26 Nov 2018 10:29:34 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48810) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRIoh-0007qa-12 for qemu-devel@nongnu.org; Mon, 26 Nov 2018 10:28:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRIoc-0004ex-14 for qemu-devel@nongnu.org; Mon, 26 Nov 2018 10:28:55 -0500 Received: from mail-eopbgr80137.outbound.protection.outlook.com ([40.107.8.137]:6126 helo=EUR04-VI1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gRIob-0004YN-Er for qemu-devel@nongnu.org; Mon, 26 Nov 2018 10:28:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OFSkG9PPmvv+l2+OD2LQ20boJnDtu54lDHRlI/Q5M1I=; b=GeXNxAkcCm8+DItCvap6e0tzV40qP0eOd1L7+/SYLZO33XdB7y73gMjcFOtolzbzCwQyFnrCxgMyWysq84XfCbnOruRrNxTWsnk0xiqvQIMbY9QVIZNCpDkLPWuZeyJgovtWTJHpt9QcoOCA7Ye0qLWmFo7XoNWmMvcWKLM76XI= Received: from VI1PR08MB3599.eurprd08.prod.outlook.com (20.177.61.74) by VI1PR08MB0925.eurprd08.prod.outlook.com (10.166.143.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1361.19; Mon, 26 Nov 2018 15:28:44 +0000 Received: from VI1PR08MB3599.eurprd08.prod.outlook.com ([fe80::5d2c:980a:d77e:34e2]) by VI1PR08MB3599.eurprd08.prod.outlook.com ([fe80::5d2c:980a:d77e:34e2%3]) with mapi id 15.20.1361.019; Mon, 26 Nov 2018 15:28:44 +0000 From: Roman Kagan To: "qemu-devel@nongnu.org" , Igor Mammedov , Vitaly Kuznetsov , Eduardo Habkost , Paolo Bonzini Thread-Topic: [PATCH] hw/hyperv: fix NULL dereference with pure-kvm SynIC Thread-Index: AQHUhZy3jcrf/LwAnk6Fe/ceJG0N4g== Date: Mon, 26 Nov 2018 15:28:44 +0000 Message-ID: <20181126152836.25379-1-rkagan@virtuozzo.com> Accept-Language: en-US, ru-RU Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [185.231.240.5] x-clientproxiedby: HE1P192CA0024.EURP192.PROD.OUTLOOK.COM (2603:10a6:3:fe::34) To VI1PR08MB3599.eurprd08.prod.outlook.com (2603:10a6:803:85::10) authentication-results: spf=none (sender IP is ) smtp.mailfrom=rkagan@virtuozzo.com; x-ms-exchange-messagesentrepresentingtype: 1 x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VI1PR08MB0925; 20:HsVu7uI6bKbJ4q5+f5Bw3piRmrqirxQ3Hg8XZMFcSpTH6on8nFQ/6VqCy9/i/ljxtZuLcNubjiIrec599mLgzZmedS/QOgKlq+2e4Swg9kdgVdADzE6yr+MJlaakfYRIcRoErW+xeeDqF0sVXXgIkJl0tu5/g6XIdV4Dx+XCH/s= x-ms-office365-filtering-correlation-id: 4c7c3745-5b29-4dd1-8ec4-08d653b3d9c9 x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:VI1PR08MB0925; x-ms-traffictypediagnostic: VI1PR08MB0925: x-microsoft-antispam-prvs: x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(6040522)(2401047)(5005006)(8121501046)(93006095)(93001095)(3231443)(944501410)(52105112)(10201501046)(3002001)(148016)(149066)(150057)(6041310)(20161123558120)(20161123564045)(20161123560045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051)(76991095); SRVR:VI1PR08MB0925; BCL:0; PCL:0; RULEID:; SRVR:VI1PR08MB0925; x-forefront-prvs: 086831DFB4 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(396003)(136003)(366004)(376002)(39850400004)(346002)(199004)(189003)(2616005)(53936002)(486006)(36756003)(2906002)(105586002)(106356001)(6512007)(6116002)(1076002)(3846002)(476003)(14444005)(81166006)(86362001)(81156014)(2501003)(6506007)(8676002)(66066001)(25786009)(14454004)(97736004)(110136005)(316002)(52116002)(5660300001)(386003)(99286004)(186003)(68736007)(1857600001)(26005)(102836004)(6486002)(305945005)(6436002)(7736002)(256004)(71190400001)(478600001)(8936002)(71200400001); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR08MB0925; H:VI1PR08MB3599.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: HIWmh5PbSSaFfZEB+V/sknM5GB11S/9pUVbknyJE/cXODU7c+uqePZdy+lwTnmA4h/W8qD5vEEC4R7KChgP3exG7k2h+Nc9Eq/9mFoLIt1InFy1QaGX6FKxgCaXpcQZfrhe2TQ+SmX1B9B0W8YXZLx+C7kOnS8+n/oppjLvmrxscEfJbt36ehtkHi5I+Td+F118h3DGMm5d4InooX3xO2b48tF/zS4huj5YiSM2Mzy3twZxZZ+ZgZ0y0D1LOzDMcDxbMfxBeSwef8k71c6y2rMo99V4KWsef5ix49nERC74mQPBAMnRrzlsbtKSRAIOh390CNN9qxcKuqde++/+fdvQU1P9e6+CBFviPrwcK9rU= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4c7c3745-5b29-4dd1-8ec4-08d653b3d9c9 X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Nov 2018 15:28:44.3934 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB0925 X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 [fuzzy] X-Received-From: 40.107.8.137 Subject: [Qemu-devel] [PATCH] hw/hyperv: fix NULL dereference with pure-kvm SynIC X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP When started in compat configuration of SynIC, e.g. qemu-system-x86_64 -machine pc-i440fx-2.10,accel=kvm \ -cpu host,-vmx,hv-relaxed,hv_spinlocks=0x1fff,hv-vpindex,hv-synic or explicitly qemu-system-x86_64 -enable-kvm -cpu host,hv-synic,x-hv-synic-kvm-only=on QEMU crashes in hyperv_synic_reset() trying to access the non-present qobject for SynIC. Add the missing check for NULL. Reported-by: Vitaly Kuznetsov Reported-by: Igor Mammedov Fixes: 9b4cf107b09d18ac30f46fd1c4de8585ccba030c Fixes: 4a93722f9c279184e95b1e1ad775c01deec05065 Signed-off-by: Roman Kagan Reviewed-by: Philippe Mathieu-Daudé Tested-by: Philippe Mathieu-Daudé --- hw/hyperv/hyperv.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hw/hyperv/hyperv.c b/hw/hyperv/hyperv.c index a28e7249d8..8758635227 100644 --- a/hw/hyperv/hyperv.c +++ b/hw/hyperv/hyperv.c @@ -136,7 +136,11 @@ void hyperv_synic_add(CPUState *cs) void hyperv_synic_reset(CPUState *cs) { - device_reset(DEVICE(get_synic(cs))); + SynICState *synic = get_synic(cs); + + if (synic) { + device_reset(DEVICE(synic)); + } } static const TypeInfo synic_type_info = {