hfl: hybrid fuzzing on the linux kernel · hfl: hybrid fuzzing on the linux kernel calling...

57
HFL: Hybrid Fuzzing on the Linux Kernel Kyungtae Kim*, Dae R. Jeong°, Chung Hwan Kim , Yeongjin Jang § , Insik Shin°, Byoungyoung Lee ˥ * *Purdue University, ° KAIST, NEC Labs America, § Oregon State University, ˥ Seoul National University

Upload: others

Post on 09-Oct-2020

22 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

HFL: Hybrid Fuzzing on the Linux Kernel

Kyungtae Kim*, Dae R. Jeong°, Chung Hwan Kim¶,

Yeongjin Jang§, Insik Shin°, Byoungyoung Lee˥*

*Purdue University, °KAIST, ¶NEC Labs America, §Oregon State University, ˥Seoul National University

Page 2: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

Software Security Analysis

• Random fuzzing• Pros: Fast path exploration

• Cons: Strong branch conditions e.g., if(i == 0xdeadbeef)

• Symbolic/concolic execution• Pros: Generate concrete input for strong branch conditions

• Cons: State explosion

2

Page 3: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

Hybrid Fuzzing in General

• Combining traditional fuzzing and concolic execution• Fast exploration with fuzzing (no state explosion)

• Strong branches are handled with concolic execution

• State-of-the-arts• Intriguer [CCS’19], DigFuzz [NDSS’19], QSYM [Sec’18], etc.

• Application-level hybrid fuzzers

3

Page 4: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

Kernel Testing with Hybrid Fuzzing

• Software vulnerabilities are critical threats to OS kernels • 1,018 Linux kernel vulnerabilities reported in CVE over

the last 4 years

• Hybrid-fuzzing can help improve coverage and find more bugs in kernels.• A huge number of specific branches e.g., CAB-Fuzz[ATC’17],

DIFUZE[CCS’17]

4

Page 5: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

Kernel Testing with Hybrid Fuzzing

• Software vulnerabilities are critical threats to OS kernels • 1,018 Linux kernel vulnerabilities reported in CVE over

the last 4 years

• Hybrid-fuzzing can help improve coverage and find more bugs in kernels.• A huge number of specific branches e.g., CAB-Fuzz[ATC’17],

DIFUZE[CCS’17]

Q. Is hybrid-fuzzing good enough for kernel testing?

4

Page 6: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

Challenge 1: Indirect Control Transfer

ioctl_fn _ioctls[] = {ioctl_version,ioctl_protover,

...ioctl_ismountpoint,

};

idx = cmd - INFO_FIRST;...

funp = _ioctls[idx];…

funp (sbi, param);

5

<function pointer table><indirect function call>

derived from syscall arguments

Page 7: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

Challenge 1: Indirect Control Transfer

ioctl_fn _ioctls[] = {ioctl_version,ioctl_protover,

...ioctl_ismountpoint,

};

idx = cmd - INFO_FIRST;...

funp = _ioctls[idx];…

funp (sbi, param);

5

<function pointer table><indirect function call>

derived from syscall arguments

Page 8: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

Challenge 1: Indirect Control Transfer

ioctl_fn _ioctls[] = {ioctl_version,ioctl_protover,

...ioctl_ismountpoint,

};

idx = cmd - INFO_FIRST;...

funp = _ioctls[idx];…

funp (sbi, param);

5

<function pointer table><indirect function call>

derived from syscall arguments

Page 9: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

Challenge 1: Indirect Control Transfer

ioctl_fn _ioctls[] = {ioctl_version,ioctl_protover,

...ioctl_ismountpoint,

};

idx = cmd - INFO_FIRST;...

funp = _ioctls[idx];…

funp (sbi, param);

5

<function pointer table><indirect function call>

derived from syscall arguments

indirect control transfer

Page 10: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

Challenge 1: Indirect Control Transfer

ioctl_fn _ioctls[] = {ioctl_version,ioctl_protover,

...ioctl_ismountpoint,

};

idx = cmd - INFO_FIRST;...

funp = _ioctls[idx];…

funp (sbi, param);

5

<function pointer table><indirect function call>

derived from syscall arguments targets to be hit

indirect control transfer

Page 11: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

Challenge 1: Indirect Control Transfer

ioctl_fn _ioctls[] = {ioctl_version,ioctl_protover,

...ioctl_ismountpoint,

};

