All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Pavol Sakac" <sakacpav@amazon.de>
Cc: linux-pci@vger.kernel.org
Subject: Re: [RFC PATCH 1/3] iommu: split sysfs link publication out of iommu_group_alloc_device()
Date: Fri, 11 Sep 2026 13:14:23 +0000	[thread overview]
Message-ID: <20260911131423.BCF821F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260911125907.67105-1-sakacpav@amazon.de>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Dangling stack pointer in `struct iommu_group` when `bus_iommu_probe` fails.
--

commit 40e2c611e51a4bd6297705c58373104232dd8541
Author: Pavol Sakac <sakacpav@amazon.de>
Subject: iommu: split sysfs link publication out of iommu_group_alloc_device()

The patch separates sysfs link publication from iommu_group_alloc_device().
It moves all per-member sysfs publication into a new helper,
iommu_group_link_device(), which sets a linked flag to handle teardown
correctly. This change prepares for a later commit by providing a single
seam for sysfs publication.

> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
> index cd1bca7ede9af..5f92981d9f345 100644
> --- a/drivers/iommu/iommu.c
> +++ b/drivers/iommu/iommu.c
[ ... ]
> @@ -667,6 +663,11 @@ static int __iommu_probe_device(struct device *dev, struct list_head *group_list
>  	 */
>  	list_add_tail(&gdev->list, &group->devices);
>  	WARN_ON(group->default_domain && !group->domain);
> +
> +	ret = iommu_group_link_device(group, gdev);
> +	if (ret)
> +		goto err_remove_gdev;
> +
>  	if (group->default_domain)
>  		iommu_create_device_direct_mappings(group->default_domain, dev);
>  	if (group->domain) {

[Severity: High]
This is a pre-existing issue, but does returning an error from
__iommu_probe_device() (either here or later in the function) lead to a
dangling stack pointer in the group_list?

Looking at the later part of __iommu_probe_device() in drivers/iommu/iommu.c,
it adds the group to the stack-allocated group_list:

	} else if (!group->default_domain) {
		/*
		 * Defer setup to the caller draining group_list; both in-tree
		 * callers pass one.
		 */
		if (list_empty(&group->entry))
			list_add_tail(&group->entry, group_list);
	}

If a subsequent call to __iommu_probe_device() (or any probe failure during
bus_for_each_dev()) returns an error, bus_iommu_probe() will return immediately:

drivers/iommu/iommu.c:bus_iommu_probe() {
	...
	LIST_HEAD(group_list);
	int ret;

	ret = bus_for_each_dev(bus, NULL, &group_list, probe_iommu_group);
	if (ret)
		return ret;
	...
}

Does this leave long-lived struct iommu_group objects with their group->entry
pointers pointing to the discarded group_list stack frame? This could corrupt
the internal state of the iommu_group and permanently skip deferred setup for
these groups in future retries, because list_empty(&group->entry) will
incorrectly return false.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260911-vfopt-s2-v1-0-fff3db7e01c2@amazon.de?part=1

  reply	other threads:[~2026-09-11 13:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-11 12:58 [RFC PATCH 0/3] iommu: Reduce iommu_probe_device_lock contention Pavol Sakac
2026-09-11 12:58 ` [RFC PATCH 1/3] iommu: split sysfs link publication out of iommu_group_alloc_device() Pavol Sakac
2026-09-11 13:14   ` sashiko-bot [this message]
2026-09-11 12:58 ` [RFC PATCH 2/3] iommu: create device sysfs links outside iommu_probe_device_lock Pavol Sakac
2026-09-11 13:13   ` sashiko-bot
2026-09-11 12:58 ` [RFC PATCH 3/3] iommu: set up the default domain " Pavol Sakac
2026-09-11 13:15   ` sashiko-bot
2026-09-11 17:45 ` [RFC PATCH 0/3] iommu: Reduce iommu_probe_device_lock contention 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=20260911131423.BCF821F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=sakacpav@amazon.de \
    --cc=sashiko-reviews@lists.linux.dev \
    /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.