Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp4643663rwd; Sun, 4 Jun 2023 09:28:38 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ40PZOfcgWzAexcetAF6ro+0hewOgF6lM/Jma41MDNw3SNNzCK89EmfjUP4ivKEmqP/hu5A X-Received: by 2002:a05:6a20:4308:b0:106:999f:64df with SMTP id h8-20020a056a20430800b00106999f64dfmr5182869pzk.58.1685896118320; Sun, 04 Jun 2023 09:28:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685896118; cv=none; d=google.com; s=arc-20160816; b=aEcJ7nzz+RDCHVFaN7d4+Doc0sATkClr/U0c13ClUYVM3xtEpwfYFDB/6l+TsOTy6+ oMxSVyH9KEGmf7pTk0grRMoYC/iaQwiKUxmdf2QZa6ZSsgteUszacmznb3q7h8RqBgZB FQkf/iafy+9qLHczxnuxG4IIxnqRTlihtbhwT7iJwqRzLv13qCuKkaaY85MyFoJRlCHr TNFwIBkh8NUZgKczCMVUmoH/XPhrFM3GzKylvPeuVZknOs8P2Fi0yhO3wlj2lwr59tuz BxTsT44XCGTvwpyIQ5nm/6zAuO7c0UfCnDJUfDubWqVaFeKODTPy9G4vb9BHM9nRgw6t DbZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version; bh=ZV4XWYK56iF7sVBm/3GDNY8p+n6Ip3QlgLY9zzAp76k=; b=FfstPEB5eiP2ludN1JdW0EHpNNsyvGImTW++Fb3/HsnZYKKdQE+WjQGxtsslnk2897 ULC67iAaqX+zvgeGnCyJmG2MJZPsqlwKc/IKzOjaor5ccd+/8KkV0ms65+v3VPGTHwao c7W2vQUA+DEw5vLVJuE98LSpCP02OvPYIJrNkklyo4qXTdxq5rqMzK7coiuXzSgQ/aqj WFIoGE4+xx8qWj2mIeJOOeb2FLG6qz7fNjUlfmBaeoRm4qsBT6qkoEfZiuu7V936RcN0 Qawf+Hy5UoJxLm6rYtsynp+PkFeSnVeQxmH6XKZWRaGhHwZkPpSeUn9pjgXfSd8diIkD HqDw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s132-20020a632c8a000000b00543a6ce8c33si832703pgs.78.2023.06.04.09.28.24; Sun, 04 Jun 2023 09:28:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231809AbjFDQNp convert rfc822-to-8bit (ORCPT + 99 others); Sun, 4 Jun 2023 12:13:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229449AbjFDQNo (ORCPT ); Sun, 4 Jun 2023 12:13:44 -0400 Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56508B3; Sun, 4 Jun 2023 09:13:43 -0700 (PDT) Received: by mail-ej1-f41.google.com with SMTP id a640c23a62f3a-96fc07d7e6bso81201166b.1; Sun, 04 Jun 2023 09:13:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685895222; x=1688487222; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RB2Pk7LaCOIDMRL6UqKdMxKSwM8bP2MfrOVz+JJM6Wk=; b=RZBNKkCCsupRLCUuLxhby92kIXSoEQbuFGwT8Iz9bWnWGHE2ZIvSUSnSfW3Z5DWZZr BWw30p4AESPFuQ+Ub+B86eWGANEIRsguArhKBL5QmmxrcvYSKG6GT1v80WKa03opZ9xU zEG8M9ywifTofTHnOjgeEYSoqLSVNMk27VOWn+mdkFiimpBUGGMcl3rDQzZrN+zavFQ0 ywaKYpxN8N4CeUM9iErrU89/M/dlo1igT3HTAs3GCfUk2+n58Qt+FKDUZoQ67iYxB663 n9ZFzctTmrcEQH8yG8ffTxlcVUl4mZaMPu2Jc1QyJw8QKic4Ay3gqxB/KHHhMT6rqxmS qNnQ== X-Gm-Message-State: AC+VfDyZhyNMXsfxiSBNyYEVh/n73+kyRTqGnm6VdKZVLyYg/KIZT6Pp KuEvxD8w6AxntKsk4uFzRCSGtuFIRTMPztMXgoI= X-Received: by 2002:a17:906:73cc:b0:929:b101:937d with SMTP id n12-20020a17090673cc00b00929b101937dmr10488832ejl.1.1685895221737; Sun, 04 Jun 2023 09:13:41 -0700 (PDT) MIME-Version: 1.0 References: <20230602085546.376086-1-d.dulov@aladdin.ru> In-Reply-To: <20230602085546.376086-1-d.dulov@aladdin.ru> From: "Rafael J. Wysocki" Date: Sun, 4 Jun 2023 18:13:30 +0200 Message-ID: Subject: Re: [PATCH] thermal: intel_powerclamp: Check for a possible array out of bounds access. To: Daniil Dulov , Zhang Rui , Srinivas Pandruvada Cc: Daniel Lezcano , Amit Kucheria , Chen Yu , Jacob Pan , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Cc list trimmed. On Fri, Jun 2, 2023 at 11:12 AM Daniil Dulov wrote: > > ratio may be equal to MAX_TARGET_RATIO - 1 that will result in > out of bound access. > > Found by Linux Verification Center (linuxtesting.org) with SVACE. > > Fixes: d6d71ee4a14a ("PM: Introduce Intel PowerClamp Driver") > Signed-off-by: Daniil Dulov > --- > drivers/thermal/intel/intel_powerclamp.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/thermal/intel/intel_powerclamp.c b/drivers/thermal/intel/intel_powerclamp.c > index fb04470d7d4b..9deaf2b8ccf6 100644 > --- a/drivers/thermal/intel/intel_powerclamp.c > +++ b/drivers/thermal/intel/intel_powerclamp.c > @@ -277,7 +277,8 @@ static unsigned int get_compensation(int ratio) > comp = (cal_data[ratio].steady_comp + > cal_data[ratio - 1].steady_comp + > cal_data[ratio - 2].steady_comp) / 3; > - } else if (cal_data[ratio].confidence >= CONFIDENCE_OK && > + } else if (ratio < MAX_TARGET_RATIO - 1 && > + cal_data[ratio].confidence >= CONFIDENCE_OK && > cal_data[ratio - 1].confidence >= CONFIDENCE_OK && > cal_data[ratio + 1].confidence >= CONFIDENCE_OK) { > comp = (cal_data[ratio].steady_comp + > -- Rui, Srinivas, can you have a look at this, please?