idx = cmd - INFO_FIRST;...

funp = _ioctls[idx];…

funp (sbi, param);

5

<function pointer table><indirect function call>

derived from syscall arguments targets to be hit

indirect control transfer

Page 12: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

Challenge 1: Indirect Control Transfer

ioctl_fn _ioctls[] = {ioctl_version,ioctl_protover,

...ioctl_ismountpoint,

};

idx = cmd - INFO_FIRST;...

funp = _ioctls[idx];…

funp (sbi, param);

Q. Can be fuzzed enough to explore

all functions?

5

<function pointer table><indirect function call>

derived from syscall arguments targets to be hit

indirect control transfer

Page 13: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

Challenge 2: System Call Dependencies

int open (const char *pathname, int flags, mode_t mode)ssize_t write (int fd, void *buf, size_t count)

ioctl (int fd, unsigned long req, void *argp)ioctl (int fd, unsigned long req, void *argp)

6

Page 14: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

Challenge 2: System Call Dependencies

int open (const char *pathname, int flags, mode_t mode)ssize_t write (int fd, void *buf, size_t count)

explicit syscalldependencies

ioctl (int fd, unsigned long req, void *argp)ioctl (int fd, unsigned long req, void *argp)

6

Page 15: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

Challenge 2: System Call Dependencies

int open (const char *pathname, int flags, mode_t mode)ssize_t write (int fd, void *buf, size_t count)

Q. What dependency behind?

explicit syscalldependencies

ioctl (int fd, unsigned long req, void *argp)ioctl (int fd, unsigned long req, void *argp)

6

Page 16: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

Example: System Call Dependencies

fd = open (…)ioctl (fd, D_ALLOC, arg1)ioctl (fd, D_BIND, arg2)

7

Page 17: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

Example: System Call Dependencies

fd = open (…)ioctl (fd, D_ALLOC, arg1)ioctl (fd, D_BIND, arg2)

