Testing EmbeddedSoftwareJohn RegehrUniversity of Utah
“Over 15 billion ARM based chips shipped to date”[ARM web site, 2011]“The microcontroller market is forecast to reach over $16 billion worldwide in 2011”[Microcontroller Market Tracker, 2011]2
3
Diverse!4
Diverse!I have 6 pins and 32 bytes of RAM5
Diverse!6
Diverse!7
Diverse!I am quad core @ 1.5 GHz and have a GPU 8
Usually there are multiple processorsOn-chip networksIn-device networksDistributed systemsResource constraints are…Severe – to minimize unit costHard – failure if system runs out of…TimeRAM – stack or heapEnergy9
Continuously interact with the world through I/O devicesMay be little abstraction of HWProbably using both interrupt handlers and threadsOften there are fault tolerance and security requirements10
Sensor network  -> 103–105 LOCModern airplane -> 106–107 LOC Hybrid vehicle -> 107–108 LOCHow do we get these right?Mostly testing11
Software on many individual processors is smallPermits aggressive analysis and testingConstrained domain simplifies testingEmbedded systems are (by definition) special-purpose devices12
The “Real System Problem”Many interesting embedded codes are proprietaryNecessary tools may be expensive or nonexistentCompilers, debuggers, simulatorsMay not be able to run it in the labOften lacks specifications and oracles13
Consequently, academic embedded work may be…Forced to use small, contrived examplesOut of tune with industry14
Consequently, academic embedded work may be…Forced to use small, contrived examplesOut of tune with industry15Solution: Ubiquitous open embedded platforms
ArduinoArduino Uno:8-bit AVR processor @ 16 MHz2 KB RAM~$30Emphasis is on interfacing16
ArduinoNice IDE + libraries + C/C++Minimal abstraction of the embedded processor18 new books in 201117
 Simulators and model checkers for AVR code exist
 Very few Arduino tool papers exist
 This is a big opportunityArduinoNice IDE + libraries + C/C++Minimal abstraction of the embedded processor18 new books in 201118
TinyOSOS and middleware support for sensor networksSensingCollection and disseminationLocalizationApplications are in nesC, a C dialect19
TinyOS“Motes” based on a variety of MCUsCost $50 – $200Good simulators existThere are a few books20
TinyOS ~100 tool papers
 Many open problems“Motes” based on a variety of MCUsCost $50 – $200Good simulators existThere are a few books21
AndroidOS + middleware for smart phones / tabletsARM based hardware running LinuxMuch less constrained than motes and Arduino22
AndroidApplication code in JavaGreat toolsTons of books23
Android < 100 tool papers
 Most are very recent
 This is not a scary platformApplication code in JavaGreat toolsTons of books24
