All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Sreeraj S Kurup" <sreekuttan2156239@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v3 3/6] drm/amdgpu/aca: Fix inverted validation logic and list cleanup
Date: Sun, 09 Aug 2026 05:42:53 +0000	[thread overview]
Message-ID: <20260809054253.DB9C81F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260809051200.3276-4-sreekuttan2156239@gmail.com>

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

New issues:
- [High] Using `list_del_init()` on a locklessly-iterated list causes a potential kernel infinite loop if a handle is removed concurrently with list traversal.

Pre-existing issues:
- [High] A TOCTOU race condition exists between background RAS querying and device teardown, leading to a use-after-free of the ACA error cache and its mutex.
--

--- Patch [3]: [PATCH v3 3/6] drm/amdgpu/aca: Fix inverted validation logic and list cleanup ---
commit 0f8631e3d7835b4beff6c092382f39cf69067a82
Author: Sreeraj S Kurup <sreekuttan2156239@gmail.com>

drm/amdgpu/aca: Fix inverted validation logic and list cleanup

This commit fixes the validation logic in aca_handle_is_valid() by ensuring
the handle is non-NULL, contains a valid mask, and is actively registered
in the list. It also updates amdgpu_aca_get_error_data() to return 0 for
invalid handles, and modifies remove_aca_handle() to use list_del_init()
to prevent potential use-after-free issues.

> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c
> index c76664af9902e..06cb3ad1ce623 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c
[ ... ]
> @@ -717,7 +714,7 @@ static void remove_aca_handle(struct aca_handle *handle)
>  	struct aca_handle_manager *mgr = handle->mgr;
>  
>  	aca_fini_error_cache(handle);
> -	list_del(&handle->node);
> +	list_del_init(&handle->node);

[Severity: High]
This is a pre-existing issue, but does the ordering in this function create
a race condition with the background RAS query thread?

If the background thread evaluates aca_handle_is_valid() concurrently
during teardown, it might see a valid node because the background work is
cancelled after the handles are torn down:

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c:amdgpu_ras_fini() {
	...
	amdgpu_aca_fini(adev);
	...
	cancel_delayed_work_sync(&con->ras_counte_delay_work);
	...
}

Because aca_fini_error_cache() is called before the node is removed from
the list, could the background thread see a valid node and then attempt to
acquire a destroyed mutex here?

drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c:aca_log_aca_error() {
	...
	mutex_lock(&aerr->lock);
	...
}

[Severity: High]
Does switching to list_del_init() here create a risk of an infinite loop
during list traversal?

The handle list appears to be iterated locklessly here:

drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c:aca_dispatch_bank() {
	...
	list_for_each_entry(handle, &mgr->list, node) {
	...
}

If a handle is removed concurrently with list traversal, list_del_init()
will set the node's next pointer to itself. Will this cause the lockless
iterator in aca_dispatch_bank() to get stuck repeatedly visiting the same
removed node?

>  	mgr->nr_handles--;
>  }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260809051200.3276-1-sreekuttan2156239@gmail.com?part=3

  reply	other threads:[~2026-08-09  5:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-09  5:11 [PATCH v3 0/6] drm/amdgpu: Robustness and safety fixes for ACA and RAS drivers Sreeraj S Kurup
2026-08-09  5:11 ` [PATCH v3 1/6] drm/amdgpu/aca: Fix race condition and UAF in error cache logging Sreeraj S Kurup
2026-08-09  5:11 ` [PATCH v3 2/6] drm/amdgpu/aca: Add upper bounds check in aca_bank_hwip_is_matched Sreeraj S Kurup
2026-08-09  5:11 ` [PATCH v3 3/6] drm/amdgpu/aca: Fix inverted validation logic and list cleanup Sreeraj S Kurup
2026-08-09  5:42   ` sashiko-bot [this message]
2026-08-09  5:11 ` [PATCH v3 4/6] drm/amdgpu/aca: Add missing NULL check for banks parameter in aca_banks_add_bank Sreeraj S Kurup
2026-08-09  5:11 ` [PATCH v3 5/6] drm/amdgpu/aca: Fix off-by-one buffer size parameter in add_aca_sysfs Sreeraj S Kurup
2026-08-09  5:12 ` [PATCH v3 6/6] drm/amdgpu/ras: Cancel delayed work before ACA teardown in amdgpu_ras_fini Sreeraj S Kurup
2026-08-09  5:53   ` sashiko-bot

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=20260809054253.DB9C81F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=sreekuttan2156239@gmail.com \
    /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.