Skip to contentSkip to conversation

platform/x86: intel_telemetry: initialize default trace verbosity

PATCH Superseded Aleksandrova Alyona 2 participants 2 messages Sep 15

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 platform/x86: intel_telemetry: initialize default trace verbosity

telemetry_def_get_trace_verbosity() returns success without initializing the output verbosity value.

The default telemetry operations are installed when the core driver is initialized and again by telemetry_clear_pltdata() when the platform driver is removed. The telemetry debugfs files can remain available after the platform driver removal.

A subsequent read of pss_trace_verbosity or ioss_trace_verbosity calls telemetry_get_trace_verbosity(), which may use the default callback and return success without setting verbosity. The uninitialized value is then passed to seq_printf().

Validate the output pointer and initialize the default verbosity to zero so callers never use an uninitialized value after a successful call.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes 378f956e3f93 ("platform/x86: Add Intel Telemetry Core Driver")
---
 drivers/platform/x86/intel/telemetry/core.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/platform/x86/intel/telemetry/core.c +4 -0
index f312864b8d07a..62299524a07b2 100644
@@ -24,6 +24,10 @@ static struct telemetry_core_config telm_core_conf;
 static int telemetry_def_get_trace_verbosity(enum telemetry_unit telem_unit,
 					     u32 *verbosity)
 {
+	if (!verbosity)
+		return -EINVAL;
+
+	*verbosity = 0;
 	return 0;
 }
 
Signature · 1 line
2.26.2
maintainer
#1 lore raw
Quoted 13 lines · Aleksandrova Alyona

telemetry_def_get_trace_verbosity() returns success without initializing the output verbosity value.

The default telemetry operations are installed when the core driver is initialized and again by telemetry_clear_pltdata() when the platform driver is removed. The telemetry debugfs files can remain available after the platform driver removal.

A subsequent read of pss_trace_verbosity or ioss_trace_verbosity calls telemetry_get_trace_verbosity(), which may use the default callback and return success without setting verbosity. The uninitialized value is then passed to seq_printf().

Quoted 8 lines

Validate the output pointer and initialize the default verbosity to zero so callers never use an uninitialized value after a successful call.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes 378f956e3f93 ("platform/x86: Add Intel Telemetry Core Driver")

---

You're missing the information on what is changed in v2?!

Quoted 19 lines
 drivers/platform/x86/intel/telemetry/core.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/platform/x86/intel/telemetry/core.c +4 -0
index f312864b8d07a..62299524a07b2 100644
@@ -24,6 +24,10 @@ static struct telemetry_core_config telm_core_conf;
 static int telemetry_def_get_trace_verbosity(enum telemetry_unit telem_unit,
 					     u32 *verbosity)
 {
+	if (!verbosity)
+		return -EINVAL;
+
+	*verbosity = 0;
 	return 0;
 }
 
Signature · 1 line
 i.