Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp563241ybg; Wed, 10 Jun 2020 07:55:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyaz3tgk+8shfvFPZCYgCDF5iG+KUPJiTUH/RRA9qxUdOBCoEldz2KHqQwL3pNcfkIQ16Xt X-Received: by 2002:a17:906:6c82:: with SMTP id s2mr3621592ejr.215.1591800912799; Wed, 10 Jun 2020 07:55:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591800912; cv=none; d=google.com; s=arc-20160816; b=Sp6Sd2YMDVBZCkiKgZSzYGTHl0jxVCvhKobVc4FLGDyBaYlTmAd9aiwwd7qohZO1sQ tfKoUbd+U7oo7sWfigjqZjIvuI8cZ4De5owI/EEN6PmuJ5Z/GEfl9PvzaiC467ICsmjW mFcBUtRsKzWvvI8SoIlHYvTbhM2j9zLQN3P2TmY7AYJCuBGrC2C+7oqAaWvv7dLo6QRP qwdA3DTDugDsQgtiQ7ZSm0o2KWR0TZlu76SflRvVAGEGqUpoks8WTuE8ZKquJwRL6cxl qHJI6mTVJKd5aqNkrK61cngH098B2RkvX3hoyA24lheshAaAZeUyEAevkcuJzjJnyy1X leFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:subject:cc:to:from:date:content-transfer-encoding :mime-version:dkim-signature; bh=IpS6LvB59AAFg+uXb9gY9Ph2ttT1iEsbG4T4LlRTt9U=; b=L7dKMz+0wdjfVWFK43QUB++A6TYKBtR+8kn+RYEJEE0qBB/Xe1VSDb8mDQz7/0Ybla gJ2HyXOSx4O0w/e9B+txyHDFpNhZ7/fqskAzhmQG2SxR/clWVby0ZTXZJkepp2bny99j 7K5hHIwH5W4H8Dnt5SNNrnrcmH0WEY2yIELrZ+1aUa/cvFfDMFpJey4a+3PZNfpqCxYZ Xd7PYMZbGzTctoTHOpLocFngVL4+zW72ewprwqlqFOtbwAVKHfbSpKlEiKdFUQH8Zf1+ jymXVa92ikFXtnmlybyuHK+hbLfMXMEvmWpY41cTXchw59pAhU/9AwYBRnYsUFIvIWJw sN7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=kKSw18rz; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ce14si144227ejb.12.2020.06.10.07.54.49; Wed, 10 Jun 2020 07:55:12 -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=fail header.i=@mg.codeaurora.org header.s=smtp header.b=kKSw18rz; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727783AbgFJJ1V (ORCPT + 99 others); Wed, 10 Jun 2020 05:27:21 -0400 Received: from mail27.static.mailgun.info ([104.130.122.27]:48858 "EHLO mail27.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727769AbgFJJ1U (ORCPT ); Wed, 10 Jun 2020 05:27:20 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1591781240; h=Message-ID: References: In-Reply-To: Subject: Cc: To: From: Date: Content-Transfer-Encoding: Content-Type: MIME-Version: Sender; bh=IpS6LvB59AAFg+uXb9gY9Ph2ttT1iEsbG4T4LlRTt9U=; b=kKSw18rz4ubY86WDvszvf/70ghZChHiYh5hu9dsgP9mLjmFf/BMqE6Yt5Vba/2yaSuvkLmgQ AWZYgeD5hsb2qMDIP48HwlK6ytJGv3ufCJfjLwN/koLwXFkWEGtkusFVxHo/Bodju5GGB8Rn GoU0aOtbUVvwJKTsi/M2nXnZcJo= X-Mailgun-Sending-Ip: 104.130.122.27 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n04.prod.us-west-2.postgun.com with SMTP id 5ee0a7656f2ee827dafa4723 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Wed, 10 Jun 2020 09:27:01 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 6966EC433C6; Wed, 10 Jun 2020 09:27:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: guptap) by smtp.codeaurora.org (Postfix) with ESMTPSA id DD3D8C433CA; Wed, 10 Jun 2020 09:27:00 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Wed, 10 Jun 2020 14:57:00 +0530 From: guptap@codeaurora.org To: Robin Murphy Cc: joro@8bytes.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH] iommu/iova: Don't BUG on invalid PFNs In-Reply-To: References: Message-ID: <79df62c92cf61f2b5f717c28d620a283@codeaurora.org> X-Sender: guptap@codeaurora.org User-Agent: Roundcube Webmail/1.3.9 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-06-02 18:38, Robin Murphy wrote: > 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 > --- > drivers/iommu/iova.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > Copying stable@vger.kernel.org You can add Reviewed-by: Prakash Gupta > diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c > index 0e6a9536eca6..612cbf668adf 100644 > --- a/drivers/iommu/iova.c > +++ b/drivers/iommu/iova.c > @@ -811,7 +811,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); > }