В ядре Linux была устранена следующая уязвимость: drm/amdgpu: fix IP instance memory leak on kobject add failure amdgpu_discovery_sysfs_ips() выделяет ip_hw_instance с kzalloc_flex() и инициализирует свой встроенный kobject перед вызовом kobject_add(). Если kobject_add() терпит неудачу, возвращаемое значение игнорируется, и выполнение продолжается без удаления начальной ссылки на kobject. Неудачный kobject не сохраняется в списке kset, поэтому обычный путь разбора sysfs не может его найти.
В результате ip_hw_instance_release() никогда не вызывается, а выделение ip_hw_instance просачивается. Вызов kobject_put(), когда kobject_add() терпит неудачу, поэтому начальная ссылка удаляется, и ip_hw_instance_release() может освободить выделение. Сохраняйте существующее поведение sysfs с лучшими усилиями, продолжая с оставшимися записями IP после неудачной регистрации.
Проблема была выявлена с помощью инструмента статического анализа, который я разработал и подтвердил ручным обзором. (Вишня выбрана из commit 5c75fbcca8af1096d8d9415b91d8ea6212c22ee1)
Показать оригинальное описание (EN)
In the Linux kernel, the following vulnerability has been resolved: drm/amdgpu: fix IP instance memory leak on kobject add failure amdgpu_discovery_sysfs_ips() allocates ip_hw_instance with kzalloc_flex() and initializes its embedded kobject before calling kobject_add(). If kobject_add() fails, the return value is ignored and execution continues without dropping the initial kobject reference. The failed kobject is not retained in the kset list, so the normal sysfs teardown path cannot find it. As a result, ip_hw_instance_release() is never called and the ip_hw_instance allocation is leaked. Call kobject_put() when kobject_add() fails so the initial reference is dropped and ip_hw_instance_release() can free the allocation. Keep the existing best-effort sysfs behavior by continuing with the remaining IP entries after the failed registration. The issue was identified by a static analysis tool I developed and confirmed by manual review. (cherry picked from commit 5c75fbcca8af1096d8d9415b91d8ea6212c22ee1)