All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "James Hilliard" <james.hilliard1@gmail.com>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH net-next v2 2/4] driver core: factor sync-state-only link cleanup
Date: Tue, 18 Aug 2026 00:00:46 +0000	[thread overview]
Message-ID: <20260818000046.D34CC1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260816-submit-phy-package-fwdevlink-v1-v2-2-23e55dd59fad@gmail.com>

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

Pre-existing issues:
- [High] Concurrent lockless list modification of `links.defer_sync` causes list corruption, infinite loop, and use-after-free in `device_links_flush_sync_list`.
--

--- Patch [2]: [PATCH net-next v2 2/4] driver core: factor sync-state-only link cleanup ---
commit 1c995f67e6fafdae816a7fe7115a3a496dc0c968
Author: James Hilliard <james.hilliard1@gmail.com>

driver core: factor sync-state-only link cleanup

This commit factors out the existing sync-state-only link cleanup into a 
lock-held helper to reuse it from device_links_driver_bound(). It also adds 
a public wrapper so frameworks can drop temporary proxy links without 
affecting real dependency links.

> diff --git a/drivers/base/core.c b/drivers/base/core.c
> index 4d026682944f2..627fcfa274f0e 100644
> --- a/drivers/base/core.c
> +++ b/drivers/base/core.c

[ ... ]

> @@ -1305,6 +1305,57 @@ static void device_link_drop_managed(struct device_link *link)
> +void device_links_drop_sync_state_only(struct device *dev)
> +{
> +	LIST_HEAD(sync_list);
> +
> +	device_links_write_lock();
> +	__device_links_drop_sync_state_only(dev, &sync_list);
> +	device_links_write_unlock();
> +

[Severity: High]
This is a pre-existing issue, but can a concurrent unbind corrupt this list
iteration?

Looking at device_links_flush_sync_list(), it iterates over the sync_list
without holding the device links write lock:

drivers/base/core.c:device_links_flush_sync_list() {
    ...
    list_for_each_entry_safe(dev, tmp, list, links.defer_sync) {
        list_del_init(&dev->links.defer_sync);
        ...
        put_device(dev);
    }
}

Concurrently, if a device currently queued in the sync_list is unbound,
device_links_driver_cleanup() modifies the same list node while holding
device_links_write_lock():

drivers/base/core.c:device_links_driver_cleanup() {
    ...
    list_del_init(&dev->links.defer_sync);
    ...
}

If device_links_driver_cleanup() modifies the node that happens to be the
tmp cursor in the lockless list_for_each_entry_safe() loop, wouldn't
tmp->next point to itself due to the list_del_init() call?

This appears like it would cause an infinite loop processing the same device,
calling put_device(dev) on each iteration until the refcount underflows
and triggers a use-after-free.

> +	device_links_flush_sync_list(&sync_list, NULL);
> +}
> +EXPORT_SYMBOL_GPL(device_links_drop_sync_state_only);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260816-submit-phy-package-fwdevlink-v1-v2-0-23e55dd59fad@gmail.com?part=2

  parent reply	other threads:[~2026-08-18  0:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-17  0:00 [PATCH net-next v2 0/4] of: mdio: fix fw_devlink for Ethernet PHY packages James Hilliard
2026-08-17  0:00 ` [PATCH net-next v2 1/4] of: property: skip links without a consumer node James Hilliard
2026-08-17  5:07   ` Saravana Kannan
2026-08-17 12:57     ` Andrew Lunn
2026-08-17  0:00 ` [PATCH net-next v2 2/4] driver core: factor sync-state-only link cleanup James Hilliard
2026-08-17  5:07   ` Saravana Kannan
2026-08-18  0:00   ` sashiko-bot [this message]
2026-08-17  0:00 ` [PATCH net-next v2 3/4] of: property: link PHY package suppliers to member PHYs James Hilliard
2026-08-17  5:07   ` Saravana Kannan
2026-08-17  0:00 ` [PATCH net-next v2 4/4] net: mdio: release fw_devlink proxies after population James Hilliard
2026-08-17  5:07 ` [PATCH net-next v2 0/4] of: mdio: fix fw_devlink for Ethernet PHY packages Saravana Kannan

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=20260818000046.D34CC1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=james.hilliard1@gmail.com \
    --cc=robh@kernel.org \
    --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.