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=-6.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 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 42189C43603 for ; Thu, 5 Dec 2019 00:12:42 +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 50501214B2 for ; Thu, 5 Dec 2019 00:12:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="efvPfEp1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 50501214B2 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=renesas.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 DA3E51615; Thu, 5 Dec 2019 01:11:48 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz DA3E51615 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1575504759; bh=nqJ/VyjnnboxCVY8KvxqeXpA0TIuwOlln5aSAEkfgFk=; h=Date:From:To:In-Reply-To:References:Cc:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=efvPfEp1vfBscSIiACTZ+awznUwPBDKYfHQDMAR5OYLty8e8KKAvIyIjE432iunRr Vxh7RZVztIyBT4GuLtGjI45DedgbMDBvBTrKK9VHvp4GlupHf70X4BL7SCwNZ1fiZf imJpVVS2/72DWyomMxSBjoHVI1f8kfv6GdyElrWI= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 520A0F8010F; Thu, 5 Dec 2019 01:11:48 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id DE692F801EC; Thu, 5 Dec 2019 01:11:46 +0100 (CET) Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by alsa1.perex.cz (Postfix) with ESMTP id 0F920F8010F for ; Thu, 5 Dec 2019 01:11:40 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 0F920F8010F Date: 05 Dec 2019 09:11:37 +0900 X-IronPort-AV: E=Sophos;i="5.69,279,1571670000"; d="scan'208";a="33273957" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 05 Dec 2019 09:11:37 +0900 Received: from morimoto-PC.renesas.com (unknown [10.166.18.140]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id E572E4114C09; Thu, 5 Dec 2019 09:11:37 +0900 (JST) Message-ID: <87d0d3bphi.wl-kuninori.morimoto.gx@renesas.com> From: Kuninori Morimoto To: Pierre-Louis Bossart In-Reply-To: <20191204210447.11701-4-pierre-louis.bossart@linux.intel.com> References: <20191204210447.11701-1-pierre-louis.bossart@linux.intel.com> <20191204210447.11701-4-pierre-louis.bossart@linux.intel.com> User-Agent: Wanderlust/2.15.9 Emacs/24.5 Mule/6.0 MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Cc: tiwai@suse.de, Dragos Tarcatu , alsa-devel@alsa-project.org, broonie@kernel.org, Ranjani Sridharan Subject: Re: [alsa-devel] [PATCH 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" Hi > From: Dragos Tarcatu > > remove_link() is currently calling snd_soc_remove_dai_link() 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 | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c > index 81d2af000a5c..248530d028a6 100644 > --- a/sound/soc/soc-topology.c > +++ b/sound/soc/soc-topology.c > @@ -548,12 +548,12 @@ static void remove_link(struct snd_soc_component *comp, > if (dobj->ops && dobj->ops->link_unload) > dobj->ops->link_unload(comp, dobj); > > + list_del(&dobj->list); > + snd_soc_remove_dai_link(comp->card, link); > + > kfree(link->name); > kfree(link->stream_name); > kfree(link->cpus->dai_name); > - > - list_del(&dobj->list); > - snd_soc_remove_dai_link(comp->card, link); > kfree(link); > } Yeah, indeed this is needed, I think. Reviewed-by: Kuninori Morimoto Thank you for your help !! Best regards --- Kuninori Morimoto _______________________________________________ Alsa-devel mailing list Alsa-devel@alsa-project.org https://mailman.alsa-project.org/mailman/listinfo/alsa-devel