Android security tags, read closely by Lightrion

CVE-2024-31313 AI-generated analysis

platform/system/libfmq, Fast Message Queue (include/fmq/MessageQueueBase.h)

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 (8 corrections). Verify against the commit before relying on it.

Adds underflow checks to MessageQueueBase::availableToReadBytes() and availableToWriteBytes() in system/libfmq, so that inconsistent read/write counters yield 0 (with an error log) instead of a wrapped size_t.

Root cause

The FMQ read and write counters (mReadPtr, mWritePtr, declared as std::atomic<uint64_t>*) were used without consistency checks. availableToReadBytes() returned mWritePtr - mReadPtr, which wraps to a huge value if the write counter is behind the read counter. availableToWriteBytes() returned mDesc->getSize() - availableToReadBytes(), which wraps if the available bytes exceed the queue size. Per the in-code comment, availableToReadBytes() is invoked by implementations of both read() and write().

How the fix works

Completeness

Behavior changes

Per major

Unknowns

Back to June 2024 · Findings