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 v4 5/6] drm/amdgpu/aca: Fix off-by-one buffer size parameter in add_aca_sysfs
Date: Sun, 09 Aug 2026 09:13:18 +0000	[thread overview]
Message-ID: <20260809091319.4444B1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260809084735.9743-6-sreekuttan2156239@gmail.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Invalid free of an interior pointer causing a kernel panic during driver teardown.
--

--- Patch [5]: [PATCH v4 5/6] drm/amdgpu/aca: Fix off-by-one buffer size parameter in add_aca_sysfs ---
commit 4e00dff410196f38991a5223ac5b71f0384ad6fa
Author: Sreeraj S Kurup <sreekuttan2156239@gmail.com>

    drm/amdgpu/aca: Fix off-by-one buffer size parameter in add_aca_sysfs
    
    snprintf() guarantees NUL-termination within the size limit specified by
    its second argument. Passing 'sizeof(handle->attr_name) - 1'
    unnecessarily reduces the usable buffer capacity by one byte, causing
    sysfs attribute names to be truncated early.
    
    Pass 'sizeof(handle->attr_name)' directly to snprintf() in add_aca_sysfs()
    to allow full use of the allocated buffer space.
    
    Signed-off-by: Sreeraj S Kurup <sreekuttan2156239@gmail.com>

> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c
> index dcddeb3816285..3da3d369a9187 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c
> @@ -682,7 +682,7 @@ static int add_aca_sysfs(struct amdgpu_device *adev, struct aca_handle *handle)
>  {
>  	struct device_attribute *aca_attr = &handle->aca_attr;
>  
> -	snprintf(handle->attr_name, sizeof(handle->attr_name) - 1, "aca_%s", handle->name);
> +	snprintf(handle->attr_name, sizeof(handle->attr_name), "aca_%s", handle->name);

[Severity: High]
Is the handle pointer passed here an interior pointer that gets improperly
freed later?

Looking at amdgpu_ras_bind_aca(), it appears an embedded pointer is passed
into the ACA subsystem:

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c:amdgpu_ras_bind_aca() {
    ...
    return amdgpu_aca_add_handle(adev, &obj->aca_handle, ras_block_str(blk), aca_info, data);
}

During driver teardown, remove_aca_handle() unconditionally frees this
interior pointer:

drivers/gpu/drm/amd/amdgpu/amdgpu_aca.c:remove_aca_handle() {
    ...
    kfree(handle);
}

Could this lead to a SLUB panic when removing the driver module or tearing
down the device?

>  	aca_attr->show = aca_sysfs_read;
>  	aca_attr->attr.name = handle->attr_name;
>  	aca_attr->attr.mode = S_IRUGO;

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

  reply	other threads:[~2026-08-09  9:13 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-09  8:47 [PATCH v4 0/6] drm/amdgpu: Robustness and safety fixes for ACA and RAS drivers Sreeraj S Kurup
2026-08-09  8:47 ` [PATCH v4 1/6] drm/amdgpu/aca: Fix race condition and UAF in error cache logging Sreeraj S Kurup
2026-08-09  8:47 ` [PATCH v4 2/6] drm/amdgpu/aca: Add upper bounds check in aca_bank_hwip_is_matched Sreeraj S Kurup
2026-08-09  8:47 ` [PATCH v4 3/6] drm/amdgpu/aca: Fix inverted validation logic and list cleanup Sreeraj S Kurup
2026-08-09  9:11   ` sashiko-bot
2026-08-09  8:47 ` [PATCH v4 4/6] drm/amdgpu/aca: Add missing NULL check for banks parameter in aca_banks_add_bank Sreeraj S Kurup
2026-08-09  9:19   ` sashiko-bot
2026-08-09  8:47 ` [PATCH v4 5/6] drm/amdgpu/aca: Fix off-by-one buffer size parameter in add_aca_sysfs Sreeraj S Kurup
2026-08-09  9:13   ` sashiko-bot [this message]
2026-08-09  8:47 ` [PATCH v4 6/6] drm/amdgpu/ras: Fix delayed work cancellation order during teardown Sreeraj S Kurup
2026-08-09  9:23   ` 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=20260809091319.4444B1F000E9@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.