All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Khalid Masum <khalid.masum.92@gmail.com>
Cc: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com,
	syzbot+14b0e8f3fd1612e35350@syzkaller.appspotmail.com,
	khalid.masum@aol.com
Subject: Re: [syzbot] KASAN: vmalloc-out-of-bounds Write in imageblit (2)
Date: Mon, 1 Aug 2022 13:43:43 +0300	[thread overview]
Message-ID: <20220801104343.GA3438@kadam> (raw)
In-Reply-To: <20220730081246.4567-1-khalid.masum.92@gmail.com>

On Sat, Jul 30, 2022 at 02:12:46PM +0600, Khalid Masum wrote:
> Currently the if block's condition has an unhandled case, where the
> result of ret might get greater than vc->vc_scr_end, and therefore
> the corresponding handler in else block never gets executed. Which
> eventually causes panic in fast_imageblit.
> 
> Add this extra check in the conditions to fix this breakage.
> 
> #syz-test: https://github.com/torvalds/linux.git e0dccc3b76fb 
> 
> ---
>  drivers/video/fbdev/core/fbcon.c | 13 ++++++-------
>  1 file changed, 6 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c
> index 1a9aa12cf886..d026f3845b60 100644
> --- a/drivers/video/fbdev/core/fbcon.c
> +++ b/drivers/video/fbdev/core/fbcon.c
> @@ -2591,14 +2591,13 @@ static unsigned long fbcon_getxy(struct vc_data *vc, unsigned long pos,
>  {
>  	unsigned long ret;
>  	int x, y;
> +	unsigned long offset = (pos - vc->vc_origin) / 2;
> +	x = offset % vc->vc_cols;
> +	y = offset / vc->vc_cols;
> +	ret = pos + (vc->vc_cols - x) * 2;
>  
> -	if (pos >= vc->vc_origin && pos < vc->vc_scr_end) {
> -		unsigned long offset = (pos - vc->vc_origin) / 2;
> -
> -		x = offset % vc->vc_cols;
> -		y = offset / vc->vc_cols;
> -		ret = pos + (vc->vc_cols - x) * 2;
> -	} else {
> +	if (!pos >= vc->vc_origin || !pos < vc->vc_scr_end ||
> +	                             !ret < vc->vc_scr_end) {


These are precendence bugs.  The ! will be done before the >=.  Write it
as:

	if (pos < vc->vc_origin || pos >= vc->vc_scr_end ||
	    ret >= vc->vc_scr_end) {


>  		/* Should not happen */
>  		x = y = 0;
>  		ret = vc->vc_origin;

regards,
dan carpenter


  parent reply	other threads:[~2022-08-01 10:44 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-19  9:18 [syzbot] KASAN: vmalloc-out-of-bounds Write in imageblit (2) syzbot
2022-01-20 22:58 ` syzbot
2022-01-21  1:48 ` syzbot
2022-07-29  6:51 ` Khalid Masum
2022-07-30 17:25   ` Helge Deller
2022-07-30 18:49     ` [PATCH] tty: vt: selection: Add check for valid tiocl_selection values Helge Deller
2022-08-04  5:47       ` Jiri Slaby
2022-08-04  7:15         ` Helge Deller
2022-08-04  8:44           ` Helge Deller
2022-08-04  9:22             ` Jiri Slaby
2022-08-05 11:13               ` Adam Borowski
2022-08-05 11:13                 ` Adam Borowski
2022-07-30 18:50     ` [PATCH] vt: Clear selection before changing the font Helge Deller
2022-07-31 11:32       ` Khalid Masum
2022-07-31 10:03     ` [syzbot] KASAN: vmalloc-out-of-bounds Write in imageblit (2) Khalid Masum
2022-07-31 10:54       ` Helge Deller
2022-07-31 10:54         ` Helge Deller
2022-07-31 11:23         ` Khalid Masum
2022-07-31 11:23           ` Khalid Masum
2022-07-31 13:55     ` Khalid Masum
2022-07-31 15:39       ` Helge Deller
2022-08-01  4:09         ` Khalid Masum
2022-07-30  8:12 ` Khalid Masum
2022-07-30 10:55   ` syzbot
2022-08-01 10:43   ` Dan Carpenter [this message]
2022-08-01 14:06     ` Khalid Masum
2022-07-30 11:45 ` Khalid Masum
2022-07-30 15:39   ` syzbot
2022-08-01 15:42 Khalid Masum
2022-08-01 15:53 ` syzbot

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=20220801104343.GA3438@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=khalid.masum.92@gmail.com \
    --cc=khalid.masum@aol.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=syzbot+14b0e8f3fd1612e35350@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.