Commit 5ebbb5b4 authored by Ville Syrjälä's avatar Ville Syrjälä
Browse files

drm: Check property/enum name length



Reject requests to add properties/enums with an overly long name.
Previously we would have just silently truncated the string and exposed
it userspace.

v2: drm_property_create() returns a pointer

Signed-off-by: default avatarVille Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180302140300.31110-1-ville.syrjala@linux.intel.com


Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent 8e5e83ad
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -78,6 +78,9 @@ struct drm_property *drm_property_create(struct drm_device *dev, int flags,
	struct drm_property *property = NULL;
	int ret;

	if (WARN_ON(strlen(name) >= DRM_PROP_NAME_LEN))
		return NULL;

	property = kzalloc(sizeof(struct drm_property), GFP_KERNEL);
	if (!property)
		return NULL;
@@ -372,6 +375,9 @@ int drm_property_add_enum(struct drm_property *property, int index,
{
	struct drm_property_enum *prop_enum;

	if (WARN_ON(strlen(name) >= DRM_PROP_NAME_LEN))
		return -EINVAL;

	if (!(drm_property_type_is(property, DRM_MODE_PROP_ENUM) ||
			drm_property_type_is(property, DRM_MODE_PROP_BITMASK)))
		return -EINVAL;