Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Greg KH <gregkh@linuxfoundation.org>
To: Robin Murphy <robin.murphy@arm.com>
Cc: stable@vger.kernel.org, Charan Teja Kalla <quic_charante@quicinc.com>
Subject: Re: [PATCH v3 6.6] iommu: Handle race with default domain setup
Date: Tue, 29 Apr 2025 15:00:38 +0200	[thread overview]
Message-ID: <2025042954-factual-vengeful-6614@gregkh> (raw)
In-Reply-To: <f0cac3a642f34d0d239f8d7870e33881fc7081d6.1745923148.git.robin.murphy@arm.com>

On Tue, Apr 29, 2025 at 11:47:40AM +0100, Robin Murphy wrote:
> [ Upstream commit b46064a18810bad3aea089a79993ca5ea7a3d2b2 ]
> 
> It turns out that deferred default domain creation leaves a subtle
> race window during iommu_device_register() wherein a client driver may
> asynchronously probe in parallel and get as far as performing DMA API
> operations with dma-direct, only to be switched to iommu-dma underfoot
> once the default domain attachment finally happens, with obviously
> disastrous consequences. Even the wonky of_iommu_configure() path is at
> risk, since iommu_fwspec_init() will no longer defer client probe as the
> instance ops are (necessarily) already registered, and the "replay"
> iommu_probe_device() call can see dev->iommu_group already set and so
> think there's nothing to do either.
> 
> Fortunately we already have the right tool in the right place in the
> form of iommu_device_use_default_domain(), which just needs to ensure
> that said default domain is actually ready to *be* used. Deferring the
> client probe shouldn't have too much impact, given that this only
> happens while the IOMMU driver is probing, and thus due to kick the
> deferred probe list again once it finishes.
> 
> [ Backport: The above is true for mainline, but here we still have
> arch_setup_dma_ops() to worry about, which is not replayed if the
> default domain happens to be allocated *between* that call and
> subsequently reaching iommu_device_use_default_domain(), so we need an
> additional earlier check to cover that case. Also we're now back before
> the nominal commit 98ac73f99bc4 so we need to tweak the logic to depend
> on IOMMU_DMA as well, to avoid falsely deferring on architectures not
> using default domains. This then serves us back as far as f188056352bc,
> where this specific form of the problem first arises. ]
> 
> Reported-by: Charan Teja Kalla <quic_charante@quicinc.com>
> Fixes: 98ac73f99bc4 ("iommu: Require a default_domain for all iommu drivers")
> Fixes: f188056352bc ("iommu: Avoid locking/unlocking for iommu_probe_device()")
> Link: https://lore.kernel.org/r/e88b94c9b575034a2c98a48b3d383654cbda7902.1740753261.git.robin.murphy@arm.com
> Signed-off-by: Robin Murphy <robin.murphy@arm.com>
> ---
> 
> Resending as a new version with a new Message-Id so as not to confuse
> the tools... 6.12.y should simply have a straight cherry-pick of the
> mainline commit - 98ac73f99bc4 was in 6.7 so I'm not sure why autosel
> hasn't picked that already?

autosel is "maybe we get it", NEVER rely on it for an actual backport to
happen.

If you want this in 6.12.y, and it applies cleanly, just ask!  But I
can't take this 6.6.y patch before that happens for obvious reasons.

thanks,

greg k-h

  reply	other threads:[~2025-04-29 13:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-29 10:47 [PATCH v3 6.6] iommu: Handle race with default domain setup Robin Murphy
2025-04-29 13:00 ` Greg KH [this message]
2025-04-29 13:07   ` Robin Murphy
2025-04-29 14:22     ` Greg KH
2025-05-01  7:46       ` Greg KH
2025-05-01 10:34         ` Robin Murphy

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=2025042954-factual-vengeful-6614@gregkh \
    --to=gregkh@linuxfoundation.org \
    --cc=quic_charante@quicinc.com \
    --cc=robin.murphy@arm.com \
    --cc=stable@vger.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