一句话:提出利用汇编器错误消息自动推断语法规则并差分测试汇编器的方法与工具 AsFuzzer。
汇编器是编译器工具链的关键组件,但其测试覆盖远不如其他组件。现有基于语法的模糊测试难以测试汇编器:不同汇编器语法不同且缺少语法规范,闭源汇编器又难以从源码提取语法,而黑盒语法推断方法存在可扩展性问题。本文提出利用汇编器错误消息自动推断语法规则的方法,只需对目标汇编器进行少量查询即可获得其语法,并据此开展差分测试。作者实现工具 AsFuzzer,在 Clang、GAS、ICC 和 MASM 四个真实汇编器上评估,针对六种流行架构发现 497 个有缺陷的指令操作码,并已报告给开发者。
Assembler is a critical component of the compiler toolchain, which has been less tested than the other components. Unfortunately, current grammar-based fuzzing techniques suffer from several challenges when testing assemblers. First, each different assembler accepts different grammar rules and syntaxes, and there are no existing assembly grammar specifications. Second, not every assembler is open-source, which makes it difficult to extract grammar rules from the source code. While existing black-box grammar inference approaches are applicable to such closed-source assemblers, they suffer from the scalability issue, which renders them impractical for testing assemblers. To address these challenges, we propose a novel way to test assemblers by automatically inferring their grammar rules with only a few queries to the target assemblers by leveraging their error messages. The key insight is that assembly error messages often deliver useful information to infer the underlying grammar rules. We have implemented our technique in a tool named AsFuzzer, and evaluated it on 4 real-world assemblers including Clang-integrated assembler (Clang), GNU assembler (GAS), Intel’s assembler (ICC), and Microsoft macro assembler (MASM). With AsFuzzer, we have successfully found 497 buggy instruction opcodes for six popular architectures, and reported them to the developers.