From patchwork Thu Apr 28 06:28:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Markus Armbruster X-Patchwork-Id: 8965561 Return-Path: X-Original-To: patchwork-qemu-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 704269F1D3 for ; Thu, 28 Apr 2016 06:28:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D695A2024D for ; Thu, 28 Apr 2016 06:28:33 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id 2EC2F2022A for ; Thu, 28 Apr 2016 06:28:33 +0000 (UTC) Received: from localhost ([::1]:46723 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1avfRA-00078D-8P for patchwork-qemu-devel@patchwork.kernel.org; Thu, 28 Apr 2016 02:28:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33293) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1avfQz-000759-Rk for qemu-devel@nongnu.org; Thu, 28 Apr 2016 02:28:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1avfQu-0007CS-SQ for qemu-devel@nongnu.org; Thu, 28 Apr 2016 02:28:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44572) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1avfQu-0007CG-Mh for qemu-devel@nongnu.org; Thu, 28 Apr 2016 02:28:16 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 500437F08F for ; Thu, 28 Apr 2016 06:28:16 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-116-34.ams2.redhat.com [10.36.116.34]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u3S6SEfU004905 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 28 Apr 2016 02:28:15 -0400 Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id C09031132D8C; Thu, 28 Apr 2016 08:28:13 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Thu, 28 Apr 2016 08:28:12 +0200 Message-Id: <1461824893-21125-3-git-send-email-armbru@redhat.com> In-Reply-To: <1461824893-21125-1-git-send-email-armbru@redhat.com> References: <1461824893-21125-1-git-send-email-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL for-2.6 2/3] replay: Fix dangling location bug in replay_configure() 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: , Cc: Eduardo Habkost Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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 replay_configure() pushes and pops a Location with automatic storage duration. Except it fails to pop when -icount parameter "rr" isn't given. cur_loc then points to unused stack space, and will most likely get clobbered in short order. Clobbered cur_loc can make loc_pop() and error_print_loc() crash or report bogus locations. Broken in commit 890ad55. I didn't take the time to find a reproducer. Cc: Eduardo Habkost Signed-off-by: Markus Armbruster Message-Id: <1461767349-15329-3-git-send-email-armbru@redhat.com> Reviewed-by: Eric Blake Reviewed-by: Eduardo Habkost --- replay/replay.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/replay/replay.c b/replay/replay.c index 7c2573a..167fd29 100644 --- a/replay/replay.c +++ b/replay/replay.c @@ -275,7 +275,7 @@ void replay_configure(QemuOpts *opts) rr = qemu_opt_get(opts, "rr"); if (!rr) { /* Just enabling icount */ - return; + goto out; } else if (!strcmp(rr, "record")) { mode = REPLAY_MODE_RECORD; } else if (!strcmp(rr, "replay")) { @@ -293,6 +293,7 @@ void replay_configure(QemuOpts *opts) replay_enable(fname, mode); +out: loc_pop(&loc); }