ROS – Robot Operating SystemLinux-based infrastructure for programming robotsPrimary abstraction is graph of communicating processesLocal and distributed25
ROS – Robot Operating System Very few ROS tool papers existLinux-based infrastructure for programming robotsPrimary abstraction is graph of communicating processesLocal and distributed26
Plenty of other open embedded platforms existFreeRTOSContikiPacemaker ChallengeEtc.Embarrassment of richesStill, huge room for improvementWhere’s the open automobile?27
So, let’s test some embedded softwareBut what are we testing for?28
Properties / OraclesTemporal safetyDeadlinesOr just responsivenessMemory safetyContracts / assertionsReference implementation29
Worst-Case Execution TimeWhat is the upper bound on execution time for a piece of code?We care because the world has deadlinesStatic analysis of WCET is extremely difficult if there is…A cachePreemptionAn aggressive processor30
True WCETNumber of executionsExecution timeConservative WCETLongest observed ET #2Longest observed ET #131
32+=printf()pthread_attr_setstacksize (&attr, &mystacksize);HANDLE WINAPI CreateThread(   LPSECURITY_ATTRIBUTES lpThreadAttributes,   SIZE_T dwStackSize,   LPTHREAD_START_ROUTINE lpStartAddress,   LPVOID lpParameter,   DWORD dwCreationFlags,   LPDWORD lpThreadId );
Stack Overflow in TinyOS334 KB
Stack Overflow in TinyOS34main()4 KB
Stack Overflow in TinyOS35main()irq 04 KB
Stack Overflow in TinyOS36main()irq 04 KBirq 1
Stack Overflow in TinyOS37main()irq 04 KBirq 1
Stack Overflow in TinyOS38Not the same thing as buffer overflow!Type safe language doesn’t solve this problemmain()irq 04 KBirq 1
Eliminating Stack OverflowTesting is hardNeed to drive code to its WC stack depthInterrupt coincidences are rareApproach: Static analysis of compiled codeCan’t estimate stack depth of source39
Estimate WC stack depth of each sequential flow, handlingIndirect branchesRecursionLoads into the stack pointerCompute “interrupt preemption graph”Find longest cycle in this graph40
41in      r24, 0x3f    ; r24 <- CPU status                        registercli                  ; disable interruptsadc     r24, r24     ; carry bit <- prev                       interrupt statuseor     r24, r24     ; r24 <- 0adc     r24, r24     ; r24 <- carry bitmov     r18, r24     ; r18 <- r24... critical section ...and     r18, r18     ; test r18 for zerobreq    .+2          ; if zero, skip next                        instructionsei                  ; enable interruptsret                  ; return from function
Stack analysis tool deployed in the TinyOS distributionResults are typically much larger than worst observed stack depthsBut, we validated its results by randomly firing interrupts42
Need… more… oracles…43
TinyOS applications are built using componentsInterface requirements documented but not checkedInterface misuse often silent44
We augmented nesC with contractsDynamic checking reasonable efficientFound some long-standing bugs45
nesC is not type safeMemory safety bugs in TinyOS are difficultWe ported an existing safe C dialectFound some otherwise-impossible bugsMain problem was getting overhead under controlWhole-program optimization46
47Code size35%13%-11%

More Related Content

PDF
Secure Coding Practices for Middleware
PDF
Linux randomnumbergenerator
PDF
CODE BLUE 2014 : DeviceDisEnabler : A hypervisor which hides devices to prote...
PPTX
[CB16] COFI break – Breaking exploits with Processor trace and Practical cont...
PDF
CSW2017Richard Johnson_harnessing intel processor trace on windows for vulner...
PDF
Unboxing the White-Box: Practical Attacks Against Obfuscated Ciphers
PPTX
Meltdown and Spectre
PDF
31c3 Presentation - Virtual Machine Introspection
Secure Coding Practices for Middleware
Linux randomnumbergenerator
CODE BLUE 2014 : DeviceDisEnabler : A hypervisor which hides devices to prote...
[CB16] COFI break – Breaking exploits with Processor trace and Practical cont...
CSW2017Richard Johnson_harnessing intel processor trace on windows for vulner...
Unboxing the White-Box: Practical Attacks Against Obfuscated Ciphers
Meltdown and Spectre
31c3 Presentation - Virtual Machine Introspection

What's hot (11)

PDF
Hackito Ergo Sum 2011: Capture me if you can!
PDF
Predicting and Abusing WPA2/802.11 Group Keys
PDF
SnakeGX (full version)
PDF
SnakeGX (short version)
PDF
Why is it so hard to make secure chips?
PDF
Securing a Raspberry Pi and other DIY IoT devices
ODP
Virtual Machine Introspection with Xen on ARM
PDF
Practical IoT Exploitation (DEFCON23 IoTVillage) - Lyon Yang
PDF
Secure Coding in Perl
PDF
Cloud Security with LibVMI
PPTX
How to drive a malware analyst crazy
Hackito Ergo Sum 2011: Capture me if you can!
Predicting and Abusing WPA2/802.11 Group Keys
SnakeGX (full version)
SnakeGX (short version)
Why is it so hard to make secure chips?
Securing a Raspberry Pi and other DIY IoT devices
Virtual Machine Introspection with Xen on ARM
Practical IoT Exploitation (DEFCON23 IoTVillage) - Lyon Yang
Secure Coding in Perl
Cloud Security with LibVMI
How to drive a malware analyst crazy
Ad

