Skip to contentSkip to conversation

drm: hide unregistered connectors from GETCONNECTOR IOCTL

RFC PATCH In review Simon Ser 2 participants 2 messages Aug 1, 2022

Subsystems (2)
lore
Share & tools
lore

Simon Ser

author
#0 lore raw

RFC PATCH 1/1 drm: hide unregistered connectors from GETCONNECTOR IOCTL

When registering a connector, the kernel sends a hotplug uevent in drm_connector_register(). When unregistering a connector, drivers are expected to send a uevent as well. However, user-space has no way to figure out that the connector isn't registered anymore: it'll still be reported in GETCONNECTOR IOCTLs.

The documentation for DRM_CONNECTOR_UNREGISTERED states:

Quoted 3 lines

The connector […] has since been unregistered and removed from userspace, or the connector was unregistered before it had a chance to be exposed to userspace

Cc Daniel Vetter <[email protected]>
Cc Ville Syrjälä <[email protected]>
Cc Jani Nikula <[email protected]>
---
 drivers/gpu/drm/drm_mode_config.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/gpu/drm/drm_mode_config.c +3 -0
index 688c8afe0bf1..939d621c9ad4 100644
@@ -151,6 +151,9 @@ int drm_mode_getresources(struct drm_device *dev, void *data,
 	count = 0;
 	connector_id = u64_to_user_ptr(card_res->connector_id_ptr);
 	drm_for_each_connector_iter(connector, &conn_iter) {
+		if (connector->registration_state != DRM_CONNECTOR_REGISTERED)
+			continue;
+
 		/* only expose writeback connectors if userspace understands them */
 		if (!file_priv->writeback_connectors &&
 		    (connector->connector_type == DRM_MODE_CONNECTOR_WRITEBACK))
Signature · 1 line
2.37.1
Reviewed-by on v1 1/1
#1 lore raw

Yikes! Surprised this wasn't noticed until now. This lgtm:

Quoted 39 lines · Simon Ser

When registering a connector, the kernel sends a hotplug uevent in drm_connector_register(). When unregistering a connector, drivers are expected to send a uevent as well. However, user-space has no way to figure out that the connector isn't registered anymore: it'll still be reported in GETCONNECTOR IOCTLs.

The documentation for DRM_CONNECTOR_UNREGISTERED states:

Quoted 3 lines

The connector […] has since been unregistered and removed from userspace, or the connector was unregistered before it had a chance to be exposed to userspace

Cc Daniel Vetter <[email protected]>
Cc Ville Syrjälä <[email protected]>
Cc Jani Nikula <[email protected]>

---
 drivers/gpu/drm/drm_mode_config.c | 3 +++

 1 file changed, 3 insertions(+)
drivers/gpu/drm/drm_mode_config.c +3 -0
index 688c8afe0bf1..939d621c9ad4 100644
@@ -151,6 +151,9 @@ int drm_mode_getresources(struct drm_device *dev, void
 *data,
         count = 0;
         connector_id = u64_to_user_ptr(card_res->connector_id_ptr);
         drm_for_each_connector_iter(connector, &conn_iter) {
+               if (connector->registration_state !=
 DRM_CONNECTOR_REGISTERED)
+                       continue;
+
                 /* only expose writeback connectors if userspace understands

them */
                if (!file_priv->writeback_connectors && (connector->connector_type == DRM_MODE_CONNECTOR_WRITEBACK))

Signature · 3 lines
Cheers,
 Lyude Paul (she/her)
 Software Engineer at Red Hat