|
Safe API Framework 0.1.0 build 384e6ae
Layered API framework for safety-related applications (ERTMS RBC reference targeting CENELEC EN 50128 SIL 4)
|
Document ID:** [PROJECT]-HARA-26.08
Project:** [System Name]
SIL Target:** 4
Version:** 1.0
Date:** [Date]
Status:** [DRAFT / APPROVED]
Author:** [Name]
Reviewed By:** [Functional Safety Manager]
Identify and assess all hazards and failure modes in [System Name] that could lead to unsafe conditions.
Risk-based approach per EN 50128:2011 Section 5:
[Brief description of system function, e.g., "ERTMS Radio Block Centre (RBC) - provides movement authority to trains"]
| Function | SIL | Controlled by | Hazard |
|---|---|---|---|
| [Function 1] | 4 | [Component] | [Associated hazard] |
| [Function 2] | 4 | [Component] | [Associated hazard] |
Description:** RteFramework service called before OSAdapter registered
Cause:** Missing OSAdapter registration, wrong initialization order
Effect:** NULL pointer dereference, system crash
SIL:** 4 (Loss of safety-critical function)
Prevention:**
Documentation of initialization sequence
Detection:**
Description:** String operation (rte_string_*) receives untrusted input
Cause:** Application doesn't validate input length, buffer size insufficient
Effect:** Memory corruption, security risk, crash
SIL:** 4 (Potential for unsafe condition)
Prevention:**
Code review checks for bounded string operations
Detection:**
Description:** Concurrent access to IPC queue without synchronization
Cause:** RTOS OSAdapter doesn't provide mutex/semaphore, application doesn't synchronize
Effect:** Message loss, data corruption, undefined behavior
SIL:** 4 (Loss of safe communication)
Prevention:**
Documentation of thread safety assumptions
Detection:**
Description:** Power loss or corruption during NVM write leaves data in inconsistent state
Cause:** Incomplete write, CRC check fails, corrupted sector
Effect:** Lost critical configuration, inconsistent system state
SIL:** 4 (Loss of data integrity)
Prevention:**
Application has recovery strategy for corrupted data
Detection:**
Description:** Timer service called before initialization, or timeout not met
Cause:** Missing timer_create, OSAdapter timeout inadequate
Effect:** Logic malfunction, missed safety-critical deadlines
SIL:** 4 (Potential functional failure)
Prevention:**
Watchdog timer for overall system health
Detection:**
Description:** Dynamic task creation exceeds pool size
Cause:** Application doesn't limit tasks, unbounded loop creates tasks
Effect:** Task creation fails, critical tasks don't start, system degradation
SIL:** 4 (Loss of safety function)
Prevention:**
Recovery strategy if limit exceeded
Detection:**
| ID | Hazard | Cause | Effect | SIL | Existing Control | Additional Mitigation |
|---|---|---|---|---|---|---|
| H1 | Uninitialized OSAdapter | Missing init | Crash | 4 | Code review, unit test | Documentation, runtime check |
| H2 | Buffer Overflow | Untrusted input | Memory corruption | 4 | Bounded operations | Input validation, static analysis |
| H3 | Race Condition (IPC) | No synchronization | Data corruption | 4 | RTOS mutex | Thread safety analysis, tests |
| H4 | NVM Corruption | Power loss | Data loss | 4 | CRC check | Atomic writes, recovery strategy |
| H5 | Timer Timeout Failure | Timer not ready | Missed deadline | 4 | Timer design | Watchdog, timeout verification |
| H6 | Resource Exhaustion | Dynamic creation | Functional loss | 4 | Resource limits | Static allocation, enforcement |
| Failure Mode | Failure Cause | Failure Effect | Current Control | Risk Priority |
|---|---|---|---|---|
| Returns RTE_STATUS_RESOURCE_EXHAUSTED | No timer slots available | Timer not created, no timeout protection | Pre-allocation of timer pool | Mitigated |
| Returns RTE_STATUS_INVALID_PARAM | Invalid name/handle pointer | Timer not created, error handling required | Parameter validation | Mitigated |
| NULL OSAdapter | OSAdapter not registered | Crash with NULL dereference | Application ensures OSAdapter registered | Mitigated |
Risk Level:** Low (all failure modes have mitigations)
| Failure Mode | Failure Cause | Failure Effect | Current Control | Risk Priority |
|---|---|---|---|---|
| Returns RTE_STATUS_DATA_CORRUPTION | NVM sector corrupted | Read returns invalid data | CRC check, application validation | Mitigated |
| Timeout during read | Slow NVM OSAdapter | Operation blocks indefinitely | Timeout in OSAdapter | Mitigated |
| Returns RTE_STATUS_HARDWARE_FAULT | Underlying NVM failure | Complete loss of NVM access | Application fallback to defaults | Acceptable |
Risk Level:** Medium (requires OSAdapter implementation quality)
[Continue for other RteFramework services...]
Severity (Consequence):**
Low (1): Nuisance
Likelihood (Probability):**
Rare (R): Very unlikely
Risk Score:** Severity × Likelihood
| ID | Hazard | Severity | Likelihood | Risk Score | SIL | Control Effectiveness |
|---|---|---|---|---|---|---|
| H1 | Uninitialized OSAdapter | 4 (Critical) | R (Rare) | 4 | 1 | Code review → SIL 4 |
| H2 | Buffer Overflow | 4 (Critical) | M (Medium) | 12 | 4 | Static analysis + review |
| H3 | Race Condition | 4 (Critical) | L (Low) | 4 | 1 | Thread safety + tests |
| H4 | NVM Corruption | 4 (Critical) | L (Low) | 4 | 1 | CRC + recovery |
| H5 | Timer Timeout | 4 (Critical) | R (Rare) | 4 | 1 | Verification + watchdog |
| H6 | Resource Exhaustion | 3 (High) | M (Medium) | 9 | 3 | Static limits + checks |
OSAdapter implementation must provide:
Before Controls:** Risk scores in Section 5.2
After Controls:**
| ID | Hazard | Original SIL | Control Measures | Residual SIL | Acceptable? |
|---|---|---|---|---|---|
| H1 | Uninitialized OSAdapter | 1 | Code review + docs | 4 | ✓ Yes |
| H2 | Buffer Overflow | 4 | Static analysis + review + input validation | 4 | ✓ Yes |
| H3 | Race Condition | 1 | Thread safety analysis + tests | 4 | ✓ Yes |
| H4 | NVM Corruption | 1 | CRC + atomicity + recovery | 4 | ✓ Yes |
| H5 | Timer Timeout | 1 | Verification + watchdog | 4 | ✓ Yes |
| H6 | Resource Exhaustion | 3 | Static allocation + enforcement | 4 | ✓ Yes |
Conclusion:** All hazards have been reduced to SIL 4 through appropriate controls.
| Item | Action | Owner | Target Date | Status |
|---|---|---|---|---|
| H2: Fuzzing tests for string operations | Develop test suite | QA | [Date] | Pending |
| H3: Thread safety tool evaluation | Select/configure tool | QA | [Date] | Pending |
| H4: NVM failure injection test | Implement test | Test | [Date] | Pending |
Based on HARA findings, the following safety requirements are derived:
SR-001:** RteFramework services shall not be called before OSAdapter registration
SR-002:** All string operations shall use bounded rte_string_* functions
SR-003:** Multi-threaded access to shared resources shall be protected by RTOS synchronization primitives
SR-004:** All NVM data shall be protected by CRC/integrity checks
SR-005:** Timer values shall be verified against application timing requirements
SR-006:** Resource allocations shall not exceed statically-defined limits
[See SafeRequirements document for full requirements]
| Role | Name | Signature | Date |
|---|---|---|---|
| Functional Safety Manager | |||
| System Architect |
| Version | Date | Author | Change |
|---|---|---|---|
| 0.1 | [Date] | [Name] | Initial draft |
| 1.0 | [Date] | [Name] | Approved |