Automated resource release in device drivers

Device drivers require system resources to control hardware and provide fundamental services for applications. The acquired resources must be explicitly released by drivers. Otherwise, these resources will never be reclaimed by the operating system, and they are not available for other programs any more, causing hard-to-find system problems. We study on Linux driver mailing lists, and find many applied patches handle improper resource-release operations, especially in error handling paths. In order to improve current resource management and avoid resource-release omissions in device drivers, we propose a novel approach named AutoRR, which can automatically and safely release resources based on specification-mining techniques. During execution, we maintain a resource-state table by recording the runtime information of function calls. If the driver fails to release acquired resources during execution, AutoRR will report violations and call corresponding releasing functions with the recorded runtime information to release acquired resources. To fully and safely release acquired resources, a dynamic analysis of resource dependency and allocation hierarchy is also performed, which can avoid dead resources and double frees. AutoRR works in both normal execution and error handling paths for reliable resource management. We implement AutoRR with LLVM, and evaluate it on 8 Ethernet drivers in Linux 3.17.2. The evaluation shows that the overhead of AutoRR is very low, and it has successfully fixed 18 detected resource-release omission violations without side effects. Our work shows a feasible way of using specification-mining results to avoid related violations.

[1]  Hsiang-Yu Hsu,et al.  Supporting dynamic update and resource protection in an embedded operating system , 2011, SAC '11.

[2]  Christof Fetzer,et al.  Automatically Finding and Patching Bad Error Handling , 2006, 2006 Sixth European Dependable Computing Conference.

[3]  Yuping Wang,et al.  PF-Miner: A New Paired Functions Mining Method for Android Kernel in Error Paths , 2014, 2014 IEEE 38th Annual Computer Software and Applications Conference.

[4]  Stephen V. Rice,et al.  A framework for unified resource management in Java , 2006, PPPJ '06.

[5]  Gokarna Sharma,et al.  Concurrent, parallel garbage collection in linear time , 2014, ISMM '14.

[6]  Emery D. Berger,et al.  Garbage collection without paging , 2005, PLDI '05.

[7]  Manuvir Das,et al.  Perracotta: mining temporal API rules from imperfect traces , 2006, ICSE.

[8]  Suman Saha,et al.  An approach to improving the structure of error-handling code in the linux kernel , 2011, LCTES '11.

[9]  Jingling Xue,et al.  Static memory leak detection using full-sparse value-flow analysis , 2012, ISSTA 2012.

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

[11]  Jun Yan,et al.  Characterizing and detecting resource leaks in Android applications , 2013, 2013 28th IEEE/ACM International Conference on Automated Software Engineering (ASE).

[12]  Tao Xie,et al.  Iterative mining of resource-releasing specifications , 2011, 2011 26th IEEE/ACM International Conference on Automated Software Engineering (ASE 2011).

[13]  Lu Zhang,et al.  Safe Memory-Leak Fixing for C Programs , 2015, 2015 IEEE/ACM 37th IEEE International Conference on Software Engineering.

[14]  Monica S. Lam,et al.  Static detection of leaks in polymorphic containers , 2006, ICSE '06.

[15]  Kathryn S. McKinley,et al.  Cork: dynamic memory leak detection for garbage-collected languages , 2007, POPL '07.

[16]  Kathryn S. McKinley,et al.  Free-Me: a static analysis for automatic individual object reclamation , 2006, PLDI '06.

[17]  George Candea,et al.  Testing Closed-Source Binary Device Drivers with DDT , 2010, USENIX Annual Technical Conference.

[18]  Chandra Krintz,et al.  Dynamic prediction of collection yield for managed runtimes , 2009, ASPLOS.

[19]  Suman Saha,et al.  Hector: Detecting Resource-Release Omission Faults in error-handling code for systems software , 2013, 2013 43rd Annual IEEE/IFIP International Conference on Dependable Systems and Networks (DSN).

[20]  Qian Wu,et al.  An Effective Defect Detection and Warning Prioritization Approach for Resource Leaks , 2012, 2012 IEEE 36th Annual Computer Software and Applications Conference.

[21]  CotroneoDomenico,et al.  On Fault Representativeness of Software Fault Injection , 2013 .

[22]  Jongmoo Choi,et al.  Design and implementation of a kernel resource protector for robustness of Linux module programming , 2006, SAC '06.

[23]  Ju Qian,et al.  Inferring weak references for fixing Java memory leaks , 2012, 2012 28th IEEE International Conference on Software Maintenance (ICSM).

[24]  Emina Torlak,et al.  Effective interprocedural resource leak detection , 2010, 2010 ACM/IEEE 32nd International Conference on Software Engineering.

[25]  Derek Rayside,et al.  Object ownership profiling: a technique for finding and fixing memory leaks , 2007, ASE.

[26]  Shi-Min Hu,et al.  Runtime Checking for Paired Functions in Device Drivers , 2014, 2014 21st Asia-Pacific Software Engineering Conference.

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

[28]  Witawas Srisa-an,et al.  AS-GC: An Efficient Generational Garbage Collector for Java Application Servers , 2007, ECOOP.

[29]  Sigmund Cherem,et al.  Compile-time deallocation of individual objects , 2006, ISMM '06.

[30]  Matthias Hauswirth,et al.  Low-overhead memory leak detection using adaptive statistical profiling , 2004, ASPLOS XI.

[31]  Domenico Cotroneo,et al.  On Fault Representativeness of Software Fault Injection , 2013, IEEE Transactions on Software Engineering.

[32]  Isil Dillig,et al.  The CLOSER: automating resource management in java , 2008, ISMM '08.

[33]  Vikram S. Adve,et al.  Making context-sensitive points-to analysis with heap cloning practical for the real world , 2007, PLDI '07.

[34]  Atanas Rountev,et al.  LeakChecker: Practical Static Memory Leak Detection for Managed Languages , 2014, CGO '14.

[35]  Atanas Rountev,et al.  Precise memory leak detection for java software using container profiling , 2013, 2008 ACM/IEEE 30th International Conference on Software Engineering.

[36]  Rob Williams,et al.  Linux device drivers , 2006 .

[37]  George C. Necula,et al.  Exceptional situations and program reliability , 2008, TOPL.

[38]  Chen Liu,et al.  R2Fix: Automatically Generating Bug Fixes from Bug Reports , 2013, 2013 IEEE Sixth International Conference on Software Testing, Verification and Validation.

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