ALSA: hda: Fix UAF of leds class devs at unbinding
authorTakashi Iwai <tiwai@suse.de>
Wed, 26 Jan 2022 14:50:11 +0000 (15:50 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 8 Feb 2022 17:34:03 +0000 (18:34 +0100)
commit0e629052f013eeb61494d4df2f1f647c2a9aef47
treed8141f09e7311a8e202caf6d8cd8c91bc7ccd1ae
parent303e89f94b66ec3ad3e3e94f315faceb7ae7b9ea
ALSA: hda: Fix UAF of leds class devs at unbinding

commit 549f8ffc7b2f7561bea7f90930b6c5104318e87b upstream.

The LED class devices that are created by HD-audio codec drivers are
registered via devm_led_classdev_register() and associated with the
HD-audio codec device.  Unfortunately, it turned out that the devres
release doesn't work for this case; namely, since the codec resource
release happens before the devm call chain, it triggers a NULL
dereference or a UAF for a stale set_brightness_delay callback.

For fixing the bug, this patch changes the LED class device register
and unregister in a manual manner without devres, keeping the
instances in hda_gen_spec.

Reported-by: Alexander Sergeyev <sergeev917@gmail.com>
Cc: <stable@vger.kernel.org>
Link: https://lore.kernel.org/r/20220111195229.a77wrpjclqwrx4bx@localhost.localdomain
Link: https://lore.kernel.org/r/20220126145011.16728-1-tiwai@suse.de
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
sound/pci/hda/hda_generic.c
sound/pci/hda/hda_generic.h