Skip to contentSkip to conversation

drm/fb-helper: add virtual screen size check to drm_fb_helper_check_var()

PATCH Superseded Andrey Strachuk 4 participants 5 messages Aug 11, 2022 – Sep 7, 2022

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 drm/fb-helper: add virtual screen size check to drm_fb_helper_check_var()

Add virtual screen size check to drm_fb_helper_check_var() in order to validate userspace input.

Found by Linux Verification Center (linuxtesting.org) with syzkaller.

Fixes 785b93ef8c30 ("drm/kms: move driver specific fb common code to helper functions (v2)")
---
 drivers/gpu/drm/drm_fb_helper.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/gpu/drm/drm_fb_helper.c +6 -0
index 2d4cee6a10ff..5c8b211769eb 100644
@@ -1355,6 +1355,12 @@ int drm_fb_helper_check_var(struct fb_var_screeninfo *var,
 	    (drm_format_info_block_height(fb->format, 0) > 1))
 		return -EINVAL;
 
+	/* verify that virtual resolution >= physical resolution */
+	if (var->xres_virtual < var->xres)
+		var->xres_virtual = var->xres;
+	if (var->yres_virtual < var->yres)
+		var->yres_virtual = var->yres;
+
 	/*
 	 * Changes struct fb_var_screeninfo are currently not pushed back
 	 * to KMS, hence fail if different settings are requested.
Signature · 1 line
2.25.1
Reviewed-by on v2 1/1
#1 lore raw

Hi Andrey,

Quoted 6 lines · Andrey Strachuk

Add virtual screen size check to drm_fb_helper_check_var() in order to validate userspace input.

Found by Linux Verification Center (linuxtesting.org) with syzkaller.

Thanks for the update!

Quoted 1 line
Fixes 785b93ef8c30 ("drm/kms: move driver specific fb common code to helper functions (v2)")

I'd drop the Fixes tag completely, as the bug was present in the intel and radeon drivers before. But probably it doesn't matter, as no one is gonna backport this to v2.6.31 and earlier ;-)

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

#2 lore raw

For v2 I would suggest to update description to something like this:

Make sure that virtual screen size is not less than physical screen one.

and comment to:

    /* make sure that virtual resolution >= physical resolution */

--
Alexey

Quoted 36 lines · Geert Uytterhoeven

Hi Andrey,

Quoted 6 lines · Andrey Strachuk

Add virtual screen size check to drm_fb_helper_check_var() in order to validate userspace input.

Found by Linux Verification Center (linuxtesting.org) with syzkaller.

Thanks for the update!

Quoted 1 line
Fixes 785b93ef8c30 ("drm/kms: move driver specific fb common code to helper functions (v2)")

I'd drop the Fixes tag completely, as the bug was present in the intel and radeon drivers before. But probably it doesn't matter, as no one is gonna backport this to v2.6.31 and earlier ;-)

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

_______________________________________________
ldv-project mailing list
[email protected]
http://linuxtesting.org/cgi-bin/mailman/listinfo/ldv-project

#3 lore raw
Quoted 6 lines · Alexey Khoroshilov

For v2 I would suggest to update description to something like this:

Make sure that virtual screen size is not less than physical screen one.

and comment to:

    /* make sure that virtual resolution >= physical resolution */

Did this land somewhere? If not please resend with r-b tags and everything.

Thanks, Daniel

Quoted 43 lines

--
Alexey

Quoted 36 lines · Geert Uytterhoeven

Hi Andrey,

Quoted 6 lines · Andrey Strachuk

Add virtual screen size check to drm_fb_helper_check_var() in order to validate userspace input.

Found by Linux Verification Center (linuxtesting.org) with syzkaller.

Thanks for the update!

Quoted 1 line
Fixes 785b93ef8c30 ("drm/kms: move driver specific fb common code to helper functions (v2)")

I'd drop the Fixes tag completely, as the bug was present in the intel and radeon drivers before. But probably it doesn't matter, as no one is gonna backport this to v2.6.31 and earlier ;-)

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

_______________________________________________
ldv-project mailing list
[email protected]
http://linuxtesting.org/cgi-bin/mailman/listinfo/ldv-project

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
#4 lore raw
Quoted 8 lines · Daniel Vetter
Quoted 6 lines · Alexey Khoroshilov

For v2 I would suggest to update description to something like this:

Make sure that virtual screen size is not less than physical screen one.

and comment to:

    /* make sure that virtual resolution >= physical resolution */

Did this land somewhere?

As far as I can see it is not.

Quoted 2 lines

If not please resend with r-b tags and
everything.

The final version (v3) was resent Fri, 12 Aug 2022 04:32:12 -0700:

https://www.mail-archive.com/[email protected]/msg407965.html

--
Alexey