Viewers also liked (9)

PDF
2.01 weathering
PPT
Guide to multiplying trinomials
PDF
Multi step powerpoint
PDF
Thesis presentation
PDF
Bytecode'13 presentation
PDF
Satyam final
PPT
Pythagorean theorem and distance formula powerpoint1
PDF
Hype vs. Reality: The AI Explainer
PDF
Study: The Future of VR, AR and Self-Driving Cars
2.01 weathering
Guide to multiplying trinomials
Multi step powerpoint
Thesis presentation
Bytecode'13 presentation
Satyam final
Pythagorean theorem and distance formula powerpoint1
Hype vs. Reality: The AI Explainer
Study: The Future of VR, AR and Self-Driving Cars
Ad

Similar to Issta11 (20)

PPTX
The Hacking Games - Operation System Vulnerabilities Meetup 29112022
PDF
The trials and tribulations of providing engineering infrastructure
PDF
OSCON: System software goes weird
PPT
Detecting and Preventing Memory Attacks#
PDF
Affordable trustworthy-systems
PDF
PPTX
Reverse engineering &amp; immunity debugger
PDF
Typhoon Managed Execution Toolkit
PPTX
Advanced SOHO Router Exploitation XCON
PDF
Understanding and Improving Device Access Complexity
PPTX
Using hypervisor and container technology to increase datacenter security pos...
PPTX
Using hypervisor and container technology to increase datacenter security pos...
PDF
Embedded Os [Linux & Co.]
PPT
ES-CH1.ppt
PPTX
MiniOS: an instructional platform for teaching operating systems labs
PPTX
Chapter_01_See_Program_Running.pptx
PDF
Breaking paravirtualized devices
PDF
Monitoring ICS Communications
PDF
Inria Tech Talk : RIOT, l'OS libre pour vos objets connectés #IoT
PPTX
OWASP Appsec USA 2014 Talk "Pwning the Pawns with Wihawk" Santhosh Kumar
The Hacking Games - Operation System Vulnerabilities Meetup 29112022
The trials and tribulations of providing engineering infrastructure
OSCON: System software goes weird
Detecting and Preventing Memory Attacks#
Affordable trustworthy-systems
Reverse engineering &amp; immunity debugger
Typhoon Managed Execution Toolkit
Advanced SOHO Router Exploitation XCON
Understanding and Improving Device Access Complexity
Using hypervisor and container technology to increase datacenter security pos...
Using hypervisor and container technology to increase datacenter security pos...
Embedded Os [Linux & Co.]
ES-CH1.ppt
MiniOS: an instructional platform for teaching operating systems labs
Chapter_01_See_Program_Running.pptx
Breaking paravirtualized devices
Monitoring ICS Communications
Inria Tech Talk : RIOT, l'OS libre pour vos objets connectés #IoT
OWASP Appsec USA 2014 Talk "Pwning the Pawns with Wihawk" Santhosh Kumar

Recently uploaded (20)

PPTX
O2C Customer Invoices to Receipt V15A.pptx
PDF
Hybrid model detection and classification of lung cancer
PDF
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
PDF
CloudStack 4.21: First Look Webinar slides
DOCX
search engine optimization ppt fir known well about this
PDF
sustainability-14-14877-v2.pddhzftheheeeee
PDF
A Late Bloomer's Guide to GenAI: Ethics, Bias, and Effective Prompting - Boha...
PDF
Taming the Chaos: How to Turn Unstructured Data into Decisions
PDF
Getting Started with Data Integration: FME Form 101
PDF
WOOl fibre morphology and structure.pdf for textiles
PPTX
Modernising the Digital Integration Hub
PDF
Zenith AI: Advanced Artificial Intelligence
PDF
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
PPT
Module 1.ppt Iot fundamentals and Architecture
PDF
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
PDF
NewMind AI Weekly Chronicles – August ’25 Week III
PPTX
Web Crawler for Trend Tracking Gen Z Insights.pptx
PPT
What is a Computer? Input Devices /output devices
PDF
A comparative study of natural language inference in Swahili using monolingua...
PDF
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
O2C Customer Invoices to Receipt V15A.pptx
Hybrid model detection and classification of lung cancer
Microsoft Solutions Partner Drive Digital Transformation with D365.pdf
CloudStack 4.21: First Look Webinar slides
search engine optimization ppt fir known well about this
sustainability-14-14877-v2.pddhzftheheeeee
A Late Bloomer's Guide to GenAI: Ethics, Bias, and Effective Prompting - Boha...
Taming the Chaos: How to Turn Unstructured Data into Decisions
Getting Started with Data Integration: FME Form 101
WOOl fibre morphology and structure.pdf for textiles
Modernising the Digital Integration Hub
Zenith AI: Advanced Artificial Intelligence
From MVP to Full-Scale Product A Startup’s Software Journey.pdf
Module 1.ppt Iot fundamentals and Architecture
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
NewMind AI Weekly Chronicles – August ’25 Week III
Web Crawler for Trend Tracking Gen Z Insights.pptx
What is a Computer? Input Devices /output devices
A comparative study of natural language inference in Swahili using monolingua...
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game

Issta11

  • 2. “Over 15 billion ARM based chips shipped to date”[ARM web site, 2011]“The microcontroller market is forecast to reach over $16 billion worldwide in 2011”[Microcontroller Market Tracker, 2011]2
  • 3. 3
  • 5. Diverse!I have 6 pins and 32 bytes of RAM5
  • 8. Diverse!I am quad core @ 1.5 GHz and have a GPU 8
  • 9. Usually there are multiple processorsOn-chip networksIn-device networksDistributed systemsResource constraints are…Severe – to minimize unit costHard – failure if system runs out of…TimeRAM – stack or heapEnergy9
  • 10. Continuously interact with the world through I/O devicesMay be little abstraction of HWProbably using both interrupt handlers and threadsOften there are fault tolerance and security requirements10
  • 11. Sensor network -> 103–105 LOCModern airplane -> 106–107 LOC Hybrid vehicle -> 107–108 LOCHow do we get these right?Mostly testing11
  • 12. Software on many individual processors is smallPermits aggressive analysis and testingConstrained domain simplifies testingEmbedded systems are (by definition) special-purpose devices12
  • 13. The “Real System Problem”Many interesting embedded codes are proprietaryNecessary tools may be expensive or nonexistentCompilers, debuggers, simulatorsMay not be able to run it in the labOften lacks specifications and oracles13
  • 14. Consequently, academic embedded work may be…Forced to use small, contrived examplesOut of tune with industry14
  • 15. Consequently, academic embedded work may be…Forced to use small, contrived examplesOut of tune with industry15Solution: Ubiquitous open embedded platforms
  • 16. ArduinoArduino Uno:8-bit AVR processor @ 16 MHz2 KB RAM~$30Emphasis is on interfacing16
  • 17. ArduinoNice IDE + libraries + C/C++Minimal abstraction of the embedded processor18 new books in 201117
  • 18. Simulators and model checkers for AVR code exist
  • 19. Very few Arduino tool papers exist
  • 20. This is a big opportunityArduinoNice IDE + libraries + C/C++Minimal abstraction of the embedded processor18 new books in 201118
  • 21. TinyOSOS and middleware support for sensor networksSensingCollection and disseminationLocalizationApplications are in nesC, a C dialect19
  • 22. TinyOS“Motes” based on a variety of MCUsCost $50 – $200Good simulators existThere are a few books20
  • 24. Many open problems“Motes” based on a variety of MCUsCost $50 – $200Good simulators existThere are a few books21
  • 25. AndroidOS + middleware for smart phones / tabletsARM based hardware running LinuxMuch less constrained than motes and Arduino22
  • 26. AndroidApplication code in JavaGreat toolsTons of books23
  • 27. Android < 100 tool papers
  • 28. Most are very recent
  • 29. This is not a scary platformApplication code in JavaGreat toolsTons of books24
  • 30. ROS – Robot Operating SystemLinux-based infrastructure for programming robotsPrimary abstraction is graph of communicating processesLocal and distributed25
  • 31. ROS – Robot Operating System Very few ROS tool papers existLinux-based infrastructure for programming robotsPrimary abstraction is graph of communicating processesLocal and distributed26
  • 32. Plenty of other open embedded platforms existFreeRTOSContikiPacemaker ChallengeEtc.Embarrassment of richesStill, huge room for improvementWhere’s the open automobile?27
  • 33. So, let’s test some embedded softwareBut what are we testing for?28
  • 34. Properties / OraclesTemporal safetyDeadlinesOr just responsivenessMemory safetyContracts / assertionsReference implementation29
  • 35. Worst-Case Execution TimeWhat is the upper bound on execution time for a piece of code?We care because the world has deadlinesStatic analysis of WCET is extremely difficult if there is…A cachePreemptionAn aggressive processor30
  • 36. True WCETNumber of executionsExecution timeConservative WCETLongest observed ET #2Longest observed ET #131
  • 37. 32+=printf()pthread_attr_setstacksize (&attr, &mystacksize);HANDLE WINAPI CreateThread( LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize, LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId );
  • 38. Stack Overflow in TinyOS334 KB
  • 39. Stack Overflow in TinyOS34main()4 KB
  • 40. Stack Overflow in TinyOS35main()irq 04 KB
  • 41. Stack Overflow in TinyOS36main()irq 04 KBirq 1
  • 42. Stack Overflow in TinyOS37main()irq 04 KBirq 1
  • 43. Stack Overflow in TinyOS38Not the same thing as buffer overflow!Type safe language doesn’t solve this problemmain()irq 04 KBirq 1
  • 44. Eliminating Stack OverflowTesting is hardNeed to drive code to its WC stack depthInterrupt coincidences are rareApproach: Static analysis of compiled codeCan’t estimate stack depth of source39
  • 45. Estimate WC stack depth of each sequential flow, handlingIndirect branchesRecursionLoads into the stack pointerCompute “interrupt preemption graph”Find longest cycle in this graph40
  • 46. 41in r24, 0x3f ; r24 <- CPU status registercli ; disable interruptsadc r24, r24 ; carry bit <- prev interrupt statuseor r24, r24 ; r24 <- 0adc r24, r24 ; r24 <- carry bitmov r18, r24 ; r18 <- r24... critical section ...and r18, r18 ; test r18 for zerobreq .+2 ; if zero, skip next instructionsei ; enable interruptsret ; return from function
  • 47. Stack analysis tool deployed in the TinyOS distributionResults are typically much larger than worst observed stack depthsBut, we validated its results by randomly firing interrupts42
  • 49. TinyOS applications are built using componentsInterface requirements documented but not checkedInterface misuse often silent44
  • 50. We augmented nesC with contractsDynamic checking reasonable efficientFound some long-standing bugs45
  • 51. nesC is not type safeMemory safety bugs in TinyOS are difficultWe ported an existing safe C dialectFound some otherwise-impossible bugsMain problem was getting overhead under controlWhole-program optimization46
  • 53. 48Increasing AvailabilityNormal TinyOS:0% average availabilityArray Out-of-boundsNormalTinyOSSafe TinyOS:95% average availabilityArray Out-of-boundsRebuildSoft stateSafeTinyOSReboot
  • 54. What about application-level sensornet properties?All the interesting ones are distributedWe adapted TOSSIM, a non-cycle-accurate simulator, to be…A random testerA depth-bounded model checkerOracles: Type safety checksApplication-level properties49
  • 55. Application-Level PropertiesEventually…Each send buffer is unlockedNo cycles in the routing treeAll nodes become part of the collection treeAll nodes have consistent values6 out of 8 of these properties require global knowledge50
  • 56. Found 12 previously unknown bugs in TinyOS 2.010 safety, 2 livenessRandom testing outperformed depth-bounded model checkingEven after a lot of work on PORBut required work to shorten long error traces51
  • 57. ConclusionsOpen embedded platforms existSome have steep learning curvesFinding oracles is hardGenerating valid input is hardEmbedded systems are fun and important and rewarding52