dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm: Fix uabi regression by allowing garbage mode->type from userspace
@ 2018-03-21 21:12 Ville Syrjala
  2018-03-22  7:42 ` Thomas Hellstrom
  2018-03-23 11:05 ` Daniel Stone
  0 siblings, 2 replies; 5+ messages in thread
From: Ville Syrjala @ 2018-03-21 21:12 UTC (permalink / raw)
  To: dri-devel; +Cc: Alex Deucher, intel-gfx

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Apparently xf86-video-vmware leaves the mode->type uninitialized
when feeding the mode to the kernel. Thus we have no choice but
to accept the garbage in. We'll just ignore any of the bits we
don't want. The mode type is just a hint anyway, and more
useful for the kernel->userspace direction.

Reported-by: Thomas Hellstrom <thomas@shipmail.org>
CC: Thomas Hellstrom <thomas@shipmail.org>
Cc: Adam Jackson <ajax@redhat.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Fixes: c6ed6dad5cfb ("drm/uapi: Validate the mode flags/type")
References: https://lists.freedesktop.org/archives/dri-devel/2018-March/170213.html
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_modes.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
index f6b7c0e36a1a..e82b61e08f8c 100644
--- a/drivers/gpu/drm/drm_modes.c
+++ b/drivers/gpu/drm/drm_modes.c
@@ -1611,7 +1611,13 @@ int drm_mode_convert_umode(struct drm_device *dev,
 	out->vscan = in->vscan;
 	out->vrefresh = in->vrefresh;
 	out->flags = in->flags;
-	out->type = in->type;
+	/*
+	 * Old xf86-video-vmware (possibly others too) used to
+	 * leave 'type' unititialized. Just ignore any bits we
+	 * don't like. It's a just hint after all, and more
+	 * useful for the kernel->userspace direction anyway.
+	 */
+	out->type = in->type & DRM_MODE_TYPE_ALL;
 	strncpy(out->name, in->name, DRM_DISPLAY_MODE_LEN);
 	out->name[DRM_DISPLAY_MODE_LEN-1] = 0;
 
-- 
2.16.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] drm: Fix uabi regression by allowing garbage mode->type from userspace
  2018-03-21 21:12 [PATCH] drm: Fix uabi regression by allowing garbage mode->type from userspace Ville Syrjala
@ 2018-03-22  7:42 ` Thomas Hellstrom
  2018-03-23 11:04   ` Maarten Lankhorst
  2018-03-23 11:52   ` Ville Syrjälä
  2018-03-23 11:05 ` Daniel Stone
  1 sibling, 2 replies; 5+ messages in thread
From: Thomas Hellstrom @ 2018-03-22  7:42 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel; +Cc: Alex Deucher, intel-gfx

