dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Kees Cook <keescook@chromium.org>
To: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: linux-fbdev@vger.kernel.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org,
	Jiri Slaby <jslaby@suse.com>,
	syzbot <syzbot+017265e8553724e514e8@syzkaller.appspotmail.com>,
	Dmitry Vyukov <dvyukov@google.com>
Subject: Re: [PATCH v3] vt: Reject zero-sized screen buffer size.
Date: Wed, 19 Aug 2020 15:07:46 -0700	[thread overview]
Message-ID: <202008191452.0278B57D43@keescook> (raw)
In-Reply-To: <20200712111013.11881-1-penguin-kernel@I-love.SAKURA.ne.jp>

On Sun, Jul 12, 2020 at 08:10:12PM +0900, Tetsuo Handa wrote:
> [...]
> @@ -1125,6 +1134,11 @@ int vc_allocate(unsigned int currcons)	/* return 0 on success */
>  	if (!*vc->vc_uni_pagedir_loc)
>  		con_set_default_unimap(vc);
>  
> +	err = -EINVAL;
> +	if (vc->vc_cols > VC_MAXCOL || vc->vc_rows > VC_MAXROW ||
> +	    vc->vc_screenbuf_size > KMALLOC_MAX_SIZE || !vc->vc_screenbuf_size)
> +		goto err_free;
> +	err = -ENOMEM;
>  	vc->vc_screenbuf = kzalloc(vc->vc_screenbuf_size, GFP_KERNEL);
>  	if (!vc->vc_screenbuf)
>  		goto err_free;

I realize this patch already landed, but I wanted to remind folks to
use the check_*_overflow() helpers, which can make a lot of this kind
of stuff easier to deal with.

For example, in this case, I think visual_init() could likely be changed
to return success/failure and do all the sanity checking:

	if (check_shl_overflow(vc->vc_cols, 1, &vc->vc_size_row) ||
	    check_mul_overflow(vc->vc_rows, vc->vc_size_row, &vc->vc_screenbuf_size))
		return -EINVAL;


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

      parent reply	other threads:[~2020-08-19 22:07 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20200710055329.3759-1-penguin-kernel@I-love.SAKURA.ne.jp>
2020-07-10  5:56 ` fbconsole needs more parameter validations Tetsuo Handa
2020-07-10 10:56   ` Greg Kroah-Hartman
2020-07-11  6:16     ` Tetsuo Handa
2020-07-11 11:08       ` Tetsuo Handa
2020-07-12 11:10         ` [PATCH v3] vt: Reject zero-sized screen buffer size Tetsuo Handa
2020-07-12 11:10           ` [PATCH] fbdev: Detect integer underflow at "struct fbcon_ops"->clear_margins Tetsuo Handa
     [not found]             ` <CGME20200714072231eucas1p17c53f0a661346ebfd316ebd5796ca346@eucas1p1.samsung.com>
2020-07-14  7:22               ` Bartlomiej Zolnierkiewicz
2020-07-14 10:27                 ` Tetsuo Handa
2020-07-14 13:37                   ` Tetsuo Handa
2020-07-15  1:51                     ` [PATCH v2] " Tetsuo Handa
2020-07-15  9:48                       ` Dan Carpenter
2020-07-15 11:17                         ` Tetsuo Handa
2020-07-15 14:02                           ` Tetsuo Handa
2020-07-15 15:12                             ` Dan Carpenter
2020-07-15 15:29                               ` Tetsuo Handa
2020-07-16 10:00                                 ` Daniel Vetter
2020-07-16 11:27                                   ` Tetsuo Handa
2020-07-21 16:08                                     ` Greg Kroah-Hartman
2020-07-22  8:07                                       ` Daniel Vetter
2020-07-23 14:21                                         ` Greg Kroah-Hartman
2020-07-24  8:28                                           ` Bartlomiej Zolnierkiewicz
2020-07-14 17:15                   ` [PATCH] " George Kennedy
2020-07-15  0:24                     ` Tetsuo Handa
2020-08-19 22:07           ` Kees Cook [this message]

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=202008191452.0278B57D43@keescook \
    --to=keescook@chromium.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=dvyukov@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jslaby@suse.com \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=penguin-kernel@I-love.SAKURA.ne.jp \
    --cc=syzbot+017265e8553724e514e8@syzkaller.appspotmail.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 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).