arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2107.12867cs.PLcs.CRcs.DCcs.SE
收藏

从库移植到Para-rehosting:在商品硬件上本地执行微控制器软件

From Library Portability to Para-rehosting: Natively Executing Microcontroller Software on Commodity Hardware

Wenqiang Li, Le Guan, Jingqiang Lin, Jiameng Shi, Fengjun Li

摘要:

查找微控制器(MCU)固件中的错误是一项挑战,即使对于拥有源代码的设备制造商也是如此。MCU运行与x86不同的指令集,并暴露出非常不同的开发环境。这使x86上许多现有的复杂软件测试工具失效。为了维护一个统一的开发和测试环境,一个简单的方法是将源代码重新编译为商品机器的本机可执行文件(称为rehosting)。然而,ad-hoc re-hosting是一项艰巨而繁琐的任务,并且存在许多问题(库依赖性,内核依赖性和硬件依赖性)。在这项工作中,我们系统地探讨了MCU软件的可移植性问题,并提出pararehosting,以减轻移植过程。具体来说,我们抽象和实现一个便携式MCU(PMCU)使用POSIX接口。它模拟了MCU内核的常见功能。对于外围特定的逻辑,我们提出了基于HAL的外围功能替换,其中高级别的硬件功能被替换为主机上的等效后端驱动程序。这些后端驱动程序由精心设计的para-API调用,可以在许多MCU操作系统中重用。我们将常见的HAL函数分为四种类型,并实现了用于快速后端开发的模板。使用所提出的方法,我们已经成功地重新托管了9个MCU操作系统,包括广泛部署的Amazon FreeRTOS、ARM Mbed OS、Zephyr和LiteOS。为了证明我们的方法在安全测试方面的优越性,我们使用现成的动态分析工具(AFL和ASAN)对重新托管的程序,并发现了28个以前未知的错误,其中5个被确认的CVE和其他19个被确认的供应商在撰写本文时。

英文摘要:

Finding bugs in microcontroller (MCU) firmware is challenging, even for device manufacturers who own the source code. The MCU runs different instruction sets than x86 and exposes a very different development environment. This invalidates many existing sophisticated software testing tools on x86. To maintain a unified developing and testing environment, a straightforward way is to re-compile the source code into the native executable for a commodity machine (called rehosting). However, ad-hoc re-hosting is a daunting and tedious task and subject to many issues (library-dependence, kernel-dependence and hardware-dependence). In this work, we systematically explore the portability problem of MCU software and propose pararehosting to ease the porting process. Specifically, we abstract and implement a portable MCU (PMCU) using the POSIX interface. It models common functions of the MCU cores. For peripheral specific logic, we propose HAL-based peripheral function replacement, in which high-level hardware functions are replaced with an equivalent backend driver on the host. These backend drivers are invoked by well-designed para-APIs and can be reused across many MCU OSs. We categorize common HAL functions into four types and implement templates for quick backend development. Using the proposed approach, we have successfully rehosted nine MCU OSs including the widely deployed Amazon FreeRTOS, ARM Mbed OS, Zephyr and LiteOS. To demonstrate the superiority of our approach in terms of security testing, we used off-the-shelf dynamic analysis tools (AFL and ASAN) against the rehosted programs and discovered 28 previously-unknown bugs, among which 5 were confirmed by CVE and the other 19 were confirmed by vendors at the time of writing.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