All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Das, Nirmoy" <nirmoy.das@intel.com>
To: Lucas De Marchi <lucas.demarchi@intel.com>
Cc: alsa-devel@alsa-project.org, tiwai@suse.com,
	kai.vehmanen@linux.intel.com, matthew.auld@intel.com
Subject: Re: [PATCH v2] ALSA: hda: handle UAF at probe error
Date: Fri, 15 Apr 2022 10:24:52 +0200	[thread overview]
Message-ID: <e365082a-672d-8cdc-2117-1af9e4a6fc89@intel.com> (raw)
In-Reply-To: <20220415042356.arajaxgmzbkzltc4@ldmartin-desk2>


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
>>

  reply	other threads:[~2022-04-19 11:56 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [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 [this message]
2022-04-15  7:27 ` Takashi Iwai
2022-04-15  8:16   ` Das, Nirmoy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e365082a-672d-8cdc-2117-1af9e4a6fc89@intel.com \
    --to=nirmoy.das@intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=kai.vehmanen@linux.intel.com \
    --cc=lucas.demarchi@intel.com \
    --cc=matthew.auld@intel.com \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.