Skip to main content
QUICK REVIEW

[论文解读] KernelGPT: Enhanced Kernel Fuzzing via Large Language Models

Chenyuan Yang, Zijie Zhao|arXiv (Cornell University)|Dec 31, 2023
Security and Verification in Computing被引用 7
一句话总结

KernelGPT 是首个基于大语言模型(LLM)的自动推断 Syzkaller syscalls 规范的方法,可提升内核模糊测试效果。它通过迭代式 LLM 推理与验证反馈,生成准确且高覆盖率的规范,显著提升 Syzkaller 的漏洞检测能力——发现 7 个此前未知的漏洞,并获得 Syzkaller 团队的上游采纳兴趣。

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.

研究动机与目标

  • 为解决内核模糊测试中手动编写、易出错的 syscalls 规范编写这一关键挑战。
  • 通过利用大语言模型自动生成准确、全面的 syscalls 规范,提升 Syzkaller 的有效性。
  • 克服基于静态分析的工具(如 SyzDescribe)在罕见或复杂内核代码模式下失效的局限性。
  • 实现可扩展、可维护且可适应的规范生成机制,随内核变更动态演化。
  • 证明大语言模型在生成正确且实用的内核 syscalls 描述方面,可超越人工编写的启发式规则。

提出的方法

  • 利用在大量内核代码、文档和 syscalls 使用案例中预训练的大语言模型,推断 syscalls 规范。
  • 采用迭代式、反馈驱动的流程,逐步生成并优化规范组件(如设备名称、命令值、类型等)。
  • 通过 Syzkaller 运行的验证反馈检测并修正规范错误,经过多轮优化提升准确性。
  • 分析内核源码,包括复杂模式(如宏转换,例如 _IOC_NR(command)),以推断正确的 syscalls 参数。
  • 生成完整的 syzlang 规范,包括 syscalls 名称、参数类型及设备驱动的依赖关系。
  • 应用 few-shot prompting 和思维链(chain-of-thought)推理,引导大语言模型理解底层内核接口及边界情况。
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

实验结果

研究问题

  • RQ1大语言模型能否在无需人工规则工程的情况下,仅从内核源码自动推断出准确且全面的 Syzkaller syscalls 规范?
  • RQ2与基于静态分析的工具(如 SyzDescribe)相比,基于大语言模型的规范生成在正确性和覆盖率方面表现如何?
  • RQ3大语言模型推断的规范能否在以往未测试的驱动中发现此前未知的内核漏洞?
  • RQ4大语言模型在多样化内核驱动模式(包括罕见或非标准实现)上的泛化能力如何?
  • RQ5规范生成与 Syzkaller 验证之间的反馈循环,能否实现规范质量的迭代提升?

主要发现

  • 在 11 个测试驱动中的 10 个上,KernelGPT 的 Syzkaller 覆盖率高于 SyzDescribe,其中两个规范因设备路径推断错误在 SyzDescribe 中完全失败。
  • KernelGPT 检测到 8 个独立的内核漏洞,其中 7 个是此前未知且默认 Syzkaller 未检测到的。
  • Syzkaller 团队已请求将 KernelGPT 生成的规范纳入上游,表明其具备真实世界采纳潜力。
  • KernelGPT 已成功识别出设备映射器和 CEC 驱动中的复杂漏洞,如 slab-use-after-free 和 kmalloc 内存损坏。
  • 在 CEC 驱动中,KernelGPT 揭示了因解引用非规范指针导致的一般保护故障,以及因未完成的配置任务导致的任务挂起。
  • 该方法在边界情况(如通过 .nodename 而非 .name 推断设备名称)和正确处理 ioctl 命令值转换方面,优于 SyzDescribe。
(a) Device Operation Handler
(a) Device Operation Handler

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。