mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jaroslav Kysela <perex@perex.cz>
To: Takashi Iwai <tiwai@suse.de>, Lv Yunlong <lyl2019@mail.ustc.edu.cn>
Cc: tiwai@suse.com, alsa-devel@alsa-project.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] sound/isa/sb/emu8000: Fix a use after free in snd_emu8000_create_mixer
Date: Mon, 26 Apr 2021 16:38:41 +0200	[thread overview]
Message-ID: <af5a6764-76ee-3184-2622-a756c23fbc98@perex.cz> (raw)
In-Reply-To: <s5ha6pl2kh8.wl-tiwai@suse.de>

Dne 26. 04. 21 v 16:23 Takashi Iwai napsal(a):
> On Mon, 26 Apr 2021 15:11:29 +0200,
> Lv Yunlong wrote:
>>
>> Our code analyzer reported a uaf.
>>
>> In snd_emu8000_create_mixer, the callee snd_ctl_add(..,emu->controls[i])
>> calls snd_ctl_add_replace(.., kcontrol,..). Inside snd_ctl_add_replace(),
>> if error happens, kcontrol will be freed by snd_ctl_free_one(kcontrol).
>> Then emu->controls[i] points to a freed memory, and the execution comes
>> to __error branch of snd_emu8000_create_mixer. The freed emu->controls[i]
>> is used in snd_ctl_remove(card, emu->controls[i]).
>>
>> My patch set emu->controls[i] to NULL if snd_ctl_add() failed to avoid
>> the uaf.
>>
>> Signed-off-by: Lv Yunlong <lyl2019@mail.ustc.edu.cn>
> 
> Thanks, applied now.
> 
> The bug was hard to be seen due to the coding style, so we'd need a
> cleanup, but it's a different story...

Yes, it would be better to assign the return value from snd_ctl_new1 to a
local variable and set emu->controls[i] only when everything succeeds.

					Jaroslav

-- 
Jaroslav Kysela <perex@perex.cz>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.

      reply	other threads:[~2021-04-26 14:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-26 13:11 Lv Yunlong
2021-04-26 14:23 ` Takashi Iwai
2021-04-26 14:38   ` Jaroslav Kysela [this message]

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=af5a6764-76ee-3184-2622-a756c23fbc98@perex.cz \
    --to=perex@perex.cz \
    --cc=alsa-devel@alsa-project.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lyl2019@mail.ustc.edu.cn \
    --cc=tiwai@suse.com \
    --cc=tiwai@suse.de \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®