Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1001482ybi; Wed, 3 Jul 2019 07:54:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqwgO22iJCqbdoC5rGIqbuUSbCp9illZN2YGXwEhMfRIqawhvxZOrybG8ctRDW++7cirkBLw X-Received: by 2002:a63:ee0c:: with SMTP id e12mr14468357pgi.184.1562165689410; Wed, 03 Jul 2019 07:54:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562165689; cv=none; d=google.com; s=arc-20160816; b=ItLmxc9TGmq/xoyDyaMB4dKjHnKtVZlv+HJ9U9G456iHLXJVSOvbMcqt4MeLsP4QNb ciIzywQBvT8DolZJ33Q50uCsHQO6sZeU43jguxfBspD1S0+Ib+aBiRSdNRQ40i1vFWJd WHNwPuAND1vCLULMg7Si+hiSr3bca/Sc2lC6KWnKSHB5IMqU16cBLCqvsKkPXlghd2LA tf+QA7UypZin0V9eoAo7Ai1u4WqUYQq/+InDAjVKE59F2qD7QfUO8bXxfDxzdatGYb9a DgvU5aEB3XrTwYLA9RE8c/RcXShU8ULRq5Bc7aZ7WLJYaT4XhGnIiUCIGnzxxN00jFIV VzbA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=tHQnGbBpY9pdEMFwl5SGtw7h8GH4iqmU8JE1m/r3EcQ=; b=01xCfcOpOuqlSbh5KzW6G0G/Bh0PiVbRg0qX5qjpqjcXOfq3I2pkas/zVBkZgK6pcy 7NYyUzklFypG+pnfX1zeKDGgghENb18N1lN4vqaj2keZIfvKnGjYgKUr29SKPB1Kwl23 ObsLFALnewMKNxmHRs16AFWzs3xkWJfy5Tt+lXrTbbr6irHU+Qw7M1lmXwwkyueyH5Nu iF2UFFfs94B2U3R0YqA7JacyvHqOhVKXvjIar1aDPOlphbcgdx7IbXdi7A8bhEuhxLv1 NtlM2xoN/cSwgebr2ICa3roWOpz1w/Ee5E4yLNBSKldBkQAtfWTYyOml6B5uiL5wMk2G K22A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 77si2789157pge.315.2019.07.03.07.54.34; Wed, 03 Jul 2019 07:54:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726900AbfGCOwm (ORCPT + 99 others); Wed, 3 Jul 2019 10:52:42 -0400 Received: from gofer.mess.org ([88.97.38.141]:45647 "EHLO gofer.mess.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725933AbfGCOwm (ORCPT ); Wed, 3 Jul 2019 10:52:42 -0400 Received: by gofer.mess.org (Postfix, from userid 1000) id E1CEB60A67; Wed, 3 Jul 2019 15:52:39 +0100 (BST) Date: Wed, 3 Jul 2019 15:52:39 +0100 From: Sean Young To: syzbot Cc: andreyknvl@google.com, hans.verkuil@cisco.com, keescook@chromium.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org, linux-usb@vger.kernel.org, mchehab@kernel.org, syzkaller-bugs@googlegroups.com Subject: [PATCH] media: technisat-usb2: break out of loop at end of buffer Message-ID: <20190703145239.ridwf2jegipnoxfz@gofer.mess.org> References: <000000000000089d7f058683115e@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <000000000000089d7f058683115e@google.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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