From: Takashi Iwai <tiwai@suse.de>
To: Dan Carpenter <dan.carpenter@oracle.com>
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 15:42:44 +0100 [thread overview]
Message-ID: <s5hwocp9biz.wl-tiwai@suse.de> (raw)
In-Reply-To: <20191028143406.GE1922@kadam>
On Mon, 28 Oct 2019 15:34:06 +0100,
Dan Carpenter wrote:
>
> 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.
That'd be awesome :) Of even a simple checker code that can run in
the git commit hook should suffice for careless maintainers like me.
thanks,
Takashi
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
prev parent reply other threads:[~2019-10-28 14:43 UTC|newest]
Thread overview: 4+ 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 15:45 ` Takashi Iwai
2019-10-28 14:34 ` Dan Carpenter
2019-10-28 14:42 ` Takashi Iwai [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=s5hwocp9biz.wl-tiwai@suse.de \
--to=tiwai@suse.de \
--cc=alsa-devel@alsa-project.org \
--cc=andreyknvl@google.com \
--cc=benquike@gmail.com \
--cc=dan.carpenter@oracle.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=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox