Home
last modified time | relevance | path

Searched hist:"6 c59f64b7ecf2bccbe73931d7d573d66ed13b537" (Results 1 – 2 of 2) sorted by relevance

/openbmc/linux/tools/thermal/tmon/
H A Dsysfs.cdiff 6c59f64b7ecf2bccbe73931d7d573d66ed13b537 Mon Mar 12 13:57:06 CDT 2018 Frank Asseg <frank.asseg@objecthunter.net> tools/thermal: tmon: fix for segfault

Fixes a segfault occurring when e.g. <TAB> is pressed multiple times in the
ncurses tmon application. The segfault is caused by incrementing
cur_thermal_record in the main function without checking if it's value reached
NR_THERMAL_RECORD immediately. Since the boundary check only occurred in
update_thermal_data a race condition existed, which lead to an attempted read
beyond the last element of the trec array.

The fix was implemented by moving the cur_thermal_record incrementation to the
update_thermal_data function using a temporary variable on which the boundary
condition is checked before updating cur_thread_record, so that the variable is
never incremented beyond the trec array's boundary.

It seems the segfault does not occur on every machine: On a HP EliteBook G4 the
segfault happens, while it does not happen on a Thinkpad T540p.

Signed-off-by: Frank Asseg <frank.asseg@objecthunter.net>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
H A Dtmon.cdiff 6c59f64b7ecf2bccbe73931d7d573d66ed13b537 Mon Mar 12 13:57:06 CDT 2018 Frank Asseg <frank.asseg@objecthunter.net> tools/thermal: tmon: fix for segfault

Fixes a segfault occurring when e.g. <TAB> is pressed multiple times in the
ncurses tmon application. The segfault is caused by incrementing
cur_thermal_record in the main function without checking if it's value reached
NR_THERMAL_RECORD immediately. Since the boundary check only occurred in
update_thermal_data a race condition existed, which lead to an attempted read
beyond the last element of the trec array.

The fix was implemented by moving the cur_thermal_record incrementation to the
update_thermal_data function using a temporary variable on which the boundary
condition is checked before updating cur_thread_record, so that the variable is
never incremented beyond the trec array's boundary.

It seems the segfault does not occur on every machine: On a HP EliteBook G4 the
segfault happens, while it does not happen on a Thinkpad T540p.

Signed-off-by: Frank Asseg <frank.asseg@objecthunter.net>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>