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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 210CCC433F5 for ; Wed, 27 Apr 2022 06:56:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358426AbiD0G7Z (ORCPT ); Wed, 27 Apr 2022 02:59:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1358486AbiD0G6m (ORCPT ); Wed, 27 Apr 2022 02:58:42 -0400 Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0465416582 for ; Tue, 26 Apr 2022 23:55:22 -0700 (PDT) Received: by mail-pg1-x533.google.com with SMTP id r83so751385pgr.2 for ; Tue, 26 Apr 2022 23:55:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=/H/dr1bU3IWO2Zz3V0TPFg82hzHtg38B7AemVKe2A0M=; b=Swzf4xKjfP1XA2e+DubAp3b10kwTb8AthU76bMCJuIkF5WelHZd8ki7PyrmZBVV73h 7V0jsT/TNILRELnOmATKXQELGQt181VCk812Hg2n6tfah6g6r7R2L/PSsTy2SWXPPtYc VLmH7wlBiSjVx2ZkoP8BNPMn9iXWfbmvOKFZg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=/H/dr1bU3IWO2Zz3V0TPFg82hzHtg38B7AemVKe2A0M=; b=SR6LwFlgxpby03lz1xpNO5IGKEeCB8EQ4/2EG66+EqKGE5HeXSNnXNxOzED/EuxTT4 lAAZEV5ST//pMZCVQNVuOWflin1Mju3ilE3QozbL3MV8uQvj0kPt3tMrfHtwM7d2M092 TQQLuqiWMwgaGn/YZaEtSjA+ftYoyg6ND/xAQ/9crU7BUPqYiDYtc1fDV1/LgiWUBWZ5 QXPHtQ42C5CSAU+HtMZt68mSaZfYwRpzdoRTIO6SumZlhzeRQluL8yjAeHxXnymuiZlh +mJLMYN/dj6E91tEgxy/m+qo8FaXCLWsCvOYzZ3BnmYEE++JF21D7cyk7df0zVB80qa1 MSHw== X-Gm-Message-State: AOAM533lzUR9tpYxArpDIRkRKNvOcP/9ivkn8Ygbr+CeqFMAYoZLvloE IONYmxjZcyHA2iFzQk16+Ch/Aw== X-Google-Smtp-Source: ABdhPJxAbcUOPHGpu19WyFlEpx1bs/thLds4ctz1Fli9HAULfa6p4OeS6pNFkws8wrL4iVVeIVrnCw== X-Received: by 2002:a63:df18:0:b0:3ab:938b:e6c5 with SMTP id u24-20020a63df18000000b003ab938be6c5mr5157870pgg.165.1651042522409; Tue, 26 Apr 2022 23:55:22 -0700 (PDT) Received: from google.com ([2401:fa00:8f:203:8e2d:263:26e7:c039]) by smtp.gmail.com with ESMTPSA id 7-20020a17090a000700b001da3920d985sm1276416pja.12.2022.04.26.23.55.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Apr 2022 23:55:21 -0700 (PDT) Date: Wed, 27 Apr 2022 15:55:17 +0900 From: Sergey Senozhatsky To: Pierre-Louis Bossart Cc: =?iso-8859-1?Q?P=E9ter?= Ujfalusi , Sergey Senozhatsky , Liam Girdwood , Ranjani Sridharan , Kai Vehmanen , Jaska Uimonen , alsa-devel@alsa-project.org, Takashi Iwai , linux-kernel@vger.kernel.org, Tomasz Figa , Mark Brown , Ricardo Ribalda , sound-open-firmware@alsa-project.org Subject: Re: out-of-bounds access in sound/soc/sof/topology.c Message-ID: References: <8eeb08ec-4836-cf7d-2285-8ed74ccfc1cb@linux.intel.com> <8986a1c6-b546-7a66-a778-048487624c95@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On (22/04/19 08:07), Pierre-Louis Bossart wrote: > > Your analyzes are spot on, unfortunately. But... > > > > As of today, the sof_get_control_data() is in the call path of > > (ipc3-topology.c): > > > > sof_widget_update_ipc_comp_process() -> sof_process_load() -> > > sof_get_control_data() > > > > sof_widget_update_ipc_comp_process() is the ipc_setup callback for > > snd_soc_dapm_effect. If I'm not mistaken these only carries bin payload > > and never MIXER/ENUM/SWITCH/VOLUME. > > This means that the sof_get_control_data() is only called with > > SND_SOC_TPLG_TYPE_BYTES and for that the allocated data area is correct. > > > > This can explain why we have not seen any issues so far. This does not > > renders the code right, as how it is written atm is wrong. > > > Sergey's results with KASAN show that there's a real-life problem though. I also don't understand how that might happen. > > Could it be that these results are with a specific topology where our assumptions are incorrect? Is there anything I can do to help? 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 7940AC433F5 for ; Wed, 27 Apr 2022 06:56:24 +0000 (UTC) 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 E232817AD; Wed, 27 Apr 2022 08:55:31 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz E232817AD DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1651042582; bh=VeTMeAnQEqV6fQ1FFHVy6c3cu7Gb8b0iiU6QU+llVuU=; h=Date:From:To:Subject:References:In-Reply-To:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=thpUfqjrioUeBVVJjkmpMKhzCHGjkQB9fi1ggnAg3wndtn07s7Cys33mVq8VipSvJ mntLWCquiW74C2s8EKxLW7jv4JNsuGlmBKsTg4IxD54Hbs9M5ffOY+flTXdA7DVOYP +jHOrDVWtCQa8ai/lJ+9eiXhwzsz71pP1qVkp55s= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 76150F80155; Wed, 27 Apr 2022 08:55:31 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 63262F80152; Wed, 27 Apr 2022 08:55:29 +0200 (CEST) Received: from mail-pg1-x533.google.com (mail-pg1-x533.google.com [IPv6:2607:f8b0:4864:20::533]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 84586F80152 for ; Wed, 27 Apr 2022 08:55:25 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 84586F80152 Authentication-Results: alsa1.perex.cz; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="Swzf4xKj" Received: by mail-pg1-x533.google.com with SMTP id 15so745010pgf.4 for ; Tue, 26 Apr 2022 23:55:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=/H/dr1bU3IWO2Zz3V0TPFg82hzHtg38B7AemVKe2A0M=; b=Swzf4xKjfP1XA2e+DubAp3b10kwTb8AthU76bMCJuIkF5WelHZd8ki7PyrmZBVV73h 7V0jsT/TNILRELnOmATKXQELGQt181VCk812Hg2n6tfah6g6r7R2L/PSsTy2SWXPPtYc VLmH7wlBiSjVx2ZkoP8BNPMn9iXWfbmvOKFZg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=/H/dr1bU3IWO2Zz3V0TPFg82hzHtg38B7AemVKe2A0M=; b=z6nJsgmsAEfCMZpyocmyeIh5Fpmb4PRj1eYx2ldd3JX/R5gYdJL1kEbYqtmeDK0Omx pWRxuhLt6X421Ubuk9xnlIX2ZJn4M2qygKGdTu5CPT0B/NbE1VLwPHji9LEl5dnO7JoP A6jYUBhlD8CO0G2MZFUKScRtvCCl/NBIDIL6bLmmVEJeUkzN2gqedgzchyv5M9kvZJbF fcNbKWBI7qxoRivUeC5erwq4DSuGYcLLYlh1Lfe5GxHUFXedRivK7fQNgcNVKLcalue6 ZE6tS9Vo9J6lzQj0MUYH+Uw3RJdzaYocp0gtl3m8UihiNI2NRYcsao7HJUWbrIFK1Xbb YNDA== X-Gm-Message-State: AOAM533NYGF6Ec+azwItesuIGGlFloYTESO9hyrF9yiSY41PX2a71kMo w8RFkV/F7NGEoSwZ3Bqg1eRTUA== X-Google-Smtp-Source: ABdhPJxAbcUOPHGpu19WyFlEpx1bs/thLds4ctz1Fli9HAULfa6p4OeS6pNFkws8wrL4iVVeIVrnCw== X-Received: by 2002:a63:df18:0:b0:3ab:938b:e6c5 with SMTP id u24-20020a63df18000000b003ab938be6c5mr5157870pgg.165.1651042522409; Tue, 26 Apr 2022 23:55:22 -0700 (PDT) Received: from google.com ([2401:fa00:8f:203:8e2d:263:26e7:c039]) by smtp.gmail.com with ESMTPSA id 7-20020a17090a000700b001da3920d985sm1276416pja.12.2022.04.26.23.55.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Apr 2022 23:55:21 -0700 (PDT) Date: Wed, 27 Apr 2022 15:55:17 +0900 From: Sergey Senozhatsky To: Pierre-Louis Bossart Subject: Re: out-of-bounds access in sound/soc/sof/topology.c Message-ID: References: <8eeb08ec-4836-cf7d-2285-8ed74ccfc1cb@linux.intel.com> <8986a1c6-b546-7a66-a778-048487624c95@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Cc: alsa-devel@alsa-project.org, Kai Vehmanen , linux-kernel@vger.kernel.org, Ranjani Sridharan , Takashi Iwai , Liam Girdwood , Sergey Senozhatsky , Mark Brown , Ricardo Ribalda , Tomasz Figa , =?iso-8859-1?Q?P=E9ter?= Ujfalusi , Jaska Uimonen , sound-open-firmware@alsa-project.org 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: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" On (22/04/19 08:07), Pierre-Louis Bossart wrote: > > Your analyzes are spot on, unfortunately. But... > > > > As of today, the sof_get_control_data() is in the call path of > > (ipc3-topology.c): > > > > sof_widget_update_ipc_comp_process() -> sof_process_load() -> > > sof_get_control_data() > > > > sof_widget_update_ipc_comp_process() is the ipc_setup callback for > > snd_soc_dapm_effect. If I'm not mistaken these only carries bin payload > > and never MIXER/ENUM/SWITCH/VOLUME. > > This means that the sof_get_control_data() is only called with > > SND_SOC_TPLG_TYPE_BYTES and for that the allocated data area is correct. > > > > This can explain why we have not seen any issues so far. This does not > > renders the code right, as how it is written atm is wrong. > > > Sergey's results with KASAN show that there's a real-life problem though. I also don't understand how that might happen. > > Could it be that these results are with a specific topology where our assumptions are incorrect? Is there anything I can do to help?