On 03/21/2018 10:12 PM, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> Apparently xf86-video-vmware leaves the mode->type uninitialized
> when feeding the mode to the kernel. Thus we have no choice but
> to accept the garbage in. We'll just ignore any of the bits we
> don't want. The mode type is just a hint anyway, and more
> useful for the kernel->userspace direction.
>
> Reported-by: Thomas Hellstrom <thomas@shipmail.org>
> CC: Thomas Hellstrom <thomas@shipmail.org>
> Cc: Adam Jackson <ajax@redhat.com>
> Cc: Alex Deucher <alexander.deucher@amd.com>
> Fixes: c6ed6dad5cfb ("drm/uapi: Validate the mode flags/type")
> References: https://lists.freedesktop.org/archives/dri-devel/2018-March/170213.html
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>   drivers/gpu/drm/drm_modes.c | 8 +++++++-
>   1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
> index f6b7c0e36a1a..e82b61e08f8c 100644
> --- a/drivers/gpu/drm/drm_modes.c
> +++ b/drivers/gpu/drm/drm_modes.c
> @@ -1611,7 +1611,13 @@ int drm_mode_convert_umode(struct drm_device *dev,
>   	out->vscan = in->vscan;
>   	out->vrefresh = in->vrefresh;
>   	out->flags = in->flags;
> -	out->type = in->type;
> +	/*
> +	 * Old xf86-video-vmware (possibly others too) used to
> +	 * leave 'type' unititialized. Just ignore any bits we
> +	 * don't like. It's a just hint after all, and more
> +	 * useful for the kernel->userspace direction anyway.
> +	 */
> +	out->type = in->type & DRM_MODE_TYPE_ALL;
>   	strncpy(out->name, in->name, DRM_DISPLAY_MODE_LEN);
>   	out->name[DRM_DISPLAY_MODE_LEN-1] = 0;
>   

Tested-by: Thomas Hellstrom <thellstrom@vmware.com>

Thanks,

Thomas


_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] drm: Fix uabi regression by allowing garbage mode->type from userspace
  2018-03-22  7:42 ` Thomas Hellstrom
@ 2018-03-23 11:04   ` Maarten Lankhorst
  2018-03-23 11:52   ` Ville Syrjälä
  1 sibling, 0 replies; 5+ messages in thread
From: Maarten Lankhorst @ 2018-03-23 11:04 UTC (permalink / raw)
  To: Thomas Hellstrom, Ville Syrjala, dri-devel; +Cc: Alex Deucher, intel-gfx

Op 22-03-18 om 08:42 schreef Thomas Hellstrom:
> On 03/21/2018 10:12 PM, Ville Syrjala wrote:
>> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>>
>> Apparently xf86-video-vmware leaves the mode->type uninitialized
>> when feeding the mode to the kernel. Thus we have no choice but
>> to accept the garbage in. We'll just ignore any of the bits we
>> don't want. The mode type is just a hint anyway, and more
>> useful for the kernel->userspace direction.
>>
>> Reported-by: Thomas Hellstrom <thomas@shipmail.org>
>> CC: Thomas Hellstrom <thomas@shipmail.org>
>> Cc: Adam Jackson <ajax@redhat.com>
>> Cc: Alex Deucher <alexander.deucher@amd.com>
>> Fixes: c6ed6dad5cfb ("drm/uapi: Validate the mode flags/type")
>> References: https://lists.freedesktop.org/archives/dri-devel/2018-March/170213.html
>> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
>> ---
>>   drivers/gpu/drm/drm_modes.c | 8 +++++++-
>>   1 file changed, 7 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
>> index f6b7c0e36a1a..e82b61e08f8c 100644
>> --- a/drivers/gpu/drm/drm_modes.c
>> +++ b/drivers/gpu/drm/drm_modes.c
>> @@ -1611,7 +1611,13 @@ int drm_mode_convert_umode(struct drm_device *dev,
>>       out->vscan = in->vscan;
>>       out->vrefresh = in->vrefresh;
>>       out->flags = in->flags;
>> -    out->type = in->type;
>> +    /*
>> +     * Old xf86-video-vmware (possibly others too) used to
>> +     * leave 'type' unititialized. Just ignore any bits we
>> +     * don't like. It's a just hint after all, and more
>> +     * useful for the kernel->userspace direction anyway.
>> +     */
>> +    out->type = in->type & DRM_MODE_TYPE_ALL;
>>       strncpy(out->name, in->name, DRM_DISPLAY_MODE_LEN);
>>       out->name[DRM_DISPLAY_MODE_LEN-1] = 0;
>>   
>
> Tested-by: Thomas Hellstrom <thellstrom@vmware.com>
>
> Thanks,
>
> Thomas
>
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] drm: Fix uabi regression by allowing garbage mode->type from userspace
  2018-03-21 21:12 [PATCH] drm: Fix uabi regression by allowing garbage mode->type from userspace Ville Syrjala
  2018-03-22  7:42 ` Thomas Hellstrom
