Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp165818pxx; Wed, 28 Oct 2020 01:19:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyFaBUo2Kuaa23BITypgUj3MRXUNeMb8jv+lm2ssozx0xEPYbuPJRgCgS1QNoWEMTCRz/50 X-Received: by 2002:a17:906:2e0e:: with SMTP id n14mr6249230eji.120.1603873161011; Wed, 28 Oct 2020 01:19:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603873161; cv=none; d=google.com; s=arc-20160816; b=Pl78NWROGGvBWfwyDddIWhaTOdjXGs63zb32K4cMqTsdP5BGW6jcMtRRixc/vWLAI8 Wen4RgHInvseV9JUb4mjVYpXZ+9omMU85O0tBPwRJWKghiaMyd8XS6Im1PgEUcpEdhzZ 63hbwMLGLxnKQPCy9W1nBsMqYLvU8pE7HILsNbb6+G8Njd3MwOzOf4Vp5I6lbBXSU2Vu qDi6DIFrAjIJqTOFI1BNCLlvDSpjEG9ybk0apI6wRSPM4pWEbU2cz7NqDLmhwM15wViZ EaTwjROLZjrM+U1fhI+mWXhAzgOB9aY2a7D02LZLCVhI/ttC5gIKNj0OPcZmYC9fgmBG dfjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=FKiGSJvsZMwMZPDFhoJ/rTaoH1fNmXwOV9Aa6U29OfY=; b=HiQN4nzc7TkvJUCcXBLsxvvzdDO9yV2ub+wRuoJMXUfq+3WZ6NLHzeVsojxQ0z9zef Q0XWbLZ13UM8fxLVtqKNdB9U10j7zjIIPQXTtRa59HN88GzhNs9hc8yI6fSFfFJhU1ti MEgo31wgPPPavPaXtBDVGivS/+gI/7LUgXB+wMFRcCzA/Ibbuc/XGdv6s5ciFa6cHepj hvYkopu5CHN+nHZBoTIo50SQdauDJ5sYBkkbTmClywcNPwc0q+ctanagyQ/kE5sXjxru tADP+PcrUhWkRUJF3GdJktyp/zR9aWKD5sfELjgjsKdlMDvVoGgx63if4SpRsUxKz2uA hsgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=I0lHprmL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lg14si2653130ejb.82.2020.10.28.01.18.58; Wed, 28 Oct 2020 01:19:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=I0lHprmL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753713AbgJ0OBh (ORCPT + 99 others); Tue, 27 Oct 2020 10:01:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:48380 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753585AbgJ0OAu (ORCPT ); Tue, 27 Oct 2020 10:00:50 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7CF1B2068D; Tue, 27 Oct 2020 14:00:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603807250; bh=+8vX1VinRHaPxHQP//7V7RE1VtE+iGQeIsS+lgB40Qo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=I0lHprmLes8RaLbJqMlg5AppWRZxoEWKD1y3T+846pyLwEhPuhLcsHHT+Xr6uS9Tg FzM6+oj9JBKqmQb1QLPgXBDUTp8Db0HFITjq6RcgxmwLEOioGHBMRKwXjd/BOaQOkw vvOqDYtoKjOCDRuJNhcxhcT1bQDwa3+DcabfGbQg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, guomin chen , Alex Williamson , Sasha Levin Subject: [PATCH 4.4 067/112] vfio/pci: Clear token on bypass registration failure Date: Tue, 27 Oct 2020 14:49:37 +0100 Message-Id: <20201027134903.735252217@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027134900.532249571@linuxfoundation.org> References: <20201027134900.532249571@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alex Williamson [ Upstream commit 852b1beecb6ff9326f7ca4bc0fe69ae860ebdb9e ] The eventfd context is used as our irqbypass token, therefore if an eventfd is re-used, our token is the same. The irqbypass code will return an -EBUSY in this case, but we'll still attempt to unregister the producer, where if that duplicate token still exists, results in removing the wrong object. Clear the token of failed producers so that they harmlessly fall out when unregistered. Fixes: 6d7425f109d2 ("vfio: Register/unregister irq_bypass_producer") Reported-by: guomin chen Tested-by: guomin chen Signed-off-by: Alex Williamson Signed-off-by: Sasha Levin --- drivers/vfio/pci/vfio_pci_intrs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/vfio/pci/vfio_pci_intrs.c b/drivers/vfio/pci/vfio_pci_intrs.c index f7d48661aa944..af4f7ebb45a79 100644 --- a/drivers/vfio/pci/vfio_pci_intrs.c +++ b/drivers/vfio/pci/vfio_pci_intrs.c @@ -364,11 +364,13 @@ static int vfio_msi_set_vector_signal(struct vfio_pci_device *vdev, vdev->ctx[vector].producer.token = trigger; vdev->ctx[vector].producer.irq = irq; ret = irq_bypass_register_producer(&vdev->ctx[vector].producer); - if (unlikely(ret)) + if (unlikely(ret)) { dev_info(&pdev->dev, "irq bypass producer (token %p) registration fails: %d\n", vdev->ctx[vector].producer.token, ret); + vdev->ctx[vector].producer.token = NULL; + } vdev->ctx[vector].trigger = trigger; return 0; -- 2.25.1