drm: Reject replacing property enum values
Subsystems (2)
PATCH 1/6 drm: Reject replacing property enum values
From: Ville Syrjälä <[email protected]>
If the property already has the enum value WARN and bail. Replacing enum values doesn't make sense to me.
Throw out the pointless list_empty() while at it.
--- drivers/gpu/drm/drm_property.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)
drivers/gpu/drm/drm_property.c +3 -8
@@ -390,14 +390,9 @@ int drm_property_add_enum(struct drm_property *property, int index, (value > 63))return -EINVAL ; -if (!list_empty (&property->enum_list)) { -list_for_each_entry (prop_enum, &property->enum_list, head) { -if (prop_enum->value == value) { -strncpy (prop_enum->name, name,DRM_PROP_NAME_LEN ); - prop_enum->name[DRM_PROP_NAME_LEN -1 ] ='\0' ; -return 0 ; - } - } +list_for_each_entry (prop_enum, &property->enum_list, head) { +if (WARN_ON (prop_enum->value == value)) +return -EINVAL ; } prop_enum =kzalloc (sizeof (struct drm_property_enum ),GFP_KERNEL );
Signature · 6 lines
2.16.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/6 drm: WARN when trying add enum values to non-enum/bitmask properties
From: Ville Syrjälä <[email protected]>
Trying to add enum values to non-enum/bitmask properties is a programmer mistake. WARN to make sure the developers notice their mistake.
--- drivers/gpu/drm/drm_property.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_property.c +2 -2
@@ -378,8 +378,8 @@ int drm_property_add_enum(struct drm_property *property, int index,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 ))) +if (WARN_ON (!drm_property_type_is (property,DRM_MODE_PROP_ENUM ) && + !drm_property_type_is (property,DRM_MODE_PROP_BITMASK )))return -EINVAL ;/*
Signature · 6 lines
2.16.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 2/6] drm: WARN when trying add enum values to non-enum/bitmask properties
Quoted 7 lines · Ville Syrjala
From: Ville Syrjälä <[email protected]>
Trying to add enum values to non-enum/bitmask properties is a programmer mistake. WARN to make sure the developers notice their mistake.
Signed-off-by Ville Syrjälä <[email protected]>
Quoted 26 lines
--- drivers/gpu/drm/drm_property.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/drm_property.c +2
-2@@ -378,8 +378,8 @@ int drm_property_add_enum(struct drm_property *property, int index,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 ))) +if (WARN_ON (!drm_property_type_is (property,DRM_MODE_PROP_ENUM ) && + !drm_property_type_is (property,DRM_MODE_PROP_BITMASK )))return -EINVAL ;/* Signature · 6 lines
2.16.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 3/6 drm: WARN when trying to add enum value > 63 to a bitmask property
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
Enum values >63 with a bitmask property is a programmer error. WARN when someone is attempting this.
--- drivers/gpu/drm/drm_property.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_property.c +2 -2
@@ -386,8 +386,8 @@ int drm_property_add_enum(struct drm_property *property, int index,* Bitmask enum properties have the additional constraint of values * from 0 to 63 */ -if (drm_property_type_is (property,DRM_MODE_PROP_BITMASK ) && - (value >63 )) +if (WARN_ON (drm_property_type_is (property,DRM_MODE_PROP_BITMASK ) && + value >63 ))return -EINVAL ;list_for_each_entry (prop_enum, &property->enum_list, head) {
Signature · 6 lines
2.16.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 3/6] drm: WARN when trying to add enum value > 63 to a bitmask property
Quoted 6 lines · Ville Syrjala
From: Ville Syrjälä <[email protected]>
Enum values >63 with a bitmask property is a programmer error. WARN when someone is attempting this.
Signed-off-by Ville Syrjälä <[email protected]>
Quoted 26 lines
--- drivers/gpu/drm/drm_property.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/drm_property.c +2
-2@@ -386,8 +386,8 @@ int drm_property_add_enum(struct drm_property *property, int index,* Bitmask enum properties have the additional constraint of values * from 0 to 63 */ -if (drm_property_type_is (property,DRM_MODE_PROP_BITMASK ) && - (value >63 )) +if (WARN_ON (drm_property_type_is (property,DRM_MODE_PROP_BITMASK ) && + value >63 ))return -EINVAL ;list_for_each_entry (prop_enum, &property->enum_list, head) {Signature · 6 lines
2.16.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 4/6 drm/uapi: Deprecate DRM_MODE_PROP_PENDING
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
DRM_MODE_PROP_PENDING is not used anywhere (except printed out by libdrm proptest/modetest).
This seems to be yet another thing blindly copied from xrandr. Quoting from the protocol spec:
"If 'pending' is TRUE, changes made to property values with
RRChangeOutputProperty will be saved in the pending property value and be automatically copied to the current value on the next RRSetCrtcConfig request involving the named output. If 'pending' is FALSE, changes are copied immediately."
So it was some kind of early idea for atomic property updates.
--- include/uapi/drm/drm_mode.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/drm/drm_mode.h +1 -1
@@ -363,7 +363,7 @@ struct drm_mode_get_connector {__u32 pad; }; -#define DRM_MODE_PROP_PENDING (1<<0) +#define DRM_MODE_PROP_PENDING (1<<0)/* deprecated, do not use */ #define DRM_MODE_PROP_RANGE (1<<1)#define DRM_MODE_PROP_IMMUTABLE (1<<2)#define DRM_MODE_PROP_ENUM (1<<3)/* enumerated type with text strings */
Signature · 6 lines
2.16.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 4/6] drm/uapi: Deprecate DRM_MODE_PROP_PENDING
Quoted 13 lines · Ville Syrjala
From: Ville Syrjälä <[email protected]>
DRM_MODE_PROP_PENDINGis not used anywhere (except printed out by libdrm proptest/modetest).This seems to be yet another thing blindly copied from xrandr. Quoting from the protocol spec:
"If 'pending' is TRUE, changes made to property values with
RRChangeOutputProperty will be saved in the pending property value and be automatically copied to the current value on the next RRSetCrtcConfig request involving the named output. If 'pending' is FALSE, changes are copied immediately."
Quoted 3 lines
So it was some kind of early idea for atomic property updates.
Signed-off-by Ville Syrjälä <[email protected]>
Quoted 24 lines
--- include/uapi/drm/drm_mode.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)include/uapi/drm/drm_mode.h +1
-1@@ -363,7 +363,7 @@ struct drm_mode_get_connector {__u32 pad; }; -#define DRM_MODE_PROP_PENDING (1<<0) +#define DRM_MODE_PROP_PENDING (1<<0)/* deprecated, do not use */ #define DRM_MODE_PROP_RANGE (1<<1)#define DRM_MODE_PROP_IMMUTABLE (1<<2)#define DRM_MODE_PROP_ENUM (1<<3)/* enumerated type with text strings */ Signature · 6 lines
2.16.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 5/6 drm: Make property flags u32
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
The property flags are part of the uabi and we have 32 bits for them. Pass them around as u32 internally as well, instead of a signed int.
--- drivers/gpu/drm/drm_property.c | 41 +++++++++++++++++++++-------------------- include/drm/drm_property.h | 24 +++++++++++++----------- 2 files changed, 34 insertions(+), 31 deletions(-)
drivers/gpu/drm/drm_property.c +21 -20
@@ -72,8 +72,9 @@ static bool drm_property_type_valid(struct drm_property *property)* Returns: * A pointer to the newly created property on success, NULL on failure. */ -struct drm_property *drm_property_create (struct drm_device *dev,int flags, -const char *name,int num_values) +struct drm_property *drm_property_create (struct drm_device *dev, +u32 flags,const char *name, +int num_values) {struct drm_property *property =NULL ;int ret;
@@ -136,10 +137,10 @@ EXPORT_SYMBOL(drm_property_create);* Returns: * A pointer to the newly created property on success, NULL on failure. */ -struct drm_property *drm_property_create_enum (struct drm_device *dev,int flags, -const char *name, -const struct drm_prop_enum_list *props, -int num_values) +struct drm_property *drm_property_create_enum (struct drm_device *dev, +u32 flags,const char *name, +const struct drm_prop_enum_list *props, +int num_values) {struct drm_property *property;int i, ret;
@@ -185,10 +186,10 @@ EXPORT_SYMBOL(drm_property_create_enum);* A pointer to the newly created property on success, NULL on failure. */ struct drm_property *drm_property_create_bitmask (struct drm_device *dev, -int flags,const char *name, -const struct drm_prop_enum_list *props, -int num_props, -uint64_t supported_bits) +u32 flags,const char *name, +const struct drm_prop_enum_list *props, +int num_props, +uint64_t supported_bits) {struct drm_property *property;int i, ret, index =0 ;
@@ -222,8 +223,8 @@ struct drm_property *drm_property_create_bitmask(struct drm_device *dev,EXPORT_SYMBOL (drm_property_create_bitmask);static struct drm_property *property_create_range (struct drm_device *dev, -int flags,const char *name, -uint64_t min,uint64_t max) +u32 flags,const char *name, +uint64_t min,uint64_t max) {struct drm_property *property;
@@ -256,9 +257,9 @@ static struct drm_property *property_create_range(struct drm_device *dev,* Returns: * A pointer to the newly created property on success, NULL on failure. */ -struct drm_property *drm_property_create_range (struct drm_device *dev,int flags, -const char *name, -uint64_t min,uint64_t max) +struct drm_property *drm_property_create_range (struct drm_device *dev, +u32 flags,const char *name, +uint64_t min,uint64_t max) {return property_create_range (dev,DRM_MODE_PROP_RANGE | flags, name, min, max);
@@ -285,8 +286,8 @@ EXPORT_SYMBOL(drm_property_create_range);* A pointer to the newly created property on success, NULL on failure. */ struct drm_property *drm_property_create_signed_range (struct drm_device *dev, -int flags,const char *name, -int64_t min,int64_t max) +u32 flags,const char *name, +int64_t min,int64_t max) {return property_create_range (dev,DRM_MODE_PROP_SIGNED_RANGE | flags, name,I642U64 (min),I642U64 (max));
@@ -312,7 +313,7 @@ EXPORT_SYMBOL(drm_property_create_signed_range);* A pointer to the newly created property on success, NULL on failure. */ struct drm_property *drm_property_create_object (struct drm_device *dev, -int flags,const char *name, +u32 flags,const char *name,uint32_t type) {struct drm_property *property;
@@ -348,8 +349,8 @@ EXPORT_SYMBOL(drm_property_create_object);* Returns: * A pointer to the newly created property on success, NULL on failure. */ -struct drm_property *drm_property_create_bool (struct drm_device *dev,int flags, -const char *name) +struct drm_property *drm_property_create_bool (struct drm_device *dev, +u32 flags,const char *name) {return drm_property_create_range (dev, flags, name,0 ,1 ); }
include/drm/drm_property.h +13 -11
@@ -237,27 +237,29 @@ static inline bool drm_property_type_is(struct drm_property *property,return property->flags & type; } -struct drm_property *drm_property_create (struct drm_device *dev,int flags, -const char *name,int num_values); -struct drm_property *drm_property_create_enum (struct drm_device *dev,int flags, -const char *name, +struct drm_property *drm_property_create (struct drm_device *dev, +u32 flags,const char *name, +int num_values); +struct drm_property *drm_property_create_enum (struct drm_device *dev, +u32 flags,const char *name,const struct drm_prop_enum_list *props,int num_values);struct drm_property *drm_property_create_bitmask (struct drm_device *dev, -int flags,const char *name, +u32 flags,const char *name,const struct drm_prop_enum_list *props,int num_props,uint64_t supported_bits); -struct drm_property *drm_property_create_range (struct drm_device *dev,int flags, -const char *name, +struct drm_property *drm_property_create_range (struct drm_device *dev, +u32 flags,const char *name,uint64_t min,uint64_t max);struct drm_property *drm_property_create_signed_range (struct drm_device *dev, -int flags,const char *name, +u32 flags,const char *name,int64_t min,int64_t max);struct drm_property *drm_property_create_object (struct drm_device *dev, -int flags,const char *name,uint32_t type); -struct drm_property *drm_property_create_bool (struct drm_device *dev,int flags, -const char *name); +u32 flags,const char *name, +uint32_t type); +struct drm_property *drm_property_create_bool (struct drm_device *dev, +u32 flags,const char *name);int drm_property_add_enum (struct drm_property *property,int index,uint64_t value,const char *name);void drm_property_destroy (struct drm_device *dev,struct drm_property *property);
Signature · 6 lines
2.16.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [Intel-gfx] [PATCH 5/6] drm: Make property flags u32
Quoted 6 lines · Ville Syrjala
From: Ville Syrjälä <[email protected]>
The property flags are part of the uabi and we have 32 bits for them. Pass them around as u32 internally as well, instead of a signed int.
Signed-off-by Ville Syrjälä <[email protected]>
u32 vs uint32_t (in struct drm_property) ftw, but who cares.
Quoted 158 lines
--- drivers/gpu/drm/drm_property.c | 41 +++++++++++++++++++++-------------------- include/drm/drm_property.h | 24 +++++++++++++----------- 2 files changed, 34 insertions(+), 31 deletions(-)drivers/gpu/drm/drm_property.c +21
-20@@ -72,8 +72,9 @@ static bool drm_property_type_valid(struct drm_property *property)* Returns: * A pointer to the newly created property on success, NULL on failure. */ -struct drm_property *drm_property_create (struct drm_device *dev,int flags, -const char *name,int num_values) +struct drm_property *drm_property_create (struct drm_device *dev, +u32 flags,const char *name, +int num_values) {struct drm_property *property =NULL ;int ret;@@ -136,10 +137,10 @@ EXPORT_SYMBOL(drm_property_create);* Returns: * A pointer to the newly created property on success, NULL on failure. */ -struct drm_property *drm_property_create_enum (struct drm_device *dev,int flags, -const char *name, -const struct drm_prop_enum_list *props, -int num_values) +struct drm_property *drm_property_create_enum (struct drm_device *dev, +u32 flags,const char *name, +const struct drm_prop_enum_list *props, +int num_values) {struct drm_property *property;int i, ret;@@ -185,10 +186,10 @@ EXPORT_SYMBOL(drm_property_create_enum);* A pointer to the newly created property on success, NULL on failure. */ struct drm_property *drm_property_create_bitmask (struct drm_device *dev, -int flags,const char *name, -const struct drm_prop_enum_list *props, -int num_props, -uint64_t supported_bits) +u32 flags,const char *name, +const struct drm_prop_enum_list *props, +int num_props, +uint64_t supported_bits) {struct drm_property *property;int i, ret, index =0 ;@@ -222,8 +223,8 @@ struct drm_property *drm_property_create_bitmask(struct drm_device *dev,EXPORT_SYMBOL (drm_property_create_bitmask);static struct drm_property *property_create_range (struct drm_device *dev, -int flags,const char *name, -uint64_t min,uint64_t max) +u32 flags,const char *name, +uint64_t min,uint64_t max) {struct drm_property *property;@@ -256,9 +257,9 @@ static struct drm_property *property_create_range(struct drm_device *dev,* Returns: * A pointer to the newly created property on success, NULL on failure. */ -struct drm_property *drm_property_create_range (struct drm_device *dev,int flags, -const char *name, -uint64_t min,uint64_t max) +struct drm_property *drm_property_create_range (struct drm_device *dev, +u32 flags,const char *name, +uint64_t min,uint64_t max) {return property_create_range (dev,DRM_MODE_PROP_RANGE | flags, name, min, max);@@ -285,8 +286,8 @@ EXPORT_SYMBOL(drm_property_create_range);* A pointer to the newly created property on success, NULL on failure. */ struct drm_property *drm_property_create_signed_range (struct drm_device *dev, -int flags,const char *name, -int64_t min,int64_t max) +u32 flags,const char *name, +int64_t min,int64_t max) {return property_create_range (dev,DRM_MODE_PROP_SIGNED_RANGE | flags, name,I642U64 (min),I642U64 (max));@@ -312,7 +313,7 @@ EXPORT_SYMBOL(drm_property_create_signed_range);* A pointer to the newly created property on success, NULL on failure. */ struct drm_property *drm_property_create_object (struct drm_device *dev, -int flags,const char *name, +u32 flags,const char *name,uint32_t type) {struct drm_property *property;@@ -348,8 +349,8 @@ EXPORT_SYMBOL(drm_property_create_object);* Returns: * A pointer to the newly created property on success, NULL on failure. */ -struct drm_property *drm_property_create_bool (struct drm_device *dev,int flags, -const char *name) +struct drm_property *drm_property_create_bool (struct drm_device *dev, +u32 flags,const char *name) {return drm_property_create_range (dev, flags, name,0 ,1 ); }include/drm/drm_property.h +13
-11@@ -237,27 +237,29 @@ static inline bool drm_property_type_is(struct drm_property *property,return property->flags & type; } -struct drm_property *drm_property_create (struct drm_device *dev,int flags, -const char *name,int num_values); -struct drm_property *drm_property_create_enum (struct drm_device *dev,int flags, -const char *name, +struct drm_property *drm_property_create (struct drm_device *dev, +u32 flags,const char *name, +int num_values); +struct drm_property *drm_property_create_enum (struct drm_device *dev, +u32 flags,const char *name,const struct drm_prop_enum_list *props,int num_values);struct drm_property *drm_property_create_bitmask (struct drm_device *dev, -int flags,const char *name, +u32 flags,const char *name,const struct drm_prop_enum_list *props,int num_props,uint64_t supported_bits); -struct drm_property *drm_property_create_range (struct drm_device *dev,int flags, -const char *name, +struct drm_property *drm_property_create_range (struct drm_device *dev, +u32 flags,const char *name,uint64_t min,uint64_t max);struct drm_property *drm_property_create_signed_range (struct drm_device *dev, -int flags,const char *name, +u32 flags,const char *name,int64_t min,int64_t max);struct drm_property *drm_property_create_object (struct drm_device *dev, -int flags,const char *name,uint32_t type); -struct drm_property *drm_property_create_bool (struct drm_device *dev,int flags, -const char *name); +u32 flags,const char *name, +uint32_t type); +struct drm_property *drm_property_create_bool (struct drm_device *dev, +u32 flags,const char *name);int drm_property_add_enum (struct drm_property *property,int index,uint64_t value,const char *name);void drm_property_destroy (struct drm_device *dev,struct drm_property *property);Signature · 6 lines
2.16.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH 6/6 drm: Reject bad property flag combinations
In reply to Ville SyrjalaFrom: Ville Syrjälä <[email protected]>
Pimp drm_property_type_valid() to check for more fails with the property flags. Also make the check before adding the property, and bail out if things look bad.
Since we're now chekcing for more than the type let's also change the function name to drm_property_flags_valid().
--- drivers/gpu/drm/drm_property.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-)
drivers/gpu/drm/drm_property.c +23 -6
@@ -50,11 +50,27 @@* IOCTL and in the get/set property IOCTL. */ -static bool drm_property_type_valid (struct drm_property *property) +static bool drm_property_flags_valid (u32 flags) { -if (property->flags &DRM_MODE_PROP_EXTENDED_TYPE ) -return !(property->flags &DRM_MODE_PROP_LEGACY_TYPE ); -return !!(property->flags &DRM_MODE_PROP_LEGACY_TYPE ); +u32 legacy_type = flags &DRM_MODE_PROP_LEGACY_TYPE ; +u32 ext_type = flags &DRM_MODE_PROP_EXTENDED_TYPE ; + +/* Reject undefined/deprecated flags */ +if (flags & ~(DRM_MODE_PROP_LEGACY_TYPE | +DRM_MODE_PROP_EXTENDED_TYPE | +DRM_MODE_PROP_IMMUTABLE | +DRM_MODE_PROP_ATOMIC )) +return false; + +/* We want either a legacy type or an extended type, but not both */ +if (!legacy_type == !ext_type) +return false; + +/* Only one legacy type at a time please */ +if (legacy_type && !is_power_of_2 (legacy_type)) +return false; + +return true; }/**
@@ -79,6 +95,9 @@ struct drm_property *drm_property_create(struct drm_device *dev,struct drm_property *property =NULL ;int ret; +if (WARN_ON (!drm_property_flags_valid (flags))) +return NULL ; +if (WARN_ON (strlen (name) >=DRM_PROP_NAME_LEN ))return NULL ;
@@ -108,8 +127,6 @@ struct drm_property *drm_property_create(struct drm_device *dev,list_add_tail (&property->head, &dev->mode_config.property_list); -WARN_ON (!drm_property_type_valid (property)); -return property; fail:kfree (property->values);
Signature · 6 lines
2.16.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 6/6] drm: Reject bad property flag combinations
Quoted 38 lines · Ville Syrjala
From: Ville Syrjälä <[email protected]>
Pimp
drm_property_type_valid()to check for more fails with the property flags. Also make the check before adding the property, and bail out if things look bad.Since we're now chekcing for more than the type let's also change the function name to
drm_property_flags_valid().Signed-off-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/drm_property.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-)drivers/gpu/drm/drm_property.c +11
-4@@ -50,11 +50,27 @@* IOCTL and in the get/set property IOCTL. */ -static bool drm_property_type_valid (struct drm_property *property) +static bool drm_property_flags_valid (u32 flags) { -if (property->flags &DRM_MODE_PROP_EXTENDED_TYPE ) -return !(property->flags &DRM_MODE_PROP_LEGACY_TYPE ); -return !!(property->flags &DRM_MODE_PROP_LEGACY_TYPE ); +u32 legacy_type = flags &DRM_MODE_PROP_LEGACY_TYPE ; +u32 ext_type = flags &DRM_MODE_PROP_EXTENDED_TYPE ; + +/* Reject undefined/deprecated flags */ +if (flags & ~(DRM_MODE_PROP_LEGACY_TYPE | +DRM_MODE_PROP_EXTENDED_TYPE | +DRM_MODE_PROP_IMMUTABLE | +DRM_MODE_PROP_ATOMIC )) +return false; +
drivers/gpu/drm/drm_property.c line 74
Quoted 10 lines
drivers/gpu/drm/drm_property.c +9
-0+/* We want either a legacy type or an extended type, but not both */ +if (!legacy_type == !ext_type) +return false; + +/* Only one legacy type at a time please */ +if (legacy_type && !is_power_of_2 (legacy_type)) +return false; + +return true; }
I think this catches everything. Well except not-yet-assigned EXTENDED_TYPE defines, but really we can overdo this :-)
Quoted 28 lines
drivers/gpu/drm/drm_property.c +3
-2/** @@ -79,6 +95,9 @@ struct drm_property *drm_property_create(struct drm_device *dev,struct drm_property *property =NULL ;int ret; +if (WARN_ON (!drm_property_flags_valid (flags))) +return NULL ; +if (WARN_ON (strlen (name) >=DRM_PROP_NAME_LEN ))return NULL ;@@ -108,8 +127,6 @@ struct drm_property *drm_property_create(struct drm_device *dev,list_add_tail (&property->head, &dev->mode_config.property_list); -WARN_ON (!drm_property_type_valid (property)); -return property; fail:kfree (property->values);Signature · 6 lines
2.16.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 6/6] drm: Reject bad property flag combinations
Quoted 44 lines · Daniel Vetter
Quoted 43 lines · Ville Syrjala
From: Ville Syrjälä <[email protected]>
Pimp
drm_property_type_valid()to check for more fails with the property flags. Also make the check before adding the property, and bail out if things look bad.Since we're now chekcing for more than the type let's also change the function name to
drm_property_flags_valid().Signed-off-by Ville Syrjälä <[email protected]>--- drivers/gpu/drm/drm_property.c | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-)drivers/gpu/drm/drm_property.c +16
-4@@ -50,11 +50,27 @@* IOCTL and in the get/set property IOCTL. */ -static bool drm_property_type_valid (struct drm_property *property) +static bool drm_property_flags_valid (u32 flags) { -if (property->flags &DRM_MODE_PROP_EXTENDED_TYPE ) -return !(property->flags &DRM_MODE_PROP_LEGACY_TYPE ); -return !!(property->flags &DRM_MODE_PROP_LEGACY_TYPE ); +u32 legacy_type = flags &DRM_MODE_PROP_LEGACY_TYPE ; +u32 ext_type = flags &DRM_MODE_PROP_EXTENDED_TYPE ; + +/* Reject undefined/deprecated flags */ +if (flags & ~(DRM_MODE_PROP_LEGACY_TYPE | +DRM_MODE_PROP_EXTENDED_TYPE | +DRM_MODE_PROP_IMMUTABLE | +DRM_MODE_PROP_ATOMIC )) +return false; + +/* We want either a legacy type or an extended type, but not both */ +if (!legacy_type == !ext_type) +return false; + +/* Only one legacy type at a time please */
Quoted 8 lines
drivers/gpu/drm/drm_property.c line 74
Quoted 5 lines
drivers/gpu/drm/drm_property.c +4
-0+if (legacy_type && !is_power_of_2 (legacy_type)) +return false; + +return true; }I think this catches everything. Well except not-yet-assigned
EXTENDED_TYPEdefines, but really we can overdo this :-)
Hmm. Yeah, I guess that kind of a fail is fairly unlikely because the defines won't be there. Would require the driver to basically pass in utter garbage instead of just a bad combination of existing flags.
Quoted 2 lines
Reviewed-by Daniel Vetter <[email protected]>
Thanks. Series pushed to drm-misc-next.
Quoted 33 lines
Quoted 28 lines
drivers/gpu/drm/drm_property.c +3
-2/** @@ -79,6 +95,9 @@ struct drm_property *drm_property_create(struct drm_device *dev,struct drm_property *property =NULL ;int ret; +if (WARN_ON (!drm_property_flags_valid (flags))) +return NULL ; +if (WARN_ON (strlen (name) >=DRM_PROP_NAME_LEN ))return NULL ;@@ -108,8 +127,6 @@ struct drm_property *drm_property_create(struct drm_device *dev,list_add_tail (&property->head, &dev->mode_config.property_list); -WARN_ON (!drm_property_type_valid (property)); -return property; fail:kfree (property->values);Signature · 6 lines
2.16.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-develSignature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Patchwork
CI✓ Fi.CI.BAT: success for series starting with [1/6] drm: Reject replacing property enum values
In reply to Ville Syrjala== Series Details ==
== Series Details ==
Series: series starting with [1/6] drm: Reject replacing property enum values
URL : https://patchwork.freedesktop.org/series/39465/
State : success
== Summary ==
Series 39465v1 series starting with [1/6] drm: Reject replacing property enum values
https://patchwork.freedesktop.org/api/1.0/series/39465/revisions/1/mbox/
---- Known issues:
Test gem_mmap_gtt:
Subgroup basic-small-bo-tiledx:
pass -> FAIL (fi-gdg-551) fdo#102575
Test kms_pipe_crc_basic:
Subgroup suspend-read-crc-pipe-b:
incomplete -> PASS (fi-snb-2520m) fdo#103713
Test prime_vgem:
Subgroup basic-fence-flip:
fail -> PASS (fi-ilk-650) fdo#104008fdo#102575 https://bugs.freedesktop.org/show_bug.cgi?id=102575
fdo#103713 https://bugs.freedesktop.org/show_bug.cgi?id=103713
fdo#104008 https://bugs.freedesktop.org/show_bug.cgi?id=104008
fi-bdw-5557u total:288 pass:267 dwarn:0 dfail:0 fail:0 skip:21 time:423s fi-bdw-gvtdvm total:288 pass:264 dwarn:0 dfail:0 fail:0 skip:24 time:425s fi-blb-e6850 total:288 pass:223 dwarn:1 dfail:0 fail:0 skip:64 time:373s fi-bsw-n3050 total:288 pass:242 dwarn:0 dfail:0 fail:0 skip:46 time:512s fi-bwr-2160 total:288 pass:183 dwarn:0 dfail:0 fail:0 skip:105 time:281s fi-bxt-dsi total:288 pass:258 dwarn:0 dfail:0 fail:0 skip:30 time:491s fi-bxt-j4205 total:288 pass:259 dwarn:0 dfail:0 fail:0 skip:29 time:495s fi-byt-j1900 total:288 pass:253 dwarn:0 dfail:0 fail:0 skip:35 time:483s fi-byt-n2820 total:288 pass:249 dwarn:0 dfail:0 fail:0 skip:39 time:470s fi-cfl-8700k total:288 pass:260 dwarn:0 dfail:0 fail:0 skip:28 time:405s fi-cfl-s2 total:288 pass:262 dwarn:0 dfail:0 fail:0 skip:26 time:572s fi-cnl-y3 total:288 pass:262 dwarn:0 dfail:0 fail:0 skip:26 time:590s fi-elk-e7500 total:288 pass:229 dwarn:0 dfail:0 fail:0 skip:59 time:410s fi-gdg-551 total:288 pass:179 dwarn:0 dfail:0 fail:1 skip:108 time:292s fi-glk-1 total:288 pass:260 dwarn:0 dfail:0 fail:0 skip:28 time:517s fi-hsw-4770 total:288 pass:261 dwarn:0 dfail:0 fail:0 skip:27 time:402s fi-ilk-650 total:288 pass:228 dwarn:0 dfail:0 fail:0 skip:60 time:413s fi-ivb-3520m total:288 pass:259 dwarn:0 dfail:0 fail:0 skip:29 time:468s fi-ivb-3770 total:288 pass:255 dwarn:0 dfail:0 fail:0 skip:33 time:417s fi-kbl-7500u total:288 pass:263 dwarn:1 dfail:0 fail:0 skip:24 time:468s fi-kbl-7560u total:108 pass:104 dwarn:0 dfail:0 fail:0 skip:3 fi-kbl-7567u total:288 pass:268 dwarn:0 dfail:0 fail:0 skip:20 time:463s fi-kbl-r total:288 pass:261 dwarn:0 dfail:0 fail:0 skip:27 time:507s fi-pnv-d510 total:288 pass:222 dwarn:1 dfail:0 fail:0 skip:65 time:589s fi-skl-6260u total:288 pass:268 dwarn:0 dfail:0 fail:0 skip:20 time:437s fi-skl-6600u total:288 pass:261 dwarn:0 dfail:0 fail:0 skip:27 time:519s fi-skl-6700hq total:288 pass:262 dwarn:0 dfail:0 fail:0 skip:26 time:534s fi-skl-6700k2 total:288 pass:264 dwarn:0 dfail:0 fail:0 skip:24 time:496s fi-skl-6770hq total:288 pass:268 dwarn:0 dfail:0 fail:0 skip:20 time:486s fi-skl-guc total:288 pass:260 dwarn:0 dfail:0 fail:0 skip:28 time:424s fi-snb-2520m total:288 pass:248 dwarn:0 dfail:0 fail:0 skip:40 time:522s fi-snb-2600 total:288 pass:248 dwarn:0 dfail:0 fail:0 skip:40 time:396s
dc9f7f3e78b982ee999e018cd51c2df4240515cf drm-tip: 2018y-03m-06d-16h-12m-59s UTC integration manifest d1dea82c33b7 drm: Reject bad property flag combinationsb774a71d30fe drm: Make property flags u320e0109bc93e3 drm/uapi: Deprecate DRM_MODE_PROP_PENDINGff5973f3a330 drm: WARN when trying to add enum value > 63 to a bitmask property f8f70aa3a389 drm: WARN when trying add enum values to non-enum/bitmask properties 35933b28d4af drm: Reject replacing property enum values
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_8247/issues.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 10 lines · Ville Syrjala
From: Ville Syrjälä <[email protected]>
If the property already has the enum value WARN and bail. Replacing enum values doesn't make sense to me.
Throw out the pointless
list_empty()while at it.Cc Daniel Vetter <[email protected]>Suggested-by Daniel Vetter <[email protected]>Signed-off-by Ville Syrjälä <[email protected]>
Quoted 29 lines
--- drivers/gpu/drm/drm_property.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-)drivers/gpu/drm/drm_property.c +3
-8@@ -390,14 +390,9 @@ int drm_property_add_enum(struct drm_property *property, int index, (value > 63))return -EINVAL ; -if (!list_empty (&property->enum_list)) { -list_for_each_entry (prop_enum, &property->enum_list, head) { -if (prop_enum->value == value) { -strncpy (prop_enum->name, name,DRM_PROP_NAME_LEN ); - prop_enum->name[DRM_PROP_NAME_LEN -1 ] ='\0' ; -return 0 ; - } - } +list_for_each_entry (prop_enum, &property->enum_list, head) { +if (WARN_ON (prop_enum->value == value)) +return -EINVAL ; } prop_enum =kzalloc (sizeof (struct drm_property_enum ),GFP_KERNEL );Signature · 1 line
2.16.1
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Patchwork
CI✗ Fi.CI.IGT: warning for series starting with [1/6] drm: Reject replacing property enum values
In reply to Ville Syrjala== Series Details ==
== Series Details ==
Series: series starting with [1/6] drm: Reject replacing property enum values
URL : https://patchwork.freedesktop.org/series/39465/
State : warning
== Summary ==
---- Possible new issues:
Test kms_chv_cursor_fail:
Subgroup pipe-a-64x64-top-edge:
dmesg-warn -> PASS (shard-hsw)
Subgroup pipe-c-64x64-right-edge:
pass -> DMESG-WARN (shard-apl)---- Known issues:
Test gem_eio:
Subgroup in-flight-contexts:
pass -> INCOMPLETE (shard-apl) fdo#105341
Test kms_atomic_transition:
Subgroup 1x-modeset-transitions:
pass -> FAIL (shard-apl) fdo#103207
Test kms_chv_cursor_fail:
Subgroup pipe-b-256x256-right-edge:
dmesg-warn -> PASS (shard-snb) fdo#105185
Test kms_cursor_legacy:
Subgroup 2x-long-flip-vs-cursor-atomic:
fail -> PASS (shard-hsw) fdo#104873
Subgroup flip-vs-cursor-toggle:
fail -> PASS (shard-hsw) fdo#102670
Test kms_flip:
Subgroup plain-flip-ts-check:
fail -> PASS (shard-hsw) fdo#100368 +2
Test kms_frontbuffer_tracking:
Subgroup fbc-1p-primscrn-spr-indfb-fullscreen:
fail -> PASS (shard-apl) fdo#101623 +1
Test pm_lpsp:
Subgroup screens-disabled:
pass -> FAIL (shard-hsw) fdo#104941fdo#105341 https://bugs.freedesktop.org/show_bug.cgi?id=105341
fdo#103207 https://bugs.freedesktop.org/show_bug.cgi?id=103207
fdo#105185 https://bugs.freedesktop.org/show_bug.cgi?id=105185
fdo#104873 https://bugs.freedesktop.org/show_bug.cgi?id=104873
fdo#102670 https://bugs.freedesktop.org/show_bug.cgi?id=102670
fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
fdo#101623 https://bugs.freedesktop.org/show_bug.cgi?id=101623
fdo#104941 https://bugs.freedesktop.org/show_bug.cgi?id=104941
shard-apl total:3381 pass:1779 dwarn:2 dfail:0 fail:7 skip:1591 time:11922s shard-hsw total:3467 pass:1771 dwarn:1 dfail:0 fail:3 skip:1691 time:11848s shard-snb total:3467 pass:1363 dwarn:1 dfail:0 fail:2 skip:2101 time:6972s
Blacklisted hosts:
shard-kbl total:3394 pass:1908 dwarn:3 dfail:0 fail:8 skip:1474 time:9081s
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_8247/shards.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: ✗ Fi.CI.IGT: warning for series starting with [1/6] drm: Reject replacing property enum values
Quoted 8 lines · Patchwork
== Series Details ==
Series: series starting with [1/6] drm: Reject replacing property enum values
URL : https://patchwork.freedesktop.org/series/39465/
State : warning== Summary ==
Quoted 7 lines
---- Possible new issues:
Test
kms_chv_cursor_fail:Subgroup pipe-a-64x64-top-edge: dmesg-warn -> PASS (shard-hsw) Subgroup pipe-c-64x64-right-edge: pass -> DMESG-WARN (shard-apl)
Unrelated pipe crc vs. vblank warn:
[ 39.323847] WARNING: CPU: 1 PID: 0 at drivers/gpu/drm/drm_vblank.c:620 drm_calc_vbltimestamp_from_scanoutpos+0x13e/0x2f0
Quoted 45 lines
---- Known issues:
Test
gem_eio:Subgroup in-flight-contexts: pass -> INCOMPLETE (shard-apl) fdo#105341 Test kms_atomic_transition: Subgroup 1x-modeset-transitions: pass -> FAIL (shard-apl) fdo#103207 Test kms_chv_cursor_fail: Subgroup pipe-b-256x256-right-edge: dmesg-warn -> PASS (shard-snb) fdo#105185 Test kms_cursor_legacy: Subgroup 2x-long-flip-vs-cursor-atomic: fail -> PASS (shard-hsw) fdo#104873 Subgroup flip-vs-cursor-toggle: fail -> PASS (shard-hsw) fdo#102670 Test kms_flip: Subgroup plain-flip-ts-check: fail -> PASS (shard-hsw) fdo#100368 +2 Test kms_frontbuffer_tracking: Subgroup fbc-1p-primscrn-spr-indfb-fullscreen: fail -> PASS (shard-apl) fdo#101623 +1 Test pm_lpsp: Subgroup screens-disabled: pass -> FAIL (shard-hsw) fdo#104941fdo#105341 https://bugs.freedesktop.org/show_bug.cgi?id=105341
fdo#103207 https://bugs.freedesktop.org/show_bug.cgi?id=103207
fdo#105185 https://bugs.freedesktop.org/show_bug.cgi?id=105185
fdo#104873 https://bugs.freedesktop.org/show_bug.cgi?id=104873
fdo#102670 https://bugs.freedesktop.org/show_bug.cgi?id=102670
fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
fdo#101623 https://bugs.freedesktop.org/show_bug.cgi?id=101623
fdo#104941 https://bugs.freedesktop.org/show_bug.cgi?id=104941shard-apl total:3381 pass:1779 dwarn:2 dfail:0 fail:7 skip:1591 time:11922s shard-hsw total:3467 pass:1771 dwarn:1 dfail:0 fail:3 skip:1691 time:11848s shard-snb total:3467 pass:1363 dwarn:1 dfail:0 fail:2 skip:2101 time:6972sBlacklisted hosts:
shard-kbl total:3394 pass:1908 dwarn:3 dfail:0 fail:8 skip:1474 time:9081s== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_8247/shards.html
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx