From nobody Sun May 19 11:06:52 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1594972457; cv=none; d=zohomail.com; s=zohoarc; b=fkAe6olTFcOfH3hQO2INFwHqQhI2ihn9awjvjcfBAuIhWLhYSkJaJtEctBaJfbqKOPZfbcWh2q/rebMHC64qOqDn8JChIZlyWfTfljURb73Iz3UzYtE8emv2aQFraRdbxEsprAUKwMO+iOvmIRTy3bo/Rf5LOPjZGx4pdzdr3Nw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594972457; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=FJ1tf4qbatTndPOfdRaDTzxz07OMiFLDimu/y/P84Ic=; b=iTvVa/8pIq+Gc5dDZM8UbilYgeUP0xN658ZearIWY96TlCGEioE+Y1fvNBriBRst2XnYjT8vXGQdDEp8cgFhwBsqhisaixyeTZH/AzhNgt9cK89ouYLtE1SrF5xUOEHPTuDQHMjNbLni0b2UC9Dx1UKNQHQ4IbHhMwhcMyWZdl4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1594972457628421.41829031273323; Fri, 17 Jul 2020 00:54:17 -0700 (PDT) Received: from localhost ([::1]:49204 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jwLCC-0001IL-76 for importer@patchew.org; Fri, 17 Jul 2020 03:54:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55416) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jwLBK-0000KB-QM; Fri, 17 Jul 2020 03:53:22 -0400 Received: from mail-ej1-x629.google.com ([2a00:1450:4864:20::629]:34987) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jwLBJ-0003X0-Ad; Fri, 17 Jul 2020 03:53:22 -0400 Received: by mail-ej1-x629.google.com with SMTP id rk21so9810536ejb.2; Fri, 17 Jul 2020 00:53:20 -0700 (PDT) Received: from x1w.redhat.com (138.red-83-57-170.dynamicip.rima-tde.net. [83.57.170.138]) by smtp.gmail.com with ESMTPSA id lm22sm7044918ejb.109.2020.07.17.00.53.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jul 2020 00:53:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=FJ1tf4qbatTndPOfdRaDTzxz07OMiFLDimu/y/P84Ic=; b=U++a87U1PTL3GJYC1xLptgbfTx2iKXVXgRaGqdbLdlGVdNkmFPiJW44Ne3byC+Y0tJ zjblfzzwdCkT203gbS3mmnKXkulEA0UWIZ6oNuYCd56fGOPfnaYhGtl+GUDOOO01PFeg KRo8N5N+0n+eCP5768RkWjeL9d+HjLJi1v83yt+y5tmUURx/LoCMYGWsHVc2JmFMwWs7 DX3Bu2ssM7ON8SwBHFR7Avd237qtVqv01UAfLWV0pjcjjkFLwobdNBpkJMtrqPhT8gIq WjgaPGjsDyuTv5mQLPRpGGLhfpgZcei2UYE9aqDz0G34Fts5IAiunjXK4gpuC18V2RHe t5Hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=FJ1tf4qbatTndPOfdRaDTzxz07OMiFLDimu/y/P84Ic=; b=CsUy+I5A/2YpIUd5BmYl66yTXDJO0TcjkOxqELQ8TfM5HFCK06ecx12cxznTTHS4zV 3KDDFNHky55nA9c9S4pst1HxNpsbZ3n65HuOE7ZyvSKQZQ40ACJpBEY87YBTugMYaf98 Yk6lK7CYh0FKX3YUL9/j4FaY0xlrrFLfpG7Em5ZM+OJSMrR4CiaWmO2xfRq4vv7gqfJ0 HoZtNfykRlSiFs2HNHIGCYsLodBcCvFLk/HH7MrvVF7HYyeSZORcxU7LushlqcthL/DK C1bU/NHxqqWUvxKuXwxU9gmN1twB1YP2qRauZlYBfE2xg/md8PsaJ2iQ93VHnADW1Af5 EITA== X-Gm-Message-State: AOAM5313utLT3GqmnP/3z5pZO2xfdld8Ey/N9ZUPgAiE6TtYTMt+dvjT eOCCsIrpoebvDzKy77bXQFapvI0DR2Y= X-Google-Smtp-Source: ABdhPJyYAca6loWPnP0DWMzeZAOl0879XcYScF0iDOKK5FFPsa2nad7tMCU25VsLedjNy83S05DABQ== X-Received: by 2002:a17:906:5f98:: with SMTP id a24mr7187547eju.241.1594972399239; Fri, 17 Jul 2020 00:53:19 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [RFC PATCH-for-5.1 v2] hw/ide: Cancel pending DMA requests before setting as inactive Date: Fri, 17 Jul 2020 09:53:17 +0200 Message-Id: <20200717075317.5376-1-f4bug@amsat.org> X-Mailer: git-send-email 2.21.3 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::629; envelope-from=philippe.mathieu.daude@gmail.com; helo=mail-ej1-x629.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: 0 X-Spam_score: 0.0 X-Spam_bar: / X-Spam_report: (0.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alexander Bulekov , John Snow , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) libFuzzer found a case where requests are queued for later in the AIO context, but a command set the bus inactive, then when finally the requests are processed by the DMA it aborts because it is inactive: include/hw/ide/pci.h:59: IDEState *bmdma_active_if(BMDMAState *): Assertio= n `bmdma->bus->retry_unit !=3D (uint8_t)-1' failed. Reproducer available on the BugLink. Fix by draining the pending DMA requests before inactivating the bus. BugLink: https://bugs.launchpad.net/qemu/+bug/1887303 Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reported-by: Alexander Bulekov --- RFC because I don't have much clue about block drive and IDE, so block-team please be very careful while reviewing this bug. --- hw/ide/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/ide/core.c b/hw/ide/core.c index d997a78e47..f7affafb0c 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -804,7 +804,7 @@ void dma_buf_commit(IDEState *s, uint32_t tx_bytes) =20 void ide_set_inactive(IDEState *s, bool more) { - s->bus->dma->aiocb =3D NULL; + ide_cancel_dma_sync(s); ide_clear_retry(s); if (s->bus->dma->ops->set_inactive) { s->bus->dma->ops->set_inactive(s->bus->dma, more); --=20 2.21.3