KATCH: High-Coverage Tes2ng of So6ware Patches Paul - - PowerPoint PPT Presentation

katch high coverage tes2ng of so6ware patches
SMART_READER_LITE
LIVE PREVIEW

KATCH: High-Coverage Tes2ng of So6ware Patches Paul - - PowerPoint PPT Presentation

KATCH: High-Coverage Tes2ng of So6ware Patches Paul Marinescu and Cris2an Cadar Imperial College London Intro Manual tes2ng is hard Supplement it


slide-1
SLIDE 1

KATCH: ¡High-­‑Coverage ¡Tes2ng ¡of ¡ So6ware ¡Patches ¡

Paul ¡Marinescu ¡and ¡Cris2an ¡Cadar ¡

Imperial ¡College ¡London ¡

slide-2
SLIDE 2

Intro ¡

  • Manual ¡tes2ng ¡is ¡hard ¡
  • Supplement ¡it ¡with ¡automa2c ¡tes2ng ¡
  • We ¡focus ¡on ¡tes2ng ¡so6ware ¡changes ¡

¡

2 ¡

slide-3
SLIDE 3

Manual ¡Patch ¡Coverage ¡

0% ¡ 10% ¡ 20% ¡ 30% ¡ 40% ¡ 50% ¡ 60% ¡ 70% ¡ 80% ¡ 90% ¡ 100% ¡

findu2ls ¡ diffu2ls ¡ binu2ls ¡ Covered ¡by ¡test ¡suite ¡ Not ¡covered ¡

3 ¡

slide-4
SLIDE 4

4 ¡

slide-5
SLIDE 5

Example: ¡Tes2ng ¡diffu2ls ¡

$ ls diffutils config.sh build.sh regression-test.sh $ cat config.sh REPO="git://git.savannah.gnu.org/diffutils.git" DIFFTARGETS="src lib" PROGRAMS="src/diff src/diff3 src/sdiff src/cmp" LIBS="-lrt" $ katch diffutils 0 100

5 ¡

slide-6
SLIDE 6

High-­‑Level ¡Idea ¡

  • Synthesize ¡inputs ¡which ¡execute ¡the ¡patch ¡

code ¡

  • Given ¡a ¡program ¡loca2on ¡(e.g. ¡file ¡name, ¡line ¡

number), ¡synthesize ¡an ¡input ¡which ¡executes ¡ that ¡loca2on ¡

6 ¡

slide-7
SLIDE 7

High-­‑Level ¡Approach ¡

  • Concrete/Symbolic ¡execu2on ¡mix ¡+ ¡heuris2cs ¡
  • Seeded ¡with ¡exis2ng ¡inputs ¡from ¡the ¡

regression ¡test ¡suites ¡

7 ¡

slide-8
SLIDE 8

System ¡Overview ¡

8 ¡

Patch ¡ Preprocessing ¡ Input ¡ Selec4on ¡ Symbolic ¡ Execu4on ¡ Greedy ¡ Explora2on ¡ Defini2on ¡ Switching ¡ Informed ¡Path ¡ Regenera2on ¡

Program, ¡ Patch, ¡ Test ¡suite ¡ New ¡ program ¡ inputs ¡

KATCH ¡

slide-9
SLIDE 9

Patch ¡Preprocessing ¡

Index: src/mod_accesslog.c ==========================================

  • -- src/mod_accesslog.c

(revision 2659) +++ src/mod_accesslog.c (revision 2660) @@ -156,6 +156,13 @@

