Krace: Data Race Fuzzing for Kernel File Systems Meng Xu , Sanidhya - - PowerPoint PPT Presentation

krace data race fuzzing
SMART_READER_LITE
LIVE PREVIEW

Krace: Data Race Fuzzing for Kernel File Systems Meng Xu , Sanidhya - - PowerPoint PPT Presentation

Introduction Title Krace: Data Race Fuzzing for Kernel File Systems Meng Xu , Sanidhya Kashyap, Hanqing Zhao, Taesoo Kim May 1, 2020 Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems 1 May 1, 2020 Introduction Data


slide-1
SLIDE 1

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

May 1, 2020

Krace: Data Race Fuzzing

for Kernel File Systems

1

Meng Xu, Sanidhya Kashyap, Hanqing Zhao, Taesoo Kim

Introduction Title

slide-2
SLIDE 2

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

Let’s talk about data race

2 Introduction Data race concept

Definition: Two memory accesses from different threads such that

  • 1. They access the same memory location
  • 2. At least one of them is a write operation
  • 3. They may interleave without restrictions (i.e., locks, orderings, etc)
slide-3
SLIDE 3

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020 3 Introduction A classic data race example

The classic race condition example

for(i=0; i<50000; i++) { counter++; } counter = 0 Thread 1 Thread 2 for(i=0; i<50000; i++) { counter++; } What is the value of counter when both threads terminate? Any value between 50,000 to 100,000

slide-4
SLIDE 4

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020 4 Introduction A classic data race example

The classic race condition example

counter = 0 Thread 1 Thread 2 What is the value of counter when both threads terminate? for(i=0; i<50000; i++) { lock(mutex); counter++; unlock(mutex); } for(i=0; i<50000; i++) { lock(mutex); counter++; unlock(mutex); } 100,000

slide-5
SLIDE 5

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020 5 Introduction Kernel concurrency

High level of concurrency in the Linux kernel

22 threads run in the background!

slide-6
SLIDE 6

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020 6 Introduction A data race in the kernel

A data race in the kernel

Information lost! if (!p) p = kmalloc(...); p is a global pointer initialized to null Thread 1 Thread 2 if (!p) p = kmalloc(...);

slide-7
SLIDE 7

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020 7 Introduction A data race in the kernel

A data race in the kernel

Information lost! if (!p) p = kmalloc(...); p is a global pointer initialized to null Thread 1 Thread 2 if (!p) p = kmalloc(...);

This data race can be easily detected…

if we drive the execution into these code paths at runtime

slide-8
SLIDE 8

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020 8 Background Fuzzing in general

Fuzzing as a way to explore the program

1 2 3 4 5 6 7 8 9 Start End

slide-9
SLIDE 9

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

Code coverage as an approximation

9

1 2 3 4 5 6 7 8 9 Start End

  • pen(“some-file”, O_READ, ...)

Background Edge coverage

slide-10
SLIDE 10

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

Code coverage as an approximation

10

1 2 3 4 5 6 7 8 9 Start End

  • pen(“some-file”, O_READ, ...)
  • pen(“some-file”, O_WRITE, ...)

Background Edge coverage

slide-11
SLIDE 11

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

Code coverage as an approximation

11

1 2 3 4 5 6 7 8 9 Start End

  • pen(“some-file”, O_READ, ...)
  • pen(“some-file”, O_WRITE, ...)
  • pen(“new-file”, O_READ, ...)

Background Edge coverage

slide-12
SLIDE 12

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

Code coverage as an approximation

12

1 2 3 4 5 6 7 8 9 Start End

  • pen(“some-file”, O_READ, ...)
  • pen(“some-file”, O_WRITE, ...)
  • pen(“new-file”, O_READ, ...)

......

  • pen(“some-file”, O_RDWR, ...)

20 trials

Coverage growth stalled!

Background Edge coverage

slide-13
SLIDE 13

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

Code coverage as an approximation

13

1 2 3 4 5 6 7 8 9 Start End

  • pen(“some-file”, O_READ, ...)
  • pen(“some-file”, O_WRITE, ...)
  • pen(“new-file”, O_READ, ...)

