From patchwork Tue Nov 21 02:23:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Cody X-Patchwork-Id: 839884 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3ygqDL2tQ8z9sRn for ; Tue, 21 Nov 2017 13:24:50 +1100 (AEDT) Received: from localhost ([::1]:60628 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGyEy-00031d-Ck for incoming@patchwork.ozlabs.org; Mon, 20 Nov 2017 21:24:48 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58818) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eGyDv-0002nr-MQ for qemu-devel@nongnu.org; Mon, 20 Nov 2017 21:23:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eGyDt-0003ZI-IU for qemu-devel@nongnu.org; Mon, 20 Nov 2017 21:23:43 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55036) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eGyDo-0003Y8-6e; Mon, 20 Nov 2017 21:23:36 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DEC9A83F44; Tue, 21 Nov 2017 02:23:34 +0000 (UTC) Received: from localhost (ovpn-124-90.rdu2.redhat.com [10.10.124.90]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E04D660BE0; Tue, 21 Nov 2017 02:23:26 +0000 (UTC) From: Jeff Cody To: qemu-devel@nongnu.org Date: Mon, 20 Nov 2017 21:23:22 -0500 Message-Id: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Tue, 21 Nov 2017 02:23:35 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 for-2.11 0/4] Fix segfault in blockjob race condition 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: kwolf@redhat.com, famz@redhat.com, qemu-block@nongnu.org, mreitz@redhat.com, stefanha@redhat.com, pbonzini@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Changes from v1 -> v2: Patch 1: Updated docs in blockjob_int.h (Thanks Stefan) Patch 2/3: Squashed, and used const char * to hold the __func__ name of the original scheduler (Thanks Paolo) Patch 4: Unchanged. Patch 5: Dropped qcow format for the test, it was so slow the test times out, and it doesn't add any new dimension to the test. # git-backport-diff -r qemu/master.. -u github/bz1508708 001/4:[0003] [FC] 'blockjob: do not allow coroutine double entry or entry-after-completion' 002/4:[down] 'coroutine: abort if we try to schedule or enter a pending coroutine' 003/4:[----] [--] 'qemu-iotests: add option in common.qemu for mismatch only' 004/4:[0002] [FC] 'qemu-iotest: add test for blockjob coroutine race condition' This series fixes a race condition segfault when using iothreads with blockjobs. The qemu iotest in this series is a reproducer, as is the reproducer script attached in this bug report: https://bugzilla.redhat.com/show_bug.cgi?id=1508708 There are two additional patches to try and catch this sort of scenario with an abort, before a segfault or memory corruption occurs. Jeff Cody (4): blockjob: do not allow coroutine double entry or entry-after-completion coroutine: abort if we try to schedule or enter a pending coroutine qemu-iotests: add option in common.qemu for mismatch only qemu-iotest: add test for blockjob coroutine race condition blockjob.c | 9 ++-- include/block/blockjob_int.h | 3 +- include/qemu/coroutine_int.h | 6 +++ tests/qemu-iotests/200 | 99 ++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/200.out | 14 ++++++ tests/qemu-iotests/common.qemu | 8 +++- tests/qemu-iotests/group | 1 + util/async.c | 11 +++++ util/qemu-coroutine-sleep.c | 11 +++++ util/qemu-coroutine.c | 11 +++++ 10 files changed, 168 insertions(+), 5 deletions(-) create mode 100755 tests/qemu-iotests/200 create mode 100644 tests/qemu-iotests/200.out