Finding Semantic Bugs in File Systems with an Extensible Fuzzing Framework
Seulbae Kim, Meng Xu*, Sanidhya Kashyap*, Jungyeon Yoon, Wen Xu, Taesoo Kim
* On the job market
Finding Semantic Bugs in File Systems with an Extensible Fuzzing - - PowerPoint PPT Presentation
Finding Semantic Bugs in File Systems with an Extensible Fuzzing Framework Seulbae Kim, Meng Xu * , Sanidhya Kashyap * , Jungyeon Yoon, Wen Xu, Taesoo Kim * On the job market Demonstration Fuzzing F2FS in Linux v5.0-rc7 for crash consistency
Seulbae Kim, Meng Xu*, Sanidhya Kashyap*, Jungyeon Yoon, Wen Xu, Taesoo Kim
* On the job market
2
3
4
5
39 KLoC 98 KLoC 94 KLoC
39 KLoC 98 KLoC 94 KLoC
6
7
39 KLoC 98 KLoC 94 KLoC
8
!
! !
!
9
Linux Test Project xfstests fsck FSCQ Yggdrasil DFSCQ SFSCQ (SOSP’15) (OSDI’16) (SOSP’17) (OSDI’18) FiSC eXplode Juxta Ferrite B3 (OSDI’04) (OSDI’06) (SOSP’15) (ASPLOS’16) (OSDI’18) Syzkaller kAFL Janus (Google) (Security’17) (S&P’19)
10
Linux Test Project xfstests fsck Only test known cases FSCQ Yggdrasil DFSCQ SFSCQ (SOSP’15) (OSDI’16) (SOSP’17) (OSDI’18) FiSC eXplode Juxta Ferrite B3 (OSDI’04) (OSDI’06) (SOSP’15) (ASPLOS’16) (OSDI’18) Syzkaller kAFL Janus (Google) (Security’17) (S&P’19)
11
Linux Test Project xfstests fsck Only test known cases High false positive Limited to known test cases FSCQ Yggdrasil DFSCQ SFSCQ (SOSP’15) (OSDI’16) (SOSP’17) (OSDI’18) FiSC eXplode Juxta Ferrite B3 (OSDI’04) (OSDI’06) (SOSP’15) (ASPLOS’16) (OSDI’18) Syzkaller kAFL Janus (Google) (Security’17) (S&P’19)
12
Linux Test Project xfstests fsck Only test known cases High false positive Limited to known test cases
Large unverified parts (buggy)
FSCQ Yggdrasil DFSCQ SFSCQ (SOSP’15) (OSDI’16) (SOSP’17) (OSDI’18) FiSC eXplode Juxta Ferrite B3 (OSDI’04) (OSDI’06) (SOSP’15) (ASPLOS’16) (OSDI’18) Syzkaller kAFL Janus (Google) (Security’17) (S&P’19)
13
Linux Test Project xfstests fsck FiSC eXplode Juxta Ferrite B3 Only test known cases High false positive Limited to known test cases
Large unverified parts (buggy) ?
(OSDI’04) (OSDI’06) (SOSP’15) (ASPLOS’16) (OSDI’18) FSCQ Yggdrasil DFSCQ SFSCQ (SOSP’15) (OSDI’16) (SOSP’17) (OSDI’18) FiSC eXplode Juxta Ferrite B3 (OSDI’04) (OSDI’06) (SOSP’15) (ASPLOS’16) (OSDI’18) Syzkaller kAFL Janus (Google) (Security’17) (S&P’19)
■ kAFL (Security’17), Syzkaller (Google)
■ Janus (S&P’19) - our previous work!
14
🙃 🙃
■ kAFL (Security’17), Syzkaller (Google)
■ Janus (S&P’19) - our previous work!
15
🙃 🙃 Janus discovered 90 memory-safety bugs
■ kAFL (Security’17), Syzkaller (Google)
■ Janus (S&P’19) - our previous work!
16
🙃 🙃 Janus discovered 90 memory-safety bugs
17
*Reference: Lu, Lanyue, et al. “A study of Linux file system evolution.” FAST’13
18
*Reference: Lu, Lanyue, et al. “A study of Linux file system evolution.” FAST’13
19
*Reference: Lu, Lanyue, et al. “A study of Linux file system evolution.” FAST’13
20
FUZZER Target program
Fuzzing for memory-safety bugs
21
FUZZER Target program input
Fuzzing for memory-safety bugs
22
FUZZER Target program input
Fuzzing for memory-safety bugs
if BUG, crash
23
FUZZER Target program input
Fuzzing for memory-safety bugs
feedback (e.g., SIGSEGV)
if BUG, crash
24
FUZZER Target program input
Fuzzing for memory-safety bugs
feedback (e.g., SIGSEGV) FUZZER Target program if BUG, crash
Fuzzing for semantic bugs (e.g., spec. violation)
25
FUZZER Target program input
Fuzzing for memory-safety bugs
feedback (e.g., SIGSEGV) FUZZER Target program input if BUG, crash
Fuzzing for semantic bugs (e.g., spec. violation)
26
FUZZER Target program input
Fuzzing for memory-safety bugs
feedback (e.g., SIGSEGV) FUZZER Target program input
Fuzzing for semantic bugs (e.g., spec. violation)
if BUG, function returns a wrong value internally if BUG, crash
27
FUZZER Target program input
Fuzzing for memory-safety bugs
if BUG, crash feedback (e.g., SIGSEGV) FUZZER Target program
Fuzzing for semantic bugs (e.g., spec. violation)
input if BUG, function returns a wrong value internally
28
FUZZER Target program input
Fuzzing for memory-safety bugs
if BUG, crash feedback (e.g., SIGSEGV) FUZZER Target program
Fuzzing for semantic bugs (e.g., spec. violation)
input
Checker if BUG, function returns a wrong value internally feedback
29
FUZZER Target program input
Fuzzing for memory-safety bugs
if BUG, crash feedback (e.g., SIGSEGV) FUZZER Target program
Fuzzing for semantic bugs (e.g., spec. violation)
input
Retval checker if BUG, function returns a wrong value internally signal
30
31
Input generator Test case LibOS-based Test Executor Checker BUG! Feedback
32
Input generator Test case LibOS-based Test Executor Checker BUG! Feedback AFL variant*
* Fuzzing File Systems via Two-Dimensional Input Space Exploration - IEEE S&P 2019
33
Input generator Test case LibOS-based Test Executor Checker BUG! Feedback
* Fuzzing File Systems via Two-Dimensional Input Space Exploration - IEEE S&P 2019
AFL variant* FS image + System calls
34
Input generator Test case LibOS-based Test Executor Checker BUG! Feedback
* Fuzzing File Systems via Two-Dimensional Input Space Exploration - IEEE S&P 2019
Mount img, exec syscalls AFL variant* FS image + System calls
35
Input generator Test case LibOS-based Test Executor Checker BUG! Feedback
* Fuzzing File Systems via Two-Dimensional Input Space Exploration - IEEE S&P 2019
FS image + System calls Check for bug AFL variant* Mount img, exec syscalls
36
Input generator Test case LibOS-based Test Executor Checker BUG! Feedback
* Fuzzing File Systems via Two-Dimensional Input Space Exploration - IEEE S&P 2019
FS image + System calls Check for bug AFL variant* Mount img, exec syscalls
37
Input generator Test case LibOS-based Test Executor Checker BUG! Feedback
38
Input generator Test case LibOS-based Test Executor Checker BUG! Feedback
39
Input generator Test case LibOS-based Test Executor Checker BUG! Feedback
40
Input generator Test case LibOS-based Test Executor BUG! Feedback Crash consistency bug Consistency checker e.g., SymC3
POSIX checker e.g., SibylFS Logic bug Built-in FS checks Memory safety bug Address sanitizer e.g., KASAN In-house developed checker Existing oracle, with few lines for integration In-kernel checker, used as is
41
Input generator Test case LibOS-based Test Executor BUG! Feedback Crash consistency bug Consistency checker e.g., SymC3
POSIX checker e.g., SibylFS Logic bug Built-in FS checks Memory safety bug Address sanitizer e.g., KASAN In-house developed checker Existing oracle, with few lines for integration In-kernel checker, used as is
42
(i.e., keeping in-memory and on-disk states, like real FS implementation)
43
(i.e., keeping in-memory and on-disk states, like real FS implementation)
44
Test case
(i.e., keeping in-memory and on-disk states, like real FS implementation)
45
Test case LibOS Executor
execute & crash
𝛿: Crash-recovered concrete state
(i.e., keeping in-memory and on-disk states, like real FS implementation)
46
Test case LibOS Executor SymC3
(states contain symbols)
execute & crash emulate
𝚻: Set of legit. states {state1, state2, …} 𝛿: Crash-recovered concrete state
(i.e., keeping in-memory and on-disk states, like real FS implementation)
47
Test case LibOS Executor SymC3 𝚻: Set of legit. states {state1, state2, …} 𝛿: Crash-recovered concrete state
(states contain symbols)
𝛿 ∈ 𝚻 ?
execute & crash emulate
Not bug Bug
True False
48
1 mkdir “A” 0775 2 sync 3 chmod “A” 0600 4 fsync “A”
49
1 mkdir “A” 0775 2 sync 3 chmod “A” 0600 4 fsync “A”
Tree i0 . In-memory i0.dents=[.] On-disk i0.dents=[.] i0 . Snapshots
50
Tree i0 . i1 A i0 . i0 . i1 A In-memory i0.dents=[., A] i1.dents=[.] i1.mode =[0775] On-disk i0.dents=[.] Snapshots
1 mkdir “A” 0775 2 sync 3 chmod “A” 0600 4 fsync “A”
51
Tree i0 . i1 A i0 . i0 . i1 A In-memory i0.dents=[., A] i1.dents=[.] i1.mode =[0775] On-disk i0.dents=[., A] i1.dents=[.] i1.mode =[0775] Snapshots
1 mkdir “A” 0775 2 sync 3 chmod “A” 0600 4 fsync “A”
52
Tree i0 . i1 A i0 . i0 . i1 A In-memory i0.dents=[., A] i1.dents=[.] i1.mode =[0775,0600] On-disk i0.dents=[., A] i1.dents=[.] i1.mode =[0775] Snapshots
1 mkdir “A” 0775 2 sync 3 chmod “A” 0600 4 fsync “A”
53
Tree i0 . i1 A i0 . i0 . i1 A In-memory i0.dents=[., A] i1.dents=[.] i1.mode =[0600] On-disk i0.dents=[., A] i1.dents=[.] i1.mode =[0600] Snapshots
1 mkdir “A” 0775 2 sync 3 chmod “A” 0600 4 fsync “A”
54
Tree i0 . i1 A i0 . i0 . i1 A In-memory i0.dents=[., A] i1.dents=[.] i1.mode =[0600] On-disk i0.dents=[., A] i1.dents=[.] i1.mode =[0600] Snapshots
1 mkdir “A” 0775 2 sync 3 chmod “A” 0600 4 fsync “A”
55
Snapshots i0 . i0 . i1 A [S1] [S0] In-memory i0.dents=[., A] i1.dents=[.] i1.mode =[0600] On-disk i0.dents=[., A] i1.dents=[.] i1.mode =[0600]
56
i0 . i0 . i1 A [S1] [S0] In-memory i0.dents=[., A] i1.dents=[.] i1.mode =[0600] On-disk i0.dents=[., A] i1.dents=[.] i1.mode =[0600] Drop S0 (i1 is persisted) Snapshots ./A must exist!
1. Check validity of snapshots
57
i0 . i0 . i1 A [S1] [S0] In-memory i0.dents=[., A] i1.dents=[.] i1.mode =[0600] On-disk i0.dents=[., A] i1.dents=[.] i1.mode =[0600] Snapshots
1. Check validity of snapshots
S1 is valid (does not violate persisted state)
58
i0 . i0 . i1 A [S1] [S0] In-memory i0.dents=[., A] i1.dents=[.] i1.mode =[0600] On-disk i0.dents=[., A] i1.dents=[.] i1.mode =[0600] [Post-crash state 1] i0 - name: . i1 - name: ./A mode: 0600 Snapshots
2. Generate possible crash states from valid snapshots
59
[Post-crash state 1] i0 - name: . i1 - name: ./A mode: 0600 Crashed F2FS image from Executor (𝛿) $ cd mnt_point $ stat A Access: (0775/drwxrwxr-x)
?
3. Check if the set of legitimate states 𝚻 has crashed state 𝛿 as a member
60
[Post-crash state 1] i0 - name: . i1 - name: ./A mode: 0600 Crashed F2FS image from Executor (𝛿) $ cd mnt_point $ stat A Access: (0775/drwxrwxr-x)
3. Check if the set of legitimate states 𝚻 has crashed state 𝛿 as a member
61
62
File System
(checker)
Crash Consistency
(SymC3)
Logic Bugs
(In-kernel checks)
(SibylFS)
ext4 1 1 Btrfs 4 7 2 F2FS 3 16 1 FSCQ 1
9 23 4
63
File System
(checker)
Crash Consistency
(SymC3)
Logic Bugs
(In-kernel checks)
(SibylFS)
ext4 1 1 Btrfs 4 7 2 F2FS 3 16 1 FSCQ 1
9 23 4 Bug: dir is lost upon crash, if another file is truncated Dev: “ftruncate was broken, and used an unverified helper function”
64
Logic bugs (102.8 exec/sec) Memory safety (98.4 exec/sec) Crash consistency (11.4 exec/sec) POSIX conformance (4.5 exec/sec) Checker overhead (ms) Throughput (exec/sec)
65
Logic bugs (102.8 exec/sec) Memory safety (98.4 exec/sec) Crash consistency (11.4 exec/sec) POSIX conformance (4.5 exec/sec) Checker overhead (ms) Throughput (exec/sec) VM-based approach (0.7 exec/sec)
66
Code coverage (12 hours) Hydra Syzkaller kAFL
67
Code coverage (12 hours) Hydra Syzkaller kAFL 1.6x 8.7x
68
Hydra B3
(used up all B3 test cases)
Code coverage (12 hours)
69
Hydra B3
(used up all B3 test cases)
Code coverage (12 hours)
B3’s enumerated test cases explore less code Hydra generates test cases on-the-fly
70
Hydra B3
(used up all B3 test cases)
Code coverage (12 hours)
B3’s enumerated test cases explore less code
Hydra generates test cases on-the-fly
71
72
73
This research is supported by