From: sashiko-bot@kernel.org
To: "Ibrahim Hashimov" <security@auditcode.ai>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/vkms: Fix UAF between connector configfs rmdir and .detect
Date: Thu, 09 Jul 2026 15:21:53 +0000 [thread overview]
Message-ID: <20260709152154.22B5F1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260709150637.45052-1-security@auditcode.ai>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [Medium] RCU-001 violation: `xa_destroy` is called on `possible_encoders` before the object is unlinked from the RCU list.
Pre-existing issues:
- [High] The debugfs helper `vkms_config_show` is vulnerable to a Use-After-Free because it traverses configuration lists without locks or RCU protection.
--
--- Patch [1]: [PATCH] drm/vkms: Fix UAF between connector configfs rmdir and .detect ---
commit 7286ff600c4e0777d618b609fd944dc368ecbf69
Author: Ibrahim Hashimov <security@auditcode.ai>
drm/vkms: Fix UAF between connector configfs rmdir and .detect
This commit addresses a race condition between concurrent configfs directory
removal and drm connector detection in the vkms driver. It introduces RCU
protection for the connector configuration list to decouple the free side
from the read side, avoiding a lock-ordering deadlock.
> No other vkms_config_for_each_connector() call site (vkms_output.c,
> vkms_config.c is_valid()/debugfs helpers) races a concurrent free:
> they all run either at device-build time (single-threaded) or already
> under connector->dev->lock, so they are left untouched to keep the fix
> minimal and scoped to the reported sink.
[Severity: High]
This is a pre-existing issue, but is this statement about debugfs helpers
accurate?
Looking at vkms_config_show() in drivers/gpu/drm/vkms/vkms_config.c, it is
invoked by the VFS seq_read and iterates over the device's planes, CRTCs,
encoders, and connectors locklessly. It does not appear to acquire the
configfs device mutex dev->lock.
Since configfs permits users to rmdir configuration directories at any time,
a concurrent rmdir triggers the configfs release callbacks like
plane_release() and connector_release(). For planes, CRTCs, and encoders,
these callbacks synchronously kfree() the objects.
Could a concurrent rmdir executed during a debugfs read cause
vkms_config_show() to traverse into freed memory?
> diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c
> index 5a654d6dead84..fc402cf487753 100644
> --- a/drivers/gpu/drm/vkms/vkms_config.c
> +++ b/drivers/gpu/drm/vkms/vkms_config.c
[ ... ]
> @@ -608,8 +615,19 @@ EXPORT_SYMBOL_IF_KUNIT(vkms_config_create_connector);
> void vkms_config_destroy_connector(struct vkms_config_connector *connector_cfg)
> {
> xa_destroy(&connector_cfg->possible_encoders);
[Severity: Medium]
Does this code fully unlink the object from the RCU-protected list before
destroying its components?
In vkms_config_destroy_connector(), xa_destroy() is called on
connector_cfg->possible_encoders before list_del_rcu() removes the object
from the list. This leaves the object partially destructed while it is still
globally visible to concurrent RCU readers traversing the config->connectors
list.
Even if the current RCU reader does not access this field, should the object
be unlinked via list_del_rcu() before calling xa_destroy() to ensure safe
remove-before-reclaim ordering?
> - list_del(&connector_cfg->link);
> - kfree(connector_cfg);
> +
> + /*
> + * connector_release() (vkms_configfs.c) can free a connector while
> + * vkms_connector_detect() is concurrently walking the connectors list
> + * under its own RCU read-side critical section (it cannot take the
> + * configfs device lock: it already runs under
> + * drm_device.mode_config.mutex, and vkms_destroy() takes the two
> + * locks in the opposite order, so plain locking here would deadlock).
> + * Unlink with the RCU-safe primitive and defer the free to after a
> + * grace period so concurrent readers never dereference freed memory.
> + */
> + list_del_rcu(&connector_cfg->link);
> + kfree_rcu(connector_cfg, rcu);
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260709150637.45052-1-security@auditcode.ai?part=1
next parent reply other threads:[~2026-07-09 15:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260709150637.45052-1-security@auditcode.ai>
2026-07-09 15:21 ` sashiko-bot [this message]
[not found] ` <20260709195129.50856-1-security@auditcode.ai>
2026-07-09 20:06 ` [PATCH v2] drm/vkms: Fix UAF between connector configfs rmdir and .detect 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=20260709152154.22B5F1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=security@auditcode.ai \
/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