Android security tags, read closely by Lightrion

CVE-2024-31339 AI-generated analysis

platform/packages/modules/StatsD, statsd native daemon (StatsService / utils/MultiConditionTrigger)

AI-generated: written from the bulletin and the fixing diffs by claude-fable-5-1, then checked against the code by claude-opus-5-5 (7 corrections). Verify against the commit before relying on it.

MultiConditionTrigger no longer runs its trigger callback on a detached std::thread; the thread becomes a class member joined in the destructor, and StatsService gains a condition-variable based early-termination request so the delayed onStatsdInitCompleted handler exits promptly on shutdown, termination, destruction or StatsCompanionService death.

Root cause

MultiConditionTrigger (constructor and markComplete) launched `std::thread executorThread([this] { mTrigger(); })` and immediately called detach(). The lambda captures `this` and calls mTrigger, a std::function member. Nothing tied the thread's lifetime to the object. If the MultiConditionTrigger was destroyed while the thread was still running, the thread could access freed memory. In practice the owner is StatsService, which holds it as mBootCompleteTrigger and whose trigger runs StatsService::onStatsdInitCompleted. The window could be long because onStatsdInitCompleted, inside a conditional block, slept for mInitEventDelaySecs (`std::this_thread::sleep_for`) before calling mProcessor->onStatsdInitCompleted.

How the fix works

Completeness

Behavior changes

Per major

Unknowns

Back to July 2024 · Findings