Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1898400pxk; Tue, 1 Sep 2020 10:18:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwkYhICassKtmwkDVaPcbbd0uXanQMH1HlEongX34kFhfsPYeG7A6lRSVRtsYHogWi8xoLp X-Received: by 2002:a17:906:40c9:: with SMTP id a9mr2454589ejk.3.1598980698321; Tue, 01 Sep 2020 10:18:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598980698; cv=none; d=google.com; s=arc-20160816; b=icfFPLblkB2e0zbLkuxJvYx16vDBaVOlA7Soc7xwwkSkQSgs/G36i4SjOyEh2el5UF korPsPhRSbJjGJD/6d1bWj/GQTrcm4ImeUQttQ9tXfXf6/ZuRj7mUIktb+F8lpLywb4P huXe+Yk3KjL822TdP8OHtuihv99x3+HZ2pO7zfUgv32C/llOrCxTcLGMf0V0AvhSMSev qfPU0fOhQYeXWyWySoPUA4ZHm9+nZs74jnjsmQefQlkv6SIEryTVgx7iwn3FiPaYbLl0 SsgXeqj0FjCXrJrrI+YPISlFHGHXGDKugjwVb/PfEMko8OzEeyspGVgpL2xKj36OLmA7 6FSQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=HREqcCi7kRLaSgivYRY3Heh99F6HMqMYsSZ9Mnj4yFA=; b=HHP/Vycu06r2coqmSueEkG7wJC9kw+/V6oWAs57nAkE4HRRW/6A56f2MKrbXMm8+XC 8h5r0ciZhpzsKMnd9eaIpNMzA8zuYKGDAEc7g1XqnWYXt3P9xDI+zZt4c9sm4RPGVPZ7 VqcbFnsj0PtV3ntkXYbHttjAleB17zZawajjwCpFa1yM8WSCHjHwfMc9HcAHs/Jl4JSR 0e9fBtz2Bn2JAr+ZLigwPiLjZINdPHxeNs6jGtrpKcAFesANlP5oN0IGxdNw440r4rw5 58Cl6Ec0YX+skjbtqeUdl+SpeCFQgNANicGDgwqc21zDb8xoRtMzhK7o1f4qBdKR7PkQ ui2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dglZEr2B; 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 dp16si1496778ejc.17.2020.09.01.10.17.54; Tue, 01 Sep 2020 10:18:18 -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=dglZEr2B; 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 S1729143AbgIAPOx (ORCPT + 99 others); Tue, 1 Sep 2020 11:14:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:58242 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729045AbgIAPO3 (ORCPT ); Tue, 1 Sep 2020 11:14:29 -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 A2D1D20BED; Tue, 1 Sep 2020 15:14:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1598973269; bh=EC0gZpwbVWyRCJJFNNRf8jvNqjXRs7By//WD6ow1/qg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dglZEr2Bg9rS4++EUO2G5DR8S/6cttEJn95LDDk82yabPqfkhBFjKekHsgf9FavKM nBS/7abMgWAx/fuCM6H9/+oJ+nhy9D6g60M8H4BKvCayFpEq+G1B5oHMU2ZN567Akx zo1blnkkKppLq0nOBOH0qm2oND1Rhxiqzqi79Opw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Prakash Gupta , Robin Murphy , Joerg Roedel , Sasha Levin Subject: [PATCH 4.9 12/78] iommu/iova: Dont BUG on invalid PFNs Date: Tue, 1 Sep 2020 17:09:48 +0200 Message-Id: <20200901150925.346875694@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200901150924.680106554@linuxfoundation.org> References: <20200901150924.680106554@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Robin Murphy [ Upstream commit d3e3d2be688b4b5864538de61e750721a311e4fc ] Unlike the other instances which represent a complete loss of consistency within the rcache mechanism itself, or a fundamental and obvious misconfiguration by an IOMMU driver, the BUG_ON() in iova_magazine_free_pfns() can be provoked at more or less any time in a "spooky action-at-a-distance" manner by any old device driver passing nonsense to dma_unmap_*() which then propagates through to queue_iova(). Not only is this well outside the IOVA layer's control, it's also nowhere near fatal enough to justify panicking anyway - all that really achieves is to make debugging the offending driver more difficult. Let's simply WARN and otherwise ignore bogus PFNs. Reported-by: Prakash Gupta Signed-off-by: Robin Murphy Reviewed-by: Prakash Gupta Link: https://lore.kernel.org/r/acbd2d092b42738a03a21b417ce64e27f8c91c86.1591103298.git.robin.murphy@arm.com Signed-off-by: Joerg Roedel Signed-off-by: Sasha Levin --- drivers/iommu/iova.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c index f106fd9782bfb..99c36a5438a75 100644 --- a/drivers/iommu/iova.c +++ b/drivers/iommu/iova.c @@ -676,7 +676,9 @@ iova_magazine_free_pfns(struct iova_magazine *mag, struct iova_domain *iovad) for (i = 0 ; i < mag->size; ++i) { struct iova *iova = private_find_iova(iovad, mag->pfns[i]); - BUG_ON(!iova); + if (WARN_ON(!iova)) + continue; + private_free_iova(iovad, iova); } -- 2.25.1