dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: manushprajwal <manushprajwal555@gmail.com>
To: Paul Kocialkowski <paulk@sys-base.io>
Cc: Maxime Ripard <mripard@kernel.org>,
	dri-devel@lists.freedesktop.org,
	Manush Prajwal <manushprajwal555@gmail.com>
Subject: Re: [PATCH] drm: logicvc: fix device_node refcount leak in logicvc_layers_init()
Date: Sat, 15 Aug 2026 00:35:57 +0530	[thread overview]
Message-ID: <20260814190557.987-1-manushprajwal555@gmail.com> (raw)

From: Manush Prajwal <manushprajwal555@gmail.com>

Thanks for the review. I traced this through and the UAF is real,
though it's independent of this patch, as noted:

- logicvc_layer_init() embeds drm_plane in a devm_kzalloc()'d struct
  and registers it with the unmanaged drm_universal_plane_init(), so
  the plane stays linked into drm_dev->mode_config.plane_list.
- On a later layer's init failure, logicvc_layers_init()'s error path
  calls logicvc_layer_fini() on every already-succeeded layer, which
  does list_del() + devm_kfree() immediately, but never calls
  drm_plane_cleanup() first, so the freed layer's plane is still
  linked in mode_config.plane_list.
- drmm_mode_config_init() (drivers/gpu/drm/logicvc/logicvc_drm.c)
  registers drm_mode_config_cleanup() as a drmm action tied to
  drm_dev's own refcount, which is only dropped via
  devm_drm_dev_alloc()'s devres release on the parent device, i.e.
  later than the explicit devm_kfree() above, not before it.
- So drm_mode_config_cleanup() later walks plane_list and dereferences
  the already-freed layer/plane.

The same devm_kzalloc() plus unmanaged-DRM-object pattern exists in
logicvc_crtc_init() and logicvc_interface_init(), so this looks
driver-wide rather than layer-specific.

That's a separate, pre-existing bug in the error-unwind path and out
of scope for this one-line of_node_put() fix. A real fix would need
either drm_plane_cleanup()/drm_encoder_cleanup()/drm_connector_cleanup()
calls added to the _fini() helpers before devm_kfree(), or switching
these to drmm-managed allocations. Happy to send that as a follow-up
patch if there's interest.

Signed-off-by: Manush Prajwal <manushprajwal555@gmail.com>

             reply	other threads:[~2026-08-16 14:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-14 19:05 manushprajwal [this message]
  -- strict thread matches above, loose matches on Subject: below --
2026-08-13 11:10 [PATCH] drm: logicvc: fix device_node refcount leak in logicvc_layers_init() Manush Prajwal
2026-08-14  7:19 ` sashiko-bot
2026-08-24  8:41 ` Markus Elfring

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=20260814190557.987-1-manushprajwal555@gmail.com \
    --to=manushprajwal555@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=mripard@kernel.org \
    --cc=paulk@sys-base.io \
    /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