From: sashiko-bot@kernel.org
To: "Louis Chauvet" <louis.chauvet@bootlin.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v7 37/43] drm/vkms: Introduce configfs for connector EDID
Date: Thu, 26 Nov 2026 11:59:27 +0000 [thread overview]
Message-ID: <sashiko-outbox-235457@kernel.org> (raw)
In-Reply-To: <20261126-vkms-all-config-v7-37-21194cda2468@bootlin.com>
Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [High] drm/vkms: self-deadlock on config->lock in connector EDID store
callbacks
- [High] drm/vkms: sleeping allocations under rcu_read_lock() in
vkms_conn_get_modes()
- [Medium] drm/vkms: race with device_enabled_store() passes NULL dev on
EDID store
- [Medium] drm/vkms: CONFIGFS_ATTR for connector edid truncates 4K EDID
and blocks clear
--
commit 08c0713c865d891af6ca094b53a173337d1d80d5
Author: Louis Chauvet <louis.chauvet@bootlin.com>
drm/vkms: Introduce configfs for connector EDID
This commit adds the edid_enabled and edid configfs attributes to configure
connector EDID data and trigger a connector hotplug when updated.
> diff --git a/drivers/gpu/drm/vkms/vkms_configfs.c b/drivers/gpu/drm/vkms/vkms_configfs.c
> index 7377d967be75d..32ac4d7c41944 100644
> --- a/drivers/gpu/drm/vkms/vkms_configfs.c
> +++ b/drivers/gpu/drm/vkms/vkms_configfs.c
[ ... ]
> @@ -1191,14 +1192,111 @@ static ssize_t connector_supported_colorspaces_store(struct config_item *item,
> return count;
> }
>
> +static ssize_t connector_edid_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_get_edid_enabled(connector->config);
> +
> + return sprintf(page, "%d\n", enabled);
> +}
> +
> +static ssize_t connector_edid_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;
> +
> + 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)
> + {
> + vkms_config_connector_set_edid_enabled(connector_cfg, enabled);
> +
> + if (connector->dev->enabled &&
> + vkms_config_connector_get_status(connector_cfg) !=
> + connector_status_disconnected)
> + vkms_trigger_connector_hotplug(connector->dev->config->dev);
> + }
[Severity: High]
Does calling vkms_trigger_connector_hotplug() under
connector->dev->config->lock self-deadlock on config->lock (both here and in
connector_edid_store() below)?
vkms_create() registers in-kernel DRM clients with drm_client_setup(), so
hotplug notification probes the connector synchronously on the same task:
connector_edid_enabled_store()
mutex_lock(&connector->dev->config->lock)
vkms_trigger_connector_hotplug()
drm_kms_helper_hotplug_event()
drm_client_dev_hotplug()
...
drm_client_modeset_probe()
drm_helper_probe_single_connector_modes()
drm_helper_probe_detect()
vkms_connector_detect()
mutex_lock(&cfg->config->lock) <-- deadlocks
This also inverts the mode_config.mutex -> mode_config.connection_mutex ->
config->lock hierarchy used during normal connector probing. Dropping
config->lock before calling vkms_trigger_connector_hotplug() avoids the
deadlock.
[Severity: Medium]
Can connector->dev->config->dev still be NULL or unregistered when
connector->dev->enabled is true here and in connector_edid_store()?
device_enabled_store() sets dev->enabled = true and releases
dev->config->lock before calling vkms_create(dev->config):
CPU0 CPU1
device_enabled_store()
mutex_lock(&dev->config->lock)
dev->enabled = true
mutex_unlock(&dev->config->lock)
connector_edid_enabled_store()
mutex_lock(&dev->config->lock)
if (connector->dev->enabled && ...)
vkms_trigger_connector_hotplug(NULL)
drm_kms_helper_hotplug_event()
<-- NULL pointer dereference
vkms_create(dev->config)
[Severity: High]
When connector_edid_enabled_store() sets edid_enabled to true and triggers
mode probing, does vkms_conn_get_modes() sleep inside an RCU read-side
critical section?
connector_edid_enabled_store() is the first caller of
vkms_config_connector_set_edid_enabled(), activating the edid_enabled branch
in vkms_conn_get_modes():
drivers/gpu/drm/vkms/vkms_connector.c:vkms_conn_get_modes() {
if (vkms_config_connector_get_edid_enabled(cfg)) {
/*
* Hold rcu_read_lock() for the entire duration so that
* the EDID data accessed via the callback remains valid.
*/
rcu_read_lock();
drm_edid = drm_edid_read_custom(connector,
vkms_connector_read_block, cfg);
drm_edid_connector_update(connector, drm_edid);
count = drm_edid_connector_add_modes(connector);
drm_edid_free(drm_edid);
rcu_read_unlock();
}
}
drm_edid_read_custom(), drm_edid_connector_update(), and
drm_edid_connector_add_modes() all perform GFP_KERNEL allocations and acquire
sleeping mutexes (such as connector->edid_override_mutex,
connector->eld_mutex, and dev->mode_config.blob_lock). Taking rcu_read_lock()
only inside vkms_connector_read_block() while dereferencing and copying the
EDID block would avoid sleeping under RCU.
> + return count;
> +}
> +
> +static ssize_t connector_edid_show(struct config_item *item, char *page)
> +{
> + struct vkms_configfs_connector *connector;
> + ssize_t ret = 0;
> +
> + connector = connector_item_to_vkms_configfs_connector(item);
> +
> + scoped_guard(mutex, &connector->dev->config->lock)
> + {
> + int len = 0;
> + const u8 *edid;
> + size_t copy_len;
> +
> + /*
> + * vkms_config_connector_get_edid() is an RCU reader; hold
> + * the read-side critical section while copying the data to
> + * the userspace page, like the debugfs reader does.
> + */
> + rcu_read_lock();
> + edid = vkms_config_connector_get_edid(connector->config, &len);
> + if (edid && len > 0) {
> + copy_len = min_t(size_t, (size_t)len, PAGE_SIZE);
> + memcpy(page, edid, copy_len);
> + ret = copy_len;
> + }
> + rcu_read_unlock();
> + }
> +
> + return ret;
> +}
> +
> +static ssize_t connector_edid_store(struct config_item *item,
> + const char *page, size_t count)
> +{
> + struct vkms_configfs_connector *connector;
> +
> + connector = connector_item_to_vkms_configfs_connector(item);
> +
> + scoped_guard(mutex, &connector->dev->config->lock)
> + {
> + int ret;
> +
> + ret = vkms_config_connector_set_edid(connector->config, page, count);
> + if (ret)
> + return ret;
> +
> + if (connector->dev->enabled &&
> + vkms_config_connector_get_status(connector->config) !=
> + connector_status_disconnected)
> + vkms_trigger_connector_hotplug(connector->dev->config->dev);
> + }
> +
> + return count;
> +}
> +
> CONFIGFS_ATTR(connector_, status);
> CONFIGFS_ATTR(connector_, type);
> CONFIGFS_ATTR(connector_, supported_colorspaces);
> +CONFIGFS_ATTR(connector_, edid_enabled);
> +CONFIGFS_ATTR(connector_, edid);
[Severity: Medium]
Should edid be registered with CONFIGFS_BIN_ATTR() instead of
CONFIGFS_ATTR()?
Because CONFIGFS_ATTR() uses configfs text attribute handling
(SIMPLE_ATTR_SIZE == 4096):
1. fill_write_buffer() accepts at most SIMPLE_ATTR_SIZE - 1 (4095) bytes so
it can append a trailing NUL. Writing a 4096-byte (32-block) EDID truncates
the last checksum byte on the first write, and if userspace writes the
remaining 1 byte in a second write() call, connector_edid_store() replaces
the entire EDID with a 1-byte buffer.
2. The ABI documentation says writing zero bytes clears the EDID, and
vkms_config_connector_set_edid() checks for !len, but vfs_write() and
configfs_write_iter() never invoke .store() when count == 0, nor on
O_TRUNC, making the !len clear path unreachable.
3. In connector_edid_show(), copy_len is clamped to PAGE_SIZE rather than
SIMPLE_ATTR_SIZE (4096), which triggers WARN_ON_ONCE(count >
SIMPLE_ATTR_SIZE) and returns -EIO in fill_read_buffer() on architectures
with PAGE_SIZE > 4096.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261126-vkms-all-config-v7-0-21194cda2468@bootlin.com?part=37
next prev parent reply other threads:[~2026-11-26 11:59 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 [this message]
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
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-235457@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