Runtime Checking for Paired Functions in Device Drivers

Device drivers usually invoke functions to allocate resources for managing hardware devices and communicating with the kernel, and these resources should be released by functions when the work is finished. Thus allocating functions and releasing functions must be invoked in pairs. However, many developers ignore this vital rule, and some allocated resources are not released in time, which may cause resource related problems like deadlocks and memory leak. For improving the resource management of device drivers, we propose an approach named Pair Dyn to check these paired functions during runtime. When the driver runs, Pair Dyn records the runtime information of allocating functions such as key parameters and return value, and dynamically detects whether the relevant releasing functions are invoked to free allocated resources during runtime. Before the driver exits, Pair Dyn automatically attempts to invoke the related releasing functions which are lacked in runtime, in order to free the allocated resources of the operation system. We have implemented Pair Dyn with the LLVM compiler infrastructure, and make the evaluation with four real device drivers in Linux version 3.10.1. The experimental result shows that with the low extra overhead, Pair Dyn can provide effective runtime checking for allocate-release paired functions. Moreover, 9 potential bugs are found in the four drivers, which are all fixed automatically before exiting. Finally, no manual modification of the source code is needed with Pair Dyn.

[1]  Asim Kadav,et al.  Tolerating hardware device failures in software , 2009, SOSP '09.

[2]  Brian N. Bershad,et al.  Improving the reliability of commodity operating systems , 2005, TOCS.

[3]  M. Mellia,et al.  Click vs. Linux: two efficient open-source IP network stacks for software routers , 2005, HPSR. 2005 Workshop on High Performance Switching and Routing, 2005..

[4]  Asim Kadav,et al.  Understanding modern device drivers , 2012, ASPLOS XVII.

[5]  Carsten Sinz,et al.  LLBMC: Bounded Model Checking of C and C++ Programs Using a Compiler IR , 2012, VSTTE.

[6]  George C. Necula,et al.  SafeDrive: safe and recoverable extensions using language-based techniques , 2006, OSDI '06.

[7]  Zhenmin Li,et al.  PR-Miner: automatically extracting implicit programming rules and detecting violations in large software code , 2005, ESEC/FSE-13.

[8]  Wei Zhang,et al.  Automated Concurrency-Bug Fixing , 2012, OSDI.

[9]  Sriram K. Rajamani,et al.  Thorough static analysis of device drivers , 2006, EuroSys.

[10]  Benjamin Livshits,et al.  Tracking pointers with path and context sensitivity for bug detection in C programs , 2003, ESEC/FSE-11.

[11]  Dawson R. Engler,et al.  Bugs as deviant behavior: a general approach to inferring errors in systems code , 2001, SOSP.

[12]  Brian N. Bershad,et al.  Recovering device drivers , 2004, TOCS.

[13]  Junfeng Yang,et al.  An empirical study of operating systems errors , 2001, SOSP.

[14]  Dawson R. Engler,et al.  KLEE: Unassisted and Automatic Generation of High-Coverage Tests for Complex Systems Programs , 2008, OSDI.

[15]  Xi Wang,et al.  Improving Integer Security for Systems with KINT , 2012, OSDI.