Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp546047pxj; Thu, 20 May 2021 15:53:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx0ei7DGXV01U7PHkD+353qviicYWRvrxiuWdlRuWdcKnAw4uJtU457TJ/pjjWJSbZw2v88 X-Received: by 2002:a5d:87d0:: with SMTP id q16mr8479086ios.177.1621551189467; Thu, 20 May 2021 15:53:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621551189; cv=none; d=google.com; s=arc-20160816; b=jb7VUun0XKEGfBQHCCgBxVN+yDvEqJe+pK2M4RWga7F5HAXkD9UhMCjtsEKsgWCMVf r11nSejR9foOTy6UQC8i5XcvemOj+f7TapdB/MyNEAFymGUlfPKfWThWe64L1nwHW00o 5xPFYONSfe+NxZf/BLQDYgtuwkOZeQBJLXQj0D7uJ9IcUoCrRTj9uYORQBpPkxAoNGGv om2yskh0UNUMt1LkF583zugEfT8/KkMer7SIY/5l8hDq+TW23AJ1CIQDDY7y/ri0Y3t+ N1fV4+M+3+nB2dEwLS5TfifYTYN9uwCHyK2ciC1KLjm7l4QVmGe+K/ImoQ/ouuEl/62+ 6Mog== 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=cHcBdv9vDgilH+5pIH1c8eriv8nc69jtgksrfWTSMQ0=; b=DXo6Lf7kmnhfbcnkjRP3U/0bmp7jIowd+NGgfK7ETFyJvbjVTLrJ4Fn/mLMAbJh4Kc ILxpgrQ2VoJLSy7qegV0sdHhWCTx5PPooUKjcRbf2AbY6D0pNzDgCJra+c2VTwEK78LK 8JP+zm47MCvTt+uovW06/O11FtbK/rj9HrkkeLYRLEg5qOqy8cIR3ZD9gBHog7QptPkE xGtoa++WyQRlI4Rk3j/IhkGj45yZYUa38s1H7IZmguSjbhY57F1jNCRDTUTMoxY/fyUJ K182oq9+l3xAP/KD75Q8H89gtocVZ6hRk+lKKWnFebR9yZimhnCBQh6bN6fkmec/fsVN tRHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=b+vmHTwz; 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 w8si3591301jaw.8.2021.05.20.15.52.56; Thu, 20 May 2021 15:53:09 -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=b+vmHTwz; 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 S240045AbhETLPd (ORCPT + 99 others); Thu, 20 May 2021 07:15:33 -0400 Received: from mail.kernel.org ([198.145.29.99]:54442 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239386AbhETKyx (ORCPT ); Thu, 20 May 2021 06:54:53 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6C7DE61CE2; Thu, 20 May 2021 10:01:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621504881; bh=pUU7Sk1wS29Qif8RB2nCfqehjHYuPivh06PDo2M0P1E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b+vmHTwzSdp6IweFvoAkT6ijSA5/tPAZ9l0VKEBWQSPmJ9mMEDrd56rxx7hmN0RZd XKuzQgo4efjOGpRaGviZOI8qOHUN/zVtO5bXt9j6GVIlcT8/bQcnM/WJVsAU1NKKIF gTPg6rjaXEmTYzgF2pi8W4GoBc4HNKjlPE689+e8= 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.9 124/240] media: m88rs6000t: avoid potential out-of-bounds reads on arrays Date: Thu, 20 May 2021 11:21:56 +0200 Message-Id: <20210520092112.828024442@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092108.587553970@linuxfoundation.org> References: <20210520092108.587553970@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 9f3e0fd4cad9..d4443f9c9fa3 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