ioctl (fd, cmd, arg):switch (cmd) {

case D_ALLOC: d_alloc (arg);case D_BIND: d_bind (arg);…

❶ first

ioctl

7

Page 18: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

d_alloc (struct d_alloc *arg):…arg->ID = g_var;…

Example: System Call Dependencies

fd = open (…)ioctl (fd, D_ALLOC, arg1)ioctl (fd, D_BIND, arg2)

ioctl (fd, cmd, arg):switch (cmd) {

case D_ALLOC: d_alloc (arg);case D_BIND: d_bind (arg);…

❶ first

ioctl ❷

7

Page 19: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

d_alloc (struct d_alloc *arg):…arg->ID = g_var;…

Example: System Call Dependencies

fd = open (…)ioctl (fd, D_ALLOC, arg1)ioctl (fd, D_BIND, arg2)

ioctl (fd, cmd, arg):switch (cmd) {

case D_ALLOC: d_alloc (arg);case D_BIND: d_bind (arg);…

struct d_allocs32 x; s32 ID;

❶ first

ioctl ❷

Write

7

Page 20: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

d_alloc (struct d_alloc *arg):…arg->ID = g_var;…

Example: System Call Dependencies

fd = open (…)ioctl (fd, D_ALLOC, arg1)ioctl (fd, D_BIND, arg2)

ioctl (fd, cmd, arg):switch (cmd) {

case D_ALLOC: d_alloc (arg);case D_BIND: d_bind (arg);…

struct d_allocs32 x; s32 ID;

❶ first

ioctl ❷

Write

copy_to_user

7

Page 21: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

d_alloc (struct d_alloc *arg):…arg->ID = g_var;…

Example: System Call Dependencies

fd = open (…)ioctl (fd, D_ALLOC, arg1)ioctl (fd, D_BIND, arg2)

ioctl (fd, cmd, arg):switch (cmd) {

case D_ALLOC: d_alloc (arg);case D_BIND: d_bind (arg);…

struct d_allocs32 x; s32 ID;

❶ first

ioctl

❸ second

ioctl ❷

Write

copy_to_user

7

Page 22: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

d_alloc (struct d_alloc *arg):…arg->ID = g_var;…

Example: System Call Dependencies

fd = open (…)ioctl (fd, D_ALLOC, arg1)ioctl (fd, D_BIND, arg2)

ioctl (fd, cmd, arg):switch (cmd) {

case D_ALLOC: d_alloc (arg);case D_BIND: d_bind (arg);…

struct d_allocs32 x; s32 ID;

d_bind (struct d_bind *arg):if (g_var != arg->ID)

return -EINVAL;/* main functionality */...

❶ first

ioctl

❸ second

ioctl ❷

Write

copy_to_user

7

Page 23: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

d_alloc (struct d_alloc *arg):…arg->ID = g_var;…

Example: System Call Dependencies

fd = open (…)ioctl (fd, D_ALLOC, arg1)ioctl (fd, D_BIND, arg2)

ioctl (fd, cmd, arg):switch (cmd) {

case D_ALLOC: d_alloc (arg);case D_BIND: d_bind (arg);…

struct d_allocs32 x; s32 ID;

struct d_binds32 ID; s32 y;

d_bind (struct d_bind *arg):if (g_var != arg->ID)

return -EINVAL;/* main functionality */...

❶ first

ioctl

❸ second

ioctl ❷

ReadWrite

copy_to_user

7

Page 24: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

d_alloc (struct d_alloc *arg):…arg->ID = g_var;…

Example: System Call Dependencies

fd = open (…)ioctl (fd, D_ALLOC, arg1)ioctl (fd, D_BIND, arg2)

ioctl (fd, cmd, arg):switch (cmd) {

case D_ALLOC: d_alloc (arg);case D_BIND: d_bind (arg);…

struct d_allocs32 x; s32 ID;

struct d_binds32 ID; s32 y;

d_bind (struct d_bind *arg):if (g_var != arg->ID)

return -EINVAL;/* main functionality */...

❶ first

ioctl

❸ second

ioctl ❷

Check IDwith g_var

ReadWrite

copy_to_user

7

Page 25: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

d_alloc (struct d_alloc *arg):…arg->ID = g_var;…

Example: System Call Dependencies

fd = open (…)ioctl (fd, D_ALLOC, arg1)ioctl (fd, D_BIND, arg2)

ioctl (fd, cmd, arg):switch (cmd) {

case D_ALLOC: d_alloc (arg);case D_BIND: d_bind (arg);…

struct d_allocs32 x; s32 ID;

struct d_binds32 ID; s32 y;

d_bind (struct d_bind *arg):if (g_var != arg->ID)

return -EINVAL;/* main functionality */...

❶ first

ioctl

❸ second

ioctl ❷

Q. Can be inferred exactly?

7

Page 26: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

d_alloc (struct d_alloc *arg):…arg->ID = g_var;…

Example: System Call Dependencies

fd = open (…)ioctl (fd, D_ALLOC, arg1)ioctl (fd, D_BIND, arg2)

ioctl (fd, cmd, arg):switch (cmd) {

case D_ALLOC: d_alloc (arg);case D_BIND: d_bind (arg);…

struct d_allocs32 x; s32 ID;

struct d_binds32 ID; s32 y;

d_bind (struct d_bind *arg):if (g_var != arg->ID)

return -EINVAL;/* main functionality */...

❶ first

ioctl

❸ second

ioctl ❷

Q. Can be inferred exactly?

7

Page 27: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

Challenge 3: Complex Argument Structure

ioctl (int fd, unsigned long cmd, void *argp)

write (int fd, void *buf, size_t count)

8

Page 28: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

Challenge 3: Complex Argument Structure

ioctl (int fd, unsigned long cmd, void *argp)

write (int fd, void *buf, size_t count)

unknown type

unknown type

8

Page 29: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

Example: Nested Arguments Structure

ioctl (fd, USB_X, arg)

9

Page 30: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

struct usbdev_ctrl ctrl; uchar *tbuf;

…copy_from_user (&ctrl, arg, sizeof(ctrl))

…copy_from_user (tbuf, ctrl.data, ctrl.len)

/* do main functionality */…

struct usbdev_ctrl:void *data;unsigned len;

Example: Nested Arguments Structure

ioctl (fd, USB_X, arg)

syscall

9

Page 31: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

struct usbdev_ctrl ctrl; uchar *tbuf;

…copy_from_user (&ctrl, arg, sizeof(ctrl))

…copy_from_user (tbuf, ctrl.data, ctrl.len)

/* do main functionality */…

struct usbdev_ctrl:void *data;unsigned len;

Example: Nested Arguments Structure

ioctl (fd, USB_X, arg)

syscall

9

src addr

dst addr

Page 32: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

struct usbdev_ctrl ctrl; uchar *tbuf;

…copy_from_user (&ctrl, arg, sizeof(ctrl))

…copy_from_user (tbuf, ctrl.data, ctrl.len)

/* do main functionality */…

struct usbdev_ctrl:void *data;unsigned len;

Example: Nested Arguments Structure

data lenarg:

arg.len

memory view

ioctl (fd, USB_X, arg)

syscall

9

src addr

dst addr

Page 33: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

struct usbdev_ctrl ctrl; uchar *tbuf;

…copy_from_user (&ctrl, arg, sizeof(ctrl))

…copy_from_user (tbuf, ctrl.data, ctrl.len)

/* do main functionality */…

struct usbdev_ctrl:void *data;unsigned len;

Example: Nested Arguments Structure

data lenarg:

arg.len

memory view

ioctl (fd, USB_X, arg)

syscall

Q. Can be inferred exactly?

9

src addr

dst addr

Page 34: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

HFL: Hybrid Fuzzing on the Linux Kernel

callingorders

argumentretrieval

candidatedependency

pairs

static analysis

convert

hybrid-fuzzing

SymbolicAnalyzer

Fuzzer

LinuxKernel

inputs

unsolved conds

ondemandexec

solved

*Linux

Kernel

inferfeedback

Agent

10

• The first hybrid kernel fuzzer

• Coverage-guided/system call fuzzer

• Hybrid fuzzing • Combining fuzzer and symbolic

analyzer

• Agent act as a glue between the two components

Page 35: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

HFL: Hybrid Fuzzing on the Linux Kernel

• Handling the challengescallingorders

argumentretrieval

candidatedependency

pairs

static analysis

convert

hybrid-fuzzing

SymbolicAnalyzer

Fuzzer

LinuxKernel

inputs

unsolved conds

ondemandexec

solved

*Linux

Kernel

inferfeedback

Agent

1. Implicit control transfer

• Convert to direct control-flow

2. System call dependencies

• Infer system call dependency

3. Complex argument structure

• Infer nested argument structure

10

Page 36: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

ioctl_fn _ioctls[] = {ioctl_version,ioctl_protover,

...ioctl_ismountpoint,

};

1. Conversion to Direct Control-flow

idx = cmd – INFO_FIRST;...

funp = _ioctls[idx];...

funp (sbi, param);

11

<Before>

Page 37: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

ioctl_fn _ioctls[] = {ioctl_version,ioctl_protover,

...ioctl_ismountpoint,

};

1. Conversion to Direct Control-flow

idx = cmd – INFO_FIRST;...

funp = _ioctls[idx];...

funp (sbi, param);

11

idx = cmd – INFO_FIRST;...

funp = _ioctls[idx];...

if (cmd == IOCTL_VERSION)ioctl_version (sbi, param);

else if (cmd == IOCTL_PROTO)ioctl_protover (sbi, param);

…ioctl_ismountpoint (sbi, param);

<Before> <After>

Compile time conversion:direct control transfer

Page 38: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

2. Syscall Dependency Inferencefd = open (…)ioctl (fd, D_ALLOC, {struct d_alloc})ioctl (fd, D_BIND, {struct d_bind})

❷ Runtime

validation

❸ Parameter

dependency

❶ Collecting

W-R pairs

12

Page 39: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

2. Syscall Dependency Inference

<instruction dependency pair>

W: g_varR: g_var

fd = open (…)ioctl (fd, D_ALLOC, {struct d_alloc})ioctl (fd, D_BIND, {struct d_bind})

❷ Runtime

validation

❸ Parameter

dependency

❶ Collecting

W-R pairs

12

❶ static

analysis

LinuxKernel

Page 40: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

2. Syscall Dependency Inference

<instruction dependency pair>

W: g_varR: g_var

fd = open (…)ioctl (fd, D_ALLOC, {struct d_alloc})ioctl (fd, D_BIND, {struct d_bind})

❷ Runtime

validation

❸ Parameter

dependency

❶ Collecting

W-R pairs

12

❶ static

analysis

LinuxKernel

symbolize

Page 41: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

d_bind (struct d_bind *arg):...if( g_var == arg->ID)...

2. Syscall Dependency Inference

d_alloc (struct d_alloc *arg):g_var = gen();arg->ID = g_var;

❷ hit

❷ hit

<instruction dependency pair>

W: g_varR: g_var

fd = open (…)ioctl (fd, D_ALLOC, {struct d_alloc})ioctl (fd, D_BIND, {struct d_bind})

syscallswrite

read

❷ Runtime

validation

❸ Parameter

dependency

❶ Collecting

W-R pairs

12

❶ static

analysis

LinuxKernel

symbolize

Page 42: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

d_bind (struct d_bind *arg):...if( g_var == arg->ID)...

2. Syscall Dependency Inference

d_alloc (struct d_alloc *arg):g_var = gen();arg->ID = g_var;

if yes, true dependency

❷ hit

❷ hit

=

❷ address

❷ address

<instruction dependency pair>

W: g_varR: g_var

fd = open (…)ioctl (fd, D_ALLOC, {struct d_alloc})ioctl (fd, D_BIND, {struct d_bind})

syscallswrite

read

❷ Runtime

validation

❸ Parameter

dependency

❶ Collecting

W-R pairs

12

❶ static

analysis

LinuxKernel

symbolize

Page 43: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

d_bind (struct d_bind *arg):...if( g_var == arg->ID)...

2. Syscall Dependency Inference

d_alloc (struct d_alloc *arg):g_var = gen();arg->ID = g_var;

if yes, true dependency

❷ hit

❷ hit

=

❸ symbolic

checking

❷ address

❷ address

<instruction dependency pair>

W: g_varR: g_var

ID

{struct d_bind} arg

{struct d_alloc} arg

ID

0x8

fd = open (…)ioctl (fd, D_ALLOC, {struct d_alloc})ioctl (fd, D_BIND, {struct d_bind})

syscallswrite

read

❷ Runtime

validation

❸ Parameter

dependency

❶ Collecting

W-R pairs

❸ symbolic

checking

symbolically tainted

12

❶ static

analysis

LinuxKernel symbolically

tainted

Page 44: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

d_bind (struct d_bind *arg):...if( g_var == arg->ID)...

2. Syscall Dependency Inference

d_alloc (struct d_alloc *arg):g_var = gen();arg->ID = g_var;

if yes, true dependency

❷ hit

❷ hit

=

❸ symbolic

checking

❷ address

❷ address

<instruction dependency pair>

W: g_varR: g_var

ID

{struct d_bind} arg

{struct d_alloc} arg

ID

0x8

fd = open (…)ioctl (fd, D_ALLOC, {struct d_alloc})ioctl (fd, D_BIND, {struct d_bind})

syscallswrite

read

W: offset(0x8)R: offset(0x0)

❷ Runtime

validation

❸ Parameter

dependency

❶ Collecting

W-R pairs

❸ symbolic

checking

symbolically tainted

12

❶ static

analysis

LinuxKernel symbolically

tainted

❸ offset

❸ offset

Page 45: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

d_bind (struct d_bind *arg):...if( g_var == arg->ID)...

2. Syscall Dependency Inference

d_alloc (struct d_alloc *arg):g_var = gen();arg->ID = g_var;

if yes, true dependency

❷ hit

❷ hit

=

❸ symbolic

checking

❷ address

❷ address

<instruction dependency pair>

W: g_varR: g_var

ID

{struct d_bind} arg

{struct d_alloc} arg

ID

0x8

fd = open (…)ioctl (fd, D_ALLOC, {struct d_alloc})ioctl (fd, D_BIND, {struct d_bind})

syscallswrite

read

W: offset(0x8)R: offset(0x0)

❷ Runtime

validation

❸ Parameter

dependency

❶ Collecting

W-R pairs

❸ symbolic

checking

symbolically tainted

12

❶ static

analysis

LinuxKernel symbolically

tainted

❸ offset

❸ offset

struct _1 {u64 x; u32 ID;}

prio1: ioctl (fd, D_ALLOC, {*_1})prio2: ioctl (fd, D_BIND, {*_2})

inferred syscall sequence

struct _2 { u32 ID, u64 x; }

Page 46: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

3. Nested Argument Format Retrieval

struct usbdev_ctrl ctrl; uchar *tbuf;…

copy_from_user (&ctrl, arg, sizeof(ctrl));…

copy_from_user (tbuf, ctrl.data, ctrl.len));…

syscall

ioctl (fd, USB_X, arg)

13

Page 47: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

3. Nested Argument Format Retrieval

struct usbdev_ctrl ctrl; uchar *tbuf;…

copy_from_user (&ctrl, arg, sizeof(ctrl));…

copy_from_user (tbuf, ctrl.data, ctrl.len));…

ctrl:❶ hit

memory view

data

0x14

0x8

syscall

ioctl (fd, USB_X, arg)

13

Page 48: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

3. Nested Argument Format Retrieval

struct usbdev_ctrl ctrl; uchar *tbuf;…

copy_from_user (&ctrl, arg, sizeof(ctrl));…

copy_from_user (tbuf, ctrl.data, ctrl.len));…

ctrl:❶ hit

memory view

data

0x14

0x8

syscall

ioctl (fd, USB_X, arg)symbolically

tainted

13

Page 49: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

3. Nested Argument Format Retrieval

struct usbdev_ctrl ctrl; uchar *tbuf;…

copy_from_user (&ctrl, arg, sizeof(ctrl));…

copy_from_user (tbuf, ctrl.data, ctrl.len));…

ctrl:

ctrl.data:

❷ hit

❶ hit

memory view

0x10

data

0x14

0x8

syscall

ioctl (fd, USB_X, arg)symbolically

tainted

13

Page 50: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

3. Nested Argument Format Retrieval

struct usbdev_ctrl ctrl; uchar *tbuf;…

copy_from_user (&ctrl, arg, sizeof(ctrl));…

copy_from_user (tbuf, ctrl.data, ctrl.len));…

ctrl:

ctrl.data:

❷ hit

❶ hit

memory view

0x10

data

0x14

0x8

syscall

ioctl (fd, USB_X, arg)symbolically

tainted

symbolic check

13

Page 51: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

3. Nested Argument Format Retrieval

struct usbdev_ctrl ctrl; uchar *tbuf;…

copy_from_user (&ctrl, arg, sizeof(ctrl));…

copy_from_user (tbuf, ctrl.data, ctrl.len));…

ctrl:

ctrl.data:

❷ hit

❶ hit

memory view

0x10

data

0x14

0x8

syscall

ioctl (fd, USB_X, arg)symbolically

tainted

symbolic check

13

inferred syscall interface

ioctl (fd, USB_X, {*_1})

struct _1: u64 x;

{*_2} y; u64 z;

final memory view

0x14

0x10

upperbuffer

lowerbuffer

0x8

struct _2:u64 x; u64 y;

Page 52: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

Implementation

14

callingorders

argumentretrieval

candidatedependency

pairs

static analysis

convert

hybrid-fuzzing

SymbolicAnalyzer

Fuzzer

LinuxKernel

inputs

unsolved conds

ondemandexec

solved

*Linux

Kernel

inferfeedback

Agent

❶ Syzkaller

❸ GCC❶ ❷

❺ Python-based

❷ S2E

❹ SVF/LLVMLINUX

- convert to direct control-flow

- constraint solving- symbolic checking

- send unsolved conds- process solved conditions

- collect dependency set

- transfer data

Page 53: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

Vulnerability Discovery

• Discovered new vulnerabilities • 24 new vulnerabilities found in the Linux kernels

• 17 confirmed by Linux kernel community

• UAF, integer overflow, uninitialized variable access, etc.

• Efficiency of bug-finding capability• 13 known bugs for HFL and Syzkaller

• They were all found by HFL 3x faster

than Syzkaller

15

Page 54: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

TriforceAFL

Moonshine

Syzkaller

S2E

HFL

kAFL

Code Coverage Enhancement

• Compared with state-of-the-art kernel fuzzers• Moonshine [Sec’18], kAFL [CCS’17], etc.

• KCOV-based coverage measurement

• HFL presents coverage improvement over the others• Ranging from 15% to 4x

16

Page 55: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

Effectiveness of HFL per-feature solution

ext4 ppp rds

HFL-struct

HFL-fullbaseline

HFL-hybrid HFL-direct

17

Page 56: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

Conclusion

• HFL is the first hybrid kernel fuzzer.

• HFL addresses the crucial challenges in the Linux kernel.

• HFL found 24 new vulnerabilities, and presented the better code coverage, compared to state-of-the-arts.

18

Page 57: HFL: Hybrid Fuzzing on the Linux Kernel · HFL: Hybrid Fuzzing on the Linux Kernel calling •Handling the challenges orders argument retrieval candidate dependency pairs static analysis

Thank you

19