Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp441147pxb; Wed, 24 Feb 2021 06:22:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJzcDuIkhX+QjiKKnqVvVZT0CneVpgYxgFvRj/TrfPJYJJ5163H3DwQaKzOC+BLdWxAJrbOm X-Received: by 2002:a17:906:7485:: with SMTP id e5mr16054364ejl.86.1614176542250; Wed, 24 Feb 2021 06:22:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614176542; cv=none; d=google.com; s=arc-20160816; b=yF51M4CBaTVDb5qxZ1zHxVTsxcB9AKHjVfASDZnO+/TXp3F55HklXYyQ+c++f/ylJF sKe0bdGuBpiRNBrwq7A3AgY2hm2XkkQNvU0OsrkEqGDrm03Fs3O5nhhvTgUqhc0lkLIv gfdU0Sy6iASDZU47EsjnBRkJrECRfw53HSPD27PedCWU7Ub3D4AOKMiGuwrk9eg41amD kGdWU+iaJPkw2q615H/z0eRAA7AbTOzP93gH2CQpAnCmZe6lkfGCjlDJFRHiIxJiH4Qt lbJan1PQ8kLtLujsnouNimrS3mtlhdifbDtkQVBpB6srL69zxYvdaBc21MK4USQCPL3B ioHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=NUWGbY35LJaCeLue8F6DC6CU2G2Sx4PC4iJAFz4SBAQ=; b=p9F1dKhRLmOk3t9VwbADy1203pF18Bj77bRH12l8Y5lkEXroztKHisM7pUm6Vv7mOD 0RQQ1wpJ/GWURyJWT+JlIr11+CioucEfkiPT2zJaPYGvRhPd4iHMJK+L+1hW9vNL29KS clT6i4UqBY5DF4yhGdFnFJluQ+nB/h7/SJjMSNSYBMYWWSI4/DheEJS+K750pAxhtvqI JdnaZUHvEYyFxeDfnuGwFMA93ml+F9tnZqPc/canKd82krTYe6aMBEjZ9czSNBFFVOmp maMDEWjzC198Vcn0bOYZJdptv6Y3Fm7yTJSoOsIA3UuHUh2eaGGU85r1sklJOL6ZpnDj roEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Ptx2bI/l"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c24si1125557edt.244.2021.02.24.06.21.41; Wed, 24 Feb 2021 06:22:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Ptx2bI/l"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236288AbhBXOQG (ORCPT + 99 others); Wed, 24 Feb 2021 09:16:06 -0500 Received: from mail.kernel.org ([198.145.29.99]:59882 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235324AbhBXNLR (ORCPT ); Wed, 24 Feb 2021 08:11:17 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1CAE864FA0; Wed, 24 Feb 2021 12:55:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1614171327; bh=BMmT6/hWLV9+rdvo3ixw5fJP7Sbe3gl7300X0F+P8+A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ptx2bI/l9hBdnAq4SBx9ULPgbfcW2ByGDrSTQq0Hos6gI9m52ibZGRx8cC7VgUXpT PfmGWMIWTOoRxcnupDqXhq5xRL8p3OeGSwaTxwBqi9pWfZz+P+CVhu6LG2taKo/Gl4 FjfkfhoNu6zhOZ1OkaFncrF7dEvzFhPsHxG8me1k3nmA9+2bHW84c0RK0ZrzRsGNOt K3nxNXyXNI1770KupfqTG9WlNXpg04p0jCXLulLi0ZiSqhlLJUfHolmaX6jK6iNGg2 fUe+k2gj8ptURiDxhYCdSyRzL6i3hqRZ5IpKCM3U+UL5OOQ40Ew5+mz7McsIahlgbx CUOj1qxxm0yqg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Sean Young , syzbot+6d31bf169a8265204b8d@syzkaller.appspotmail.com, Mauro Carvalho Chehab , Sasha Levin , linux-media@vger.kernel.org Subject: [PATCH AUTOSEL 4.14 10/16] media: mceusb: sanity check for prescaler value Date: Wed, 24 Feb 2021 07:55:07 -0500 Message-Id: <20210224125514.483935-10-sashal@kernel.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210224125514.483935-1-sashal@kernel.org> References: <20210224125514.483935-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sean Young [ Upstream commit 9dec0f48a75e0dadca498002d25ef4e143e60194 ] prescaler larger than 8 would mean the carrier is at most 152Hz, which does not make sense for IR carriers. Reported-by: syzbot+6d31bf169a8265204b8d@syzkaller.appspotmail.com Signed-off-by: Sean Young Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/rc/mceusb.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/media/rc/mceusb.c b/drivers/media/rc/mceusb.c index bf7aaff3aa375..bbbbfd697f9c4 100644 --- a/drivers/media/rc/mceusb.c +++ b/drivers/media/rc/mceusb.c @@ -630,11 +630,18 @@ static void mceusb_dev_printdata(struct mceusb_dev *ir, u8 *buf, int buf_len, data[0], data[1]); break; case MCE_RSP_EQIRCFS: + if (!data[0] && !data[1]) { + dev_dbg(dev, "%s: no carrier", inout); + break; + } + // prescaler should make sense + if (data[0] > 8) + break; period = DIV_ROUND_CLOSEST((1U << data[0] * 2) * (data[1] + 1), 10); if (!period) break; - carrier = (1000 * 1000) / period; + carrier = USEC_PER_SEC / period; dev_dbg(dev, "%s carrier of %u Hz (period %uus)", inout, carrier, period); break; -- 2.27.0