All of lore.kernel.org
 help / color / mirror / Atom feed
From: Geert Uytterhoeven <geert@linux-m68k.org>
To: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>
Cc: Dan Carpenter <dan.carpenter@oracle.com>,
	Randy Dunlap <rdunlap@infradead.org>,
	syzbot <syzbot+04168c8063cfdde1db5e@syzkaller.appspotmail.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
	Colin King <colin.king@canonical.com>,
	DRI Development <dri-devel@lists.freedesktop.org>,
	Linux Fbdev development list <linux-fbdev@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Masahiro Yamada <masahiroy@kernel.org>,
	syzkaller-bugs@googlegroups.com
Subject: Re: [syzbot] BUG: unable to handle kernel paging request in vga16fb_fillrect
Date: Mon, 30 Aug 2021 16:30:36 +0200	[thread overview]
Message-ID: <CAMuHMdXp7D02Z_Hs4wT9y4WeNzqdxHMgExiOzVauvpfgf4Veig@mail.gmail.com> (raw)
In-Reply-To: <03d0f549-9731-8b06-1393-60d4bef27884@i-love.sakura.ne.jp>

Hi Tetsuo,

On Mon, Aug 30, 2021 at 4:26 PM Tetsuo Handa
<penguin-kernel@i-love.sakura.ne.jp> wrote:
> On 2021/08/30 22:47, Dan Carpenter wrote:
> > On Mon, Aug 30, 2021 at 10:37:31PM +0900, Tetsuo Handa wrote:
> >> On 2021/08/30 22:00, Dan Carpenter wrote:
> >>>>> diff --git a/drivers/video/fbdev/vga16fb.c b/drivers/video/fbdev/vga16fb.c
> >>>>> index e2757ff1c23d..e483a3f5fd47 100644
> >>>>> --- a/drivers/video/fbdev/vga16fb.c
> >>>>> +++ b/drivers/video/fbdev/vga16fb.c
> >>>>> @@ -403,7 +403,7 @@ static int vga16fb_check_var(struct fb_var_screeninfo *var,
> >>>>>
> >>>>>         if (yres > vyres)
> >>>>>                 vyres = yres;
> >>>>> -       if (vxres * vyres > maxmem) {
> >>>>> +       if ((u64) vxres * vyres > (u64) maxmem) {
> >>>>
> >>>> Mindlessly changing the sizes is not the solution.
> >>>> Please use e.g. the array_size() helper from <linux/overflow.h>
> >>>> instead.
> >>>
> >>> On a 64bit system the array_size() macro is going to do the exact same
> >>> casts?  But I do think this code would be easier to understand if the
> >>> integer overflow check were pull out separately and done first:
> >>>
> >>>     if (array_size(vxres, vyres) >= UINT_MAX)
> >>>             return -EINVAL;
> >>
> >> This is wrong. array_size() returns ULONG_MAX on 64bits upon overflow and
> >> returns UINT_MAX on 32bits upon overflow. However, UINT_MAX is a valid
> >> value without overflow (e.g. vxres == UINT_MAX / 15 && vyres == 15).
> >
> > Huh...  I just assumed we didn't allow resolutions that high.
>
> Of course, we don't allow resolutions that high. ;-)
>
> Since I don't know possible max resolutions, I chose UINT_MAX + 1 as a common
> limit for returning -EINVAL. Unless overflow happens, vga16fb_check_var() will
> return -ENOMEM on such high resolutions.

The highest possible value of maxmem inside vga16fb_check_var()
is 65536.

So I believe

    if (array_size(vxres, vyres) > maxmem)

should work fine.

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

  parent reply	other threads:[~2021-08-30 14:30 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-14  5:16 [syzbot] BUG: unable to handle kernel paging request in vga16fb_fillrect syzbot
2021-07-14  5:16 ` syzbot
2021-08-30  0:24 ` Randy Dunlap
2021-08-30  2:27   ` Tetsuo Handa
2021-08-30  2:31     ` Randy Dunlap
2021-08-30 16:05       ` [PATCH] fbmem: don't allow too huge resolutions Tetsuo Handa
2021-08-31  6:48         ` Geert Uytterhoeven
2021-08-31  6:48           ` Geert Uytterhoeven
2021-08-31 15:23           ` Tetsuo Handa
2021-08-31 16:20             ` Daniel Vetter
2021-08-31 16:20               ` Daniel Vetter
2021-08-31 17:19             ` Geert Uytterhoeven
2021-08-31 17:19               ` Geert Uytterhoeven
2021-08-31 18:53               ` Daniel Vetter
2021-08-31 18:53                 ` Daniel Vetter
2021-08-31 18:56                 ` Geert Uytterhoeven
2021-08-31 18:56                   ` Geert Uytterhoeven
2021-08-31 19:04                   ` Daniel Vetter
2021-08-31 19:04                     ` Daniel Vetter
2021-09-01  1:14                     ` [PATCH v2] " Tetsuo Handa
2021-09-01  7:12                       ` Geert Uytterhoeven
2021-09-01  7:12                         ` Geert Uytterhoeven
2021-09-08 10:27                       ` [PATCH v2 (repost)] " Tetsuo Handa
2021-09-08 16:52                         ` Daniel Vetter
2021-08-30 12:00     ` [syzbot] BUG: unable to handle kernel paging request in vga16fb_fillrect Geert Uytterhoeven
2021-08-30 12:00       ` Geert Uytterhoeven
2021-08-30 13:00       ` Dan Carpenter
2021-08-30 13:37         ` Tetsuo Handa
2021-08-30 13:47           ` Dan Carpenter
2021-08-30 14:25             ` Tetsuo Handa
2021-08-30 14:29               ` Dan Carpenter
2021-08-30 14:30               ` Geert Uytterhoeven [this message]
2021-08-30 14:30                 ` Geert Uytterhoeven
2021-08-30 14:38                 ` Tetsuo Handa
2021-08-30 14:53                   ` Geert Uytterhoeven
2021-08-30 14:53                     ` Geert Uytterhoeven
2021-08-30 15:00                     ` Geert Uytterhoeven
2021-08-30 15:00                       ` 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=CAMuHMdXp7D02Z_Hs4wT9y4WeNzqdxHMgExiOzVauvpfgf4Veig@mail.gmail.com \
    --to=geert@linux-m68k.org \
    --cc=akpm@linux-foundation.org \
    --cc=b.zolnierkie@samsung.com \
    --cc=colin.king@canonical.com \
    --cc=dan.carpenter@oracle.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=masahiroy@kernel.org \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    --cc=rdunlap@infradead.org \
    --cc=syzbot+04168c8063cfdde1db5e@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    /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: link
Be 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.