#!/usr/bin/env python3 """A `pair`: two builds of one program against each other. overflow.c, built plain and with clang's AddressSanitizer (-O0 -g -fno-omit-frame-pointer -no-pie -fno-stack-protector), each recorded by instruction from `fill` with ztrace; the frames, the shadow and the report are those recordings'. python3 -B pair.py # 26-pair-rest, 27-pair-store, 28-pair-part (.svg) """ import gen import context as C from context import (PAGE, RAISED, RULE, VELLUM, BRIGHT, DIM, FAINT, GOLD, KW, CODE, STACK, DATA, HEAP, LIT, READ, A, S, ROW, TAG, PAD, MONO, BOLD, b, ph, mix, Svg) HERE = __file__.rsplit("/", 1)[0] SRC = open(HERE + "/overflow.c").read().split("\n") S_, D_, C_ = STACK, DATA, CODE LEFT, RIGHT = 64, 976 P = VELLUM PLAIN = [(0x401144, 4, "mov", "dword ptr [rbp - 0x14], 0"), (0x40114b, 4, "cmp", "dword ptr [rbp - 0x14], 0x20"), (0x40114f, 4, "jge", 0x401165), (0x401151, 4, "movsxd", "rax, dword ptr [rbp - 0x14]"), (0x401155, 4, "mov", "byte ptr [rbp + rax - 0x10], 0x41"), (0x40115a, 4, "mov", "eax, dword ptr [rbp - 0x14]"), (0x40115d, 4, "add", "eax, 1"), (0x401160, 4, "mov", "dword ptr [rbp - 0x14], eax"), (0x401163, 4, "jmp", 0x40114b), (0x401165, 5, "pop", "rbp"), (0x401166, 5, "ret", "")] ASAN = [(0x523d1e, 4, "cmp", "dword ptr [rbx + 0x64], 0x20"), (0x523d22, 4, "jl", 0x523d26), (0x523d24, 4, "jmp", 0x523d6c), (0x523d26, 4, "mov", "rax, qword ptr [rbx + 0x18]"), (0x523d2a, 4, "movsxd", "rcx, dword ptr [rbx + 0x64]"), (0x523d2e, 4, "add", "rax, rcx"), (0x523d31, 4, "mov", "qword ptr [rbx], rax"), (0x523d34, 4, "shr", "rax, 3"), (0x523d38, 4, "mov", "al, byte ptr [rax + 0x7fff8000]"), (0x523d3e, 4, "mov", "byte ptr [rbx + 0xf], al"), (0x523d41, 4, "cmp", "al, 0"), (0x523d43, 4, "je", 0x523d5b), (0x523d45, 4, "mov", "cl, byte ptr [rbx + 0xf]"), (0x523d48, 4, "mov", "rax, qword ptr [rbx]"), (0x523d4b, 4, "and", "rax, 7"), (0x523d4f, 4, "cmp", "al, cl"), (0x523d51, 4, "jl", 0x523d5b), (0x523d53, 4, "mov", "rdi, qword ptr [rbx]"), (0x523d56, 4, "call", 0x4e8450), (0x523d5b, 4, "mov", "rax, qword ptr [rbx]"), (0x523d5e, 4, "mov", "byte ptr [rax], 0x41"), (0x523d61, 4, "mov", "eax, dword ptr [rbx + 0x64]"), (0x523d64, 4, "add", "eax, 1"), (0x523d67, 4, "mov", "dword ptr [rbx + 0x64], eax"), (0x523d6a, 4, "jmp", 0x523d1e)] ONLY = {0x523d24, 0x523d26, 0x523d2e, 0x523d31, 0x523d34, 0x523d38, 0x523d3e, 0x523d41, 0x523d43, 0x523d45, 0x523d48, 0x523d4b, 0x523d4f, 0x523d51, 0x523d53, 0x523d56, 0x523d5b} # rows the plain build has no counterpart for NAMES = {0x4e8450: "__asan_report_store1"} FAKE = 0x7bfff58f0000 def rows_of(code, first, n, states, notes): out = [] for a, ln, mn, ops in code: if a < first or len(out) == n: continue parts = [((ops, NAMES[ops]) if ops in NAMES else ops, C_)] if isinstance(ops, int) else ([(ops, P)] if ops else []) out.append((a, ln, mn, parts, states.get(a), notes.get(a))) return out def bar(g, x, y, ink, w=4, h=ROW): """`only here` (dim) and `differs` (bright): a bar on the row's edge that faces the seam.""" g.rect(x, y + 1, w, h - 2, ink) def at_side(x): C.LX = x C.RX = x def regs(g, x, y, title, rows, marks=None): y0 = C.panel(g, x, y, C.CW, len(rows), title, note="the line's registers, and rip") marks = marks or {} for i, (name, links, end) in enumerate(rows): yy = y0 + i * ROW if name == "rip": g.t(x + 12, b(yy), name, S, C.current_row(g, x + 2, yy, C.CW - 4, 54), BOLD) else: g.t(x + 12, b(yy), name, S, DIM, MONO) if links: C.chain(g, x + 72, yy, links, end, marks.get(name), room=x + C.CW - 12) elif marks.get(name, {}).get(0) == "strike": s_ = "0x%x" % end[1] g.t(x + 72, b(yy), s_, S, C.struck(g, x + 67, yy, len(s_) * A + 10), BOLD) else: C.integer(g, x + 72, yy, end[1]) def shadow_cell(g, x, y, v, read=False): """A shadow byte on the row of the eight bytes it stands for, in the offset's place.""" if v >= 0xf0: # a redzone: poisoned, on the freed hatch g.rect(x - 3, y + 2, 30, ROW - 4, "url(#hatch)") g.t(x, b(y), "%02x" % v, S, BRIGHT, BOLD) else: g.t(x, b(y), "%02x" % v, S, FAINT, MONO) if read: g.frame(x - 6, y, 36, ROW, READ, 2) def source_pair(g, cur_l, cur_r, waiting_r=False): """The source shared across both columns; the left run's mark on the number, the right run's at the right end.""" C.LX, C.CW = 64, 1792 ys = C.source(g, 48, 5, SRC, 2, cur_l, [], "overflow.c · both builds", 10) y_r = 48 + TAG + PAD + (cur_r - 2) * ROW xr = 64 + 1792 - 2 - 24 if cur_r != cur_l: g.rect(64 + 2, y_r, 1792 - 4, ROW, C.WASH) g.rect(xr, y_r, 24, ROW, GOLD) g.path(f"M{xr + 8},{y_r + 12} l8,-6 v12 Z", fill=gen.INK) g.t(xr - 10, b(y_r), "asan", 18, DIM, "sans", "end") g.t(64 + 46 + 60, b(ys) if False else b(ys), "", 18, DIM, "sans") C.CW = 880 return ys # ---- the frame as bytes: `hexdump` `eight`, by the frame's own fields -------------------------------------------- PX, AX, BX8, RD = 12, 118, 274, 522 # a row: the pin lane, the address, eight bytes 30 apart, the reading SHX = 62 # in a run with ASan, the row's shadow byte, in the pin lane's end def plain_region(v): """Where a word of the plain build points, by its mappings; None: nowhere (a number).""" if 0x7ffffffde000 <= v < 0x7ffffffff000: return S_ if 0x401000 <= v < 0x402000: return C_ if 0x404000 <= v < 0x405000: return D_ return None def asan_region(v): if 0x7ffffffde000 <= v < 0x7ffffffff000: return S_ if 0x7bfff58e7000 <= v < 0x7bfff6400000: return D_ if 0x42c000 <= v < 0x524000: return C_ if 0x524000 <= v < 0x55f000: return VELLUM return None CODE_NAMES = {0x401120: "main", 0x401140: "fill", 0x523c40: "main", 0x523c60: "fill"} def code_name(v): f = max((a for a in CODE_NAMES if a <= v and v - a < 0x100), default=None) return None if f is None else (CODE_NAMES[f] + ("+%d" % (v - f) if v > f else "")) def plain_mem(stored, i): """The plain build's stack from 7fffffffecb0 to 7fffffffed00 after `stored` of the loop's stores, i in its slot.""" m = {a: 0 for a in range(0x7fffffffecb0, 0x7fffffffed00)} for k, v in enumerate([0x00, 0xed, 0xff, 0xff, 0xff, 0x7f, 0, 0, 0x34, 0x11, 0x40, 0, 0, 0, 0, 0]): m[0x7fffffffece0 + k] = v for k in range(4): m[0x7fffffffeccc + k] = i >> (8 * k) & 0xff for k in range(stored): m[0x7fffffffecd0 + k] = 0x41 return m def asan_mem(stored): """ASan's fake frame (the header as its prologue wrote it, buf, the redzone) and the real stack's way back.""" m = {} for off, v in [(0, 0x41b58ab3), (8, 0x5387a7), (0x10, 0x523c60), (0x18, 0x7fffffffec10), (0x38, 0x7bfff58e8000)]: for k in range(8): m[FAKE + off + k] = v >> (8 * k) & 0xff for k in range(0x20, 0x38): m[FAKE + k] = 0x41 if 0x20 <= k < 0x20 + stored else 0 for a, v in [(0x7fffffffecc0, 0x7fffffffece0), (0x7fffffffecc8, 0x523c54)]: for k in range(8): m[a + k] = v >> (8 * k) & 0xff return m DESCR = {0x5387a7: "1 32 16 5 buf:3"} def frame_dump(g, x, y, title, note, rows, mem, region, pins=None, shadow=None, struck=None, held=(), letters=(), read_shadow=None, span=None, rule_after=None, differs=(), seam=None): """`hexdump` `eight` by the frame's fields: a row a word of the stack (eight bytes), its pins and address, the bytes on their field's paper, the reading: the field's name (Go 18, dim) and what its type makes of its bytes. rows: (address, [(offset, length, reads, name)]); reads in text | pointer | number | bytes; what no field covers is loose. letters: bytes stored past the field the store aimed at, which keep its ink (text) wherever they land. shadow: {row: byte}. span: (name, first row, last row). Returns the rows' y.""" pins = pins or {} y0 = C.panel(g, x, y, C.CW, len(rows) + (0 if rule_after is None else 0), title, note=note) lead = C.shared([a for a, _ in rows if region(a) == region(rows[0][0])]) ys = [] for r, (a0, flist) in enumerate(rows): yy = y0 + r * ROW ys.append(yy) if rule_after is not None and r == rule_after + 1: # another region (the real stack): a rule before it g.rect(x + 2, yy - 1, C.CW - 4, 2, RULE) if r in pins: C.pin(g, x + PX, yy, pins[r], S_) if shadow and r in shadow: shadow_cell(g, x + SHX, yy, shadow[r], read=read_shadow == r) ink_a = region(a0) or VELLUM C.addr(g, x + AX, yy, a0, ink_a, lead=lead if region(a0) == region(rows[0][0]) else 0) bx = lambda k: x + BX8 + 30 * k covered = {} for f in flist: for k in range(f[0], f[0] + f[1]): covered[k] = f rx = x + RD for f in flist: off, n, reads, name = f vals = [mem[a0 + off + k] for k in range(n)] word = sum(v << (8 * k) for k, v in enumerate(vals)) g.rect(bx(off) - 4, yy + 1, 30 * n - 2, ROW - 2, RAISED) ink = {"text": LIT, "number": VELLUM, "bytes": VELLUM, "pointer": region(word) or VELLUM}[reads] nz = [k for k, v in enumerate(vals) if v] for k, v in enumerate(vals): a = a0 + off + k xx = bx(off + k) if a == struck: g.t(xx, b(yy), "%02x" % v, S, C.struck(g, xx - 5, yy, 34), BOLD) continue if a in held: C.held(g, xx, yy, 24) padded = reads in ("number", "pointer") and nz and k > nz[-1] kink = LIT if a in letters else ink g.t(xx, b(yy), "%02x" % v, S, mix(kink, PAGE, 0.45) if padded else kink, MONO) # the reading: the field's name, then its value g.t(rx, b(yy) - 1, name, 18, DIM, "sans") vx = rx + gen.tw(name, 18, "sans") + 10 if reads == "text": s_ = '"' + bytes(v for v in vals).split(b"\0")[0].decode("latin1") + '"' g.t(vx, b(yy), s_, S, LIT, MONO) elif reads == "number": # a count: in decimal, as the source writes it g.t(vx, b(yy), str(word), S, VELLUM, MONO) elif reads == "pointer": ink_w = region(word) if ink_w: vx = C.addr(g, C.link_arrow(g, vx, yy), yy, word, ink_w) nm = code_name(word) if ink_w == C_ else None if nm: g.t(vx + 10, b(yy), nm, S, VELLUM, MONO) elif word in DESCR: room = int((x + C.CW - 24 - vx - 10) // A) t_ = '"%s"' % DESCR[word] g.t(vx + 10, b(yy), t_ if len(t_) <= room else t_[:room - 1] + "…", S, LIT, MONO) else: # no longer an address: a number, no arrow, no name g.t(vx, b(yy), "0x%x" % word, S, VELLUM, MONO) rx = vx + 200 for k in range(8): # what no field covers: loose if k not in covered: v = mem.get(a0 + k) g.t(bx(k), b(yy), "%02x" % v, S, mix(DIM, PAGE, 0.6), MONO) if r in differs: bar(g, seam, yy, BRIGHT) if span: # the frame's span, as the stack's: a bracket 14 in, its name left of it name, r0, r1 = span bx_, ya, yb = x + C.CW - 14, ys[r0] + 3, ys[r1] + ROW - 3 g.rect(bx_ - 1, ya, 2, yb - ya, GOLD) g.rect(bx_ - 7, ya, 8, 2, GOLD) g.rect(bx_ - 7, yb - 2, 8, 2, GOLD) g.t(bx_ - 14, (ya + yb) / 2 + 6, name, 18, BRIGHT, "sansm", "end") return ys PLAIN_ROWS = [(0x7fffffffecb0, []), (0x7fffffffecb8, []), (0x7fffffffecc0, []), (0x7fffffffecc8, [(4, 4, "number", "i")]), (0x7fffffffecd0, [(0, 8, "text", "buf[0..7]")]), (0x7fffffffecd8, [(0, 8, "text", "buf[8..15]")]), (0x7fffffffece0, [(0, 8, "pointer", "saved rbp")]), (0x7fffffffece8, [(0, 8, "pointer", "return")]), (0x7fffffffecf0, []), (0x7fffffffecf8, [])] ASAN_ROWS = [(FAKE, [(0, 8, "bytes", "magic")]), (FAKE + 8, [(0, 8, "pointer", "descr")]), (FAKE + 0x10, [(0, 8, "pointer", "pc")]), (FAKE + 0x18, [(0, 8, "pointer", "real stack")]), (FAKE + 0x20, [(0, 8, "text", "buf[0..7]")]), (FAKE + 0x28, [(0, 8, "text", "buf[8..15]")]), (FAKE + 0x30, [(0, 8, "bytes", "redzone")]), (FAKE + 0x38, [(0, 8, "bytes", "redzone")]), (0x7fffffffecc0, [(0, 8, "pointer", "saved rbp")]), (0x7fffffffecc8, [(0, 8, "pointer", "return")])] SHADOW = {0: 0xf1, 1: 0xf1, 2: 0xf1, 3: 0xf1, 4: 0, 5: 0, 6: 0xf3, 7: 0xf3} def plain_dump(g, i, stored, struck=None, held=(), note="fill's frame as bytes, eight a row"): letters = {0x7fffffffecd0 + k for k in range(16, stored)} return frame_dump(g, LEFT, 612, "plain · stack", note, PLAIN_ROWS, plain_mem(stored, i), plain_region, pins={6: ["rbp", "rsp"]}, struck=struck, held=held, letters=letters, span=("fill", 3, 7), differs=(6, 7), seam=LEFT + 880 - 6) def asan_dump(g, stored, read=False): return frame_dump(g, RIGHT, 612, "asan · fake frame", "its shadow at addr >> 3 + 7fff8000 · then the real " "stack's way back", ASAN_ROWS, asan_mem(stored), asan_region, pins={8: ["rbp"]}, shadow=SHADOW, read_shadow=6 if read else None, span=("fill", 0, 9), rule_after=7, differs=(6, 7), seam=RIGHT + 2) def frame(name, i): """The pair at the loop, the frame as bytes in each column. i = 15: both builds at the line's store (plain) and its check (asan). i = 16: the step in which they part: plain's store struck into the saved rbp; asan's check read f3.""" gen.W, gen.H = 1920, 1080 g = Svg() part = i == 16 source_pair(g, 4, 4) # ---- the left column: plain ---- at_side(LEFT) pn = {0x401155: ("chain", [(0x7fffffffece0 if part else 0x7fffffffecdf, S_)], ("int", 0x41) if part else ("int", 0), {"end": "strike"} if part else None)} ps = {0x401155: "cur", 0x401151: "trail0", 0x40114f: "trail1", 0x40114b: "trail2"} C.disasm(g, 212, rows_of(PLAIN, 0x401144, 9, ps, pn), "plain · fill", 4) regs(g, LEFT, 472, "plain · registers", [("rax", [], ("int", i)), ("rbp", [(0x7fffffffece0, S_), (0x7fffffffed41 if part else 0x7fffffffed00, S_)], None), ("rsp", [(0x7fffffffece0, S_)], None), ("rip", [(0x401155, C_, "fill+21")], None)], {"rax": {0: "tick"}}) plain_dump(g, i, i + 1 if part else i, struck=0x7fffffffece0 if part else None, held={0x7fffffffecdf, 0x7fffffffeccc} if part else {0x7fffffffecde, 0x7fffffffeccc}) # ---- the right column: asan ---- at_side(RIGHT) an = {0x523d38: ("chain", [(0xf807eb16006 if part else 0xf807eb16005, D_)], ("int", 0xf3 if part else 0), {0: "read"} if part else None), 0x523d34: ("set", "rax", [], ("int", (FAKE + 0x20 + i) >> 3))} ast = {0x523d38: "cur", 0x523d34: "trail0", 0x523d31: "trail1", 0x523d2e: "trail2"} if part: an[0x523d41] = ("runs", [("f3", VELLUM), (" : ", FAINT), ("0", VELLUM), (" ", FAINT), ("zf", DIM)]) an[0x523d43] = ("runs", [("not taken", DIM)]) at = C.disasm(g, 212, rows_of(ASAN, 0x523d26, 9, ast, an), "asan · fill", 4) for a, yy in at.items(): if a in ONLY: bar(g, RIGHT + 2, yy, DIM) # its seam is on its left regs(g, RIGHT, 472, "asan · registers", [("rax", [], ("int", (FAKE + 0x20 + i) >> 3)), ("rbx", [(0x7fffffffec20, S_), (FAKE + 0x20 + i, D_)], None), ("rcx", [], ("int", i)), ("rip", [(0x523d38, C_, "fill+216")], None)], {"rax": {0: "tick"}}) asan_dump(g, 16 if part else 15, read=part) clock(g, 17 if part else 16, "i %d · moments %d / %d" % (i, 164 if part else 156, 770 if part else 753)) if part: gen.caption(g, [[("i = 16, one past ",), ("buf", "mono"), (": plain writes ",), ("41", "mono"), (", an ",), ("'A'", "mono"), (", into the saved rbp.",)], [("ASan reads the shadow first: ",), ("f3", "mono"), (", a redzone. It does not store.",)]]) else: gen.caption(g, [[("Each turn is one more byte: ",), ("41", "mono"), (", the letter ",), ("A", "mono"), (". Fifteen in ",), ("buf", "mono"), (",",)], [("on both sides; ASan read ",), ("00", "mono"), (" in the shadow before each one.",)]]) g.save(name) def clock(g, steps, text): g.rect(64, 899, 1792, 2, RULE) g.rect(64, 898, 1792 * steps / 33, 4, GOLD) g.t(1648, 934, text, S, FAINT, MONO, "end") REPORT = [("==1438870==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7bfff58f0030 at pc 0x000000523d5b", "stack-buffer-overflow"), ("WRITE of size 1 at 0x7bfff58f0030 thread T0", "WRITE of size 1"), ("Address 0x7bfff58f0030 is located in stack of thread T0 at offset 48 in frame", None), (" This frame has 1 object(s):", None), (" [32, 48) 'buf' (line 3) <== Memory access at offset 48 overflows this variable", "[32, 48) 'buf'"), ("=>0x7bfff58f0000: f1 f1 f1 f1 00 00[f3]f3 00 00 00 00 00 00 00 00", "[f3]")] def report(g, x, y, lines): """A run's stderr, as written: a panel of its lines, the ones the narration names framed; cut at its edge.""" y0 = C.panel(g, x, y, C.CW, len(lines), "asan · stderr", note="its report, as written · exit 1") room = (C.CW - 24) // A for k, (t, mark) in enumerate(lines): yy = y0 + k * ROW s_ = t if len(t) <= room else t[:room - 1] + "…" g.t(x + 12, b(yy), s_, S, VELLUM, MONO) if mark and mark in s_: c = s_.index(mark) g.frame(x + 12 + c * A, yy, len(mark) * A, ROW, BRIGHT, 2) def frame_ret(name): """Mock 38: i = 27, plain alone: its store struck into the return address's fourth byte, which now reads 0x41414141, no longer an address; ASan stopped at i = 16, its report in place of its registers.""" gen.W, gen.H = 1920, 1080 g = Svg() source_pair(g, 4, 4) at_side(LEFT) pn = {0x401155: ("chain", [(0x7fffffffeceb, S_)], ("int", 0x41), {"end": "strike"})} ps = {0x401155: "cur", 0x401151: "trail0", 0x40114f: "trail1", 0x40114b: "trail2"} C.disasm(g, 212, rows_of(PLAIN, 0x401144, 9, ps, pn), "plain · fill", 4) regs(g, LEFT, 472, "plain · registers", [("rax", [], ("int", 27)), ("rbp", [(0x7fffffffece0, S_)], ("int", 0x4141414141414141)), ("rsp", [(0x7fffffffece0, S_)], None), ("rip", [(0x401155, C_, "fill+21")], None)], {"rax": {0: "tick"}}) plain_dump(g, 27, 28, struck=0x7fffffffeceb, held={0x7fffffffece8, 0x7fffffffece9, 0x7fffffffecea, 0x7fffffffeccc}) # ---- asan: stopped at i = 16. Its disassembly's upper rows, down to the call; its report in place of the rest at_side(RIGHT) ar = rows_of(ASAN, 0x523d4b, 5, {0x523d56: "trail0", 0x523d53: "trail1", 0x523d51: "trail2"}, {0x523d56: ("text", "never returned", DIM)}) at = C.disasm(g, 212, ar, "asan · fill · stopped", 4) for a, yy in at.items(): if a in ONLY: bar(g, RIGHT + 2, yy, DIM) report(g, RIGHT, 376, REPORT) asan_dump(g, 16) clock(g, 28, "i 27 · moment 252 · asan exited") gen.caption(g, [[("i = 27: the return address is half ",), ("41", "mono"), ("s, and reads",)], [("41414141", "mono"), (", no longer an address. ASan stopped at i = 16.",)]]) g.save(name) def sheet_store(name): """Mock 27: one turn of the loop, row by row, the plain build's rows facing their counterparts in the ASan build's; the rows only ASan has barred on the seam side, the plain side's page facing them. i = 3. Under each, its buf as bytes: the turn's one byte struck, the letter it is.""" gen.W, gen.H = 1920, 1080 g = Svg() face = {0x40114b: 0x523d1e, 0x40114f: 0x523d22, 0x401151: 0x523d2a, 0x401155: 0x523d5e, 0x40115a: 0x523d61, 0x40115d: 0x523d64, 0x401160: 0x523d67, 0x401163: 0x523d6a} order = [a for a, *_ in ASAN] notes = {0x523d26: ("chain", [(FAKE + 0x20, D_)], None, None), 0x523d2e: ("set", "rax", [(FAKE + 0x23, D_)], ("str", "AAA")), 0x523d34: ("set", "rax", [], ("int", (FAKE + 0x23) >> 3)), 0x523d38: ("chain", [(0xf807eb16004, D_)], ("int", 0), None), 0x523d41: ("runs", [("0", VELLUM), (" : ", FAINT), ("0", VELLUM), (" ", FAINT), ("ZF", "chip")]), 0x523d43: ("runs", [("taken", VELLUM), (" · reads ZF", FAINT)]), 0x523d5e: ("chain", [(FAKE + 0x23, D_)], ("int", 0x41), None)} skipped = {0x523d45, 0x523d48, 0x523d4b, 0x523d4f, 0x523d51, 0x523d53, 0x523d56} # the partial check: not run at 00 ar = [(a, ln, mn, [((ops, NAMES[ops]) if ops in NAMES else ops, C_)] if isinstance(ops, int) else ([(ops, P)] if ops else []), "skip" if a in skipped else None, notes.get(a)) for a, ln, mn, ops in ASAN] at_side(RIGHT) y = 96 at = C.disasm(g, y, ar, "asan · line 4, one turn · 17 instructions", 4) for a, yy in at.items(): if a in ONLY: bar(g, RIGHT + 2, yy, DIM) # the plain side: each row at its counterpart's height; page where it has none at_side(LEFT) C.tag(g, LEFT, y, 880, ph(len(ASAN)), "plain · line 4, one turn · 8 instructions", note="each row facing its counterpart") pnotes = {0x401151: ("set", "rax", [], ("int", 3)), 0x401155: ("chain", [(0x7fffffffecd3, S_)], ("int", 0x41), None)} for a, ln, mn, ops in PLAIN: if a not in face: continue parts = [(ops, C_)] if isinstance(ops, int) else [(ops, P)] C.insn_rows(g, at[face[a]], [(a, ln if a == 0x40114b else None, mn, parts, None, pnotes.get(a))], 4, lead=4) g.t(LEFT + 400, at[0x523d34] + 18, "the check: plain has nothing here", 18, FAINT, "sans") # the turn's one byte, in each build's buf: the store struck, the reading one letter longer frame_dump(g, LEFT, 740, "plain · buf", "the turn's byte", PLAIN_ROWS[4:6], plain_mem(4, 3), plain_region, struck=0x7fffffffecd3) frame_dump(g, RIGHT, 740, "asan · buf", "its shadow, read before the store", ASAN_ROWS[4:6], asan_mem(4), asan_region, shadow={0: 0, 1: 0}, read_shadow=0, struck=FAKE + 0x23) gen.caption(g, [[("Plain: one store. ASan: the address, its shadow byte (",), ("addr >> 3", "mono"), (" + ",), ("7fff8000", "mono"), ("),", )], [("a compare with 0, a branch; the partial check and the report only if it is not 0.",)]]) g.save(name) if __name__ == "__main__": frame("26-pair-rest", 15) sheet_store("27-pair-store") frame("28-pair-part", 16) frame_ret("38-pair-ret")