[all-commits] [llvm/llvm-project] f9dd3e: [hwasan] Fix data race between ReleaseThread() and...

Enna1 via All-commits all-commits at lists.llvm.org
Fri May 5 03:39:34 PDT 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f9dd3ea475e467d42bd3a3ff28c9aa384fe75549
      https://github.com/llvm/llvm-project/commit/f9dd3ea475e467d42bd3a3ff28c9aa384fe75549
  Author: Enna1 <xumingjie.enna1 at bytedance.com>
  Date:   2023-05-05 (Fri, 05 May 2023)

  Changed paths:
    M compiler-rt/lib/hwasan/hwasan_thread_list.h

  Log Message:
  -----------
  [hwasan] Fix data race between ReleaseThread() and VisitAllLiveThreads()

Data race scenario:
```
Thread 1                                | Thread 2
ReportTagMismatch()                     |
Call VisitAllLiveThreads() to scan all  |
threads' ring buffers to find           |
if it's a heap-use-after-free.          |
Lock live_list_mutex_                   |
                                        | Thread 2 exit
                                        | ReleaseThread() calls Thread::Destroy() for Thread 2,
                                        | which frees heap alloctions ring buffer
                                        | RemoveThreadFromLiveList() tries to take live_list_mutex_ again
Iterate the heap alloctions ring buffer |
of Thread 2, which is already freed     |
```

Reviewed By: vitalybuka

Differential Revision: https://reviews.llvm.org/D148909




More information about the All-commits mailing list