Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Abdurrahman Hussain" <abdurrahman@nexthop.ai>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH v5 2/9] of: update /aliases lookup on reconfig notifications
Date: Thu, 23 Jul 2026 03:34:20 +0000	[thread overview]
Message-ID: <20260723033421.503EA1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260722-nh-of-alias-overlay-v5-2-2abe2bb9cdbc@nexthop.ai>

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

Pre-existing issues:
- [High] Lockless iteration over `aliases->properties` in `of_find_node_opts_by_path()` races with concurrent property additions/removals.
--

--- Patch [2]: [PATCH v5 2/9] of: update /aliases lookup on reconfig notifications ---
commit 9797d916f1b83a48a93f588ed426470feb4bed4a
Author: Abdurrahman Hussain <abdurrahman@nexthop.ai>

of: update /aliases lookup on reconfig notifications
    
Registers a reconfig notifier to mirror /aliases property changes into
aliases_lookup. The notifier chain covers changesets and overlays, matching
the /aliases node by name and root parent.

Link: https://lore.kernel.org/lkml/1435675876-2159-1-git-send-email-geert+renesas@glider.be/
Link: https://lore.kernel.org/lkml/20150630172131.D4E6CC4041A@trevor.secretlab.ca/

> diff --git a/drivers/of/base.c b/drivers/of/base.c
> index 6f79f593fc779..612e2cd31688d 100644
> --- a/drivers/of/base.c
> +++ b/drivers/of/base.c
[ ... ]
> +	case OF_RECONFIG_ADD_PROPERTY:
> +		of_alias_create(rd->prop, alias_alloc, true);
> +		break;
> +	case OF_RECONFIG_REMOVE_PROPERTY:
> +		of_alias_destroy(rd->prop->name);
> +		break;
> +	case OF_RECONFIG_UPDATE_PROPERTY:
> +		if (rd->old_prop)
> +			of_alias_destroy(rd->old_prop->name);
> +		of_alias_create(rd->prop, alias_alloc, true);
> +		break;

[Severity: High]
This isn't a bug introduced by this patch, but can this concurrent property
addition or removal race with the lockless property iteration in
of_find_node_opts_by_path()?

In drivers/of/base.c:of_find_node_opts_by_path(), aliases->properties is
iterated locklessly:

		for_each_property_of_node(aliases, pp) {
			if (!strncmp(pp->name, path, len) && !pp->name[len]) {
				if (of_alias_value_ok(pp))
					value = pp->value;
				break;
			}
		}

Concurrent property modifications via __of_add_property() or
__of_update_property() manipulate the list pointers without memory barriers.
A lockless reader may traverse to a newly added property before its contents
(like pp->name) are globally visible, leading to a crash. Additionally,
__of_update_property() repoints oldprop->next to deadprops, which can divert
a lockless reader into the dead properties list.

Could taking devtree_lock during the iteration, or utilizing the newly
synchronized aliases_lookup list, prevent this race?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260722-nh-of-alias-overlay-v5-0-2abe2bb9cdbc@nexthop.ai?part=2

  reply	other threads:[~2026-07-23  3:34 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-23  3:19 [PATCH v5 0/9] of: teach overlay code to keep /aliases in sync Abdurrahman Hussain
2026-07-23  3:19 ` [PATCH v5 1/9] of: hold a reference on of_aliases during alias path resolution Abdurrahman Hussain
2026-07-23  3:35   ` sashiko-bot
2026-07-23  3:19 ` [PATCH v5 2/9] of: update /aliases lookup on reconfig notifications Abdurrahman Hussain
2026-07-23  3:34   ` sashiko-bot [this message]
2026-07-23  3:19 ` [PATCH v5 3/9] of/overlay: look up absolute target-paths absolutely Abdurrahman Hussain
2026-07-23  3:19 ` [PATCH v5 4/9] of/overlay: put property on deadprops only after changeset add succeeds Abdurrahman Hussain
2026-07-23  3:19 ` [PATCH v5 5/9] of/overlay: don't keep a negative id in ovcs->id on idr_alloc() failure Abdurrahman Hussain
2026-07-23  3:39   ` sashiko-bot
2026-07-23  3:19 ` [PATCH v5 6/9] of/overlay: don't create "//" paths for fragments targeting the root Abdurrahman Hussain
2026-07-23  3:35   ` sashiko-bot
2026-07-23  3:19 ` [PATCH v5 7/9] of/overlay: return ERR_PTR from dup_and_fixup_symbol_prop() Abdurrahman Hussain
2026-07-23  3:19 ` [PATCH v5 8/9] of/overlay: rewrite /aliases path values to live-tree paths Abdurrahman Hussain
2026-07-23  3:19 ` [PATCH v5 9/9] of: unittest: cover /aliases updates from overlay apply/revert Abdurrahman Hussain

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=20260723033421.503EA1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=abdurrahman@nexthop.ai \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox