From: "Roger Pau Monné" <roger.pau@citrix.com>
To: Jan Beulich <jbeulich@suse.com>
Cc: xen-devel@lists.xenproject.org
Subject: Re: [PATCH for-4.17 3/6] vpci: don't assume that vpci per-device data exists unconditionally
Date: Mon, 24 Oct 2022 18:01:37 +0200 [thread overview]
Message-ID: <Y1a24cSD9zVZFHn/@Air-de-Roger> (raw)
In-Reply-To: <ff8559d8-12b6-9218-94bb-8c9a731250a2@suse.com>
On Mon, Oct 24, 2022 at 01:04:01PM +0200, Jan Beulich wrote:
> On 20.10.2022 11:46, Roger Pau Monne wrote:
> > It's possible for a device to be assigned to a domain but have no
> > vpci structure if vpci_process_pending() failed and called
> > vpci_remove_device() as a result. The unconditional accesses done by
> > vpci_{read,write}() and vpci_remove_device() to pdev->vpci would
> > then trigger a NULL pointer dereference.
> >
> > Add checks for pdev->vpci presence in the affected functions.
> >
> > Fixes: 9c244fdef7 ('vpci: add header handlers')
> > Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
>
> Reviewed-by: Jan Beulich <jbeulich@suse.com>
>
> I wonder though whether these changes are enough. Is
> vpci_process_pending() immune to a pdev losing its ->vpci?
I think this is safe so far because the only place where
vpci_remove_device() gets called that doesn't also deassign the device
from the domain is vpci_process_pending(), and in that error path it
also clears any pending work. Since the device no longer has ->vpci
handlers no further calls to vpci_process_pending() can happen.
> Furthermore msix_find() iterates over d->arch.hvm.msix_tables, which
> looks to only ever be added to. Doesn't this list need pruning by
> vpci_remove_device()? I've noticed this only because of looking at
> derefs of ->vpci in msix.c - I don't think I can easily see that all
> of those derefs are once again immune to a pdev losing its ->vpci.
I think you are correct, we are missing a
list_del(&pdev->vpci->msix->next) in vpci_remove_device(). We will
however have locking issues with this, as msix_find() doesn't take any
locks, neither do it's callers. I guess this will be fixed as part of
the lager add vPCI locking series. Will add another patch to the
series with the MSIX table removal.
Thanks, Roger.
next prev parent reply other threads:[~2022-10-24 16:02 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-20 9:46 [PATCH for-4.17 0/6] (v)pci: fixes related to memory decoding handling Roger Pau Monne
2022-10-20 9:46 ` [PATCH for-4.17 1/6] test/vpci: add dummy cfcheck define Roger Pau Monne
2022-10-20 9:57 ` Andrew Cooper
2022-10-20 13:20 ` Anthony PERARD
2022-10-20 9:46 ` [PATCH for-4.17 2/6] test/vpci: fix vPCI test harness to provide pci_get_pdev() Roger Pau Monne
2022-10-20 13:21 ` Anthony PERARD
2022-10-20 9:46 ` [PATCH for-4.17 3/6] vpci: don't assume that vpci per-device data exists unconditionally Roger Pau Monne
2022-10-24 11:04 ` Jan Beulich
2022-10-24 16:01 ` Roger Pau Monné [this message]
2022-10-24 16:06 ` Jan Beulich
2022-10-20 9:46 ` [PATCH for-4.17 4/6] vpci: introduce a local vpci_bar variable to modify_decoding() Roger Pau Monne
2022-10-24 11:05 ` Jan Beulich
2022-10-20 9:46 ` [PATCH for-4.17 5/6] pci: do not disable memory decoding for devices Roger Pau Monne
2022-10-24 11:19 ` Jan Beulich
2022-10-24 12:45 ` Roger Pau Monné
2022-10-24 13:59 ` Jan Beulich
2022-10-24 15:45 ` Roger Pau Monné
2022-10-24 15:56 ` Jan Beulich
2022-10-24 16:24 ` Roger Pau Monné
2022-10-20 9:46 ` [PATCH for-4.17 6/6] vpci: refuse BAR writes only if the BAR is mapped Roger Pau Monne
2022-10-24 11:51 ` Jan Beulich
2022-10-24 15:04 ` Roger Pau Monné
2022-10-24 16:03 ` Jan Beulich
2022-10-20 10:12 ` [PATCH for-4.17 0/6] (v)pci: fixes related to memory decoding handling Henry Wang
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=Y1a24cSD9zVZFHn/@Air-de-Roger \
--to=roger.pau@citrix.com \
--cc=jbeulich@suse.com \
--cc=xen-devel@lists.xenproject.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.