All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH v2] ALSA: hda: handle UAF at probe error
       [not found] <20220414182437.14944-1-nirmoy.das@intel.com>
@ 2022-04-15  4:23 ` Lucas De Marchi
  2022-04-15  8:24   ` Das, Nirmoy
  2022-04-15  7:27 ` Takashi Iwai
  1 sibling, 1 reply; 4+ messages in thread
From: Lucas De Marchi @ 2022-04-15  4:23 UTC (permalink / raw)
  To: Nirmoy Das; +Cc: alsa-devel, tiwai, kai.vehmanen, matthew.auld

On Thu, Apr 14, 2022 at 08:24:37PM +0200, Nirmoy Das wrote:
>Call snd_card_free_on_error() on probe error instead of
>calling snd_card_free() which should handle devres call orders.
>
>Issues: https://gitlab.freedesktop.org/drm/intel/-/issues/5701
>Fixes: e8ad415b7a55 ("ALSA: core: Add managed card creation")
>Signed-off-by: Nirmoy Das <nirmoy.das@intel.com>

This failure in i915 CI seems suspicious since is around module removal.
https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_102714v1/fi-tgl-1115g4/igt@i915_suspend@system-suspend-without-i915.html

And it seems it didn't fix the issue in dg2:

https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_102714v1/bat-dg2-8/igt@gem_lmem_swapping@random-engines.html

Lucas De Marchi

>---
> sound/pci/hda/hda_intel.c | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
>diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
>index 82a45f2b31c4..eb4228c9e37f 100644
>--- a/sound/pci/hda/hda_intel.c
>+++ b/sound/pci/hda/hda_intel.c
>@@ -1730,7 +1730,9 @@ static void azx_check_snoop_available(struct azx *chip)
> static void azx_probe_work(struct work_struct *work)
> {
> 	struct hda_intel *hda = container_of(work, struct hda_intel, probe_work.work);
>-	azx_probe_continue(&hda->chip);
>+	struct azx *chip = &hda->chip;
>+
>+	snd_card_free_on_error(&chip->pci->dev, azx_probe_continue(chip));
> }
>
> static int default_bdl_pos_adj(struct azx *chip)
>@@ -2028,7 +2030,7 @@ static void azx_firmware_cb(const struct firmware *fw, void *context)
> 		dev_err(card->dev, "Cannot load firmware, continue without patching\n");
> 	if (!chip->disabled) {
> 		/* continue probing */
>-		azx_probe_continue(chip);
>+		snd_card_free_on_error(&chip->pci->dev, azx_probe_continue(chip));
> 	}
> }
> #endif
>@@ -2338,7 +2340,6 @@ static int azx_probe_continue(struct azx *chip)
> out_free:
> 	if (err < 0) {
> 		pci_set_drvdata(pci, NULL);
>-		snd_card_free(chip->card);
> 		return err;
> 	}
>
>-- 
>2.35.1
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] ALSA: hda: handle UAF at probe error
       [not found] <20220414182437.14944-1-nirmoy.das@intel.com>
  2022-04-15  4:23 ` [PATCH v2] ALSA: hda: handle UAF at probe error Lucas De Marchi
@ 2022-04-15  7:27 ` Takashi Iwai
  2022-04-15  8:16   ` Das, Nirmoy
  1 sibling, 1 reply; 4+ messages in thread
From: Takashi Iwai @ 2022-04-15  7:27 UTC (permalink / raw)
  To: Nirmoy Das; +Cc: alsa-devel, lucas.demarchi, tiwai, kai.vehmanen, matthew.auld

On Thu, 14 Apr 2022 20:24:37 +0200,
Nirmoy Das wrote:
> 
> Call snd_card_free_on_error() on probe error instead of
> calling snd_card_free() which should handle devres call orders.

This won't change any practical behavior, because HD-audio driver
doesn't use snd_devm_card_new().  snd_card_free() still gets called
explicitly in the relevant code paths.

> Issues: https://gitlab.freedesktop.org/drm/intel/-/issues/5701

So it must be a different cause for this problem...


thanks,

Takashi

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] ALSA: hda: handle UAF at probe error
  2022-04-15  7:27 ` Takashi Iwai
@ 2022-04-15  8:16   ` Das, Nirmoy
  0 siblings, 0 replies; 4+ messages in thread
From: Das, Nirmoy @ 2022-04-15  8:16 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: alsa-devel, lucas.demarchi, tiwai, kai.vehmanen, matthew.auld


