snd/hda: fix use-after-free after module unload
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 17 lines · Peter Wu
register_vga_switcheroo()sets the PM ops from the hda structure which is freed later inazx_free. Make sure that these ops are cleared.Caught by KASAN.
Fixes 246efa4a072f ("snd/hda: add runtime suspend/resume on optimus support (v4)")Signed-off-by Peter Wu <[email protected]>--- sound/pci/hda/hda_intel.c | 1 + 1 file changed, 1 insertion(+)sound/pci/hda/hda_intel.c +0
-0
sound/pci/hda/hda_intel.c static int azx_free(struct azx *chip) · line 1222
Quoted 4 lines
sound/pci/hda/hda_intel.c +1
-0@@ -1219,6 +1219,7 @@ static int azx_free(struct azx *chip)snd_hda_unlock_devices (&chip->bus);if (hda->vga_switcheroo_registered)vga_switcheroo_unregister_client (chip->pci); +vga_switcheroo_fini_domain_pm_ops (chip->card->dev);
The domain pm ops is set only when hda->vga_switcheroo_registered flag is set. So the call should be in the previous if block.
Also, the indentation looks wrong. Please use the correct indentation.
Could you resubmit with these fixes?
thanks,
Takashi
Quoted 14 lines · Takashi Iwai
Quoted 12 lines · Peter Wu
register_vga_switcheroo()sets the PM ops from the hda structure which is freed later inazx_free. Make sure that these ops are cleared.Caught by KASAN.
Fixes 246efa4a072f ("snd/hda: add runtime suspend/resume on optimus support (v4)")Signed-off-by Peter Wu <[email protected]>--- sound/pci/hda/hda_intel.c | 1 + 1 file changed, 1 insertion(+)
Quoted 12 lines
sound/pci/hda/hda_intel.c static int azx_free(struct azx *chip) · line 1222
Quoted 9 lines
sound/pci/hda/hda_intel.c +1
-0@@ -1219,6 +1219,7 @@ static int azx_free(struct azx *chip)snd_hda_unlock_devices (&chip->bus);if (hda->vga_switcheroo_registered)vga_switcheroo_unregister_client (chip->pci); +vga_switcheroo_fini_domain_pm_ops (chip->card->dev);The domain pm ops is set only when
hda->vga_switcheroo_registeredflag is set. So the call should be in the previous if block.
Yes that would be cleaner, will do that.
Quoted 2 lines
Also, the indentation looks wrong. Please use the correct indentation.
Noticed too late that the editor config was wrong on the testing machine.
Quoted 1 line
Could you resubmit with these fixes?
I will, thanks for the feedback!
Signature · 3 lines
Kind regards, Peter Wu https://lekensteyn.nl
PATCH v2 1/1 snd/hda: fix use-after-free after module unload
In reply to Takashi Iwairegister_vga_switcheroo() sets the PM ops from the hda structure which is freed later in azx_free. Make sure that these ops are cleared.
Caught by KASAN, initially noticed due to a general protection fault.
---
Maybe Cc stable?
--- sound/pci/hda/hda_intel.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
sound/pci/hda/hda_intel.c +3 -1
@@ -1217,8 +1217,10 @@ static int azx_free(struct azx *chip)if (use_vga_switcheroo (hda)) {if (chip->disabled && hda->probe_continued)snd_hda_unlock_devices (&chip->bus); -if (hda->vga_switcheroo_registered) +if (hda->vga_switcheroo_registered) {vga_switcheroo_unregister_client (chip->pci); +vga_switcheroo_fini_domain_pm_ops (chip->card->dev); + } }if (bus->chip_init) {
Signature · 1 line
2.9.0
Quoted 10 lines · Peter Wu
register_vga_switcheroo()sets the PM ops from the hda structure which is freed later inazx_free. Make sure that these ops are cleared.Caught by KASAN, initially noticed due to a general protection fault.
Fixes 246efa4a072f ("snd/hda: add runtime suspend/resume on optimus support (v4)")Signed-off-by Peter Wu <[email protected]>---
Maybe Cc stable?
Yes, I applied with Cc to stable now.
thanks,
Takashi