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=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 D0A73C43603 for ; Wed, 18 Dec 2019 00:08:14 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 49B432176D for ; Wed, 18 Dec 2019 00:08:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="htU0MCjy" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 49B432176D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 7A09D1614; Wed, 18 Dec 2019 01:07:22 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 7A09D1614 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1576627692; bh=zpM4asH930XV8j7Xlw7Y6iI0xa5tkLYHuUb15mfz3QE=; h=From:To:Date:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=htU0MCjy0Qz8jG8IueZEMF2EVJHQgDoWXJHeDD0RLHLoEqRo6qTepWOIXoLmtNoYU CjAciKzNxVrl6IUyH3ZWfI3VZjh/4iFvcE0ktxdh0JTWnJyffMpbTPsqV+vfRIVo7R UXkktAxAyoVtgfwC0rxqOoYMi/7h8Lsj4BpO56ms= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 59F15F80269; Wed, 18 Dec 2019 01:05:51 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 41A82F80260; Wed, 18 Dec 2019 01:05:41 +0100 (CET) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 12D4FF80218 for ; Wed, 18 Dec 2019 01:05:36 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 12D4FF80218 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Dec 2019 16:05:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,327,1571727600"; d="scan'208";a="266723547" Received: from dshoemak-mobl.amr.corp.intel.com (HELO pbossart-mobl3.amr.corp.intel.com) ([10.251.3.243]) by FMSMGA003.fm.intel.com with ESMTP; 17 Dec 2019 16:05:31 -0800 From: Pierre-Louis Bossart To: alsa-devel@alsa-project.org Date: Tue, 17 Dec 2019 18:05:18 -0600 Message-Id: <20191218000518.5830-4-pierre-louis.bossart@linux.intel.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191218000518.5830-1-pierre-louis.bossart@linux.intel.com> References: <20191218000518.5830-1-pierre-louis.bossart@linux.intel.com> MIME-Version: 1.0 Cc: Dragos Tarcatu , Kuninori Morimoto , tiwai@suse.de, Ranjani Sridharan , Pierre-Louis Bossart , broonie@kernel.org Subject: [alsa-devel] [PATCH v2 3/3] ASoC: topology: Prevent use-after-free in snd_soc_get_pcm_runtime() X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" From: Dragos Tarcatu remove_link() is currently calling snd_soc_remove_pcm_runtime() after it has already freed the memory for the link name. But this is later read from snd_soc_get_pcm_runtime() causing a KASAN use-after-free warning. Reorder the cleanups to fix this issue. Reviewed-by: Ranjani Sridharan Signed-off-by: Dragos Tarcatu Signed-off-by: Pierre-Louis Bossart --- sound/soc/soc-topology.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c index f8bd406c6198..2b3c74a0b126 100644 --- a/sound/soc/soc-topology.c +++ b/sound/soc/soc-topology.c @@ -548,14 +548,14 @@ static void remove_link(struct snd_soc_component *comp, if (dobj->ops && dobj->ops->link_unload) dobj->ops->link_unload(comp, dobj); - kfree(link->name); - kfree(link->stream_name); - kfree(link->cpus->dai_name); - list_del(&dobj->list); snd_soc_remove_pcm_runtime(comp->card, snd_soc_get_pcm_runtime(comp->card, link)); + + kfree(link->name); + kfree(link->stream_name); + kfree(link->cpus->dai_name); kfree(link); } -- 2.20.1 _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org https://mailman.alsa-project.org/mailman/listinfo/alsa-devel