Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4615751pxj; Wed, 12 May 2021 09:18:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwRDU8FjHNaqoF4epB3vJp+HhS2rB8sINzcPpf8Wwhlv7R81y1Tv0KQhc9TUnCH/4Asoknc X-Received: by 2002:a4a:db42:: with SMTP id 2mr17501567oot.47.1620836284971; Wed, 12 May 2021 09:18:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620836284; cv=none; d=google.com; s=arc-20160816; b=KgE9HwNpWZyXdN2a/82VpfxszgbKUpEebg6Y7IFCEWNB96qv/QMq6UzLUo44hvVv1P SuP7OmLXasvjAvzRHhiZAG7mj2gj20uWsx37bE9ZHYViiVA5OMCG16vyEBf1HIExu6q4 UQ8YD7fhxaHk/mtBhlxJKbYuvrHT2LaS+p1miMi8DF2ReuNa9cH4HFE6niuUnOb5Qmld BVRExdDYAzs1wiPL80Umtp7E0JMjxq5K1J/5yRW9se/4QQVqMYcaBGc9ZhgGkGQExWlg DAaQoYcxClkqZEWwloLJ+SrF03lhMOOMYX1lstJBw5nzBENQjN5efRs0mPvgQNVIMolc 2DmQ== 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=CABvx5sj2DRElTRRow3FsD18LtfrRGCWtOp0gaLHjr8=; b=J3//AHeT8iAHg95MPuJda0ftIZw8TlOoxGuCl+/Yv0Fm7SRXiakYr/q3E0QfpUzTqc jGRv5bEfUcKPUP0r91FOtPHDU09waeCjAUVkt7yfnfoRKFKy3eKDRevatbWHFT5WIDpJ hrWA0DRJF7WI0fW+dko+d/br1eXWoF5HNn3jdvbxB03wQW/JiCCwBoBzQWEZQwX3h+eT FknrXnZ9+NeAERT8s761O7m+BVAKB9WjraCrt6LlUEvHwQIZGPo8O9tF5rkNSV6NVMkl Of2B1sqSuzgOqwHQEoB/zTwngaLyYcMMjB4ZhTxPxFBNHWS8VuMRKYPdbvZ5DszpWL3z onDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=TNjVTotG; 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 v23si233749oth.205.2021.05.12.09.17.47; Wed, 12 May 2021 09:18:04 -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=TNjVTotG; 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 S231651AbhELQNk (ORCPT + 99 others); Wed, 12 May 2021 12:13:40 -0400 Received: from mail.kernel.org ([198.145.29.99]:48794 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233434AbhELPbF (ORCPT ); Wed, 12 May 2021 11:31:05 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8525461C34; Wed, 12 May 2021 15:16:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832562; bh=JrvIiW/qHHM9SLnA5IfAcParDd5L5y2qxO9yu/1Fw+c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TNjVTotGtU6/EBljG40vYSEIyhDtaD9QXaNoOBM2SHDFB157xGSHM/JhhoPXbbnuv PHDPgL8IklTey2s0VFg8J4e6LVXm9Y6W/0W89bQqoS+7jhYdJ1Ok5xnKqnYgKEgpLo Ttr0oaY2lv6ILLf5fC/XFW9kgyUdv0miSNZqO+xc= 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 5.10 297/530] media: m88rs6000t: avoid potential out-of-bounds reads on arrays Date: Wed, 12 May 2021 16:46:47 +0200 Message-Id: <20210512144829.566541348@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144819.664462530@linuxfoundation.org> References: <20210512144819.664462530@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 b3505f402476..8647c50b66e5 100644 --- a/drivers/media/tuners/m88rs6000t.c +++ b/drivers/media/tuners/m88rs6000t.c @@ -525,7 +525,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) @@ -537,12 +537,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