Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp5998797ybc; Wed, 27 Nov 2019 13:09:18 -0800 (PST) X-Google-Smtp-Source: APXvYqwemPIXJavc4E1lf3Tnt6CZZFSczo1ijdrCqqm6/gkpuXW/G7XA/fVOjUlgjWWWsG0cdHHW X-Received: by 2002:a17:906:bb03:: with SMTP id jz3mr28097251ejb.314.1574888958657; Wed, 27 Nov 2019 13:09:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574888958; cv=none; d=google.com; s=arc-20160816; b=t1W1jJAoojHaDtW95zNlFceMj8egpFlwki5sTlGTCUbL5iQF0RP6xZShhNjOJo7vzU /H/0q9fspTgVgcvvgnRSvq5za9ZWRwJPyIUjYazcV/5eBX6i+A3afpmvIzdFm97YqS08 Okxlpwb0mR8LBikuMfPXZulsQ0MOE7yjziMx1A/Ai3/NHlnm9WpII+gY52c2CtpJONAA Fq+JOjRRX5uCJ/BFIPcxaUdW2lKm9PsbqiMwkFMjIlzs6k3XmIJ/kx8qCaxKwiwwQPjh 3M48+qkJERj1xvqyVgYAeBFoHG1Of5+2xPDhY7QrJfB4x34VPe3DJeeLWYcXy5XSdobT XV1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=1uJIBqATT/l1+lFepmfHy7f65M7JOpVPxuDb5Fi0olo=; b=jMTld3S3v4MCGWD0FO7BWtdTOuc/FplEcePpZugf5521KfjrgqIDjZFn6mj8fO3F0U Sy5qiRyKg6OrL6WdZafdAWAgkRbh3PC8Gd1Y0o/Vn+XjY1mni4MhjTzSG7dPYrppAXXq ZVAua8ZoC0Pze85ZH0rzhi/eEdbay+FTU8/yRc5ycohWGq0NtzUzGbkghWYZxgSQaM2U 3h7S7iBZCtO/MTiMtv6cWJW+eD8X8LdGmd3Q4/b4pXJnGbpJ7xwPRxf0MvZOetacJ67n L80VRMLzNHcEfanJOuCS9kaZCef7CSvJzelCVywfGrzJwUpaLLU4kOnaSlyD2DoyW1gt Dh3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dzq8eaHV; 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 m4si9987528eja.96.2019.11.27.13.08.54; Wed, 27 Nov 2019 13:09:18 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=dzq8eaHV; 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 S1732581AbfK0VHS (ORCPT + 99 others); Wed, 27 Nov 2019 16:07:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:33346 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727368AbfK0VHP (ORCPT ); Wed, 27 Nov 2019 16:07:15 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 823A621774; Wed, 27 Nov 2019 21:07:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574888835; bh=47xrggTDc31v9aM/kKfdw7K7UZsoaHm8dxCXJkJa4LU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dzq8eaHVv99gfgT/eiAwvcFUNudPxoTnHn1ZqAV43RWC6VQGOaQ5LkaBI0pY/BwlG qO3TtGTBaNQx3xaszXaa2E72E/WSEcRGuiXSmcymOD+HBIieJt0bPA1IPJywcsCpxG 8RL4QjsLC2WScueTT4GjAJGfbUfeCCk4bQwjJiIc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Vito Caputo , syzbot , Sean Young , Mauro Carvalho Chehab Subject: [PATCH 4.19 289/306] media: cxusb: detect cxusb_ctrl_msg error in query Date: Wed, 27 Nov 2019 21:32:19 +0100 Message-Id: <20191127203135.881662548@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127203114.766709977@linuxfoundation.org> References: <20191127203114.766709977@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Vito Caputo commit ca8f245f284eeffa56f3b7a5eb6fc503159ee028 upstream. Don't use uninitialized ircode[] in cxusb_rc_query() when cxusb_ctrl_msg() fails to populate its contents. syzbot reported: dvb-usb: bulk message failed: -22 (1/-30591) ===================================================== BUG: KMSAN: uninit-value in ir_lookup_by_scancode drivers/media/rc/rc-main.c:494 [inline] BUG: KMSAN: uninit-value in rc_g_keycode_from_table drivers/media/rc/rc-main.c:582 [inline] BUG: KMSAN: uninit-value in rc_keydown+0x1a6/0x6f0 drivers/media/rc/rc-main.c:816 CPU: 1 PID: 11436 Comm: kworker/1:2 Not tainted 5.3.0-rc7+ #0 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 Workqueue: events dvb_usb_read_remote_control Call Trace: __dump_stack lib/dump_stack.c:77 [inline] dump_stack+0x191/0x1f0 lib/dump_stack.c:113 kmsan_report+0x13a/0x2b0 mm/kmsan/kmsan_report.c:108 __msan_warning+0x73/0xe0 mm/kmsan/kmsan_instr.c:250 bsearch+0x1dd/0x250 lib/bsearch.c:41 ir_lookup_by_scancode drivers/media/rc/rc-main.c:494 [inline] rc_g_keycode_from_table drivers/media/rc/rc-main.c:582 [inline] rc_keydown+0x1a6/0x6f0 drivers/media/rc/rc-main.c:816 cxusb_rc_query+0x2e1/0x360 drivers/media/usb/dvb-usb/cxusb.c:548 dvb_usb_read_remote_control+0xf9/0x290 drivers/media/usb/dvb-usb/dvb-usb-remote.c:261 process_one_work+0x1572/0x1ef0 kernel/workqueue.c:2269 worker_thread+0x111b/0x2460 kernel/workqueue.c:2415 kthread+0x4b5/0x4f0 kernel/kthread.c:256 ret_from_fork+0x35/0x40 arch/x86/entry/entry_64.S:355 Uninit was stored to memory at: kmsan_save_stack_with_flags mm/kmsan/kmsan.c:150 [inline] kmsan_internal_chain_origin+0xd2/0x170 mm/kmsan/kmsan.c:314 __msan_chain_origin+0x6b/0xe0 mm/kmsan/kmsan_instr.c:184 rc_g_keycode_from_table drivers/media/rc/rc-main.c:583 [inline] rc_keydown+0x2c4/0x6f0 drivers/media/rc/rc-main.c:816 cxusb_rc_query+0x2e1/0x360 drivers/media/usb/dvb-usb/cxusb.c:548 dvb_usb_read_remote_control+0xf9/0x290 drivers/media/usb/dvb-usb/dvb-usb-remote.c:261 process_one_work+0x1572/0x1ef0 kernel/workqueue.c:2269 worker_thread+0x111b/0x2460 kernel/workqueue.c:2415 kthread+0x4b5/0x4f0 kernel/kthread.c:256 ret_from_fork+0x35/0x40 arch/x86/entry/entry_64.S:355 Local variable description: ----ircode@cxusb_rc_query Variable was created at: cxusb_rc_query+0x4d/0x360 drivers/media/usb/dvb-usb/cxusb.c:543 dvb_usb_read_remote_control+0xf9/0x290 drivers/media/usb/dvb-usb/dvb-usb-remote.c:261 Signed-off-by: Vito Caputo Reported-by: syzbot Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- drivers/media/usb/dvb-usb/cxusb.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/media/usb/dvb-usb/cxusb.c +++ b/drivers/media/usb/dvb-usb/cxusb.c @@ -457,7 +457,8 @@ static int cxusb_rc_query(struct dvb_usb { u8 ircode[4]; - cxusb_ctrl_msg(d, CMD_GET_IR_CODE, NULL, 0, ircode, 4); + if (cxusb_ctrl_msg(d, CMD_GET_IR_CODE, NULL, 0, ircode, 4) < 0) + return 0; if (ircode[2] || ircode[3]) rc_keydown(d->rc_dev, RC_PROTO_NEC,