Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp416615pxj; Thu, 20 May 2021 12:18:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyiYc7snmiZj/dBb7ap0URndw4avv99qDQ1wWxmE9xu+Cg2nHdaq0UjcmYEdjbFGe4rftgz X-Received: by 2002:a05:6402:2547:: with SMTP id l7mr6707229edb.73.1621538336033; Thu, 20 May 2021 12:18:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621538336; cv=none; d=google.com; s=arc-20160816; b=yEvjB3RDptBCspIuCsSt4qrUzX0l9EsG2kZ6wma6tnQ0iU/ybbr/qCtvVe+oNXTo7D qkF5Ch58f1nzz9ryB5ri+ibt9cWv+HOjkL6750vpCT4j5L5ldz2Us5By8QBGOncnh77q 8/pNOuGLYGvV/FQkJh0WrxAc4Dx6PeJNg3Ea++giY50EMgptUQ9baiq9BTpSBzge7qGj ojLq52BmMJ1BQEVmuU+IPr3ptK+tNXSwYnZ1asRz2jLRYYHpqzoW8tp+5vcrf084OwuY 9i/U8yKYZuw/zjTRZXBIpPH+nqpDujdewTpH+gTgufVNIBykolEzTcaRHP2sMDvuo0pM 4hEg== 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=BgzNJPBI9lkpIMkfEDWUBtwqrkpgsGK3dxqpL9rXnC4wMDQwIr/elUI+xZZatl32Jl x1TaNjrlWUAcRwHPQ4loeCSodIgUbA/Kp1yErj5oFP6VUwTa/5RggMCvxZy89jR7fHqW wxqG4euVW+5N/Q85GrE/lTjgeqbH2RRsU1JWF/habOk1sDPOC6bijS/7iEnHDxcCs6L5 Jf6PRYKip48ToT/cgg00bi/a8zH5NHHEA5/U2vlaugHkkvr7ne9xXtMOpiHEbtRev0HI +KdnqiG6DAA8Ar+Crcqqc/1k4Mszs7C4JnWhfsJgjEAjm8iqEwamw4o0XxrsKrb45mAW XqzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=NJz6rWQZ; 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 i27si3106246ejh.691.2021.05.20.12.18.31; Thu, 20 May 2021 12:18:56 -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=NJz6rWQZ; 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 S237534AbhETKqH (ORCPT + 99 others); Thu, 20 May 2021 06:46:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:60480 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237165AbhETK3l (ORCPT ); Thu, 20 May 2021 06:29:41 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 447DB611AD; Thu, 20 May 2021 09:51:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621504294; bh=pUU7Sk1wS29Qif8RB2nCfqehjHYuPivh06PDo2M0P1E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NJz6rWQZ90J9N6Vvu2T6eO3CEMxVupOLtVxTDpoyaf13Soaxq5U8Bm4FAk498z74C kuK2tqYN/EJLgVGOLrujXoZvkltyUhfuvRhj8//6Zp1TqqzMHF9f7XHMEzKziAjhi/ aI+dK/kkkjzhc7vU74GjC/Qoktc20I/Tr5kstxGg= 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.14 181/323] media: m88rs6000t: avoid potential out-of-bounds reads on arrays Date: Thu, 20 May 2021 11:21:13 +0200 Message-Id: <20210520092126.320126348@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092120.115153432@linuxfoundation.org> References: <20210520092120.115153432@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