From da304d099acc916143ded24f19231226e8921f77 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Sat, 12 Dec 2020 06:12:14 +0000 Subject: [PATCH] import thermald-2.4.1-2.el8 --- ...001-adaptive-Fix-missing-initializer.patch | 26 ++++++++++++++++ .../0002-adaptive-Fix-use-after-free.patch | 31 +++++++++++++++++++ ...3-adaptive-Remove-useless-NULL-check.patch | 27 ++++++++++++++++ SPECS/thermald.spec | 12 ++++++- 4 files changed, 95 insertions(+), 1 deletion(-) create mode 100644 SOURCES/0001-adaptive-Fix-missing-initializer.patch create mode 100644 SOURCES/0002-adaptive-Fix-use-after-free.patch create mode 100644 SOURCES/0003-adaptive-Remove-useless-NULL-check.patch diff --git a/SOURCES/0001-adaptive-Fix-missing-initializer.patch b/SOURCES/0001-adaptive-Fix-missing-initializer.patch new file mode 100644 index 0000000..457332f --- /dev/null +++ b/SOURCES/0001-adaptive-Fix-missing-initializer.patch @@ -0,0 +1,26 @@ +From d51e3d5f78ac0d90d3bf247f1fb61a53fa3b5a71 Mon Sep 17 00:00:00 2001 +From: Benjamin Berg +Date: Thu, 10 Dec 2020 11:35:46 +0100 +Subject: [PATCH 1/3] adaptive: Fix missing initializer + +The limit_1_valid attribute was not initialized to zero. +--- + src/thd_engine_adaptive.cpp | 2 ++ + 1 file changed, 2 insertions(+) + +diff --git a/src/thd_engine_adaptive.cpp b/src/thd_engine_adaptive.cpp +index d84f1ca..4824a9d 100644 +--- a/src/thd_engine_adaptive.cpp ++++ b/src/thd_engine_adaptive.cpp +@@ -497,6 +497,8 @@ int cthd_engine_adaptive::parse_ppcc(char *name, char *buf, int len) { + if (ppcc.power_limit_1_max && ppcc.power_limit_1_min && ppcc.time_wind_1_min + && ppcc.time_wind_1_max && ppcc.step_1_size) + ppcc.limit_1_valid = 1; ++ else ++ ppcc.limit_1_valid = 0; + + ppccs.push_back(ppcc); + +-- +2.26.2 + diff --git a/SOURCES/0002-adaptive-Fix-use-after-free.patch b/SOURCES/0002-adaptive-Fix-use-after-free.patch new file mode 100644 index 0000000..d76138d --- /dev/null +++ b/SOURCES/0002-adaptive-Fix-use-after-free.patch @@ -0,0 +1,31 @@ +From a10d4ddeb8b55e238289d63a2623b8936eb6bda4 Mon Sep 17 00:00:00 2001 +From: Benjamin Berg +Date: Thu, 10 Dec 2020 11:36:43 +0100 +Subject: [PATCH 2/3] adaptive: Fix use-after-free + +The debug logging would access a recently free'ed variable. Fix this by +changing the order. +--- + src/thd_engine_adaptive.cpp | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/src/thd_engine_adaptive.cpp b/src/thd_engine_adaptive.cpp +index 4824a9d..b68cc40 100644 +--- a/src/thd_engine_adaptive.cpp ++++ b/src/thd_engine_adaptive.cpp +@@ -692,10 +692,11 @@ int cthd_engine_adaptive::parse_gddv_key(char *buf, int size, int *end_offset) { + + str = strtok(key, "/"); + if (!str) { ++ thd_log_debug("Ignoring key %s\n", key); ++ + delete[] (key); + delete[] (val); + +- thd_log_debug("Ignoring key %s\n", key); + /* Ignore */ + return THD_SUCCESS; + } +-- +2.26.2 + diff --git a/SOURCES/0003-adaptive-Remove-useless-NULL-check.patch b/SOURCES/0003-adaptive-Remove-useless-NULL-check.patch new file mode 100644 index 0000000..f186db9 --- /dev/null +++ b/SOURCES/0003-adaptive-Remove-useless-NULL-check.patch @@ -0,0 +1,27 @@ +From 268349088e0931421da65f4dce6997f197a10b12 Mon Sep 17 00:00:00 2001 +From: Benjamin Berg +Date: Thu, 10 Dec 2020 11:37:27 +0100 +Subject: [PATCH 3/3] adaptive: Remove useless NULL check + +_zone cannot be NULL in update_engine_state. Remove a useless check that +would have caused a crash earlier already. +--- + src/thd_engine_adaptive.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/thd_engine_adaptive.cpp b/src/thd_engine_adaptive.cpp +index b68cc40..bc16ad2 100644 +--- a/src/thd_engine_adaptive.cpp ++++ b/src/thd_engine_adaptive.cpp +@@ -1454,7 +1454,7 @@ void cthd_engine_adaptive::update_engine_state() { + _zone->zone_reset(1); + _zone->trip_delete_all(); + +- if (_zone && _zone->zone_active_status()) ++ if (_zone->zone_active_status()) + _zone->set_zone_inactive(); + } + +-- +2.26.2 + diff --git a/SPECS/thermald.spec b/SPECS/thermald.spec index bd5aeeb..7f977f6 100644 --- a/SPECS/thermald.spec +++ b/SPECS/thermald.spec @@ -8,7 +8,7 @@ Name: thermald Version: 2.4.1 -Release: 1%{?dist} +Release: 2%{?dist} Summary: Thermal Management daemon License: GPLv2+ @@ -36,6 +36,12 @@ Requires(pre): shadow-utils %{?systemd_requires} +# https://github.com/intel/thermal_daemon/pull/286 +Patch0001: 0001-adaptive-Fix-missing-initializer.patch +Patch0002: 0002-adaptive-Fix-use-after-free.patch +Patch0003: 0003-adaptive-Remove-useless-NULL-check.patch + + %description %{name} monitors and controls platform temperature. @@ -242,6 +248,10 @@ exit 0 %changelog +* Thu Dec 10 2020 Benjamin Berg - 2.4.1-2 +- Fix problems reported by coverity + Related: #1875505 + * Tue Dec 08 2020 Benjamin Berg - 2.4.1-1 - Update to thermald 2.4.1 Resolves: #1875505