Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit c92ef108 authored by Connor O'Brien's avatar Connor O'Brien Committed by Steven Moreland
Browse files

libtimeinstate: fix bug in clearUidCpuFreqTimes



In a preallocated bpf hash table, deleting a map element makes it
available for reuse without clearing the data it holds. This reuse can
occur when a bpf program calls bpf_map_update_elem with a key not
already present in the map. If the map is percpu, bpf_map_update_elem
will overwrite the reused entry's data for the current CPU but not for
other CPUs, resulting in stale data that is now associated with the
wrong key.

For time in state, this can show up as impossible data (e.g. reporting
that a UID ran on one cluster at a frequency only available on a
different cluster), which is detected by the SingleAndAllUidConsistent
test since getUidCpuFreqTimes() only looks up potentially valid keys
while getUidsCpuFreqTimes() iterates through every map entry.

Avoid this problem by zeroing out each entry's data prior to deleting
it from the map. Also modify getUidCpuFreqTimes and
getUidsCpuFreqTimes to check for impossible data and fail if any is
detected, since it's a sign that other map entries may also be wrong.

Bug: 138317993
Test: libtimeinstate_test can now be run repeatedly without
SingleAndAllUidConsistent test eventually failing
Signed-off-by: default avatarConnor O'Brien <connoro@google.com>

Change-Id: I17dd407f897d1e86eb85cc99842a581d88e5bc78
(cherry picked from commit 6c501ea0)
Merged-In: I17dd407f897d1e86eb85cc99842a581d88e5bc78
parent a178a73a
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment