When we talk about how much risk is enough, it is common to do things like compare the risk to current systems, or argue about whether something is more (or less) likely than events such as being killed by lightning. There are established ways to think about this topic, each with tradeoffs.
The next time you need to think about how much risk is appropriate in a safety-critical system, try these existing approaches on for size instead of making up something on your own:
ALARP: "As Low As Reasonably Practicable" Some risks are acceptable. Some are unacceptable. Some are worth taking in exchange for benefit, but if that is done the risk must be reduced to be ALARP.
GAMAB: "Globalement Au Moins Aussi Bon" Offer a level of risk at least as good as the risk offered by an equivalent existing system. (i.e., no more dangerous than what we have already for a similar function)
MEM: "Minimum Endogenous Mortality" The technical system must not create a significant risk compared to globally existing risks. For example, this should cause a minimal increase in overall death rates compared to the existing population death rates.
MGS: "Mindestens Gleiche Sicherheit" (At least the same level of safety) Deviations from accepted practices must be supported by an explicit safety argument showing at least the same level of safety. This is more about waivers than whole-system evaluation.
NMAU: "Nicht Mehr Als Unvermeidbar" (Not more than unavoidable) Assuming there is a public benefit to the operation of the system, hazards should be avoided by reasonable safety measures implemented with reasonable cost.
Each of these approaches has pros and cons. The above terms were paraphrased from this nice discussion:
Kron, On the evaluation of risk acceptance principles,
http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.455.4506&rep=rep1&type=pdf
There is an interesting set of slides that covers similar ground here, and works some examples. In particular the graphs involving whether risks are taken voluntarily for different scenarios is thought provoking:
http://agse3.informatik.uni-kl.de/teaching/suze/ws2014/material/folien/SRES_03_Risk_Acceptance.pdf
In general, if you want to dig deeper into this area, a search on
gamab mem alarp
will bring up a number of hits
Also note that legal and other types of considerations exist, especially regarding product liability.
Companion blog to the book Better Embedded System Software by Phil Koopman at Carnegie Mellon University
Saturday, September 8, 2018
Saturday, July 14, 2018
Activity on my Safe Autonomy Blog
For those who might have missed it, most of my recent blogging has been on my Safe Autonomy Blog: https://safeautonomy.blogspot.com
Recent post topics include slides and paper preprints such as:
Recent post topics include slides and paper preprints such as:
- Robustness Testing of Autonomy Software (ICSE 2018)
- Safety Validation and Edge Case Testing for Autonomous Vehicles
- Heavy Tail Ceiling Problem for AV Testing
- Toward a framework for Highly Automated Vehicle Safety Validation
Monday, March 12, 2018
Embedded Code Quality and Best Practices Training Videos full length
I've posted the full series of my available embedded system code quality and related best practices videos on YouTube. These are full-length narrated slides of the core set of safety topics from my new course. They concentrate on getting the big picture about code quality and good programming practices.
Obviously there is more to code quality and safety than just these topics. Additional topics are available slides-only. You can see the full set of course slides including for those lectures and others here:
https://users.ece.cmu.edu/~koopman/lectures/index.html#642
- Code Quality, Safety, Security overview
- Global Variables
- Spaghetti Code
- Coding Style for Humans
- Coding Style for Compilers/Language Use
- Stack Overflow
- Peer Reviews
- Key Software Process metrics
Obviously there is more to code quality and safety than just these topics. Additional topics are available slides-only. You can see the full set of course slides including for those lectures and others here:
https://users.ece.cmu.edu/~koopman/lectures/index.html#642
Sunday, February 25, 2018
New Blog on Self-Driving Car Safety
I'm doing a lot more work on self-driving car (autonomous vehicle) safety, so I've decided to split my blogging for that activity. I'll still post more general embedded system topics here, perhaps with reduced frequency.
You can see my new blog on self-driving car safety here:
https://safeautonomy.blogspot.com
Just to keep perspective, self-driving cars are still very complex embedded systems. You need to get the basics right (this blog) if you want them to be safe!
You can see my new blog on self-driving car safety here:
https://safeautonomy.blogspot.com
Just to keep perspective, self-driving cars are still very complex embedded systems. You need to get the basics right (this blog) if you want them to be safe!
Friday, February 16, 2018
Robustness Testing of Autonomy Software (ASTAA Paper Published)
I'm very pleased that our research team will present a paper on Robustness Testing of Autonomy Software at the ICSE Software Engineering in Practice session in a late May. You can see a preprint of the paper here: https://goo.gl/Pkqxy6
The work summarizes what we've learned across several years of research stress testing many robots, including self-driving cars.
Authors:
Casidhe Hutchison
Milda Zizyte
Patrick Lanigan
David Guttendorf
Mike Wagner
Claire Le Guoes
Philip Koopman
The work summarizes what we've learned across several years of research stress testing many robots, including self-driving cars.
ABSTRACT
As robotic and autonomy systems become progressively more present in industrial and human-interactive applications, it is increasingly critical for them to behave safely in the presence of unexpected inputs. While robustness testing for traditional software systems is long-studied, robustness testing for autonomy systems is relatively uncharted territory. In our role as engineers, testers, and researchers we have observed that autonomy systems are importantly different from traditional systems, requiring novel approaches to effectively test them. We present Automated Stress Testing for Autonomy Architectures (ASTAA), a system that effectively, automatically robustness tests autonomy systems by building on classic principles, with important innovations to support this new domain. Over five years, we have used ASTAA to test 17 real-world autonomy systems, robots, and robotics-oriented libraries, across commercial and academic applications, discovering hundreds of bugs. We outline the ASTAA approach and analyze more than 150 bugs we found in real systems. We discuss what we discovered about testing autonomy systems, specifically focusing on how doing so differs from and is similar to traditional software robustness testing and other high-level lessons.Authors:
Casidhe Hutchison
Milda Zizyte
Patrick Lanigan
David Guttendorf
Mike Wagner
Claire Le Guoes
Philip Koopman
Monday, January 29, 2018
New Peer Review Checklist for Embedded C Code
Here's a new peer review checklist to help improve the quality of your embedded C code.
To use the checklist, you should do a sit-down meeting with, ideally, three reviewers not including the code author. Divide the checklist up into three portions as indicated. Be sure to run decent static analysis before the review to safe reviewer time -- let the tools find the easy stuff before spending human time on the review.
After an initial orientation to what the code is supposed to do and relevant background, the review process is:
===============================================================
Peer Review Checklist: Embedded C Code
Before Review:
0 _____ Code compiles clean with extensive warning checks (e.g. MISRA C rules)
Reviewer #1:
1 _____ Commenting: top of file, start of function, code that needs an explanation
2 _____ Style is consistent and follows style guidelines
3 _____ Proper modularity, module size, use of .h files and #includes
4 _____ No orphans (redundant, dead, commented out, unused code & variables)
5 _____ Conditional expressions evaluate to a boolean value; no assignments
6 _____ Parentheses used to avoid operator precedence confusion
7 _____ All switch statements have a default clause; preferably an error trap
Reviewer #2:
8 _____ Single point of exit from each function
9 _____ Loop entry and exit conditions correct; minimum continue/break complexity
10 _____ Conditionals should be minimally nested (generally only one or two deep)
11 _____ All functions can be unit tested; SCC or SF complexity less than 10 to 15
12 _____ Use const and inline instead of #define; minimize conditional compilation
13 _____ Avoid use of magic numbers (constant values embedded in code)
14 _____ Use strong typing (includes: sized types, structs for coupled data, const)
15 _____ Variables have well chosen names and are initialized at definition
Reviewer #3:
16 _____ Minimum scope for all functions and variables; essentially no globals
17 _____ Concurrency issues? (locking, volatile keyword, minimize blocking time)
18 _____ Input parameter checking is done (style, completeness)
19 _____ Error handling for function returns is appropriate
20 _____ Null pointers, division by zero, null strings, boundary conditions handled
21 _____ Floating point use is OK (equality, NaN, INF, roundoff); use of fixed point
22 _____ Buffer overflow safety (bound checking, avoid unsafe string operations)
All Reviewers:
23 _____ Does the code match the detailed design (correct functionality)?
24 _____ Is the code as simple, obvious, and easy to review as possible?
For TWO Reviewers assign items: Reviewer#1: 1-11; 23-24 Reviewer#2: 12-24
Items that are covered with static analysis can be removed from checklist
Template 1/28/2018: Copyright CC BY 4.0, 2018, Philip Koopman
===============================================================
Additional material to help you with successful peer reviews:
To use the checklist, you should do a sit-down meeting with, ideally, three reviewers not including the code author. Divide the checklist up into three portions as indicated. Be sure to run decent static analysis before the review to safe reviewer time -- let the tools find the easy stuff before spending human time on the review.
After an initial orientation to what the code is supposed to do and relevant background, the review process is:
- The review leader picks the next few lines of code to be reviewed and makes sure everyone is ONLY focused on those few lines. Usually this is 5-10 lines encompassing a conditional structure, a basic block, or other generally unified small chunk within the code.
- Reviewers identify any code problems relevant to their part of the checklist. It's OK if they notice others, but they should focus on individually considering each item in their part of the checklist and ask "do I see a violation of this item" in just the small chunk of code being considered.
- Reviewer comments should be recorded in the form: "Line X seems to violate Checklist Item Y for the following reason." Do NOT suggest a fix -- just record the issue.
- When all comments have been recorded, go back to step 1. Continue to review up to a maximum of 2 hours. You should be covering about 100-200 lines of code per hour. Too fast and too slow are both a problem.
A text version of the checklist is below. You can also download an acrobat version here. Additional pointers to support materials are after the checklist. If you have a static analysis tool that automates any of the checklist item, feel free to replace that item with something else that's important to you.
===============================================================
Peer Review Checklist: Embedded C Code
Before Review:
0 _____ Code compiles clean with extensive warning checks (e.g. MISRA C rules)
Reviewer #1:
1 _____ Commenting: top of file, start of function, code that needs an explanation
2 _____ Style is consistent and follows style guidelines
3 _____ Proper modularity, module size, use of .h files and #includes
4 _____ No orphans (redundant, dead, commented out, unused code & variables)
5 _____ Conditional expressions evaluate to a boolean value; no assignments
6 _____ Parentheses used to avoid operator precedence confusion
7 _____ All switch statements have a default clause; preferably an error trap
Reviewer #2:
8 _____ Single point of exit from each function
9 _____ Loop entry and exit conditions correct; minimum continue/break complexity
10 _____ Conditionals should be minimally nested (generally only one or two deep)
11 _____ All functions can be unit tested; SCC or SF complexity less than 10 to 15
12 _____ Use const and inline instead of #define; minimize conditional compilation
13 _____ Avoid use of magic numbers (constant values embedded in code)
14 _____ Use strong typing (includes: sized types, structs for coupled data, const)
15 _____ Variables have well chosen names and are initialized at definition
Reviewer #3:
16 _____ Minimum scope for all functions and variables; essentially no globals
17 _____ Concurrency issues? (locking, volatile keyword, minimize blocking time)
18 _____ Input parameter checking is done (style, completeness)
19 _____ Error handling for function returns is appropriate
20 _____ Null pointers, division by zero, null strings, boundary conditions handled
21 _____ Floating point use is OK (equality, NaN, INF, roundoff); use of fixed point
22 _____ Buffer overflow safety (bound checking, avoid unsafe string operations)
All Reviewers:
23 _____ Does the code match the detailed design (correct functionality)?
24 _____ Is the code as simple, obvious, and easy to review as possible?
For TWO Reviewers assign items: Reviewer#1: 1-11; 23-24 Reviewer#2: 12-24
Items that are covered with static analysis can be removed from checklist
Template 1/28/2018: Copyright CC BY 4.0, 2018, Philip Koopman
===============================================================
Additional material to help you with successful peer reviews:
- A slide set about peer reviews
- A video tutorial on peer reviews: YouTube
- Peer review reporting spreadsheet blog post
- Other ideas for adding to the peer review checklist are at this blog entry. It's important to keep the checklist brief, so pick your battles and keep the items high level.
- SF complexity metric blog post
- Peer reviews and the 50/50 rule blog post
Monday, November 27, 2017
Embedded Software Course Notes On-Line
I'm just wrapping up my first semester teaching a new course on embedded system software. It covers code quality, safety, and security. Below is table of lecture handouts.
NOTE: there is an update here:
https://users.ece.cmu.edu/~koopman/lectures/index.html#642
which includes newer course notes and quite a few YouTube videos of these lectures.
You should use that URL instead of this blog post, but I've left this post as-is for Fall 2017.
18-642 Embedded System Software Engineering
Prof. Philip Koopman, Carnegie Mellon University, Fall 2017
Note that in Spring 2018 these are likely to be updated, so if want to see the latest also check the main course page: https://www.ece.cmu.edu/~ece642/ For other lectures and copyright notes, please see my general lecture notes & video page: https://users.ece.cmu.edu/~koopman/lectures/index.html
NOTE: there is an update here:
https://users.ece.cmu.edu/~koopman/lectures/index.html#642
which includes newer course notes and quite a few YouTube videos of these lectures.
You should use that URL instead of this blog post, but I've left this post as-is for Fall 2017.
18-642 Embedded System Software Engineering
Prof. Philip Koopman, Carnegie Mellon University, Fall 2017
| Slides | Topics | |
| 1 | Course Introduction | Software is eating the world; embedded applications and markets; bad code is a problem; coding is 0% of software; truths and management misconceptions |
| 2 | Software Development Processes | Waterfall; swiss cheese model; lessons learned in software; V model; design vs. code; agile methods; agile for embedded |
| 3 | Global Variables | Global vs. static variables; avoiding and removing globals |
| 4 | Spaghetti Code | McCabe Cyclomatic Complexity (MCC); SCC; Spaghetti Factor (SF) |
| 5 | Unit Testing | Black box testing; white box testing; unit testing strategies; MCDC coverage; unit testing frameworks (cunit) |
| 6 | Modal Code/Statecharts | Statechart elements; statechart example; statechart implementation |
| 7 | Peer Reviews | Effective code quality practices, peer review efficiency and effectiveness; Fagan inspections; rules for peer review; review report; perspective-based reviews; review checklist; case study; economics of peer review |
| 8 | Code Style/Humans | Making code easy to read; good code hygiene; avoiding premature optimization; coding style |
| 9 | Code Style/Language | Pitfalls and problems with C; language use guidelines and analysis tools; using language wisely (strong typing); Mars Climate Orbiter; deviations & legacy code |
| 10 | Testing Quality | Smoke testing, exploratory testing; methodical test coverage; types of testing; testing philosophy; coverage; testing resources |
| 11 | Requirements | Ariane 5 flight 501; rules for good requirements; problematic requirements; extra-functional requirements; requirements approaches; ambiguity |
| 12 | System-Level Test | First bug story; effective test plans; testing won't find all bugs; F-22 Raptor date line bug; bug farms; risks of bad software |
| 13 | SW Architecture | High Level Design (HLD); boxes and arrows; sequence diagrams (SD); statechart to SD relationship; 2011 Health Plan chart |
| 14 | Integration Testing | Integration test approaches; tracing integration tests to SDs; network message testing; using SDs to generate unit tests |
| 15 | Traceability | Traceability across the V; examples; best practices |
| 16 | SQA isn't testing | SQA elements; audits; SQA as coaching staff; cost of defect fixes over project cycle |
| 17 | Lifecycle CM | A400M crash; version control; configuration management; long lifecycles |
| 18 | Maintenance | Bug fix cycle; bug prioritization; maintenance as a large cost driver; technical debt |
| 19 | Process Key Metrics | Tester to developer ratio; code productivity; peer review effectiveness |
| 33 | Date Time Management | Keeping time; time terminology; clock synchronization; time zones; DST; local time; sunrise/sunset; mobility and time; date line; GMT/UTC; leap years; leap seconds; time rollovers; Zune leap year bug; internationalization. |
| 21 | Floating Point Pitfalls | Floating point formats; special values; NaN and robots; roundoff errors; Patriot Missile mishap |
| 23 | Stack Overflow | Stack overflow mechanics; memory corruption; stack sentinels; static analysis; memory protection; avoid recursion |
| 25 | Race Conditions | Therac 25; race condition example; disabling interrupts; mutex; blocking time; priority inversion; priority inheritance; Mars Pathfinder |
| 27 | Data Integrity | Sources of faults; soft errors; Hamming distance; parity; mirroring; SECDED; checksum; CRC |
| 20 | Safety+Security Overview | Challenges of embedded code; it only takes one line of bad code; problems with large scale production; your products live or die by their software; considering the worst case; designing for safety; security matters; industrial controls as targets; designing for security; testing isn't enough Fiat Chrysler jeep hack; Ford Mytouch update; Toyota UA code quality; Heartbleed; Nest thermostats; Honda UA recall; Samsung keyboard bug; hospital infusion pumps; LIFX smart lightbulbs; German steel mill hack; Ukraine power hack; SCADA attack data; Shodan; traffic light control vulnerability; hydroelectric plant vulnerability; zero-day shopping list |
| 22 | Dependability | Dependability; availability; Windows 2000 server crash; reliability; serial and parallel reliability; example reliability calculation; other aspects of dependability |
| 24 | Critical Systems | Safety critical vs. mission critical; worst case and safety; HVAC malfunction hazard; Safety Integrity Levels (SIL); Bhopal; IEC 61508; fleet exposure |
| 26 | Safety Plan | Safety plan elements; functional safety approaches; hazards & risks; safety goals & safety requirements; FMEA; FTA; safety case (GSN) |
| 28 | Safety Requirements | Identifying safety-related requirements; safety envelope; Doer/Checker pattern |
| 29 | Single Points of Failure | Fault containment regions (FCR); Toyota UA single point failure; multi-channel pattern; monitor pattern; safety gate pattern; correlated & accumulated faults |
| 30 | SIL Isolation | Isolating different SILs, mixed-SIL interference sources; mitigating cross-SIL interference; isolation and security; CarShark hack |
| 31 | Redundancy Management | Bellingham WA gasoline pipeline mishap; redundancy for availability; redundancy for fault detection; Ariane 5 Flight 501; fail operational; triplex modular redundancy (TMR) 2-of-3 pattern; dual 2-of-2 pattern; high-SIL Doer/Checker pattern; diagnostic effectiveness and proof tests |
| 32 | Safety Architecture Patterns | Supplemental lecture with more detail on patterns: low SIL; self-diagnosis; partitioning; fail operational; voting; fail silent; dual 2-of-2; Ariane 5 Flight 501; fail silent patterns (low, high, mixed SIL); high availability mixed SIL pattern |
| 34 | Security Plan | Security plan elements; Target Attack; security requirements; threats; vulnerabilities; mitigation; validation |
| 35 | Cryptography | Confusion & diffusion; Caesar cipher; frequency analysis; Enigma; Lorenz & Colossus; DES; AES; public key cryptography; secure hashing; digital signatures; certificates; PKI; encrypting vs. signing for firmware update |
| 36 | Security Threats | Stuxnet; attack motivation; attacker threat levels; DirectTV piracy; operational environment; porous firewalls; Davis Besse incident; BlueSniper rifle; integrity; authentication; secrecy; privacy; LG Smart TV privacy; DoS/DDos; feature activation; St. Jude pacemaker recall |
| 37 | Security Vulnerabilities | Exploit vs. attack; Kettle spambot; weak passwords; master passwords; crypto key length; Mirai botnet attack; crypto mistakes; LIFX revisited; CarShark revisited; chip peels; hidden functionality; counterfeit systems; cloud connected devices; embedded-specific attacks |
| 38 | Security Mitigation Validation | Password strength; storing passwords & salt/pepper/key stretching; Adobe password hack; least privilege; Jeep firewall hack; secure update; secure boot; encryption vs. signing revisited; penetration testing; code analysis; other security approaches; rubber hose attack |
| 39 | Security Pitfalls | Konami code; security via obscurity; hotel lock USB hack; Kerckhoff's principle; hospital WPA setup hack; DECSS; Lodz tram attack; proper use of cryptography; zero day exploits; security snake oil; realities of in-system firewalls; aircraft infotainment and firewalls; zombie road sign hack |
Note that in Spring 2018 these are likely to be updated, so if want to see the latest also check the main course page: https://www.ece.cmu.edu/~ece642/ For other lectures and copyright notes, please see my general lecture notes & video page: https://users.ece.cmu.edu/~koopman/lectures/index.html
Subscribe to:
Posts (Atom)
Static Analysis Ranked Defect List
Crazy idea of the day: Static Analysis Ranked Defect List. Here is a software analysis tool feature request/product idea: So many times we...
-
(If you want to know more, see my Webinar on CRCs and checksums based on work sponsored by the FAA.) If you are looking for a lightwei...
-
I recently worked with some embedded system teams who were struggling with the best way to use .c and .h files for their source code. As I w...
-
If you want to estimate how long it's going to take to create a piece of embedded software (and how much it will cost), it's useful ...