From: Geert Uytterhoeven <geert@linux-m68k.org> To: Andrey Strachuk <strochuk@ispras.ru> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>, Maxime Ripard <mripard@kernel.org>, Thomas Zimmermann <tzimmermann@suse.de>, David Airlie <airlied@linux.ie>, Daniel Vetter <daniel@ffwll.ch>, Helge Deller <deller@gmx.de>, DRI Development <dri-devel@lists.freedesktop.org>, Linux Kernel Mailing List <linux-kernel@vger.kernel.org>, ldv-project@linuxtesting.org Subject: Re: [PATCH] drm/fb-helper: add virtual screen size check to drm_fb_helper_check_var() Date: Thu, 11 Aug 2022 13:49:35 +0200 [thread overview] Message-ID: <CAMuHMdXRVHiBZj=MQ3jLy2AEnwrvMXt6KXbZXr10ZJMhJDAmsw@mail.gmail.com> (raw) In-Reply-To: <20220811102304.70769-1-strochuk@ispras.ru> Hi Andrey, On Thu, Aug 11, 2022 at 12:23 PM Andrey Strachuk <strochuk@ispras.ru> wrote: > 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. > > Signed-off-by: Andrey Strachuk <strochuk@ispras.ru> Thanks for your patch! > Fixes: 6c11df58fd1a ("fbmem: Check virtual screen sizes in fb_set_var()") This Fixes tag is misleading: the bug has existed since basically forever. > --- a/drivers/gpu/drm/drm_fb_helper.c > +++ b/drivers/gpu/drm/drm_fb_helper.c > @@ -1355,6 +1355,16 @@ 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->yres_virtual < var->yres) { > + drm_dbg_kms(dev, "requested virtual screen size that is " > + "below the physical size(%ux%u vs. %ux%u)\n", > + var->xres_virtual, var->yres_virtual, > + var->xres, var->yres); > + return -EINVAL; According to the fbdev rounding rules, invalid values should be rounded up, if possible. Hence it is better to not return an error, but round up: 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. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org 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
WARNING: multiple messages have this Message-ID (diff)
From: Geert Uytterhoeven <geert@linux-m68k.org> To: Andrey Strachuk <strochuk@ispras.ru> Cc: ldv-project@linuxtesting.org, Thomas Zimmermann <tzimmermann@suse.de>, David Airlie <airlied@linux.ie>, Helge Deller <deller@gmx.de>, Linux Kernel Mailing List <linux-kernel@vger.kernel.org>, DRI Development <dri-devel@lists.freedesktop.org> Subject: Re: [PATCH] drm/fb-helper: add virtual screen size check to drm_fb_helper_check_var() Date: Thu, 11 Aug 2022 13:49:35 +0200 [thread overview] Message-ID: <CAMuHMdXRVHiBZj=MQ3jLy2AEnwrvMXt6KXbZXr10ZJMhJDAmsw@mail.gmail.com> (raw) In-Reply-To: <20220811102304.70769-1-strochuk@ispras.ru> Hi Andrey, On Thu, Aug 11, 2022 at 12:23 PM Andrey Strachuk <strochuk@ispras.ru> wrote: > 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. > > Signed-off-by: Andrey Strachuk <strochuk@ispras.ru> Thanks for your patch! > Fixes: 6c11df58fd1a ("fbmem: Check virtual screen sizes in fb_set_var()") This Fixes tag is misleading: the bug has existed since basically forever. > --- a/drivers/gpu/drm/drm_fb_helper.c > +++ b/drivers/gpu/drm/drm_fb_helper.c > @@ -1355,6 +1355,16 @@ 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->yres_virtual < var->yres) { > + drm_dbg_kms(dev, "requested virtual screen size that is " > + "below the physical size(%ux%u vs. %ux%u)\n", > + var->xres_virtual, var->yres_virtual, > + var->xres, var->yres); > + return -EINVAL; According to the fbdev rounding rules, invalid values should be rounded up, if possible. Hence it is better to not return an error, but round up: 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. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org 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
next prev parent reply other threads:[~2022-08-11 11:50 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-08-11 10:23 [PATCH] drm/fb-helper: add virtual screen size check to drm_fb_helper_check_var() Andrey Strachuk 2022-08-11 10:23 ` Andrey Strachuk 2022-08-11 11:49 ` Geert Uytterhoeven [this message] 2022-08-11 11:49 ` Geert Uytterhoeven
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to='CAMuHMdXRVHiBZj=MQ3jLy2AEnwrvMXt6KXbZXr10ZJMhJDAmsw@mail.gmail.com' \ --to=geert@linux-m68k.org \ --cc=airlied@linux.ie \ --cc=daniel@ffwll.ch \ --cc=deller@gmx.de \ --cc=dri-devel@lists.freedesktop.org \ --cc=ldv-project@linuxtesting.org \ --cc=linux-kernel@vger.kernel.org \ --cc=maarten.lankhorst@linux.intel.com \ --cc=mripard@kernel.org \ --cc=strochuk@ispras.ru \ --cc=tzimmermann@suse.de \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.