Closed Bug 1614249 Opened 6 years ago Closed 6 years ago

Potential UAF in ipc::MessageChannel::Close()

Categories

(Core :: IPC, defect)

defect
Not set
normal

Tracking

()

RESOLVED INVALID
Tracking Status
firefox74 --- wontfix

People

(Reporter: deian, Unassigned)

Details

Attachments

(1 file)

Attached file messagechannel.ll

Our tool flagged a potential use-after-free in ipc::MessageChannel::Close(). The tool operates on LLVM IR, where I think the UAF is pretty clear. I'm not super sure if this is a real bug or a false positive (I don't fully grok how refcounting and move within lambda play). Apologize ahead of time if this is a false report.

Mapping the LLVM back to source, I think we're looking at these lines:

    RefPtr<RefCountedMonitor> monitor(mMonitor);
    auto exit = MakeScopeExit([m = std::move(monitor)]() { m->Unlock(); }); 

    if (ChannelError == mChannelState || ChannelTimeout == mChannelState) {
      // See bug 538586: if the listener gets deleted while the
      // IO thread's NotifyChannelError event is still enqueued
      // and subsequently deletes us, then the error event will
      // also be deleted and the listener will never be notified
      // of the channel error.
      if (mListener) {
        exit.release();  // Explicitly unlocking, clear scope exit.  
        mMonitor->Unlock();  // Tool thinks the use of the freed thing is here

Attached is relevant path we flagged on FF compiled clang -O2.

Sorry about this. If this were moving mMonitor the bug would be valid, but that's not the case here. I think the basic block (from the ref counting) that free's the object in the LLVM IR is essentially dead code.

Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → INVALID
Group: core-security → dom-core-security
Group: dom-core-security
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: