From: Kees Cook <keescook@chromium.org>
To: Sean Young <sean@mess.org>
Cc: syzbot <syzbot+eaaaf38a95427be88f4b@syzkaller.appspotmail.com>,
andreyknvl@google.com, hans.verkuil@cisco.com,
linux-kernel@vger.kernel.org, linux-media@vger.kernel.org,
linux-usb@vger.kernel.org, mchehab@kernel.org,
syzkaller-bugs@googlegroups.com,
Phong Tran <tranmanphong@gmail.com>
Subject: Re: [PATCH] media: technisat-usb2: break out of loop at end of buffer
Date: Wed, 3 Jul 2019 09:54:53 -0700 [thread overview]
Message-ID: <201907030953.BD9D84DF0@keescook> (raw)
In-Reply-To: <20190703145239.ridwf2jegipnoxfz@gofer.mess.org>
On Wed, Jul 03, 2019 at 03:52:39PM +0100, Sean Young wrote:
> Ensure we do not access the buffer beyond the end if no 0xff byte
> is encountered.
>
> Reported-by: syzbot+eaaaf38a95427be88f4b@syzkaller.appspotmail.com
> Signed-off-by: Sean Young <sean@mess.org>
Both you and Phong Tran appear to be working on fixing this. At a
glance, this patch appears to be more complete in that it makes the code
flow more sane too.
Reviewed-by: Kees Cook <keescook@chromium.org>
-Kees
> ---
> drivers/media/usb/dvb-usb/technisat-usb2.c | 22 ++++++++++------------
> 1 file changed, 10 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/media/usb/dvb-usb/technisat-usb2.c b/drivers/media/usb/dvb-usb/technisat-usb2.c
> index c659e18b358b..676d233d46d5 100644
> --- a/drivers/media/usb/dvb-usb/technisat-usb2.c
> +++ b/drivers/media/usb/dvb-usb/technisat-usb2.c
> @@ -608,10 +608,9 @@ static int technisat_usb2_frontend_attach(struct dvb_usb_adapter *a)
> static int technisat_usb2_get_ir(struct dvb_usb_device *d)
> {
> struct technisat_usb2_state *state = d->priv;
> - u8 *buf = state->buf;
> - u8 *b;
> - int ret;
> struct ir_raw_event ev;
> + u8 *buf = state->buf;
> + int i, ret;
>
> buf[0] = GET_IR_DATA_VENDOR_REQUEST;
> buf[1] = 0x08;
> @@ -647,26 +646,25 @@ static int technisat_usb2_get_ir(struct dvb_usb_device *d)
> return 0; /* no key pressed */
>
> /* decoding */
> - b = buf+1;
>
> #if 0
> deb_rc("RC: %d ", ret);
> - debug_dump(b, ret, deb_rc);
> + debug_dump(buf + 1, ret, deb_rc);
> #endif
>
> ev.pulse = 0;
> - while (1) {
> - ev.pulse = !ev.pulse;
> - ev.duration = (*b * FIRMWARE_CLOCK_DIVISOR * FIRMWARE_CLOCK_TICK) / 1000;
> - ir_raw_event_store(d->rc_dev, &ev);
> -
> - b++;
> - if (*b == 0xff) {
> + for (i = 1; i < ARRAY_SIZE(state->buf); i++) {
> + if (buf[i] == 0xff) {
> ev.pulse = 0;
> ev.duration = 888888*2;
> ir_raw_event_store(d->rc_dev, &ev);
> break;
> }
> +
> + ev.pulse = !ev.pulse;
> + ev.duration = (buf[i] * FIRMWARE_CLOCK_DIVISOR *
> + FIRMWARE_CLOCK_TICK) / 1000;
> + ir_raw_event_store(d->rc_dev, &ev);
> }
>
> ir_raw_event_handle(d->rc_dev);
> --
> 2.21.0
>
--
Kees Cook
prev parent reply other threads:[~2019-07-03 16:55 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-14 20:06 KASAN: slab-out-of-bounds Read in technisat_usb2_rc_query syzbot
2019-07-02 14:02 ` [PATCH] media: usb: technisat-usb2: fix buffer overflow Phong Tran
2019-07-02 14:23 ` Alexander Potapenko
2019-07-02 16:03 ` Kees Cook
2019-07-03 2:14 ` [PATCH V2] " Phong Tran
2019-07-03 2:26 ` Kees Cook
2019-07-03 14:52 ` [PATCH] media: technisat-usb2: break out of loop at end of buffer Sean Young
2019-07-03 16:54 ` 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=201907030953.BD9D84DF0@keescook \
--to=keescook@chromium.org \
--cc=andreyknvl@google.com \
--cc=hans.verkuil@cisco.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=sean@mess.org \
--cc=syzbot+eaaaf38a95427be88f4b@syzkaller.appspotmail.com \
--cc=syzkaller-bugs@googlegroups.com \
--cc=tranmanphong@gmail.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).