Skip to main content
QUICK REVIEW

[Paper Review] KernelGPT: Enhanced Kernel Fuzzing via Large Language Models

Chenyuan Yang, Zijie Zhao|arXiv (Cornell University)|Dec 31, 2023
Security and Verification in ComputingComputer Science7 citations
TL;DR

KernelGPT is the first LLM-based approach to automatically infer Syzkaller syscall specifications for enhanced kernel fuzzing. It uses iterative LLM reasoning and validation feedback to generate accurate, high-coverage specifications, significantly improving Syzkaller's bug detection—finding 7 previously unknown vulnerabilities and earning upstream interest from the Syzkaller team.

ABSTRACT

Bugs in operating system kernels can affect billions of devices and users all over the world. As a result, a large body of research has been focused on kernel fuzzing, i.e., automatically generating syscall (system call) sequences to detect potential kernel bugs or vulnerabilities. Kernel fuzzing aims to generate valid syscall sequences guided by syscall specifications that define both the syntax and semantics of syscalls. While there has been existing work trying to automate syscall specification generation, this remains largely manual work, and a large number of important syscalls are still uncovered. In this paper, we propose KernelGPT, the first approach to automatically synthesizing syscall specifications via Large Language Models (LLMs) for enhanced kernel fuzzing. Our key insight is that LLMs have seen massive kernel code, documentation, and use cases during pre-training, and thus can automatically distill the necessary information for making valid syscalls. More specifically, KernelGPT leverages an iterative approach to automatically infer the specifications, and further debug and repair them based on the validation feedback. Our results demonstrate that KernelGPT can generate more new and valid specifications and achieve higher coverage than state-of-the-art techniques. So far, by using newly generated specifications, KernelGPT has already detected 24 new unique bugs in Linux kernel, with 12 fixed and 11 assigned with CVE numbers. Moreover, a number of specifications generated by KernelGPT have already been merged into the kernel fuzzer Syzkaller, following the request from its development team.

Motivation & Objective

  • To address the critical challenge of manual, error-prone syscall specification authoring for kernel fuzzing.
  • To improve Syzkaller's effectiveness by automatically generating accurate, comprehensive syscall specifications using LLMs.
  • To overcome limitations of static analysis-based tools like SyzDescribe, which fail on rare or complex kernel code patterns.
  • To enable scalable, maintainable, and adaptive specification generation that evolves with kernel changes.
  • To demonstrate that LLMs can surpass human-authored heuristics in generating correct and useful kernel syscall descriptions.

Proposed method

  • Leverages pre-trained LLMs with extensive exposure to kernel code, documentation, and syscall use cases to infer syscall specifications.
  • Employs an iterative, feedback-driven process to generate and refine specification components (e.g., device names, command values, types) step by step.
  • Uses validation feedback from Syzkaller runs to detect and correct specification errors, improving accuracy over multiple refinement cycles.
  • Analyzes kernel source code, including complex patterns like macro transformations (e.g., _IOC_NR(command)), to infer correct syscall parameters.
  • Generates complete syzlang specifications including syscall names, argument types, and interdependencies for device drivers.
  • Applies few-shot prompting and chain-of-thought reasoning to guide LLMs in understanding low-level kernel interfaces and edge cases.
Figure 1 : Workflows of syscall specification inference based on static analysis and LLMs
Figure 1 : Workflows of syscall specification inference based on static analysis and LLMs

Experimental results

Research questions

  • RQ1Can LLMs automatically infer accurate and comprehensive Syzkaller syscall specifications from kernel source code without manual rule engineering?
  • RQ2How does LLM-based specification generation compare to static analysis-based tools like SyzDescribe in terms of correctness and coverage?
  • RQ3Can LLM-inferred specifications lead to the discovery of previously unknown kernel bugs in previously untested drivers?
  • RQ4To what extent can LLMs generalize across diverse kernel driver patterns, including rare or non-conventional implementations?
  • RQ5Can the feedback loop between specification generation and Syzkaller validation improve specification quality iteratively?

Key findings

  • KernelGPT achieved higher Syzkaller coverage than SyzDescribe on 10 out of 11 tested drivers, with two specifications failing entirely in SyzDescribe due to incorrect device path inference.
  • KernelGPT detected 8 unique kernel bugs, 7 of which were previously unknown and undetected by default Syzkaller.
  • The Syzkaller team has requested to upstream the specifications generated by KernelGPT, indicating real-world adoption potential.
  • KernelGPT successfully identified complex bugs such as slab-use-after-free and kmalloc memory corruption in the device mapper and CEC drivers.
  • In the CEC driver, KernelGPT uncovered a general protection fault from dereferencing a non-canonical pointer and a task hang due to uncompleted configuration tasks.
  • The approach outperformed SyzDescribe on edge cases such as device name inference via .nodename instead of .name, and correct handling of ioctl command value transformations.
(a) Device Operation Handler
(a) Device Operation Handler

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.