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

07/04/2021
by   Wenqiang Li, et al.
0

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.

READ FULL TEXT
research
04/24/2020

Predicting Vulnerability In Large Codebases With Deep Code Representation

Currently, while software engineers write code for various modules, quit...
research
02/07/2022

μAFL: Non-intrusive Feedback-driven Fuzzing for Microcontroller Firmware

Fuzzing is one of the most effective approaches to finding software flaw...
research
01/31/2023

ICICLE: A Re-Designed Emulator for Grey-Box Firmware Fuzzing

Emulation-based fuzzers enable testing binaries without source code, and...
research
09/13/2019

P^2IM: Scalable and Hardware-independent Firmware Testing via Automatic Peripheral Interface Modeling (extended version)

Dynamic testing or fuzzing of embedded firmware is severely limited by h...
research
07/21/2021

Firmware Re-hosting Through Static Binary-level Porting

The rapid growth of the Industrial Internet of Things (IIoT) has brought...
research
09/03/2018

Deductive Verification of Unmodified Linux Kernel Library Functions

This paper presents results from the development and evaluation of a ded...
research
05/04/2021

Automated Driver Testing for Small Footprint Embedded Systems

Embedded systems represent a billionaire market and are present in most ...

Please sign up or login with your details

Forgot password? Click here to reset