void log(char input) { int file = open(”access.log”, ...); + if (input >= ’␣’ && + input <= ’~’) { // printable characters write(file, &input, 1); + } else { + char escinput; + escinput = escape(input); + write(file, &escinput, 1); + } close(file); }

TARGET ¡1 ¡

src/mod_accesslog.c:164

9 ¡

slide-10
SLIDE 10

Input ¡Selec2on ¡

  • Rank ¡exis2ng ¡inputs ¡based ¡on ¡how ¡‘easy’ ¡it ¡is ¡

to ¡change ¡them ¡to ¡execute ¡the ¡patch ¡

  • Op2miza2on ¡
  • Lightweight ¡

10 ¡

slide-11
SLIDE 11

Input ¡Selec2on ¡

Input ¡A ¡ Input ¡B ¡

Example ¡control-­‑flow ¡graph ¡

– ¡distance ¡4 ¡ – ¡distance ¡2 ¡

11 ¡

slide-12
SLIDE 12

Concrete/Symbolic ¡Execu2on ¡

  • Itera2ve ¡refinement ¡of ¡the ¡ini2al ¡input ¡
  • Get ¡‘closer’ ¡to ¡the ¡target ¡at ¡each ¡itera2on ¡
  • Symbolic ¡execu2on ¡+ ¡path ¡selec2on ¡heuris2cs ¡

12 ¡

slide-13
SLIDE 13

lighfpd ¡r2660: ¡patch ¡ modifies ¡log() ¡to ¡escape ¡ sensi2ve ¡characters ¡

Greedy ¡Explora2on ¡Step ¡

void log(char input) { int file = open(”access.log”, …); if (input >= ’␣’ && input <= ’~’) { // printable characters write(file, &input, 1); + } else { + char escinput = escape(input); + write(file, &escinput, 1); + } close(file); }

13 ¡

slide-14
SLIDE 14

Available ¡input: ¡“t” ¡ (or ¡any ¡printable ¡char) ¡

  • 1. Greedy ¡step: ¡

choose ¡the ¡ symbolic ¡branch ¡ whose ¡unexplored ¡ side ¡is ¡closest ¡to ¡the ¡

  • patch. ¡
  • 2. Explore ¡this ¡side! ¡

¡

Greedy ¡Explora2on ¡Step ¡

void log(char input) { int file = open(”access.log”, …); if (input >= ’␣’ && input <= ’~’) { // printable characters write(file, &input, 1); + } else { + char escinput = escape(input); + write(file, &escinput, 1); + } close(file); }

14 ¡

slide-15
SLIDE 15

void log(char input) { if (input >= ’␣’ && input <= ’~’) { . . . } else { + . . . } } if (0 == strcmp(request, “GET”) . . . for (char* p = request; *p; p++) log(*p);

Available ¡input: ¡“GET” ¡

  • 1. Backtrack ¡to ¡the ¡

symbolic ¡branch ¡ that ¡disallows ¡this ¡ side ¡to ¡be ¡executed ¡

  • 2. Explore ¡the ¡other ¡

side ¡of ¡that ¡branch ¡ ¡

Informed ¡Path ¡Regenera2on ¡

Greedy ¡step ¡fails! ¡ request[2] ¡≠ ¡‘T’ ¡

15 ¡

slide-16
SLIDE 16

enum escape_t escape; void log(char input) { if (escape == ESCAPE_ALL) { + . . . } }

  • pt = getopt_long(argc, argv, ...);

switch (opt) { case ‘a’: escape = ESCAPE_SPACE; break; case ‘b’: escape = ESCAPE_ALL; . . . log(. . .);

Available ¡test: ¡opt ¡= ¡‘a’ ¡ 1. Find ¡all ¡reaching ¡ defini2ons ¡for ¡the ¡ variables ¡involved ¡and ¡try ¡ to ¡cover ¡another ¡one ¡ 2. Favors ¡defini2ons ¡that ¡ can ¡be ¡sta2cally ¡shown ¡to ¡ sa2sfy ¡target, ¡or ¡ unexecuted ¡defini2ons ¡

Defini2on ¡Switching ¡

Backtracking ¡step ¡fails! ¡ Patch ¡guarded ¡by ¡concrete ¡ branch ¡

16 ¡

slide-17
SLIDE 17

Evalua2on ¡

0 ¡ 20 ¡ 40 ¡ 60 ¡ 80 ¡ 100 ¡ 120 ¡ Added/modified ¡executable ¡basic ¡blocks ¡ findu2ls ¡ diffu2ls ¡ binu2ls ¡

2010 ¡ 2011 ¡ 2012 ¡ 2013 ¡

114 ¡executable ¡patches ¡ 1362 ¡targets ¡

17 ¡

slide-18
SLIDE 18

Coverage ¡Improvement ¡

0% ¡ 10% ¡ 20% ¡ 30% ¡ 40% ¡ 50% ¡ 60% ¡ 70% ¡ 80% ¡ 90% ¡ 100% ¡

findu2ls ¡ diffu2ls ¡ binu2ls ¡

Covered ¡by ¡test ¡suite ¡ Covered ¡by ¡KATCH ¡ Not ¡covered ¡

18 ¡

slide-19
SLIDE 19

Bugs ¡Found ¡

15 ¡Crash ¡Bugs ¡

6 ¡bugs ¡in ¡patch ¡code ¡ 5 ¡bugs ¡close ¡to ¡patch ¡code ¡ 4 ¡bugs ¡ unknown ¡ causal ¡rela2on ¡

19 ¡

slide-20
SLIDE 20

Bugs ¡Found ¡

12 ¡ 2 ¡ 1 ¡

Already ¡fixed ¡in ¡ the ¡last ¡version ¡ Reported ¡and ¡fixed ¡ Reported ¡and ¡pending ¡

20 ¡

slide-21
SLIDE 21

Automa2c ¡Patch ¡Tes2ng ¡

Prac2cal ¡autonomous ¡tes2ng ¡system ¡ ¡ Coverage ¡improvement ¡and ¡bug ¡finding ¡ ¡ Short ¡ar2fact* ¡presenta2on ¡on ¡Friday ¡ hfp://srg.doc.ic.ac.uk/projects/katch/ ¡

*Successfully ¡evaluated ¡by ¡the ¡ESEC/FSE ¡ar2fact ¡evalua2on ¡commifee ¡

21 ¡

slide-22
SLIDE 22

Selected ¡Related ¡Work ¡

  • Directed ¡Test ¡Suite ¡Augmenta2on ¡(APSEC’09, ¡FSE’10) ¡
  • Directed ¡Symbolic ¡Execu2on ¡(SAS’11) ¡
  • Differen2al ¡Symbolic ¡Execu2on ¡(FSE’08) ¡
  • Directed ¡Incremental ¡Sym

¡bolic ¡Execu2on ¡(PLDI’11) ¡

22 ¡

slide-23
SLIDE 23

Heuris2c ¡Contribu2on ¡

Suite ¡ Greedy ¡ Greedy+IPR ¡ Greedy+DS ¡ KATCH ¡ findu2ls ¡ 74 ¡ 85 ¡ 78 ¡ 85 ¡ diffu2ls ¡ 25 ¡ 29 ¡ 49 ¡ 63 ¡ binu2ls ¡ 70 ¡ 121 ¡ 76 ¡ 135 ¡ Total ¡ 169 ¡ 235 ¡ 203 ¡ 283 ¡

IPR ¡= ¡Informed ¡Path ¡Regenera2on ¡ DS ¡ ¡= ¡Defini2on ¡Switching ¡

23 ¡