From: sashiko-bot@kernel.org
To: "Louis Chauvet" <louis.chauvet@bootlin.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v7 36/43] drm/vkms: Introduce config for connector EDID
Date: Thu, 26 Nov 2026 11:51:38 +0000 [thread overview]
Message-ID: <sashiko-outbox-235429@kernel.org> (raw)
In-Reply-To: <20261126-vkms-all-config-v7-36-21194cda2468@bootlin.com>
Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [High] drm/vkms: sleeping in RCU read-side critical section in
vkms_conn_get_modes()
- [Medium] drm/vkms: pointer signedness mismatch in
vkms_config_connector_get_edid()
- [Low] drm/vkms: direct __rcu pointer dereference in
vkms_config_connector_release()
- [Low] drm/vkms: inaccurate kernel-doc for edid_enabled in
vkms_config_connector
--
commit 2562fe9d046d1f1711056464ad1f96e4ee4649be
Author: Louis Chauvet <louis.chauvet@bootlin.com>
drm/vkms: Introduce config for connector EDID
This commit adds RCU-protected EDID configuration to vkms_config_connector
and updates vkms_conn_get_modes() to read the configured EDID when enabled.
> diff --git a/drivers/gpu/drm/vkms/vkms_config.c b/drivers/gpu/drm/vkms/vkms_config.c
> index fa4ca256b4b91..173e88122bcb1 100644
> --- a/drivers/gpu/drm/vkms/vkms_config.c
> +++ b/drivers/gpu/drm/vkms/vkms_config.c
[ ... ]
> @@ -1070,6 +1084,8 @@ static void vkms_config_connector_release(struct kref *ref)
> /* The config is dying and is draining us: just unlink */
> list_del_init(&connector_cfg->link);
> }
> + if (connector_cfg->edid)
> + call_rcu(&connector_cfg->edid->rcu, vkms_config_edid_free);
> kfree_rcu(connector_cfg, rcu);
> }
[Severity: Low]
connector_cfg->edid is annotated with __rcu, so dereferencing
&connector_cfg->edid->rcu directly without rcu_dereference_protected()
triggers a Sparse noderef warning, unlike vkms_config_connector_set_edid()
below. Also, because vkms_config_edid_free() is a module function queued
via call_rcu(), unloading the module immediately after vkms_exit() drops
default_config could race with an in-flight callback unless vkms_exit()
calls rcu_barrier() or struct vkms_config_edid embeds the data as a
flexible array freed with kfree_rcu().
[ ... ]
> diff --git a/drivers/gpu/drm/vkms/vkms_config.h b/drivers/gpu/drm/vkms/vkms_config.h
> index 341e0638b5087..ef8de0316b94c 100644
> --- a/drivers/gpu/drm/vkms/vkms_config.h
> +++ b/drivers/gpu/drm/vkms/vkms_config.h
> @@ -145,6 +145,22 @@ struct vkms_config_encoder {
> struct drm_encoder *encoder;
> };
>
> +/**
> + * struct vkms_config_edid - RCU-protected EDID data
> + *
> + * @edid: Pointer to the EDID data buffer
> + * @edid_len: Length of the EDID data
> + * @rcu: RCU head for safe freeing
> + *
> + * This struct ensures EDID data and its length are always accessed
> + * coherently by readers without requiring locks.
> + */
> +struct vkms_config_edid {
> + const u8 *edid;
> + unsigned int edid_len;
> + struct rcu_head rcu;
> +};
> +
> /**
> * struct vkms_config_connector
> *
> @@ -157,6 +173,8 @@ struct vkms_config_encoder {
> * are the sames as ones accepted by
> * drm_mode_create_hdmi_colorspace_property() and
> * drm_mode_create_dp_colorspace_property()
> + * @edid_enabled: If true, create the EDID property
> + * @edid: RCU-protected EDID data. Readers must use rcu_read_lock() to access.
[Severity: Low]
This isn't a bug, but the kernel-doc for @edid_enabled says it controls
creating the EDID property, whereas the EDID property is always attached
and edid_enabled instead controls whether vkms_conn_get_modes() exposes
the configured EDID.
[ ... ]
> +static inline const u8 *
> +vkms_config_connector_get_edid(const struct vkms_config_connector *connector_cfg, int *len)
> +{
> + const struct vkms_config_edid *edid = rcu_dereference(connector_cfg->edid);
> +
> + if (edid) {
> + *len = edid->edid_len;
> + return edid->edid;
> + }
> +
> + *len = 0;
> + return NULL;
> +}
> +
> +int vkms_config_connector_set_edid(struct vkms_config_connector *connector_cfg,
> + const u8 *edid, unsigned int len);
[Severity: Medium]
Should the len parameter of vkms_config_connector_get_edid() be
unsigned int * instead of int *?
struct vkms_config_edid.edid_len and vkms_config_connector_set_edid() both
use unsigned int, and vkms_connector_read_block() passes &edid_len of type
unsigned int *, which triggers a -Wpointer-sign compiler warning (and a
build failure under CONFIG_WERROR=y).
> diff --git a/drivers/gpu/drm/vkms/vkms_connector.c b/drivers/gpu/drm/vkms/vkms_connector.c
> index 552d767c3976e..71a0ae15be653 100644
> --- a/drivers/gpu/drm/vkms/vkms_connector.c
> +++ b/drivers/gpu/drm/vkms/vkms_connector.c
> @@ -43,13 +43,48 @@ static const struct drm_connector_funcs vkms_connector_funcs = {
> .atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
> };
>
> +static int vkms_connector_read_block(void *context, u8 *buf, unsigned int block, size_t len)
> +{
> + struct vkms_config_connector *config = context;
> + unsigned int edid_len;
> + const u8 *edid = vkms_config_connector_get_edid(config, &edid_len);
> +
> + if (block * len + len > edid_len)
> + return 1;
> + memcpy(buf, &edid[block * len], len);
> + return 0;
> +}
> +
> static int vkms_conn_get_modes(struct drm_connector *connector)
> {
> - int count;
> + struct vkms_connector *vkms_connector = drm_connector_to_vkms_connector(connector);
> + const struct drm_edid *drm_edid = NULL;
> + int count = 0;
> + struct vkms_config_connector *cfg = vkms_config_connector_get(vkms_connector->cfg);
> +
> + 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();
[Severity: High]
Does holding rcu_read_lock() across drm_edid_read_custom(),
drm_edid_connector_update(), and drm_edid_connector_add_modes() sleep in
an RCU read-side critical section?
All three helpers perform GFP_KERNEL allocations and acquire sleeping
mutexes: for example, drm_edid_read_custom() -> _drm_do_get_edid() takes
mutex_lock(&connector->edid_override_mutex) in drm_edid_override_get() and
allocates the EDID buffer with kmalloc(..., GFP_KERNEL). Also, because
vkms_connector_read_block() calls vkms_config_connector_get_edid() on each
128-byte block, a concurrent vkms_config_connector_set_edid() can swap the
RCU pointer between block 0 and extension blocks, causing a torn read.
Instead of drm_edid_read_custom(), could this snapshot the buffer under
rcu_read_lock() or pass the snapshot to drm_edid_alloc() outside the RCU
read-side critical section?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261126-vkms-all-config-v7-0-21194cda2468@bootlin.com?part=36
next prev parent reply other threads:[~2026-11-26 11:51 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 [this message]
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
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-235429@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.