Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Sanitizing 
All* The Things

Greg Heo
September 12, 2017

Sanitizing 
All* The Things

Address sanitizer and thread sanitizer. What, why, how?

Greg Heo

September 12, 2017
Tweet

More Decks by Greg Heo

Other Decks in Technology

Transcript

  1. Sanitizing

    All* The Things
    tacow / September 2017 / @gregheo

    View full-size slide

  2. ‣ ASAN
    ‣ TSAN

    View full-size slide

  3. ‣ What?
    ‣ So what?
    ‣ How?
    ‣ Show me?

    View full-size slide

  4. Address Sanitizer
    allocated buffer unallocated!

    View full-size slide

  5. ‣ Buffer overflows
    ‣ Subtle bugs
    ‣ Security vulnerabilities

    View full-size slide

  6. allocated buffer
    padding
    shadow memory
    poisoned poisoned
    OK

    View full-size slide

  7. asan_malloc
    malloc
    asan_free
    free
    Shadow memory
    check
    Pointer
    access

    View full-size slide


  8. Live Coding!

    View full-size slide

  9. Address Sanitizer
    Memory corruption & errors
    Security & crashes
    Custom malloc & free

    View full-size slide

  10. Thread Sanitizer
    memory buffer read
    write

    View full-size slide

  11. ‣ Race conditions
    ‣ Very subtle and

    difficult-to-reproduce bugs
    ‣ Thread mismatch errors

    View full-size slide

  12. ‣ Thread ID
    ‣ Timestamp
    ‣ Read or write?
    ‣ Bytes accessed

    View full-size slide


  13. Live Coding!

    View full-size slide

  14. Thread Sanitizer
    Data race detector
    Find race conditions & thread issues
    Thread IDs & timestamps

    View full-size slide

  15. Address Sanitizer
    Memory corruption & errors
    Security & crashes
    Custom malloc & free

    View full-size slide