From patchwork Tue Dec 3 16:29:26 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 296246 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 2E8BE2C0089 for ; Wed, 4 Dec 2013 03:36:28 +1100 (EST) Received: from localhost ([::1]:43495 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VnsxV-0000DJ-PY for incoming@patchwork.ozlabs.org; Tue, 03 Dec 2013 11:36:25 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42112) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VnsnT-0006Ss-OL for qemu-devel@nongnu.org; Tue, 03 Dec 2013 11:26:09 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VnsnN-0006ud-GI for qemu-devel@nongnu.org; Tue, 03 Dec 2013 11:26:03 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58840) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VnsnM-0006uB-Jn; Tue, 03 Dec 2013 11:25:57 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rB3GPs7Y001871 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 3 Dec 2013 11:25:55 -0500 Received: from redhat.com ([10.35.213.190]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with SMTP id rB3GPqOP026514; Tue, 3 Dec 2013 11:25:53 -0500 Date: Tue, 3 Dec 2013 18:29:26 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Message-ID: <1386087086-3691-24-git-send-email-mst@redhat.com> References: <1386087086-3691-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1386087086-3691-1-git-send-email-mst@redhat.com> X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: qemu-stable@nongnu.org Subject: [Qemu-devel] [PATCH 23/23] savevm: fix potential segfault on invalid state X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org savevm will segfault if version_id < vmsd->minimum_version_id && version_id >= vmsd->minimum_version_id_old This calls through a NULL pointer. This is a bug (should exit not crash). Signed-off-by: Michael S. Tsirkin Reviewed-by: Andreas Färber --- savevm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/savevm.c b/savevm.c index 3f912dd..04349f6 100644 --- a/savevm.c +++ b/savevm.c @@ -1686,6 +1686,9 @@ int vmstate_load_state(QEMUFile *f, const VMStateDescription *vmsd, return -EINVAL; } if (version_id < vmsd->minimum_version_id) { + if (!vmsd->load_state_old) { + return -EINVAL; + } return vmsd->load_state_old(f, opaque, version_id); } if (vmsd->pre_load) {