Improving resource ownership and life-time in linux device drivers
summary
Many subsystems mix reference‑counted resources with regular data and embed implementation structs inside driver private data, leading to use‑after‑free and leaked resources on unplug or provider unbind. Proposed fix: subsystems create and own a reference‑counted wrapper around the provider implementation, consumers hold opaque resource handles that weakly reference the wrapper, and API calls enter SRCU protection so calls return clean errors when providers vanish. Plan: convert gpio first, add a kernel library for the pattern, use Coccinelle and a test suite to find and fix affected drivers.
AI-written summary · about
chapters (11)
- 0:00Introduction
- 1:03Device driver lifetime issues
- 7:44Real-world resource problems
- 13:28Provider-consumer relationships
- 27:17Embedded struct device pitfalls
- 32:35Volfram’s proposed solution
- 35:41Unified resource wrapper model
- 41:44Abstraction library proposal
- 43:15Broader kernel implications
- 50:21Debugging and testing approaches
- 53:14Q&A
related talks
40mBoF: Object Life-Time Handling in Driver Subsystems
47mSubsystems with Object Lifetime Issues (in the Embedded Case)
41mObject Lifetime Issues - a Threat for Safety?
44mWhy is devm_kzalloc() harmful and what can we do about it
40mKernel Locking Engineering
16mSharing Reset GPIOs in the Linux Kernel
45mBOF: Corporate Use of Embedded Linux
19m"Exclusive" resources that are not exclusive - the case of shared GPIOs in...
