mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Evgenii Burenchev <evg28bur@yandex.ru>
To: sashiko-bot@kernel.org
Cc: harry.wentland@amd.com, sunpeng.li@amd.com, siqueira@igalia.com,
	alexander.deucher@amd.com, christian.koenig@amd.com,
	airlied@gmail.com, simona@ffwll.ch, mario.limonciello@amd.com,
	alex.hung@amd.com, superm1@kernel.org, timur.kristof@gmail.com,
	ivan.lipski@amd.com, ray.wu@amd.com, aurabindo.pillai@amd.com,
	chen-yu.chen@amd.com, mripard@kernel.org, Dillon.Varone@amd.com,
	mwen@igalia.com, chiahsuan.chung@amd.com, kenneth.feng@amd.com,
	srinivasan.shanmugam@amd.com, tzimmermann@suse.de,
	Alvin.Lee2@amd.com, dmitry.baryshkov@oss.qualcomm.com,
	chaitanya.kumar.borah@intel.com, ekurzinger@gmail.com,
	pierre-eric.pelloux-prayer@amd.com, HaoPing.Liu@amd.com,
	Tony.Cheng@amd.com, amd-gfx@lists.freedesktop.org,
	dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	lvc-project@linuxtesting.org, sashiko-reviews@lists.linux.dev,
	Evgenii Burenchev <evg28bur@yandex.ru>
Subject: Re: [PATCH v4 1/3] drm/amd/display: Fix dangling pointer in plane reset function
Date: Mon, 29 Jun 2026 13:32:36 +0300	[thread overview]
Message-ID: <20260629103236.12380-1-evg28bur@yandex.ru> (raw)
In-Reply-To: <20260629092538.4D19B1F000E9@smtp.kernel.org>

On Mon, Jun 29, 2026 at 09:25:37AM +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
>
> Pre-existing issues:
> - [High] Dangling pointer (Use-After-Free) vulnerability in vmwgfx component reset hooks on memory allocation failure.
> - [High] Missing NULL pointer checks in amdgpu duplicate_state hooks lead to NULL pointer dereference on allocation failure.

Thank you for the review.

> [Severity: High]
> This is a pre-existing issue, but returning here when plane->state is
> initially NULL means plane->state remains NULL. Later, when the DRM core
> attempts to duplicate the state, it calls the driver's duplicate hook.
>
> In amdgpu_dm_plane_drm_plane_duplicate_state(), there is no check if
> plane->state is NULL:
>
> amdgpu_dm_plane_drm_plane_duplicate_state() {
>     ...
>         dm_plane_state = kzalloc_obj(*dm_plane_state);
>         if (!dm_plane_state)
>                 return NULL;
>
>         __drm_atomic_helper_plane_duplicate_state(plane, &dm_plane_state->base);
>     ...
> }
>
> Will this cause a NULL pointer dereference in
> __drm_atomic_helper_plane_duplicate_state() since it will crash when trying
> to memcpy from a NULL plane->state?

The DRM core guarantees that duplicate_state() is never called on an object
with a NULL state. The state pointer is always valid when duplication is
requested, as DRM only calls this hook on objects that are already fully
initialized and have an active state.

Therefore, the scenario described above is not possible in practice.
This patch does not introduce any new NULL pointer risks.

> The same pattern appears in amdgpu_dm_connector_atomic_duplicate_state(),
> where to_dm_connector_state(connector->state) will resolve to an invalid
> pointer offset from NULL, causing kmemdup to panic:
>
> Could these duplicate_state hooks be updated to handle a NULL state?

As explained above, DRM core guarantees that duplicate_state is only called
with a valid state. Adding NULL checks in duplicate_state hooks would be
redundant and unnecessary.

> [Severity: High]
> This isn't a bug introduced by this patch, but I noticed the exact same
> dangling pointer pattern this patch fixes also exists in the vmwgfx driver.
>
> In vmw_du_connector_reset(), if kzalloc_obj() fails, it returns without
> updating the state pointer, leaving a dangling pointer:
>
> The identical issue also occurs in vmw_du_crtc_reset() and
> vmw_du_plane_reset().
>
> Since unhandled use-after-free bugs in core DRM state structures can cause
> severe stability issues, do these vmwgfx component reset hooks need a similar
> fix to allocate the new state before freeing the old one?

This is a separate pre-existing issue in a different driver (vmwgfx).
While it does appear to suffer from the same dangling pointer pattern,
it is unrelated to this patch series and should be addressed in a
separate patch by the vmwgfx maintainers.

This patch series only addresses the dangling pointer issue in the
amdgpu_dm reset functions.

Signed-off-by: Evgenii Burenchev <evg28bur@yandex.ru>

       reply	other threads:[~2026-06-29 10:33 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20260629092538.4D19B1F000E9@smtp.kernel.org>
2026-06-29 10:32 ` Evgenii Burenchev [this message]
2026-06-29  9:04 [PATCH v4 0/3] drm/amd/display: Fix dangling pointers in state reset functions Evgenii Burenchev
2026-06-29  9:04 ` [PATCH v4 1/3] drm/amd/display: Fix dangling pointer in plane reset function Evgenii Burenchev

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=20260629103236.12380-1-evg28bur@yandex.ru \
    --to=evg28bur@yandex.ru \
    --cc=Alvin.Lee2@amd.com \
    --cc=Dillon.Varone@amd.com \
    --cc=HaoPing.Liu@amd.com \
    --cc=Tony.Cheng@amd.com \
    --cc=airlied@gmail.com \
    --cc=alex.hung@amd.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=aurabindo.pillai@amd.com \
    --cc=chaitanya.kumar.borah@intel.com \
    --cc=chen-yu.chen@amd.com \
    --cc=chiahsuan.chung@amd.com \
    --cc=christian.koenig@amd.com \
    --cc=dmitry.baryshkov@oss.qualcomm.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=ekurzinger@gmail.com \
    --cc=harry.wentland@amd.com \
    --cc=ivan.lipski@amd.com \
    --cc=kenneth.feng@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lvc-project@linuxtesting.org \
    --cc=mario.limonciello@amd.com \
    --cc=mripard@kernel.org \
    --cc=mwen@igalia.com \
    --cc=pierre-eric.pelloux-prayer@amd.com \
    --cc=ray.wu@amd.com \
    --cc=sashiko-bot@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=simona@ffwll.ch \
    --cc=siqueira@igalia.com \
    --cc=srinivasan.shanmugam@amd.com \
    --cc=sunpeng.li@amd.com \
    --cc=superm1@kernel.org \
    --cc=timur.kristof@gmail.com \
    --cc=tzimmermann@suse.de \
    /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

all inboxes | Powered by JetHome®