From: Joerg Roedel <joerg.roedel@amd.com>
To: Ingo Molnar <mingo@redhat.com>
Cc: x86@kernel.org, linux-kernel@vger.kernel.org,
iommu@lists.linux-foundation.org,
Joerg Roedel <joerg.roedel@amd.com>
Subject: [PATCH 2/5] x86/amd-iommu: Fix NULL pointer dereference in __detach_device()
Date: Fri, 22 Jan 2010 18:18:10 +0100 [thread overview]
Message-ID: <1264180693-27197-3-git-send-email-joerg.roedel@amd.com> (raw)
In-Reply-To: <1264180693-27197-1-git-send-email-joerg.roedel@amd.com>
In the __detach_device function the reference count for a
device-domain binding may become zero. This results in the
device being removed from the domain and dev_data->domain
will be NULL. This is bad because this pointer is
dereferenced when trying to unlock the domain->lock. This
patch fixes the issue by keeping the domain in a seperate
variable.
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
arch/x86/kernel/amd_iommu.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/arch/x86/kernel/amd_iommu.c b/arch/x86/kernel/amd_iommu.c
index c2ccbd7..4478a48 100644
--- a/arch/x86/kernel/amd_iommu.c
+++ b/arch/x86/kernel/amd_iommu.c
@@ -1489,11 +1489,14 @@ static void __detach_device(struct device *dev)
{
struct iommu_dev_data *dev_data = get_dev_data(dev);
struct iommu_dev_data *alias_data;
+ struct protection_domain *domain;
unsigned long flags;
BUG_ON(!dev_data->domain);
- spin_lock_irqsave(&dev_data->domain->lock, flags);
+ domain = dev_data->domain;
+
+ spin_lock_irqsave(&domain->lock, flags);
if (dev_data->alias != dev) {
alias_data = get_dev_data(dev_data->alias);
@@ -1504,7 +1507,7 @@ static void __detach_device(struct device *dev)
if (atomic_dec_and_test(&dev_data->bind))
do_detach(dev);
- spin_unlock_irqrestore(&dev_data->domain->lock, flags);
+ spin_unlock_irqrestore(&domain->lock, flags);
/*
* If we run in passthrough mode the device must be assigned to the
--
1.6.6
next prev parent reply other threads:[~2010-01-22 17:19 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-22 17:18 [git pull] IOMMU fixes for 2.6.33-rc5 Joerg Roedel
2010-01-22 17:18 ` [PATCH 1/5] x86/amd-iommu: Fix possible integer overflow Joerg Roedel
2010-01-22 17:18 ` Joerg Roedel [this message]
2010-01-22 17:18 ` [PATCH 3/5] x86/amd-iommu: Fix IOMMU-API initialization for iommu=pt Joerg Roedel
2010-01-22 17:18 ` [PATCH 4/5] x86/amd-iommu: Fix deassignment of a device from the pt_domain Joerg Roedel
2010-01-22 17:18 ` [PATCH 5/5] lib/dma-debug.c: mark file-local struct symbol static Joerg Roedel
2010-01-27 10:04 ` [git pull] IOMMU fixes for 2.6.33-rc5 Ingo Molnar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1264180693-27197-3-git-send-email-joerg.roedel@amd.com \
--to=joerg.roedel@amd.com \
--cc=iommu@lists.linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®