mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Baolu Lu <baolu.lu@linux.intel.com>
To: albin_yang@163.com, gregkh@linuxfoundation.org
Cc: baolu.lu@linux.intel.com, joro@8bytes.org, will@kernel.org,
	robin.murphy@arm.com, jgg@ziepe.ca, akpm@linux-foundation.org,
	iommu@lists.linux.dev, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org, albinwyang@tencent.com
Subject: Re: [PATCH 6.6] iommu/sva: move x86 disable check before allocation
Date: Wed, 5 Aug 2026 10:16:06 +0800	[thread overview]
Message-ID: <d0dde845-15f5-4dac-af14-e8c770273ffe@linux.intel.com> (raw)
In-Reply-To: <20260803114039.319953-1-albin_yang@163.com>

On 8/3/2026 7:40 PM, albin_yang@163.com wrote:
> From: Wei Yang <albinwyang@tencent.com>
> 
> Backport of commit 72f98ef9a4be ("iommu: disable SVA when CONFIG_X86 is
> set") placed the IS_ENABLED(CONFIG_X86) early-return in
> iommu_sva_bind_device() after iommu_sva_alloc_pasid() and kzalloc(handle),
> while upstream puts it at the function start.
> 
> On x86 this leaks the kzalloc'd struct iommu_sva (early return skips
> kfree) and a globally allocated PASID (mm->pasid wrongly set, never
> unbound). Move the check before any allocation/side effect.
> 
> Fixes: 240cd7f2812c ("iommu: disable SVA when CONFIG_X86 is set")
> 
> Signed-off-by: Wei Yang <albinwyang@tencent.com>
> ---
> 
> This is a stable-only fix for the linux-6.6.y tree.
> 
> The buggy commit 240cd7f2812c ("iommu: disable SVA when CONFIG_X86 is set")
> is a backport of upstream commit 72f98ef9a4be ("iommu: disable SVA when
> CONFIG_X86 is set") to 6.6. The upstream version places the
> IS_ENABLED(CONFIG_X86) early-return at the start of iommu_sva_bind_device(),
> but the 6.6 backport placed it after iommu_sva_alloc_pasid() and
> kzalloc(handle), causing the leak described above. The upstream/mainline
> code is correct, so this fix is not needed there and only applies to 6.6.
> 
> Please double-check against upstream commit 72f98ef9a4be before applying.
> ---
>   drivers/iommu/iommu-sva.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/iommu/iommu-sva.c b/drivers/iommu/iommu-sva.c
> index 611733c02b7c..a340b805b82b 100644
> --- a/drivers/iommu/iommu-sva.c
> +++ b/drivers/iommu/iommu-sva.c
> @@ -62,6 +62,9 @@ struct iommu_sva *iommu_sva_bind_device(struct device *dev, struct mm_struct *mm
>   	struct iommu_sva *handle;
>   	int ret;
>   
> +	if (IS_ENABLED(CONFIG_X86))
> +		return ERR_PTR(-EOPNOTSUPP);
> +
>   	/* Allocate mm->pasid if necessary. */
>   	ret = iommu_sva_alloc_pasid(mm, dev);
>   	if (ret)
> @@ -71,9 +74,6 @@ struct iommu_sva *iommu_sva_bind_device(struct device *dev, struct mm_struct *mm
>   	if (!handle)
>   		return ERR_PTR(-ENOMEM);
>   
> -	if (IS_ENABLED(CONFIG_X86))
> -		return ERR_PTR(-EOPNOTSUPP);
> -
>   	mutex_lock(&iommu_sva_lock);
>   	/* Search for an existing domain. */
>   	domain = iommu_get_domain_for_dev_pasid(dev, mm->pasid,

Acked-by: Lu Baolu <baolu.lu@linux.intel.com>

  parent reply	other threads:[~2026-08-05  2:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-03 11:40 albin_yang
2026-08-05  1:13 ` Sasha Levin
2026-08-05  2:16 ` Baolu Lu [this message]
2026-08-05 16:41   ` Sasha Levin

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=d0dde845-15f5-4dac-af14-e8c770273ffe@linux.intel.com \
    --to=baolu.lu@linux.intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=albin_yang@163.com \
    --cc=albinwyang@tencent.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@ziepe.ca \
    --cc=joro@8bytes.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=stable@vger.kernel.org \
    --cc=will@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®