@ 2018-03-23 11:05 ` Daniel Stone
  1 sibling, 0 replies; 5+ messages in thread
From: Daniel Stone @ 2018-03-23 11:05 UTC (permalink / raw)
  To: Ville Syrjala; +Cc: Alex Deucher, intel-gfx, dri-devel

On 21 March 2018 at 21:12, Ville Syrjala <ville.syrjala@linux.intel.com> wrote:
> Apparently xf86-video-vmware leaves the mode->type uninitialized
> when feeding the mode to the kernel. Thus we have no choice but
> to accept the garbage in. We'll just ignore any of the bits we
> don't want. The mode type is just a hint anyway, and more
> useful for the kernel->userspace direction.

Reviewed-by: Daniel Stone <daniels@collabora.com>
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] drm: Fix uabi regression by allowing garbage mode->type from userspace
  2018-03-22  7:42 ` Thomas Hellstrom
  2018-03-23 11:04   ` Maarten Lankhorst
@ 2018-03-23 11:52   ` Ville Syrjälä
  1 sibling, 0 replies; 5+ messages in thread
From: Ville Syrjälä @ 2018-03-23 11:52 UTC (permalink / raw)
  To: Thomas Hellstrom; +Cc: Alex Deucher, intel-gfx, Adam Jackson, dri-devel

On Thu, Mar 22, 2018 at 08:42:11AM +0100, Thomas Hellstrom wrote:
> On 03/21/2018 10:12 PM, Ville Syrjala wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> > Apparently xf86-video-vmware leaves the mode->type uninitialized
> > when feeding the mode to the kernel. Thus we have no choice but
> > to accept the garbage in. We'll just ignore any of the bits we
> > don't want. The mode type is just a hint anyway, and more
> > useful for the kernel->userspace direction.
> >
> > Reported-by: Thomas Hellstrom <thomas@shipmail.org>
> > CC: Thomas Hellstrom <thomas@shipmail.org>
> > Cc: Adam Jackson <ajax@redhat.com>
> > Cc: Alex Deucher <alexander.deucher@amd.com>
> > Fixes: c6ed6dad5cfb ("drm/uapi: Validate the mode flags/type")
> > References: https://lists.freedesktop.org/archives/dri-devel/2018-March/170213.html
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > ---
> >   drivers/gpu/drm/drm_modes.c | 8 +++++++-
> >   1 file changed, 7 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
> > index f6b7c0e36a1a..e82b61e08f8c 100644
> > --- a/drivers/gpu/drm/drm_modes.c
> > +++ b/drivers/gpu/drm/drm_modes.c
> > @@ -1611,7 +1611,13 @@ int drm_mode_convert_umode(struct drm_device *dev,
> >   	out->vscan = in->vscan;
> >   	out->vrefresh = in->vrefresh;
> >   	out->flags = in->flags;
> > -	out->type = in->type;
> > +	/*
> > +	 * Old xf86-video-vmware (possibly others too) used to
> > +	 * leave 'type' unititialized. Just ignore any bits we
> > +	 * don't like. It's a just hint after all, and more
> > +	 * useful for the kernel->userspace direction anyway.
> > +	 */
> > +	out->type = in->type & DRM_MODE_TYPE_ALL;
> >   	strncpy(out->name, in->name, DRM_DISPLAY_MODE_LEN);
> >   	out->name[DRM_DISPLAY_MODE_LEN-1] = 0;
> >   
> 
> Tested-by: Thomas Hellstrom <thellstrom@vmware.com>

Thanks for the testing and reviews. And sorry for the extra hassle.

Pushed to drm-misc-next-fixes.

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-03-23 11:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-21 21:12 [PATCH] drm: Fix uabi regression by allowing garbage mode->type from userspace Ville Syrjala
2018-03-22  7:42 ` Thomas Hellstrom
2018-03-23 11:04   ` Maarten Lankhorst
2018-03-23 11:52   ` Ville Syrjälä
2018-03-23 11:05 ` Daniel Stone

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).