lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230602085546.376086-1-d.dulov@aladdin.ru>
Date:   Fri, 2 Jun 2023 01:55:46 -0700
From:   Daniil Dulov <d.dulov@...ddin.ru>
To:     Zhang Rui <rui.zhang@...el.com>
CC:     Daniil Dulov <d.dulov@...ddin.ru>,
        Daniel Lezcano <daniel.lezcano@...aro.org>,
        Amit Kucheria <amitk@...nel.org>,
        "Rafael J. Wysocki" <rafael.j.wysocki@...el.com>,
        Srinivas Pandruvada <srinivas.pandruvada@...ux.intel.com>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Chen Yu <yu.c.chen@...el.com>, Sasha Levin <sashal@...nel.org>,
        Arjan van de Ven <arjan@...ux.intel.com>,
        Jacob Pan <jacob.jun.pan@...ux.intel.com>,
        <linux-pm@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
        <lvc-project@...uxtesting.org>
Subject: [PATCH] thermal: intel_powerclamp: Check for a possible array out of bounds access.

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 <d.dulov@...ddin.ru>
---
 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 +
-- 
2.25.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