From patchwork Thu Jan 30 18:38:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 232368 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=DKIMWL_WL_HIGH, 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 9C2F1C35240 for ; Thu, 30 Jan 2020 18:45:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 73CEC20674 for ; Thu, 30 Jan 2020 18:45:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580409954; bh=j+yLi+3j4hwP60s9Q2eMbBz0UexJHV/VUghA6zCWvK4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=ExGKhC1J8UwiUojyyUuF7txajPVxGwza92kkw5ETsy3mcP2rQC/m9ysck9BUabgDG IJPshmcPGh9bRLJAGIFGwbs5BUodEjs3PUI3nd63jaLK4YGKYldKTqVxAtxyCPZyvD JefrTOjYSlBt3zvtA7HHoNOgJZBQGh1H5dLVhU8g= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731097AbgA3Spw (ORCPT ); Thu, 30 Jan 2020 13:45:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:55620 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731095AbgA3Spv (ORCPT ); Thu, 30 Jan 2020 13:45:51 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BBE01205F4; Thu, 30 Jan 2020 18:45:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580409951; bh=j+yLi+3j4hwP60s9Q2eMbBz0UexJHV/VUghA6zCWvK4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d0G9WHuBruY7cPLJtfljccyQE3NXDMY7via9op6+OD/zkxXxcMqV51wGkqs3emYhf UoZ6tl1hkNfjGHlJjOUOZjJxzD74p4LvUpllMf0bLYzrR7K3Wi9HVezJWU5DlUbq9w 9ERvmQzE9uEPehsxt0343GX7nBzodYPKIxePEwuo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ranjani Sridharan , Dragos Tarcatu , Pierre-Louis Bossart , Kuninori Morimoto , Mark Brown , Sasha Levin Subject: [PATCH 5.4 057/110] ASoC: topology: Prevent use-after-free in snd_soc_get_pcm_runtime() Date: Thu, 30 Jan 2020 19:38:33 +0100 Message-Id: <20200130183621.853126337@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200130183613.810054545@linuxfoundation.org> References: <20200130183613.810054545@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Dragos Tarcatu [ Upstream commit dd836ddf4e4e1c7f1eb2ae44783ccd70872ef24e ] 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 Reviewed-by: Kuninori Morimoto Link: https://lore.kernel.org/r/20191204210447.11701-4-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- 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 fd2d22ddc81b0..7ccbca47240d7 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); }