On 4/15/2022 9:27 AM, Takashi Iwai wrote:
> On Thu, 14 Apr 2022 20:24:37 +0200,
> Nirmoy Das wrote:
>> Call snd_card_free_on_error() on probe error instead of
>> calling snd_card_free() which should handle devres call orders.
> This won't change any practical behavior, because HD-audio driver
> doesn't use snd_devm_card_new().

OK, I guess I am looking into some timing dependent issue because with the

patch I didn't see the UAF.


Thanks,

Nirmoy


>   snd_card_free() still gets called
> explicitly in the relevant code paths.
>
>> Issues: https://gitlab.freedesktop.org/drm/intel/-/issues/5701
> So it must be a different cause for this problem...
>
>
> thanks,
>
> Takashi

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] ALSA: hda: handle UAF at probe error
  2022-04-15  4:23 ` [PATCH v2] ALSA: hda: handle UAF at probe error Lucas De Marchi
@ 2022-04-15  8:24   ` Das, Nirmoy
  0 siblings, 0 replies; 4+ messages in thread
From: Das, Nirmoy @ 2022-04-15  8:24 UTC (permalink / raw)
  To: Lucas De Marchi; +Cc: alsa-devel, tiwai, kai.vehmanen, matthew.auld


On 4/15/2022 6:23 AM, Lucas De Marchi wrote:
> On Thu, Apr 14, 2022 at 08:24:37PM +0200, Nirmoy Das wrote:
>> Call snd_card_free_on_error() on probe error instead of
>> calling snd_card_free() which should handle devres call orders.
>>
>> Issues: https://gitlab.freedesktop.org/drm/intel/-/issues/5701
>> Fixes: e8ad415b7a55 ("ALSA: core: Add managed card creation")
>> Signed-off-by: Nirmoy Das <nirmoy.das@intel.com>
>
> This failure in i915 CI seems suspicious since is around module removal.
> https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_102714v1/fi-tgl-1115g4/igt@i915_suspend@system-suspend-without-i915.html 
>


Yes, the issue is related to module reload  because I can reproduce a 
UAF by running the module reload test twice.


> And it seems it didn't fix the issue in dg2:
>
> https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_102714v1/bat-dg2-8/igt@gem_lmem_swapping@random-engines.html 
>


I guess this is some timing bug around device hotplug  as this patch 
seems to help even though this driver doesn't use devres. I need to 
check more.


Thanks,

Nirmoy


>
> Lucas De Marchi
>
>> ---
>> sound/pci/hda/hda_intel.c | 7 ++++---
>> 1 file changed, 4 insertions(+), 3 deletions(-)
>>
>> diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
>> index 82a45f2b31c4..eb4228c9e37f 100644
>> --- a/sound/pci/hda/hda_intel.c
>> +++ b/sound/pci/hda/hda_intel.c
>> @@ -1730,7 +1730,9 @@ static void azx_check_snoop_available(struct 
>> azx *chip)
>> static void azx_probe_work(struct work_struct *work)
>> {
>>     struct hda_intel *hda = container_of(work, struct hda_intel, 
>> probe_work.work);
>> -    azx_probe_continue(&hda->chip);
>> +    struct azx *chip = &hda->chip;
>> +
>> +    snd_card_free_on_error(&chip->pci->dev, azx_probe_continue(chip));
>> }
>>
>> static int default_bdl_pos_adj(struct azx *chip)
>> @@ -2028,7 +2030,7 @@ static void azx_firmware_cb(const struct 
>> firmware *fw, void *context)
>>         dev_err(card->dev, "Cannot load firmware, continue without 
>> patching\n");
>>     if (!chip->disabled) {
>>         /* continue probing */
>> -        azx_probe_continue(chip);
>> +        snd_card_free_on_error(&chip->pci->dev, 
>> azx_probe_continue(chip));
>>     }
>> }
>> #endif
>> @@ -2338,7 +2340,6 @@ static int azx_probe_continue(struct azx *chip)
>> out_free:
>>     if (err < 0) {
>>         pci_set_drvdata(pci, NULL);
>> -        snd_card_free(chip->card);
>>         return err;
>>     }
>>
>> -- 
>> 2.35.1
>>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-04-19 11:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20220414182437.14944-1-nirmoy.das@intel.com>
2022-04-15  4:23 ` [PATCH v2] ALSA: hda: handle UAF at probe error Lucas De Marchi
2022-04-15  8:24   ` Das, Nirmoy
2022-04-15  7:27 ` Takashi Iwai
2022-04-15  8:16   ` Das, Nirmoy

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.