Kernel series forces kobject release callbacks, fixes leaks and UAFs
A Clang attribute on struct kobj_type::release surfaces dozens of missing cleanups and closes real use-after-free and leak bugs across the tree.
Ian Rogers has posted a patch series that makes the kobject subsystem refuse silent omission of a release callback, fixing more than ten memory leaks and use-after-free bugs that the compiler can now diagnose automatically.
Linux documentation has long insisted that every kobject must carry a release method and must stay valid until that method runs. In practice, many struct kobj_type definitions simply left the field blank. When a dynamic kobject was dropped, the kernel either leaked the allocation or, under delayed cleanup debugging, freed the enclosing object too early and left a dangling reference.
Rogers introduces a compiler attribute that requires explicit initialization of the release field. Applied across the tree, it flagged about thirty kobj_type definitions. Ten of those belonged to dynamically allocated objects or structures that were being freed outside the kobject lifecycle. The series adds proper release callbacks (or switches to helpers that supply them) in powerpc secure variables, SuperH store-queue sysfs, the cpufreq ondemand and conservative governors, ACPI CPPC performance sysfs, the distributed lock manager, Xen hypervisor sysfs, s390 SCLP memory hotplug, UBIFS sysfs, and AMD KFD queue procfs entries.
The remaining legacy definitions cover static, per-CPU, or parent-managed objects that are never freed by kobject_put. Those sites now set release to NULL with a comment explaining why, so the requirement is satisfied without inventing empty stubs the docs discourage.
The work follows discussion at the Linux Plumbers Conference and turns a long-standing documentation rule into a compile-time check. Subsystems that register kobjects in sysfs and tear them down on error or module unload are the main beneficiaries: missing release paths no longer depend on reviewers noticing the omission by hand.