From patchwork Sat Apr 20 17:14:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Lukas Straub X-Patchwork-Id: 10910397 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 13C6E922 for ; Sat, 20 Apr 2019 17:33:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E8AD7289DA for ; Sat, 20 Apr 2019 17:33:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E711828BF8; Sat, 20 Apr 2019 17:33:28 +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=-5.0 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5F5C3289DA for ; Sat, 20 Apr 2019 17:33:27 +0000 (UTC) Received: from localhost ([127.0.0.1]:43720 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHtri-0003R0-BQ for patchwork-qemu-devel@patchwork.kernel.org; Sat, 20 Apr 2019 13:33:26 -0400 Received: from eggs.gnu.org ([209.51.188.92]:41913) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hHtoI-000174-Ap for qemu-devel@nongnu.org; Sat, 20 Apr 2019 13:29:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hHtZV-0006Zv-M3 for qemu-devel@nongnu.org; Sat, 20 Apr 2019 13:14:38 -0400 Received: from mout.web.de ([212.227.17.12]:34047) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hHtZV-0006TY-Cn for qemu-devel@nongnu.org; Sat, 20 Apr 2019 13:14:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=web.de; s=dbaedf251592; t=1555780467; bh=B2vnL8cskgePAMIBWEzCG89t4Le6gqq4G4XQoKWpkuY=; h=X-UI-Sender-Class:Date:From:To:Cc:Subject; b=R3NFYLYmhyIGFPaBy9LMF+ZC2dfHvECBI7dXF+JAe3wU36LTtou3ldnuB/5+7rGaZ eVPGBSwGIiQsaAYgBSRQhH06BnnO+D75TsbHoG9hauoRnS1VBFpUot4F99CLJNRv2Z dAViwZ3CjO9PqKzYgDMGSShJ+ZsyGRKuwjxNNIiY= X-UI-Sender-Class: c548c8c5-30a9-4db5-a2e7-cb6cb037b8f9 Received: from luklap ([46.91.89.139]) by smtp.web.de (mrweb101 [213.165.67.124]) with ESMTPSA (Nemesis) id 0MQvsg-1hP1Lw3YGU-00ULam; Sat, 20 Apr 2019 19:14:26 +0200 Date: Sat, 20 Apr 2019 19:14:25 +0200 From: Lukas Straub To: qemu-devel@nongnu.org Message-ID: <20190420191425.7d1dab82@luklap> MIME-Version: 1.0 X-Provags-ID: V03:K1:+GA36cDvXqQY+sy7ZAgMf4rVSaAFp2491DsABo1QspY791wZBka mIvvEaKpwtxQPzjC9zQpXJSGC7t+RbP+ZuVitYuQzPgs7906FwRMuC9jFYSDNH7+LS+tsio Y3tG42u+2MLcy4hpHOwe3diijwkPBAynRNuCZMySOnaEle0cQ+iDPJDQ2Gq11lNofmN9cYv FmDjS3wOy9unN5E589Z8A== X-UI-Out-Filterresults: notjunk:1;V03:K0:N5t/V2DmoIQ=:sYcTqsYp6n5AjSem0yAz+N pEPnEWGuMeMKEhSoftSzzDigyUSNjkeFnG0PUW0FsAEof39EnxFEnDrJ5Brw9CC5yVEe/T9sp DT8J/9SfBqJbRHzMn3Hp6sxYcktedwsRAXEA7njd2GmvdAZpksIX4mO72iT9ZgCv1do7A42hn l5YkkMJxWFLKLSXcxmWkEo+9T47fnl1gYrW9I+9T+nOoQIdI0857NkqlFfY4b41kOvbrO/paa 9J37gGDGqcO9nYEWFQI6kSe05qF9bTvKw/RzVz3f1pB5eUBOFsiWVaYj0yvK2Z35LpyiAqrMc GP7XWOSCd3imJvHv+m1eI1Nvo4h1qYWFqRK4kKatAh7XcrnQZh1C2v3Cp2rRWqfhZrv1dfGuo PC2fH27F8f2c6L5XGrunRurvNgjwn+7+CxSJdsdMTZP4wPbgy97qbhXyCm5u38KW7aaVTc5aO Gam66vQ0cRARuJW8HG8ZYv2fS940F0asYcGfogOkdW+STlvg3/UqTYxjC6F/xKDMy/lYhNjnK JZtvK68DZP/U513OTUERvdqiyGtbp6e0wtkG9eLAnqMgMZSlRhvrwqUTXod5HwAsNZFxUGt/q FE+USE1ZdB2Z7OVwhVl2boA0k5HSdzlvvyDuPD7xID1lc8sqYr2U22F8IySJX3MNWc7ih0ENp M1cQI6Rjnw6jlgtGNaaixd3NS5U/sGWEt/NbENwndoUNg8c7LdiuqThc1+SvKJl023i8sgYGc h9u0ZsKtPU9gc7ORuHCoHiZwTSzvROZ2G7mzfqROWGO/s+tk1e7VLH8EdD/rfz1+j8NR8T4+u mZDMF//D8iXT+HWxK2arsj73i4l3NqaguiwyFhIaa9UP9oLSclD0Ptgz5FyVedlZEmfuFQUHC rBrQ18zm0g8MQ7P4A5UJzZckbUG/Q3OkW+tm/zrxBJy24MvoYEJg98utjFuNRvqT9C4oKALKN EOFEeQI9VCw== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.17.12 Subject: [Qemu-devel] [PATCH v2] net/colo-compare.c: Fix a crash in COLO Primary. 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: "Zhang, Chen" Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Lukas Straub Because event_unhandled_count may be accessed concurrently, it needs to be protected by taking the lock. However the assert is outside the lock, probably causing it to read garbage and aborting Qemu erroneously. The Bug only happens when running Qemu in COLO mode. This Patch fixes the following bug: https://bugs.launchpad.net/qemu/+bug/1824622 Signed-off-by: Lukas Straub Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Zhang Chen --- net/colo-compare.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) -- 2.20.1 diff --git a/net/colo-compare.c b/net/colo-compare.c index bf10526f05..fcb491121b 100644 --- a/net/colo-compare.c +++ b/net/colo-compare.c @@ -813,9 +813,8 @@ static void colo_compare_handle_event(void *opaque) break; } - assert(event_unhandled_count > 0); - qemu_mutex_lock(&event_mtx); + assert(event_unhandled_count > 0); event_unhandled_count--; qemu_cond_broadcast(&event_complete_cond); qemu_mutex_unlock(&event_mtx);