From: sashiko-bot@kernel.org
To: "Louis Chauvet" <louis.chauvet@bootlin.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v7 41/43] drm/vkms: Introduce configfs for dynamic connector creation
Date: Thu, 26 Nov 2026 12:02:15 +0000 [thread overview]
Message-ID: <sashiko-outbox-235470@kernel.org> (raw)
In-Reply-To: <20261126-vkms-all-config-v7-41-21194cda2468@bootlin.com>
Thank you for your contribution! Sashiko AI review found 6 potential
issues to consider:
- [High] drm/vkms: lock ordering inversion in connector_enabled_store()
and release
- [High] drm/vkms: hot-attach before validation in
connector_possible_encoders_allow_link()
- [High] drm/vkms: vkms_config_is_valid() in connector_enabled_store()
blocks disable/hot-add
- [Medium] drm/vkms: static connector with enabled=0 bypasses -EBUSY
check on encoder link
- [Medium] drm/vkms: missing connector_is_enabled() check on EDID store
hotplug trigger
- [Medium] drm/vkms: race and dangling connector pointer between device
enable and dynamic configfs
--
commit fa8dad28555bc1ce76cc884bdb3e5a07d26b3e35
Author: Louis Chauvet <louis.chauvet@bootlin.com>
drm/vkms: Introduce configfs for dynamic connector creation
This commit adds dynamic and enabled configfs attributes to VKMS
connectors to support creating, removing, and attaching encoders to
dynamic connectors at runtime.
> diff --git a/drivers/gpu/drm/vkms/vkms_configfs.c b/drivers/gpu/drm/vkms/vkms_configfs.c
> index 1822978879ff3..0681722e98e8d 100644
> --- a/drivers/gpu/drm/vkms/vkms_configfs.c
> +++ b/drivers/gpu/drm/vkms/vkms_configfs.c
[ ... ]
> @@ -1281,6 +1287,106 @@ static ssize_t connector_edid_store(struct config_item *item,
> connector_status_disconnected)
> vkms_trigger_connector_hotplug(connector->dev->config->dev);
> }
[Severity: Medium]
Should connector_edid_store() and connector_edid_enabled_store() also
check connector_is_enabled() before calling
vkms_trigger_connector_hotplug(), as connector_status_store() does?
Because a newly created dynamic connector defaults to
connector_status_connected, configuring its EDID attributes while it is
still disabled triggers a hotplug event on the device before the connector
has been hot-added.
> + return count;
> +}
> +
> +static ssize_t connector_enabled_show(struct config_item *item, char *page)
> +{
> + struct vkms_configfs_connector *connector;
> + bool enabled;
> +
> + connector = connector_item_to_vkms_configfs_connector(item);
> +
> + scoped_guard(mutex, &connector->dev->config->lock)
> + enabled = vkms_config_connector_is_enabled(connector->config);
> +
> + return sprintf(page, "%d\n", enabled);
> +}
> +
> +static ssize_t connector_enabled_store(struct config_item *item,
> + const char *page, size_t count)
> +{
> + struct vkms_configfs_connector *connector;
> + struct vkms_config_connector *connector_cfg;
> + bool enabled, was_enabled;
> +
> + connector = connector_item_to_vkms_configfs_connector(item);
> + connector_cfg = connector->config;
> +
> + if (kstrtobool(page, &enabled))
> + return -EINVAL;
> + scoped_guard(mutex, &connector->dev->config->lock) {
> + if (!connector->dev->enabled) {
> + vkms_config_connector_set_enabled(connector_cfg, enabled);
> + } else {
> + // Only dynamic connector can be enabled/disabled at runtime
> + if (!connector_cfg->dynamic)
> + return -EBUSY;
> +
> + was_enabled = vkms_config_connector_is_enabled(connector_cfg);
> + vkms_config_connector_set_enabled(connector_cfg, enabled);
> +
> + // Resulting configuration is invalid (missing encoder for example)
> + // Early return to avoid drm core issue
> + if (!vkms_config_is_valid(connector->dev->config)) {
> + vkms_config_connector_set_enabled(connector_cfg,
> + was_enabled);
> + return -EINVAL;
> + }
[Severity: High]
Does running vkms_config_is_valid() across the whole device here prevent
enabling or disabling a dynamic connector whenever any disabled dynamic
connector has no encoder linked?
valid_connector_possible_encoders() requires every connector in
config->connectors to have at least one possible encoder, regardless of
whether it is enabled:
drivers/gpu/drm/vkms/vkms_config.c:valid_connector_possible_encoders() {
...
vkms_config_for_each_connector(config, connector_cfg) {
if (xa_empty(&connector_cfg->possible_encoders)) {
drm_info(dev,
"All connectors must have at least one possible encoder\n");
return false;
}
}
...
}
As a result, creating a new connector directory while the device is
enabled (which starts with dynamic=true, enabled=false and an empty
possible_encoders xarray) causes vkms_config_is_valid() to fail for all
connectors until that disabled connector is also given an encoder.
Similarly, if a user unlinks the encoder from a dynamic connector and then
writes 0 to enabled to remove it, connector_enabled_store() rejects the
disable with -EINVAL.
> +
> + if (!was_enabled && enabled) {
> + struct vkms_connector *conn;
> +
> + // Adding the connector
> + conn = vkms_connector_hot_add(connector->dev->config->dev,
> + connector_cfg);
> + if (IS_ERR(conn)) {
> + vkms_config_connector_set_enabled(connector_cfg, was_enabled);
> + return PTR_ERR(conn);
> + }
> + connector_cfg->connector = conn;
> + } else if (was_enabled && !enabled) {
> + vkms_connector_hot_remove(connector_cfg->connector);
> + }
> + }
> + }
> + return count;
> +}
[Severity: High]
Can calling vkms_connector_hot_add() and vkms_connector_hot_remove() under
connector->dev->config->lock in connector_enabled_store() (and in
connector_release() below) cause an ABBA deadlock with connector probing?
Both vkms_connector_hot_add() and vkms_connector_hot_remove() acquire
mode_config.mutex while config->lock is held. During connector probing,
the DRM core holds mode_config.mutex and calls vkms_connector_detect(),
which takes config->lock:
CPU0 CPU1
---- ----
lock(&config->lock)
lock(&dev->mode_config.mutex)
lock(&dev->mode_config.mutex)
lock(&config->lock)
*** DEADLOCK ***
CPU0: connector_enabled_store() -> vkms_connector_hot_add()
CPU1: drm_mode_getconnector() -> ... -> vkms_connector_detect()
[Severity: Medium]
Can connector_enabled_store(), connector_release(), or
connector_possible_encoders_allow_link() race with device_enabled_store()
and dereference an uninitialized or stale connector_cfg->connector or
config->dev pointer?
device_enabled_store() sets dev->enabled = true under config->lock and
then drops the lock before calling vkms_create(). In addition, when a
device is disabled, vkms_connector_dynamic_destroy() frees the dynamic
vkms_connector without clearing connector_cfg->connector.
CPU0 CPU1
device_enabled_store()
lock(&config->lock)
dev->enabled = true
unlock(&config->lock)
connector_enabled_store()
lock(&config->lock)
if (connector->dev->enabled)
vkms_connector_hot_remove(
connector_cfg->connector)
<-- NULL or use-after-free
vkms_create()
...
connector_cfg->connector = ...
[ ... ]
> @@ -1335,14 +1452,24 @@ static int connector_possible_encoders_allow_link(struct config_item *src,
> return -EINVAL;
>
> connector = connector_possible_encoders_item_to_vkms_configfs_connector(src);
> + connector_cfg = connector->config;
> encoder = encoder_item_to_vkms_configfs_encoder(target);
>
> scoped_guard(mutex, &connector->dev->config->lock) {
> - if (connector->dev->enabled)
> - return -EBUSY;
> + if (connector->dev->enabled && connector_cfg->enabled) {
> + if (!connector_cfg->dynamic)
> + return -EBUSY;
> +
> + ret = vkms_connector_hot_attach_encoder(connector->config->connector,
> + encoder->config->encoder);
> + if (ret)
> + return ret;
> + }
>
> ret = vkms_config_connector_attach_encoder(connector->config,
> encoder->config);
> + if (ret)
> + return ret;
> }
>
> return ret;
[Severity: High]
Can calling vkms_connector_hot_attach_encoder() before
vkms_config_connector_attach_encoder() cause a NULL pointer dereference
when linking an encoder from another disabled VKMS device?
vkms_config_connector_attach_encoder() is what checks
connector_cfg->config != encoder_cfg->config and checks for duplicate or
failed xarray insertions. Because vkms_connector_hot_attach_encoder()
runs first, linking an encoder that belongs to a different, disabled VKMS
device passes a NULL encoder->config->encoder to
drm_connector_attach_encoder() -> drm_encoder_mask(). Even for an encoder
on the same device, if vkms_config_connector_attach_encoder() fails with
-EEXIST or -ENOMEM, the encoder bit added to the live DRM connector by
vkms_connector_hot_attach_encoder() is not rolled back.
[Severity: Medium]
Should connector_possible_encoders_allow_link() check
connector_is_enabled(connector_cfg) instead of connector_cfg->enabled?
While the device is disabled, connector_enabled_store() allows setting
connector_cfg->enabled = false on a static connector. When the device is
subsequently enabled, vkms_output_init() still registers all static
connectors, so checking connector_cfg->enabled here skips the -EBUSY check
and allows mutating connector_cfg->possible_encoders on a live static
connector.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261126-vkms-all-config-v7-0-21194cda2468@bootlin.com?part=41
next prev parent reply other threads:[~2026-11-26 12:02 UTC|newest]
Thread overview: 81+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 11:28 [PATCH v7 00/43] VKMS: Introduce multiple configFS attributes Louis Chauvet
2026-11-26 11:28 ` [PATCH v7 01/43] drm/vkms: Lock the config dump against concurrent configfs changes Louis Chauvet
2026-11-26 11:50 ` sashiko-bot
2026-11-26 11:28 ` [PATCH v7 02/43] drm/drm_mode_config: Add helper to get plane type name Louis Chauvet
2026-11-26 11:28 ` [PATCH v7 03/43] drm/blend: Get a rotation name from its bitfield Louis Chauvet
2026-11-26 11:40 ` sashiko-bot
2026-11-26 11:28 ` [PATCH v7 04/43] drm/tests: Add test cases for DRM rotation name Louis Chauvet
2026-11-26 11:28 ` [PATCH v7 05/43] drm/drm_color_mgmt: Expose drm_get_color_encoding_name Louis Chauvet
2026-11-26 11:28 ` [PATCH v7 06/43] drm/drm_color_mgmt: Expose drm_get_color_range_name Louis Chauvet
2026-11-26 11:28 ` [PATCH v7 07/43] drm/connector: Export drm_get_colorspace_name Louis Chauvet
2026-11-26 11:28 ` [PATCH v7 08/43] drm/drm_atomic_state_helper: Properly load default value for rotation Louis Chauvet
2026-11-26 11:28 ` [PATCH v7 09/43] Documentation: ABI: vkms: Add current VKMS ABI documentation Louis Chauvet
2026-12-01 15:01 ` Oarora Etimis
2026-11-26 11:28 ` [PATCH v7 10/43] drm/vkms: Reset config->dev when the device creation fails Louis Chauvet
2026-11-26 11:48 ` sashiko-bot
2026-11-27 7:21 ` Oarora Etimis
2026-11-26 11:28 ` [PATCH v7 11/43] drm/vkms: Reference-count vkms_config and vkms_config_connector Louis Chauvet
2026-11-26 11:49 ` sashiko-bot
2026-11-26 11:28 ` [PATCH v7 12/43] drm/vkms: Add KUnit test for device lifecycle Louis Chauvet
2026-11-26 11:55 ` sashiko-bot
2026-11-27 10:24 ` Oarora Etimis
2026-11-26 11:28 ` [PATCH v7 13/43] drm/vkms: Add error handling in plane config creation Louis Chauvet
2026-11-27 10:36 ` Oarora Etimis
2026-11-26 11:28 ` [PATCH v7 14/43] drm/vkms: Simplify plane_release code Louis Chauvet
2026-11-26 11:28 ` [PATCH v7 15/43] drm/vkms: Explicitly display plane type Louis Chauvet
2026-11-27 10:40 ` Oarora Etimis
2026-11-26 11:28 ` [PATCH v7 16/43] drm/vkms: Use enabled/disabled instead of 1/0 for debug Louis Chauvet
2026-11-27 10:41 ` Oarora Etimis
2026-11-26 11:29 ` [PATCH v7 17/43] drm/vkms: Introduce config for plane name Louis Chauvet
2026-11-26 11:48 ` sashiko-bot
2026-11-27 11:39 ` Oarora Etimis
2026-11-26 11:29 ` [PATCH v7 18/43] drm/vkms: Use plane folder name as " Louis Chauvet
2026-11-27 11:40 ` Oarora Etimis
2026-11-26 11:29 ` [PATCH v7 19/43] drm/vkms: Introduce config for plane rotation Louis Chauvet
2026-11-26 11:46 ` sashiko-bot
2026-12-01 15:19 ` Oarora Etimis
2026-11-26 11:29 ` [PATCH v7 20/43] drm/vkms: Introduce configfs " Louis Chauvet
2026-12-01 15:27 ` Oarora Etimis
2026-11-26 11:29 ` [PATCH v7 21/43] drm/vkms: Introduce config for plane color encoding Louis Chauvet
2026-11-26 11:48 ` sashiko-bot
2026-12-01 16:59 ` Oarora Etimis
2026-11-26 11:29 ` [PATCH v7 22/43] drm/vkms: Introduce configfs " Louis Chauvet
2026-11-26 11:43 ` sashiko-bot
2026-11-26 11:29 ` [PATCH v7 23/43] drm/vkms: Introduce config for plane color range Louis Chauvet
2026-11-26 11:29 ` [PATCH v7 24/43] drm/vkms: Introduce configfs " Louis Chauvet
2026-11-26 11:45 ` sashiko-bot
2026-11-26 11:29 ` [PATCH v7 25/43] drm/vkms: Introduce config for plane format Louis Chauvet
2026-11-26 11:46 ` sashiko-bot
2026-11-26 11:29 ` [PATCH v7 26/43] drm/vkms: Introduce configfs " Louis Chauvet
2026-11-26 11:49 ` sashiko-bot
2026-11-26 11:29 ` [PATCH v7 27/43] drm/vkms: Properly render plane using their zpos Louis Chauvet
2026-12-01 17:23 ` Oarora Etimis
2026-11-26 11:29 ` [PATCH v7 28/43] drm/vkms: Introduce config for plane zpos property Louis Chauvet
2026-11-26 11:46 ` sashiko-bot
2026-11-26 11:29 ` [PATCH v7 29/43] drm/vkms: Introduce configfs " Louis Chauvet
2026-11-26 11:29 ` [PATCH v7 30/43] drm/vkms: Introduce back pointer to connector Louis Chauvet
2026-11-26 11:55 ` sashiko-bot
2026-11-26 11:29 ` [PATCH v7 31/43] drm/vkms: Introduce connector type Louis Chauvet
2026-11-27 7:15 ` Oarora Etimis
2026-11-26 11:29 ` [PATCH v7 32/43] drm/vkms: Introduce configfs for " Louis Chauvet
2026-11-26 11:29 ` [PATCH v7 33/43] drm/vkms: Rename vkms_connector_init to vkms_connector_init_static Louis Chauvet
2026-11-26 11:29 ` [PATCH v7 34/43] drm/vkms: Introduce config for connector supported colorspace Louis Chauvet
2026-11-26 11:48 ` sashiko-bot
2026-11-26 16:44 ` kernel test robot
2026-11-26 11:29 ` [PATCH v7 35/43] drm/vkms: Introduce configfs " Louis Chauvet
2026-11-26 11:50 ` sashiko-bot
2026-11-26 11:29 ` [PATCH v7 36/43] drm/vkms: Introduce config for connector EDID Louis Chauvet
2026-11-26 11:51 ` sashiko-bot
2026-11-26 11:29 ` [PATCH v7 37/43] drm/vkms: Introduce configfs " Louis Chauvet
2026-11-26 11:59 ` sashiko-bot
2026-11-26 11:29 ` [PATCH v7 38/43] drm/vkms: Store the enabled/disabled status for connector Louis Chauvet
2026-11-26 11:29 ` [PATCH v7 39/43] drm/connector: Add a way to detach encoders Louis Chauvet
2026-11-26 11:29 ` [PATCH v7 40/43] drm/vkms: Allow to hot-add connectors Louis Chauvet
2026-11-26 12:05 ` sashiko-bot
2026-11-26 11:29 ` [PATCH v7 41/43] drm/vkms: Introduce configfs for dynamic connector creation Louis Chauvet
2026-11-26 12:02 ` sashiko-bot [this message]
2026-11-26 11:29 ` [PATCH v7 42/43] drm/vkms: Add connector parent configuration in vkms_config Louis Chauvet
2026-11-26 11:56 ` sashiko-bot
2026-11-26 11:29 ` [PATCH v7 43/43] drm/vkms: Add ConfigFS interface for connector parent and port_id Louis Chauvet
2026-11-26 11:52 ` sashiko-bot
2026-11-26 19:49 ` kernel test robot
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=sashiko-outbox-235470@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=louis.chauvet@bootlin.com \
--cc=sashiko-reviews@lists.linux.dev \
/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