Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp341880pxj; Thu, 20 May 2021 10:32:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz1cprD2D9SkuduPzlFdbsk/nmpiuevEXFx0JsUjyLz45xFzajBaJZwsTkWIUHiOgOFoeWd X-Received: by 2002:a17:907:6288:: with SMTP id nd8mr5887120ejc.223.1621531942456; Thu, 20 May 2021 10:32:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621531942; cv=none; d=google.com; s=arc-20160816; b=wwginXpdH5LZGqt6N6PkR2Zbq+A3p6ItJAb38kjLcyHWxET40Z1nVZylkgDNSyJ4Hm DsMBe31s6JrgSC+yNbtbSxQ7MfGvARlvfywWQdfaTF2j/WfJ71WIHl9jWvoY2sY9ckP/ DH5UTwbQ78bWenEMUIqMJy84CjtRUsBH4C6VpAoGUuSIn+7TvW292Q858YHf+8XpOfqq InM5Qapt5+pD5w2as6abuovKGlJLCV/2rJbG5j7VoVzrVXhE0VK9atisnm7sB+5y2Kqe r7o2mudRvofbX7hr0ADP7Kwf6iQLlhoH0Do4MYrg52gj81vasVVxM0w0nDf3r9He54Jr yITA== 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=urU3NvNGUW+Hrkqey0ExxrcRG7asTBu834SapNSik6A=; b=BKd9pxMtugoAA0tRZ4VvDdDN1ctUXaeYCi4Oisracc3tE+1qVBupFh8bplrGkRQ+IO 7N7x+zv40RFGf90YbnxEnZU7AIHsUdaf0cvjoFf8DmlcX7A08I/5MBGm7DVUfAqVvku6 Jv4qnriUOzltqHvDMqSMHlNAe7VAtaXKomxpyRzyWenzz8QcSQCN34TgcmgxTFLQBdmp KXXe+Ok2ULLnwJ64hEIYnySijniaWG9RXE7yMlmzfpBaAIQaJbpgJDQ0/AtIJDaXgzcC FjX1CNYqIHLujgrJ9TJEmE77nlGl++p2oU8KoHeolMia8C4Zw1Q/33la3PtTo5gR2lmO wnog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hE6m2g1a; 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 z19si3177867edq.486.2021.05.20.10.31.58; Thu, 20 May 2021 10:32:22 -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=hE6m2g1a; 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 S234708AbhETKAl (ORCPT + 99 others); Thu, 20 May 2021 06:00:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:59182 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233578AbhETJz4 (ORCPT ); Thu, 20 May 2021 05:55:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 297F0613BB; Thu, 20 May 2021 09:37:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621503451; bh=w0Ulzhk12L4BP/+8j0NjuOGPa1a/ILJzQUAb301Qhf4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hE6m2g1aor5lAVHsBF6sQwfyAMuyERlin4yQ5Vm1I0HwhtlR4rGLTRi4tyQywYn7B j3RCQV20UoE4MQ9J793Y+6OBNOJv/szk/AJoZPdgJTvhuYHVg9FJs7Eq2r280yrwoI LmYkmIfJO4qsdMAs88/kZL2FMJ8BhSng2EyR5H/k= 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.19 228/425] media: m88rs6000t: avoid potential out-of-bounds reads on arrays Date: Thu, 20 May 2021 11:19:57 +0200 Message-Id: <20210520092138.929662152@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092131.308959589@linuxfoundation.org> References: <20210520092131.308959589@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 3df2f23a40be..3fe13de48777 100644 --- a/drivers/media/tuners/m88rs6000t.c +++ b/drivers/media/tuners/m88rs6000t.c @@ -534,7 +534,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) @@ -546,12 +546,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