From: sashiko-bot@kernel.org
To: "Sreeraj S Kurup" <sreekuttan2156239@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2 3/5] drm/amdgpu/aca: Fix inverted validation logic and handle cleanup
Date: Sat, 08 Aug 2026 22:50:15 +0000 [thread overview]
Message-ID: <20260808225016.4FFB31F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260808222742.2859-4-sreekuttan2156239@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [High] The logic change in `amdgpu_aca_get_error_data()` causes global RAS error count queries to fail with `-EOPNOTSUPP` for non-ACA blocks.
Pre-existing issues:
- [High] Delayed work `ras_counte_delay_work` is cancelled after ACA subsystems are torn down, leading to a TOCTOU race condition and use-after-destroy of a mutex.
--
--- Patch [3]: [PATCH v2 3/5] drm/amdgpu/aca: Fix inverted validation logic and handle cleanup ---
commit e884a156d93ba3896781b055b3f77054754fcf85
Author: Sreeraj S Kurup <sreekuttan2156239@gmail.com>
drm/amdgpu/aca: Fix inverted validation logic and handle cleanup
This commit fixes the validation logic in aca_handle_is_valid() and its
caller amdgpu_aca_get_error_data() to properly process valid handles. It
also changes remove_aca_handle() to use list_del_init() to prevent a
potential use-after-free during device teardown.
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c
> index c76664af9902e..b4c1438a56d8c 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c
[ ... ]
> @@ -599,7 +596,7 @@ int amdgpu_aca_get_error_data(struct amdgpu_device *adev, struct aca_handle *han
> if (!handle || !err_data)
> return -EINVAL;
>
> - if (aca_handle_is_valid(handle))
> + if (!aca_handle_is_valid(handle))
> return -EOPNOTSUPP;
[Severity: High]
Does this logic change cause global RAS error count queries to fail for
non-ACA blocks?
Before this patch, zero-initialized handles (where handle->mask is 0) would
cause aca_handle_is_valid() to return false. Since the check here wasn't
negated, the code would bypass the -EOPNOTSUPP return and fall through to:
if ((type < 0) || (!(BIT(type) & handle->mask)))
return 0;
which gracefully returned 0.
With the new negated check, zero-initialized handles for non-ACA blocks (like
HDP) evaluate as invalid and immediately return -EOPNOTSUPP.
Could this overwrite the return value in the loop within
amdgpu_ras_query_error_count() when iterating over RAS blocks?
amdgpu_ras.c:amdgpu_ras_query_error_count() {
...
list_for_each_entry(obj, &con->head, node) {
...
ret = amdgpu_ras_query_error_count_helper(adev, &ce, &ue, &info);
}
}
If a non-ACA block is queried at the end of the loop, this -EOPNOTSUPP could
propagate up, completely breaking global RAS telemetry and preventing cached
counters from updating.
>
> if ((type < 0) || (!(BIT(type) & handle->mask)))
> return 0;
[ ... ]
> @@ -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 this still leave a time-of-check to
time-of-use race condition during device teardown?
Looking at amdgpu_ras_fini(), the delayed work is cancelled after the ACA
subsystems are torn down:
amdgpu_ras.c:amdgpu_ras_fini() {
...
amdgpu_aca_fini();
...
cancel_delayed_work_sync(&con->ras_counte_delay_work);
}
If the delayed work runs concurrently, could it perform the lockless
!list_empty(&handle->node) check in aca_handle_is_valid() and evaluate to
true just before this teardown thread calls remove_aca_handle()?
If remove_aca_handle() then unlinks the node and destroys the handle's mutex,
the worker thread might proceed into __aca_get_error_data() and attempt to
lock a destroyed mutex.
> mgr->nr_handles--;
> }
>
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260808222742.2859-1-sreekuttan2156239@gmail.com?part=3
next prev parent reply other threads:[~2026-08-08 22:50 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-08 22:27 [PATCH v2 0/5] drm/amdgpu/aca: Robustness and safety fixes for ACA driver Sreeraj S Kurup
2026-08-08 22:27 ` [PATCH v2 1/5] drm/amdgpu/aca: Fix race condition and UAF in error cache logging Sreeraj S Kurup
2026-08-08 22:27 ` [PATCH v2 2/5] drm/amdgpu/aca: Add upper bounds check in aca_bank_hwip_is_matched Sreeraj S Kurup
2026-08-08 22:27 ` [PATCH v2 3/5] drm/amdgpu/aca: Fix inverted validation logic and handle cleanup Sreeraj S Kurup
2026-08-08 22:50 ` sashiko-bot [this message]
2026-08-08 22:27 ` [PATCH v2 4/5] drm/amdgpu/aca: Add missing NULL check for banks parameter in aca_banks_add_bank Sreeraj S Kurup
2026-08-08 22:27 ` [PATCH v2 5/5] drm/amdgpu/aca: Fix off-by-one buffer size parameter in add_aca_sysfs Sreeraj S Kurup
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=20260808225016.4FFB31F000E9@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.