All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Takashi Iwai <tiwai@suse.de>
Cc: alsa-devel@alsa-project.org, g@b4.vu, yuehaibing@huawei.com,
	andreyknvl@google.com, linux-usb@vger.kernel.org,
	syzkaller-bugs@googlegroups.com, linux-kernel@vger.kernel.org,
	rfontana@redhat.com, tiwai@suse.com,
	syzbot <syzbot+0620f79a1978b1133fd7@syzkaller.appspotmail.com>,
	benquike@gmail.com
Subject: Re: [alsa-devel] KASAN: slab-out-of-bounds Read in build_audio_procunit
Date: Mon, 28 Oct 2019 17:34:06 +0300	[thread overview]
Message-ID: <20191028143406.GE1922@kadam> (raw)
In-Reply-To: <s5hsgnkdbsl.wl-tiwai@suse.de>

I wish that this could have been detected with static analysis...

On Tue, Oct 22, 2019 at 05:45:14PM +0200, Takashi Iwai wrote:
> diff --git a/sound/usb/validate.c b/sound/usb/validate.c
> index 3c8f73a0eb12..a5e584b60dcd 100644
> --- a/sound/usb/validate.c
> +++ b/sound/usb/validate.c
> @@ -75,7 +75,7 @@ static bool validate_processing_unit(const void *p,
>  
>  	if (d->bLength < sizeof(*d))
            ^^^^^^^^^^^^^^^^^^^^^^^
So we know that d->bLength is >= 10.

>  		return false;
> -	len = d->bLength < sizeof(*d) + d->bNrInPins;
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Len is 1 or 0.

> +	len = sizeof(*d) + d->bNrInPins;
>  	if (d->bLength < len)
            ^^^^^^^^^^^^^^^^

So this condition can't be false.

>  		return false;

But it just makes this return into dead code and we have a lot of dead
code paths in the kernel so it doesn't make sense to generate a warning.
...  I don't know if I have a solution.

Maybe some day we will have a vim pluggin which will highlight all the
dead paths and someone would notice that it that way.

regards,
dan carpenter
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Takashi Iwai <tiwai@suse.de>
Cc: syzbot <syzbot+0620f79a1978b1133fd7@syzkaller.appspotmail.com>,
	alsa-devel@alsa-project.org, andreyknvl@google.com,
	benquike@gmail.com, g@b4.vu, linux-kernel@vger.kernel.org,
	linux-usb@vger.kernel.org, perex@perex.cz, rfontana@redhat.com,
	syzkaller-bugs@googlegroups.com, tiwai@suse.com,
	yuehaibing@huawei.com
Subject: Re: KASAN: slab-out-of-bounds Read in build_audio_procunit
Date: Mon, 28 Oct 2019 17:34:06 +0300	[thread overview]
Message-ID: <20191028143406.GE1922@kadam> (raw)
In-Reply-To: <s5hsgnkdbsl.wl-tiwai@suse.de>

I wish that this could have been detected with static analysis...

On Tue, Oct 22, 2019 at 05:45:14PM +0200, Takashi Iwai wrote:
> diff --git a/sound/usb/validate.c b/sound/usb/validate.c
> index 3c8f73a0eb12..a5e584b60dcd 100644
> --- a/sound/usb/validate.c
> +++ b/sound/usb/validate.c
> @@ -75,7 +75,7 @@ static bool validate_processing_unit(const void *p,
>  
>  	if (d->bLength < sizeof(*d))
            ^^^^^^^^^^^^^^^^^^^^^^^
So we know that d->bLength is >= 10.

>  		return false;
> -	len = d->bLength < sizeof(*d) + d->bNrInPins;
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Len is 1 or 0.

> +	len = sizeof(*d) + d->bNrInPins;
>  	if (d->bLength < len)
            ^^^^^^^^^^^^^^^^

So this condition can't be false.

>  		return false;

But it just makes this return into dead code and we have a lot of dead
code paths in the kernel so it doesn't make sense to generate a warning.
...  I don't know if I have a solution.

Maybe some day we will have a vim pluggin which will highlight all the
dead paths and someone would notice that it that way.

regards,
dan carpenter

  reply	other threads:[~2019-10-28 14:35 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-22 14:54 [alsa-devel] KASAN: slab-out-of-bounds Read in build_audio_procunit syzbot
2019-10-22 14:54 ` syzbot
2019-10-22 15:45 ` [alsa-devel] " Takashi Iwai
2019-10-22 15:45   ` Takashi Iwai
2019-10-28 14:34   ` Dan Carpenter [this message]
2019-10-28 14:34     ` Dan Carpenter
2019-10-28 14:42     ` [alsa-devel] " Takashi Iwai
2019-10-28 14:42       ` Takashi Iwai

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=20191028143406.GE1922@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=andreyknvl@google.com \
    --cc=benquike@gmail.com \
    --cc=g@b4.vu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=rfontana@redhat.com \
    --cc=syzbot+0620f79a1978b1133fd7@syzkaller.appspotmail.com \
    --cc=syzkaller-bugs@googlegroups.com \
    --cc=tiwai@suse.com \
    --cc=tiwai@suse.de \
    --cc=yuehaibing@huawei.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.