From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7D7F6C43460 for ; Mon, 26 Apr 2021 14:24:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 38CA36127A for ; Mon, 26 Apr 2021 14:24:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233758AbhDZOYv (ORCPT ); Mon, 26 Apr 2021 10:24:51 -0400 Received: from mx2.suse.de ([195.135.220.15]:43512 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233816AbhDZOX5 (ORCPT ); Mon, 26 Apr 2021 10:23:57 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 21D65ACFD; Mon, 26 Apr 2021 14:23:15 +0000 (UTC) Date: Mon, 26 Apr 2021 16:23:15 +0200 Message-ID: From: Takashi Iwai To: Lv Yunlong Cc: perex@perex.cz, 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 In-Reply-To: <20210426131129.4796-1-lyl2019@mail.ustc.edu.cn> References: <20210426131129.4796-1-lyl2019@mail.ustc.edu.cn> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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... Takashi