Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp4269642ybl; Tue, 21 Jan 2020 16:36:08 -0800 (PST) X-Google-Smtp-Source: APXvYqzNsQmggpVS07zCC0eIP84rr+gRqx+8n4MSt6SxyKkeEuvuRZwqznz/fJDfuRvIEyjCO75Z X-Received: by 2002:a05:6830:2099:: with SMTP id y25mr5216333otq.87.1579653368498; Tue, 21 Jan 2020 16:36:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579653368; cv=none; d=google.com; s=arc-20160816; b=bJK4Mr4mSDT6t1Kr+NwRdxnXNKkhTXTcQa3CAG9w9G43osF8EkUTZPbamATYFeT25A nIiHU5UYuLj8N2/E/+gz8DnXK7g8Xp7h/jkUkx6MqXtXChFTL3/VqL91cNM18v0egfBG iXxM8b0axMM3N4NCtwLbtQa0QjldJaHYyvc8uQv1JS9q6X1q2cZw9WjOsRHRVa1/wElT Vjxbo1YF+128AHPbDeWHWUhEYJaLLZpmHaIqsNYkrjQf2it0FkLFSXwjZqlltXBS/TYW TcCVj3e2retD72vaeRNGdEd5RQpFdChLQHWPx/nvxAYQJbF5o2ZKehR4AIzgv2e8ObtR pLyw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=MJ4SkbpxcRrIWzJPxY9eWD1fiCB6FFP/Gm3vsvFDakM=; b=vyc/hZgTQhnLn7AqUTEtksXoa890nehpQ+41sbxIc1X/0dwCBCFoK8FABmUZKyauvZ RwYWV8BzqN336sxF2PAH/x2HCW6ZvuXfCR/ZDaj2BaANyYBNJfE1FAxdJKox+mopnnlY 492Xld9HifKvdO4sFkN1O9S4wvk0qc7uEjbW8HdgeUcIYaBPYfOjCAoNud4ymguIZCa2 xOgoTW7Ls/CocSJjdkMjykLwFoFbeG6Umxn1xxrD6MTgl69prWuFING6x1KdJkQLuH53 PCi3TomuVsXzdwXJAztub7uCUmjfxSW5ErMggbnKB8Z/bHrjhEP5+7Lz7Tp/GluxcQVn +vkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=C96zecB2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d3si20130480oia.236.2020.01.21.16.35.56; Tue, 21 Jan 2020 16:36:08 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=C96zecB2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728904AbgAVAeq (ORCPT + 99 others); Tue, 21 Jan 2020 19:34:46 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:28939 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726876AbgAVAeq (ORCPT ); Tue, 21 Jan 2020 19:34:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1579653284; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=MJ4SkbpxcRrIWzJPxY9eWD1fiCB6FFP/Gm3vsvFDakM=; b=C96zecB2//mkxDIQEXU6N2fHHuCw/Ptt+7pJzUsIWrNekErxn4qb7/P3ODX7m2eF78seM1 jkWPZnJdpbqpJF+ndRVeTRoOGeNToTPxMHvG34NvFU4jw3Yoax1qe6mbesQHjiwLm9kzI4 BwwuEkRBsj9E4XdDEtsR8ZwXmC700XM= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-292-dI-WQVENOiO03h8Q7VUfgQ-1; Tue, 21 Jan 2020 19:34:40 -0500 X-MC-Unique: dI-WQVENOiO03h8Q7VUfgQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EE5251882CC2; Wed, 22 Jan 2020 00:34:38 +0000 (UTC) Received: from cantor.redhat.com (ovpn-118-59.phx2.redhat.com [10.3.118.59]) by smtp.corp.redhat.com (Postfix) with ESMTP id 794937DB34; Wed, 22 Jan 2020 00:34:38 +0000 (UTC) From: Jerry Snitselaar To: iommu@lists.linux-foundation.org Cc: Joerg Roedel , Lu Baolu , David Woodhouse , stable@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] iommu/vt-d: call __dmar_remove_one_dev_info with valid pointer Date: Tue, 21 Jan 2020 17:34:26 -0700 Message-Id: <20200122003426.16079-1-jsnitsel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It is possible for archdata.iommu to be set to DEFER_DEVICE_DOMAIN_INFO or DUMMY_DEVICE_DOMAIN_INFO so check for those values before calling __dmar_remove_one_dev_info. Without a check it can result in a null pointer dereference. This has been seen while booting a kdump kernel on an HP dl380 gen9. Cc: Joerg Roedel Cc: Lu Baolu Cc: David Woodhouse Cc: stable@vger.kernel.org # 5.3+ Cc: linux-kernel@vger.kernel.org Fixes: ae23bfb68f28 ("iommu/vt-d: Detach domain before using a private on= e") Signed-off-by: Jerry Snitselaar --- drivers/iommu/intel-iommu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index 1801f0aaf013..932267f49f9a 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c @@ -5163,7 +5163,8 @@ static void dmar_remove_one_dev_info(struct device = *dev) =20 spin_lock_irqsave(&device_domain_lock, flags); info =3D dev->archdata.iommu; - if (info) + if (info && info !=3D DEFER_DEVICE_DOMAIN_INFO + && info !=3D DUMMY_DEVICE_DOMAIN_INFO) __dmar_remove_one_dev_info(info); spin_unlock_irqrestore(&device_domain_lock, flags); } --=20 2.24.0