for Low Level Code Jakub Kuderski, Nhm L, Arie Gurfinkel - - PowerPoint PPT Presentation

β–Ά
for low level code
SMART_READER_LITE
LIVE PREVIEW

for Low Level Code Jakub Kuderski, Nhm L, Arie Gurfinkel - - PowerPoint PPT Presentation

TeaDsa: Type-aware DSA-style Pointer Analysis for Low Level Code Jakub Kuderski, Nhm L, Arie Gurfinkel (UWaterloo); Jorge Navas (SRI International) fmcad 2018, Austin, TX Detecting Field Overflow Memory Safety Bugs struct Node { Node *next


slide-1
SLIDE 1

TeaDsa: Type-aware DSA-style Pointer Analysis for Low Level Code

Jakub Kuderski, NhΓ’m LΓͺ, Arie Gurfinkel (UWaterloo); Jorge Navas (SRI International)

fmcad 2018, Austin, TX

slide-2
SLIDE 2

Detecting Field Overflow Memory Safety Bugs

struct Node { Node *next = nullptr; int TAG; }; struct IntNode : Node { int *i; }; struct FloatNode : Node { float *f; }; // ... Node *node; node = getNode(); if (node->TAG == INT_TAG) *(((IntNode *) node)->i) = 123; // SAFE? node = getNode(); *(((FloatNode *) node)->f) = 3.14f; // SAFE?

slide-3
SLIDE 3

Detecting Field Overflow Memory Safety Bugs

  • Existing Pointer Analyses for LLVM inadequate
  • Not scalable (SVF, Phasar)
  • Not precise enough (SeaDsa)

C or C++ LLVM IR Memory accesses Check candidates Clang Static Analyzer Pointer Analysis Memory Instructions Memory Instructions + Allocation Sites Verifier Results Safe / Unsafe Instructions

slide-4
SLIDE 4

TeaDsa

  • Based on SeaDsa
  • Context-, field-, array-sensitive
  • Unification-based (Steensgaard-style)
  • Type- and offset-based field sensitivity
  • 65% checks discharged with types vs. no types

Is relying on types Sound for low-level languages?

  • Casts, type punning, memcpy
  • Potential memory faults

Program Size [kB] SVF Time [s] SeaDsa Time [s] TeaDsa Time [s] % Checks Discharged with Types

bzip2 29 173 0.19 0.19 mcf 37 1.98 0.02 0.03

  • libquantum

80 8.66 0.08 0.09

  • sjeng

308 260 0.44 0.45 CASS 765 5390 6.20 5.85

65

htop 800

  • 5.02

3.80

71

hmmer 859 2548 3.51 3.60

1

h264ref 1784 11525 9.44 10

26

Statement Inclusion-based Unification-based π‘ž = π‘›π‘π‘šπ‘šπ‘π‘‘ π‘œ π‘ž βŠ‡ loc mallo𝑑 π‘ž β‰ˆ π‘šoc π‘›π‘π‘šπ‘šπ‘π‘‘ π‘ž = π‘Ÿ π‘ž βŠ‡ π‘Ÿ π‘ž β‰ˆ π‘Ÿ βˆ— π‘ž = π‘Ÿ pts p βŠ‡ π‘Ÿ pts p β‰ˆ π‘Ÿ π‘ž = βˆ— π‘Ÿ π‘ž βŠ‡ pts π‘Ÿ π‘ž β‰ˆ pts π‘Ÿ π‘ž = &𝑦 π‘ž βŠ‡ π‘šπ‘π‘‘ 𝑦 π‘ž β‰ˆ π‘šπ‘π‘‘ 𝑦