From: sashiko-bot@kernel.org
To: "Abdurrahman Hussain" <abdurrahman@nexthop.ai>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org
Subject: Re: [PATCH v6 06/10] of/overlay: only treat a positive changeset id as registered
Date: Wed, 05 Aug 2026 20:42:44 +0000 [thread overview]
Message-ID: <20260805204245.3F85A1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260805-nh-of-alias-overlay-v6-6-74f21d440819@nexthop.ai>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but lockless traversal of a shared list `ovcs_list` in `of_overlay_remove_all()` leads to a data race and potential Use-After-Free.
--
--- Patch [6]: [PATCH v6 06/10] of/overlay: only treat a positive changeset id as registered ---
commit ff7e3da3be86949a404438d74d2cffe93f4a4cba
Author: Abdurrahman Hussain <abdurrahman@nexthop.ai>
of/overlay: only treat a positive changeset id as registered
of_overlay_fdt_apply() stores the idr_alloc() return value in
ovcs->id before checking it. On failure the stored id is negative,
free_overlay_changeset()'s "if (ovcs->id)" check passes, idr_remove()
is called with a negative id and list_del() runs on ovcs->ovcs_list,
which is not initialized until after the id allocation. An allocation
failure at that point dereferences NULL.
Make free_overlay_changeset() treat only a strict-positive id as
registered. The rest of the function already copes with a
partially-initialized ovcs, so the error path stays a plain
goto err_free_ovcs.
Cc: stable@vger.kernel.org
> diff --git a/drivers/of/overlay.c b/drivers/of/overlay.c
> index 284c9bc6c9cfc..9b9f198a1d70a 100644
> --- a/drivers/of/overlay.c
> +++ b/drivers/of/overlay.c
> @@ -860,7 +860,8 @@ static void free_overlay_changeset(struct overlay_changeset *ovcs)
> if (ovcs->cset.entries.next)
> of_changeset_destroy(&ovcs->cset);
>
> - if (ovcs->id) {
> + /* a failed idr_alloc() leaves its negative error in ovcs->id */
> + if (ovcs->id > 0) {
> idr_remove(&ovcs_idr, ovcs->id);
> list_del(&ovcs->ovcs_list);
[Severity: High]
This problem wasn't introduced by this patch, but lockless traversal of a
shared list ovcs_list in of_overlay_remove_all() leads to a data race.
Is it safe to iterate ovcs_list without holding of_mutex?
drivers/of/overlay.c:of_overlay_remove_all() {
...
list_for_each_entry_safe_reverse(ovcs, ovcs_n, &ovcs_list, ovcs_list) {
ret = of_overlay_remove(&ovcs->id);
...
}
The list_for_each_entry_safe_reverse() iterator only protects against
the deletion of the current entry being processed.
If another thread concurrently modifies the list (e.g., via
of_overlay_fdt_apply() or of_overlay_remove()), could this corrupt the
list pointers or remove the cached next entry, leading to a Use-After-Free?
> ovcs->id = 0;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260805-nh-of-alias-overlay-v6-0-74f21d440819@nexthop.ai?part=6
next prev parent reply other threads:[~2026-08-05 20:42 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-05 20:30 [PATCH v6 00/10] of: teach overlay code to keep /aliases in sync Abdurrahman Hussain
2026-08-05 20:31 ` [PATCH v6 01/10] of: fix out-of-bounds read in of_alias_scan() stem parser Abdurrahman Hussain
2026-08-06 8:10 ` Geert Uytterhoeven
2026-08-05 20:31 ` [PATCH v6 02/10] of: hold a reference on of_aliases during alias path resolution Abdurrahman Hussain
2026-08-05 20:52 ` sashiko-bot
2026-08-05 20:31 ` [PATCH v6 03/10] of: update /aliases lookup on reconfig notifications Abdurrahman Hussain
2026-08-05 20:31 ` [PATCH v6 04/10] of/overlay: look up absolute target-paths absolutely Abdurrahman Hussain
2026-08-05 20:40 ` sashiko-bot
2026-08-05 20:31 ` [PATCH v6 05/10] of/overlay: put property on deadprops only after changeset add succeeds Abdurrahman Hussain
2026-08-05 20:45 ` sashiko-bot
2026-08-05 20:31 ` [PATCH v6 06/10] of/overlay: only treat a positive changeset id as registered Abdurrahman Hussain
2026-08-05 20:42 ` sashiko-bot [this message]
2026-08-06 7:52 ` Geert Uytterhoeven
2026-08-05 20:31 ` [PATCH v6 07/10] of/overlay: don't create "//" paths for fragments targeting the root Abdurrahman Hussain
2026-08-05 20:45 ` sashiko-bot
2026-08-05 20:31 ` [PATCH v6 08/10] of/overlay: return ERR_PTR from dup_and_fixup_symbol_prop() Abdurrahman Hussain
2026-08-05 20:31 ` [PATCH v6 09/10] of/overlay: rewrite /aliases path values to live-tree paths Abdurrahman Hussain
2026-08-05 20:31 ` [PATCH v6 10/10] 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=20260805204245.3F85A1F000E9@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