CVE-2024-49955: ACPI: battery: Fix possible crash when unregistering a battery hook
Description
===========
In the Linux kernel, the following vulnerability has been resolved:
ACPI: battery: Fix possible crash when unregistering a battery hook
When a battery hook returns an error when adding a new battery, then the battery hook is automatically unregistered.
However the battery hook provider cannot know that, so it will later call battery_hook_unregister() on the already unregistered battery hook, resulting in a crash.
Fix this by using the list head to mark already unregistered battery hooks as already being unregistered so that they can be ignored by battery_hook_unregister().
The Linux kernel CVE team has assigned CVE-2024-49955 to this issue.
Affected and fixed versions
===========================
Issue introduced in 4.17 with commit fa93854f7a7e and fixed in 5.10.227 with commit da964de4c181 Issue introduced in 4.17 with commit fa93854f7a7e and fixed in 5.15.168 with commit 07b98400cb02 Issue introduced in 4.17 with commit fa93854f7a7e and fixed in 6.1.113 with commit ca1fb7942a28 Issue introduced in 4.17 with commit fa93854f7a7e and fixed in 6.6.55 with commit ce31847f109c Issue introduced in 4.17 with commit fa93854f7a7e and fixed in 6.10.14 with commit ca26e8eed9c1 Issue introduced in 4.17 with commit fa93854f7a7e and fixed in 6.11.3 with commit 9f469ef1c79d Issue introduced in 4.17 with commit fa93854f7a7e and fixed in 6.12-rc2 with commit 76959aff14a0
Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community.
Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at
https://cve.org/CVERecord/?id=CVE-2024-49955
will be updated if fixes are backported, please check that for the most up to date information about this issue.
Affected files
==============
The file(s) affected by this issue are:
drivers/acpi/battery.c
Mitigation
==========
The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits:
https://git.kernel.org/stable/c/da964de4c18199e14b961b5b2e5e6570552a313c https://git.kernel.org/stable/c/07b98400cb0285a6348188aa8c5ec6a2ae0551f7 https://git.kernel.org/stable/c/ca1fb7942a287b40659cc79551a1de54a2c2e7d5 https://git.kernel.org/stable/c/ce31847f109c3a5b2abdd19d7bcaafaacfde53de https://git.kernel.org/stable/c/ca26e8eed9c1c6651f51f7fa38fe444f8573cd1b https://git.kernel.org/stable/c/9f469ef1c79dac7f9ac1518643a33703918f7e13 https://git.kernel.org/stable/c/76959aff14a0012ad6b984ec7686d163deccdc16