Subject: CVE-2024-43830: leds: trigger: Unregister sysfs attributes before calling deactivate()

From: Greg Kroah-Hartman <[email-masked]>

Description
===========

In the Linux kernel, the following vulnerability has been resolved:

leds: trigger: Unregister sysfs attributes before calling deactivate()

Triggers which have trigger specific sysfs attributes typically store
related data in trigger-data allocated by the activate() callback and
freed by the deactivate() callback.

Calling device_remove_groups() after calling deactivate() leaves a window
where the sysfs attributes show/store functions could be called after
deactivation and then operate on the just freed trigger-data.

Move the device_remove_groups() call to before deactivate() to close
this race window.

This also makes the deactivation path properly do things in reverse order
of the activation path which calls the activate() callback before calling
device_add_groups().

The Linux kernel CVE team has assigned CVE-2024-43830 to this issue.

Affected and fixed versions
===========================

	Issue introduced in 4.19 with commit a7e7a3156300 and fixed in 4.19.320 with commit c3b7a650c871
	Issue introduced in 4.19 with commit a7e7a3156300 and fixed in 5.4.282 with commit d1415125b701
	Issue introduced in 4.19 with commit a7e7a3156300 and fixed in 5.10.224 with commit 09c1583f0e10
	Issue introduced in 4.19 with commit a7e7a3156300 and fixed in 5.15.165 with commit 3fb6a9d67cfd
	Issue introduced in 4.19 with commit a7e7a3156300 and fixed in 6.1.103 with commit 734ba6437e80
	Issue introduced in 4.19 with commit a7e7a3156300 and fixed in 6.6.44 with commit cb8aa9d2a4c8
	Issue introduced in 4.19 with commit a7e7a3156300 and fixed in 6.10.3 with commit 0788a6f3523d
	Issue introduced in 4.19 with commit a7e7a3156300 and fixed in 6.11 with commit c0dc9adf9474

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-43830
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/leds/led-triggers.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/c3b7a650c8717aa89df318364609c86cbc040156
	https://git.kernel.org/stable/c/d1415125b701ef13370e2761f691ec632a5eb93a
	https://git.kernel.org/stable/c/09c1583f0e10c918855d6e7540a79461a353e5d6
	https://git.kernel.org/stable/c/3fb6a9d67cfd812a547ac73ec02e1077c26c640d
	https://git.kernel.org/stable/c/734ba6437e80dfc780e9ee9d95f912392d12b5ea
	https://git.kernel.org/stable/c/cb8aa9d2a4c8a15d6a43ccf901ef3d094aa60374
	https://git.kernel.org/stable/c/0788a6f3523d3686a9eed5ea1e6fcce6841277b2
	https://git.kernel.org/stable/c/c0dc9adf9474ecb7106e60e5472577375aedaed3