......

  • pen(“some-file”, O_RDWR, ...)

20 trials rename(“new-file”, “old-file”)

10 11 12 13 14

Background Edge coverage

slide-14
SLIDE 14

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

The conventional fuzzing process

14

Syscall generator Test case Program executor Feedback

code coverage

Memory error

Crashed?

Background Existing kernel fuzzers

slide-15
SLIDE 15

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

The conventional fuzzing process

15

Syscall generator Test case Program executor Feedback

code coverage

Memory error

Crashed?

The code coverage metric backs all modern kernel fuzzers

including Syzkaller, kAFL, and their follow-ups, and is one of the key reason why over 200 memory errors were found and reported during the past few years!

Background Existing kernel fuzzers

slide-16
SLIDE 16

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

Back to our data race example

16

if (!p) p = kmalloc(...); p is a global pointer initialized to null Thread 1 Thread 2 if (!p) p = kmalloc(...);

*Assume sequential consistency.

Background Motivation

slide-17
SLIDE 17

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

Back to our data race example

17

if (!p) p = kmalloc(...); p is a global pointer initialized to null Thread 1 Thread 2 if (!p) p = kmalloc(...);

*Assume sequential consistency.

No CRASH when the data race is triggered!

Background Motivation

slide-18
SLIDE 18

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

Bring out data races explicitly with a checker

18

Syscall generator Test case Program executor Feedback

code coverage

Memory error

Crashed?

Data race checker Data race

Signaled?

Design Data race checker

slide-19
SLIDE 19

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

Checking data races - locking

19

Workqueue Syscall

W

lock

R

unlock lock unlock

Design Data race checker

Fork-style

  • Work queues
  • Kernel threads
  • RCU callbacks
  • Timer functions
  • Software-based interrupts
  • Inter-processor interrupts

Join-style

  • Wait_* (e.g., wait_event)
  • Semaphores

Publisher-subscriber

  • RCU pointer operations
slide-20
SLIDE 20

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

Checking data races - ordering (causality)

20

Timer Workqueue Syscall

W

delayed_work <timer start> <timer end> queue_work

R

<work start>

Design Data race checker

Fork-style

  • Work queues
  • Kernel threads
  • RCU callbacks
  • Timer functions
  • Software-based interrupts
  • Inter-processor interrupts

Join-style

  • Wait_* (e.g., wait_event)
  • Semaphores

Publisher-subscriber

  • RCU pointer operations
slide-21
SLIDE 21

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

Bring out data races explicitly with a checker

21

Syscall generator Test case Program executor Feedback

code coverage

Memory error

Crashed?

Data race checker Data race

Signaled?

Design Data race checker

slide-22
SLIDE 22

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

A slightly complicated data race

22

sys_readlink(path, ...): global A = 1; local x; if (IS_DIR(path)) { x = A + 1; if (!G[x]) G[x] = kmalloc(...); } sys_truncate(size, ...): global A = 0; local y; if (size > 4096) { y = A * 2; if (!G[y]) G[y] = kmalloc(...); } G[…] is all null at initialization Thread 1 Thread 2

*Assume sequential consistency.

Design Interactions between threads

slide-23
SLIDE 23

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

A slightly complicated data race

23

sys_readlink(path, ...): global A = 1; local x; if (IS_DIR(path)) { x = A + 1; if (!G[x]) G[x] = kmalloc(...); } sys_truncate(size, ...): global A = 0; local y; if (size > 4096) { y = A * 2; if (!G[y]) G[y] = kmalloc(...); } G[…] is all null at initialization Thread 1 Thread 2

*Assume sequential consistency.

Design Interactions between threads

slide-24
SLIDE 24

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

Case simplified

24

A = 1; x = A + 1; Thread 1 A = 0; y = A * 2; Thread 2 Can we reach x == y?

Design Interactions between threads

slide-25
SLIDE 25

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

Case simplified

25

