Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp618925pxj; Thu, 20 May 2021 18:05:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzb5MqnyoNKRBXS8KM0FcgeUZ6gVHyZiPvNbk1s8rJGRBHqiy0n2Ep9bA2V7f30bvkG/eg9 X-Received: by 2002:a17:906:24c7:: with SMTP id f7mr7180602ejb.511.1621559124219; Thu, 20 May 2021 18:05:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621559124; cv=none; d=google.com; s=arc-20160816; b=ugEydUyBgYrszl16aZb9ixWnDPlkkbiRqRs39VJGGiufjVqQS+/jPj72j8lEyG2oFO 9YuyyE+iagbGYwEgDE9YWF0SfhuRKWVzUn3UJPPIHfVXqVk/tbLZkV79KSuPYHywJU2o vcIcgCebvUfPP7tcVTREWrsYJm5jdI9gohpuIyCS2YHWjdjc5AS21wV0PqPNialToVLd WocrzJd3yOtELlg1qlcpo07YHod7Cl9uHkoh0HLlxwrmmkLCXh2TAMo9E7hljrS0GDpH +ql9MqlwngUJFTvPVNT438x4tHIo1hQL7Dft/fc7UIfyW9AMglSgOF0UzdIDOBbdMocD hGKA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=z3w5YXi7uXDfI08m61VnQ/l3No3VuI0e0gVJPDAgHyw=; b=IjQK0HZKZI9rOlD1wd1gicYjoxTg27daiMsv9nS/cMXhhgHcOQOk8Z0JFyY/Byo/Vk auNNimUrRdnVd8Z6RBfy1qJSOagB0vfENDjtbvqyS+pzgiucMgMPhiUcgoeRfUGBBNcK Gbk0uG7eeeF9yG7EjG2aXACXrQCRYdcqgBZfkEqbiRon3c1FpzpULKgXxxkwa0dF+pOn YHH3TX9vc59h8WiVS7549JkCsdnSDcDT7hUbSj/8aZXbJ3KO5AJcyi07wuWiM9k3+QjJ Z3eEzwVJMxPY4ZYA7/ncMNK2/1XUb47HdUM8K0G5LHfrfigJsZWdTvK72LNvqEdGejSv OTZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="gL4O2/fS"; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e6si4140125edz.503.2021.05.20.18.05.01; Thu, 20 May 2021 18:05:24 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b="gL4O2/fS"; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241465AbhETLgb (ORCPT + 99 others); Thu, 20 May 2021 07:36:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:39588 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240488AbhETLQe (ORCPT ); Thu, 20 May 2021 07:16:34 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6D0B761D69; Thu, 20 May 2021 10:09:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621505359; bh=c+BtpoNXJRkzS6snii+CAcxdQ6JuXuaTn74AuOTYr4Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gL4O2/fS0SuvGa2CQFDSKU8+imdDFzDw2lE+z2Oj1FdzY28Erv2LAXgtyxFpTDGEH ZyMkqm0cublOOxXCQ6EyimFwacpexf1bYYDGLr29ZnoNY8eG3uykq0aqKk2ByOwT71 XuJOmHSIIN6HpzR13EEfpIDDKa0Sr3Rj0jGyfGLg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Colin Ian King , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 4.4 099/190] media: m88rs6000t: avoid potential out-of-bounds reads on arrays Date: Thu, 20 May 2021 11:22:43 +0200 Message-Id: <20210520092105.473603236@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092102.149300807@linuxfoundation.org> References: <20210520092102.149300807@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Colin Ian King [ Upstream commit 9baa3d64e8e2373ddd11c346439e5dfccb2cbb0d ] There a 3 array for-loops that don't check the upper bounds of the index into arrays and this may lead to potential out-of-bounds reads. Fix this by adding array size upper bounds checks to be full safe. Addresses-Coverity: ("Out-of-bounds read") Link: https://lore.kernel.org/linux-media/20201007121628.20676-1-colin.king@canonical.com Fixes: 333829110f1d ("[media] m88rs6000t: add new dvb-s/s2 tuner for integrated chip M88RS6000") Signed-off-by: Colin Ian King Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/tuners/m88rs6000t.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/media/tuners/m88rs6000t.c b/drivers/media/tuners/m88rs6000t.c index 504bfbc4027a..f78caf3c2bbd 100644 --- a/drivers/media/tuners/m88rs6000t.c +++ b/drivers/media/tuners/m88rs6000t.c @@ -535,7 +535,7 @@ static int m88rs6000t_get_rf_strength(struct dvb_frontend *fe, u16 *strength) PGA2_cri = PGA2_GC >> 2; PGA2_crf = PGA2_GC & 0x03; - for (i = 0; i <= RF_GC; i++) + for (i = 0; i <= RF_GC && i < ARRAY_SIZE(RFGS); i++) RFG += RFGS[i]; if (RF_GC == 0) @@ -547,12 +547,12 @@ static int m88rs6000t_get_rf_strength(struct dvb_frontend *fe, u16 *strength) if (RF_GC == 3) RFG += 100; - for (i = 0; i <= IF_GC; i++) + for (i = 0; i <= IF_GC && i < ARRAY_SIZE(IFGS); i++) IFG += IFGS[i]; TIAG = TIA_GC * TIA_GS; - for (i = 0; i <= BB_GC; i++) + for (i = 0; i <= BB_GC && i < ARRAY_SIZE(BBGS); i++) BBG += BBGS[i]; PGA2G = PGA2_cri * PGA2_cri_GS + PGA2_crf * PGA2_crf_GS; -- 2.30.2