xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Xen-devel <xen-devel@lists.xen.org>
Cc: George Dunlap <george.dunlap@eu.citrix.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Jan Beulich <JBeulich@suse.com>
Subject: [PATCH] x86/msi: Validate the guest-identified PCI devices in pci_prepare_msix()
Date: Wed, 22 Jan 2014 00:24:11 +0000	[thread overview]
Message-ID: <1390350251-22323-1-git-send-email-andrew.cooper3@citrix.com> (raw)
In-Reply-To: <52DF0F6A.4040309@citrix.com>

As of c/s 1035bb64fd7fd9f05c510466d98566fd82e37ad9
  "PCI: break MSI-X data out of struct pci_dev_info"

pdev->msix is now conditional on whether the device actually has MSI-X
capabilities or not, so validate it before blindly dereferencing what amounts
to a guest-controlled parameter.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
CC: Jan Beulich <JBeulich@suse.com>
CC: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
CC: George Dunlap <george.dunlap@eu.citrix.com>

---

This has only been compile tested, but is quite obviously needed to prevent
the NULL structure dereference.

George: This (well technically the fix for the underlying problem if this
  patch turns out to be incorrect) really need to be accepted for 4.4, or the
  underlying bug will turn into an XSA.  Currently only unstable is affected.
---
 xen/arch/x86/msi.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/arch/x86/msi.c b/xen/arch/x86/msi.c
index 284042e..36c5503 100644
--- a/xen/arch/x86/msi.c
+++ b/xen/arch/x86/msi.c
@@ -1033,7 +1033,7 @@ int pci_prepare_msix(u16 seg, u8 bus, u8 devfn, bool_t off)
 
     spin_lock(&pcidevs_lock);
     pdev = pci_get_pdev(seg, bus, devfn);
-    if ( !pdev )
+    if ( !pdev || !pdev->msix )
         rc = -ENODEV;
     else if ( pdev->msix->used_entries != !!off )
         rc = -EBUSY;
-- 
1.7.10.4

  reply	other threads:[~2014-01-22  0:24 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-21 21:54 Regression compared to Xen 4.3, Xen 4.4-rc2 - pci_prepare_msix+0xb1/0x12 - BOOM Konrad Rzeszutek Wilk
2014-01-22  0:23 ` Andrew Cooper
2014-01-22  0:24   ` Andrew Cooper [this message]
2014-01-22  4:31     ` [PATCH] x86/msi: Validate the guest-identified PCI devices in pci_prepare_msix() Konrad Rzeszutek Wilk
2014-01-22  9:49       ` Jan Beulich
2014-01-22 10:28         ` Andrew Cooper
2014-01-22 12:08           ` Jan Beulich
2014-01-22 21:40             ` Konrad Rzeszutek Wilk
2014-01-23  8:24               ` Jan Beulich
2014-01-24 15:01                 ` Konrad Rzeszutek Wilk
2014-01-24 15:55                   ` Jan Beulich
2014-01-24 16:19                   ` Jan Beulich
2014-01-24 17:43                     ` Konrad Rzeszutek Wilk
2014-01-24 21:56                       ` Is: pci=assign-busses blows up Xen 4.4 Was:Re: " Konrad Rzeszutek Wilk
2014-02-05 20:07                         ` Konrad Rzeszutek Wilk
2014-02-06  9:02                           ` Jan Beulich
2014-02-21 19:18                           ` Konrad Rzeszutek Wilk
2014-02-24  9:15                             ` Is: pci=assign-busses blows up Xen 4.4 Jan Beulich
2014-02-24 16:15                               ` Konrad Rzeszutek Wilk

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=1390350251-22323-1-git-send-email-andrew.cooper3@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=george.dunlap@eu.citrix.com \
    --cc=xen-devel@lists.xen.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;
as well as URLs for NNTP newsgroup(s).