A = 1; x = A + 1; Thread 1 A = 0; y = A * 2; Thread 2 Can we reach x == y? A = 0; A = 1; x = A + 1; y = A * 2; A = 0; A = 1; x = A + 1; y = A * 2; A = 0; A = 1; x = A + 1; y = A * 2; x = 2, y = 0 x = 1, y = 0 x = 1, y = 0 A = 0; A = 1; x = A + 1; y = A * 2; A = 0; A = 1; x = A + 1; y = A * 2; A = 0; A = 1; x = A + 1; y = A * 2; x = 2, y = 0 x = 2, y = 2 x = 2, y = 2

Design Interactions between threads

slide-26
SLIDE 26

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

All interleavings yield to the same code coverage!

26

A = 0; A = 1; x = A + 1; y = A * 2; A = 0; A = 1; x = A + 1; y = A * 2; A = 0; A = 1; x = A + 1; y = A * 2; x = 2, y = 0 x = 1, y = 0 x = 1, y = 0 A = 0; A = 1; x = A + 1; y = A * 2; A = 0; A = 1; x = A + 1; y = A * 2; A = 0; A = 1; x = A + 1; y = A * 2; x = 2, y = 0 x = 2, y = 2 x = 2, y = 2

global A = 1; local x; if (IS_DIR(path)) x = A + 1; if (!G[x]) G[x] = kmalloc(...); ... global A = 0; local y; if (size > 4096) y = A * 2; if (!G[y]) G[y] = kmalloc(...); ...

Design Interactions between threads

slide-27
SLIDE 27

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

Incompleteness of CFG edge coverage

27 Design Missing information in edge coverage

slide-28
SLIDE 28

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

A multi-dimensional view of coverage in fuzzing

28 Design Alias coverage

Edge-coverage only Krace

slide-29
SLIDE 29

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

Visualizing the concurrency dimension

29 Design Alias coverage

slide-30
SLIDE 30

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

Visualizing the concurrency dimension

30 Design Alias coverage

Edge-coverage only Krace

slide-31
SLIDE 31

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

Bring fuzzing to the concurrency dimension

31

Syscall generator Test case Program executor Feedback

code coverage

Data race checker Memory error

Crashed?

Data race

Signaled?

Design Alias coverage

slide-32
SLIDE 32

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

Bring fuzzing to the concurrency dimension

32

Syscall generator Test case Program executor Feedback

code coverage

Data race checker

concurrency coverage

Memory error

Crashed?

Data race

Signaled?

Design Alias coverage

slide-33
SLIDE 33

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

Bring fuzzing to the concurrency dimension

33

Syscall generator Test case Program executor Feedback

code coverage

Data race checker Interleaving generator

concurrency coverage

Memory error

Crashed?

Data race

Signaled?

Design Alias coverage

slide-34
SLIDE 34

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

Concurrency coverage tracking

34

Syscall generator Test case Program executor Feedback

code coverage

Data race checker Interleaving generator

concurrency coverage

Memory error

Crashed?

Data race

Signaled?

Design Alias coverage

slide-35
SLIDE 35

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

A straw-man solution

sys_readlink(path, ...): global A = 1; local x; if (IS_DIR(path)) { x = A + 1; if (G[x]) kmalloc(...); } sys_truncate(size, ...): global A = 0; local y; if (size > 4096) { y = A * 2; if (G[y]) kmalloc(...); } Thread 1 Thread 2

35

i1 i2 i3 i4 i5 i6 i7 i8 i9 i10 i11 i12

Design Alias coverage

slide-36
SLIDE 36

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

A straw-man solution

sys_readlink(path, ...): global A = 1; local x; if (IS_DIR(path)) { x = A + 1; if (G[x]) kmalloc(...); } sys_truncate(size, ...): global A = 0; local y; if (size > 4096) { y = A * 2; if (G[y]) kmalloc(...); } Thread 1 Thread 2 global A = 1; global A = 0; local y; local x; if (IS_DIR(path)) { if (size > 4096) { x = A + 1; y = A * 2; if(G[x]) if (G[y]) kmalloc(...); } kmalloc(...); } A possible interleaving

36

i1 i2 i3 i4 i5 i6 i7 i8 i9 i10 i11 i12 i1 i7 i8 i9 i2 i3 i4 i10 i5 i6 i11 i12

Design Alias coverage

slide-37
SLIDE 37

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

A straw-man solution

sys_readlink(path, ...): global A = 1; local x; if (IS_DIR(path)) { x = A + 1; if (G[x]) kmalloc(...); } sys_truncate(size, ...): global A = 0; local y; if (size > 4096) { y = A * 2; if (G[y]) kmalloc(...); } Thread 1 Thread 2 global A = 1; global A = 0; local y; local x; if (IS_DIR(path)) { if (size > 4096) { x = A + 1; y = A * 2; if(G[x]) if (G[y]) kmalloc(...); } kmalloc(...); }

37

i1 i2 i3 i4 i5 i6 i7 i8 i9 i10 i11 i12 i1 i7 i8 i9 i2 i3 i4 i10 i5 i6 i11 i12

if (IS_DIR(path)) { if (size > 4096) { Hash(i1, i7, i8, i2, i3, i9, i4, i10, i5, i11, i12, i6) = 7825 Hash(i1, i7, i8, i2, i9, i3, i4, i10, i5, i11, i12, i6) = 1356

Design Alias coverage

slide-38
SLIDE 38

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

A straw-man solution

sys_readlink(path, ...): global A = 1; local x; if (IS_DIR(path)) { x = A + 1; if (G[x]) kmalloc(...); } sys_truncate(size, ...): global A = 0; local y; if (size > 4096) { y = A * 2; if (G[y]) kmalloc(...); } Thread 1 Thread 2 global A = 1; global A = 0; local y; local x; if (IS_DIR(path)) { if (size > 4096) { x = A + 1; y = A * 2; if(G[x]) if (G[y]) kmalloc(...); } kmalloc(...); } A possible interleaving

38

i1 i2 i3 i4 i5 i6 i7 i8 i9 i10 i11 i12 i1 i7 i8 i9 i2 i3 i4 i10 i5 i6 i11 i12

Number of possible interleavings of two threads

If two threads have and instructions respectively, then the number interleavings between them is given by:

m n

(m + n)! m! × n!

m = n = 2

6

m = n = 4

70

m = n = 8

13K

m = n = 16

601M

Design Alias coverage

slide-39
SLIDE 39

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

Observations on practical interleaving tracking

39

Thread 1 Thread 2

Design Alias coverage

slide-40
SLIDE 40

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

Observations on practical interleaving tracking

40

Thread 1 Thread 2

Only interleaved accesses to shared memory matters

  • In an extreme case where two threads do not shared

memory, they interleaving does not matter at all.

Only interleaved read-write accesses to shared memory locations matters

  • In an extreme case where two threads only read from

shared memory, they interleaving does not matter at all.

Thread interleaving alters the def-use relation of memory locations!

Design Alias coverage

slide-41
SLIDE 41

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

Observations on practical interleaving tracking

41

Thread 1 Thread 2

R R

x = A + 1 y = A * 2

Only interleaved accesses to shared memory matters

  • In an extreme case where two threads do not shared

memory, they interleaving does not matter at all.

Only interleaved read-write accesses to shared memory locations matters

  • In an extreme case where two threads only read from

shared memory, they interleaving does not matter at all.

Thread interleaving alters the def-use relation of memory locations!

Design Alias coverage

slide-42
SLIDE 42

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

Observations on practical interleaving tracking

42

Thread 1 Thread 2

R

x = A + 1

W

A = 1

W

A = 0

Only interleaved accesses to shared memory matters

  • In an extreme case where two threads do not shared

memory, they interleaving does not matter at all.

Only interleaved read-write accesses to shared memory locations matters

  • In an extreme case where two threads only read from

shared memory, they interleaving does not matter at all.

Thread interleaving alters the def-use relation of memory locations!

Design Alias coverage

slide-43
SLIDE 43

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

Observations on practical interleaving tracking

43

Thread 1 Thread 2

R

x = A + 1

W

A = 1

W

A = 0

Only interleaved accesses to shared memory matters

  • In an extreme case where two threads do not shared

memory, they interleaving does not matter at all.

Only interleaved read-write accesses to shared memory matters

  • In an extreme case where two threads only read from

shared memory, they interleaving does not matter at all.

Thread interleaving alters the def-use relation of memory locations!

Interleaving approximation

Track cross-thread write-to-read (def-to-use) edges!

Design Alias coverage

slide-44
SLIDE 44

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

Observations on practical interleaving tracking

44

Only interleaved accesses to shared memory matters

  • In an extreme case where two threads do not shared

memory, they interleaving does not matter at all.

Only interleaved read-write accesses to shared memory matters

  • In an extreme case where two threads only read from

shared memory, they interleaving does not matter at all.

Thread interleaving alters the def-use relation of memory locations!

Interleaving approximation

Track cross-thread write-to-read (def-to-use) edges!

Design Alias coverage

slide-45
SLIDE 45

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

Aliased-instruction coverage

45

Thread 1 Thread 2

R

x = A + 1

W

A = 1

W

A = 0

i1 i2 i3

i2 i3

Design Alias coverage

slide-46
SLIDE 46

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

Aliased-instruction coverage

46

Thread 1 Thread 2

R

x = A + 1

W

A = 1

W

A = 0

W

B = 2

R

y = B * 4

i1 i2 i3 i4 i5

i2 i5, i4 i3

→ →

Design Alias coverage

slide-47
SLIDE 47

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

Aliased-instruction coverage

47

Thread 1 Thread 2

R

x = A + 1

W

A = 1

W

A = 0

W

B = 2

R

y = B * 4

i1 i2 i3 i4 i5

i2 i5, i4 i3

→ →

Concurrency coverage bitmap size

During our experiment, we observed 63,590 unique cross-thread, write-to-read edges. a bitmap size of 128KB will be sufficient.

Design Alias coverage

slide-48
SLIDE 48

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

Concurrency coverage tracking

48

Syscall generator Test case Program executor Feedback

code coverage

Data race checker Interleaving generator

concurrency coverage

Memory error

Crashed?

Data race

Signaled?

Design Alias coverage

slide-49
SLIDE 49

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

Interleaving exploration

49

Syscall generator Test case Program executor Feedback

code coverage

Data race checker Interleaving generator

concurrency coverage

Memory error

Crashed?

Data race

Signaled?

Design Interleaving generation

slide-50
SLIDE 50

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

Active interleaving exploration - ideal case

50

A = 1; x = A + 1; Thread 1 A = 0; y = A * 2; Thread 2 A = 0; A = 1; x = A + 1; y = A * 2; A = 0; A = 1; x = A + 1; y = A * 2; A = 0; A = 1; x = A + 1; y = A * 2; x = 2, y = 0 x = 1, y = 0 x = 1, y = 0 A = 0; A = 1; x = A + 1; y = A * 2; A = 0; A = 1; x = A + 1; y = A * 2; A = 0; A = 1; x = A + 1; y = A * 2; x = 2, y = 0 x = 2, y = 2 x = 2, y = 2

i3 i4 i1 i2

<nil> i3 i2

i3 i2

<nil> i1 i4

i1 i4

Design Interleaving generation

slide-51
SLIDE 51

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

Active interleaving exploration - ideal case

51

A = 1; x = A + 1; Thread 1 A = 0; y = A * 2; Thread 2 A = 0; A = 1; x = A + 1; y = A * 2; A = 0; A = 1; x = A + 1; y = A * 2; A = 0; A = 1; x = A + 1; y = A * 2; x = 2, y = 0 x = 1, y = 0 x = 1, y = 0 A = 0; A = 1; x = A + 1; y = A * 2; A = 0; A = 1; x = A + 1; y = A * 2; A = 0; A = 1; x = A + 1; y = A * 2; x = 2, y = 0 x = 2, y = 2 x = 2, y = 2

i3 i4 i1 i2

<nil> i3 i2

i3 i2

<nil> i1 i4

i1 i4

Enumerating all interleaving among all kernel threads is impossible

During our experiment, we observed at maximum 60 threads running concurrently. Assume each thread have only 10 shared memory accesses possibilities.

⟶ 1060

Design Interleaving generation

slide-52
SLIDE 52

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

Active interleaving exploration through delay injection

52

T1 T2 T3 T4

R W W R i1 i2 i3 i4

Concurrency coverage

Design Interleaving generation

slide-53
SLIDE 53

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

Active interleaving exploration through delay injection

53

T1 T2 T3 T4

R R W W i1 i2 i3 i4

d(669) d(300) d(273) d(20)

R W W R

Concurrency coverage

Design Interleaving generation

slide-54
SLIDE 54

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

Active interleaving exploration through delay injection

54

T1 T2 T3 T4

R R W W i1 i2 i3 i4

d(669) d(300) d(273) d(20) Concurrency coverage

Design Interleaving generation

slide-55
SLIDE 55

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

Active interleaving exploration through delay injection

55

T1 T2 T3 T4

R R W W i1 i2 i3 i4

d(669) d(300) d(273) d(20) Concurrency coverage

Inject delays only at instructions that have shared memory accesses

Design Interleaving generation

slide-56
SLIDE 56

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

Interleaving exploration

56

Syscall generator Test case Program executor Feedback

code coverage

Data race checker Interleaving generator

concurrency coverage

Memory error

Crashed?

Data race

Signaled?

Design Interleaving generation

slide-57
SLIDE 57

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

Bring them all together

57

Syscall generator Test case Program executor Feedback

code coverage

Data race checker Interleaving generator

concurrency coverage

Memory error

Crashed?

Data race

Signaled?

Design Summary

slide-58
SLIDE 58

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

QEMU-based implementation

58 Implementation Summary

slide-59
SLIDE 59

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

Alias coverage growth will be saturating

59 Evaluation Coverage

Btrfs Ext4 But file systems that are higher in concurrency level saturates much slower!

slide-60
SLIDE 60

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

Edge and alias coverage goes generally in synchronization

60 Evaluation Coverage

Btrfs Ext4 But there will be time when the edge coverage saturates but alias coverage keeps finding new thread interleaving

slide-61
SLIDE 61

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

Slightly more branch coverage than Syzkaller

61 Evaluation Coverage

Btrfs Ext4 This maybe due to the fact that we give each seed more chances (if they make progresses in alias coverage)

slide-62
SLIDE 62

Meng Xu (Georgia Tech) Krace: Data Race Fuzzing for Kernel File Systems May 1, 2020

Bugs found by Krace

62 Evaluation Bugs

File system # data races # harmful confirmed

Btrfs 11 8 Ext4 4 1 VFS 8 2

Total 23 11

slide-63
SLIDE 63

Meng Xu (Georgia Tech) Finding Semantic Bugs in Kernels March 18, 2020

Conclusion and contribution

63

Structured input Seed selection Application Coverage metric

[SP’19] Janus [ICSE’19] DifFuzz [VLDB’20] Apollo [CCS’17] SlowFuzz …… [ICSE’19] SLF …… [Google] Syzkaller [FSE’19] Fudge …… [ASE’18] FairFuzz [CCS’16] AFLFast [SP’18] Angora [SP’20] Krace [RAID’19] Benchmark

slide-64
SLIDE 64

Meng Xu (Georgia Tech) Finding Semantic Bugs in Kernels March 18, 2020

Conclusion and contribution

64

Structured input Seed selection Application Coverage metric

[SP’19] Janus [ICSE’19] DifFuzz [VLDB’20] Apollo [CCS’17] SlowFuzz …… [ICSE’19] SLF …… [Google] Syzkaller [FSE’19] Fudge …… [ASE’18] FairFuzz [CCS’16] AFLFast [SP’18] Angora [SP’20] Krace [RAID’19] Benchmark