From patchwork Fri Jul 26 14:10:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 814785 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 22B0FC3DA4A for ; Fri, 26 Jul 2024 14:12:18 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 67F85E76; Fri, 26 Jul 2024 16:12:06 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 67F85E76 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1722003136; bh=U0iQgUf77isNWPz5wSO/QalnZ8ymeec3WHS6WdettZs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=MuyWX1Y8XNxfSBYOvdKJFVZWV4F2JFn128CGcQNvZzzO6ZGrnYrDQebEkEr8wvx6E 0R6wMR2dJ9HQqJdbcOJSA/QEDCji0cDsqNnAvY6Y/AelgNqUwRWIiVipKUfRvkkYdu 7gVlFnvekpGO87bfpSBLkBqaHaOArzWxoJBO4N5Q= Received: by alsa1.perex.cz (Postfix, from userid 50401) id CE69BF80607; Fri, 26 Jul 2024 16:11:18 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 17192F80605; Fri, 26 Jul 2024 16:11:18 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 65CAAF805C4; Fri, 26 Jul 2024 16:11:13 +0200 (CEST) Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 6322CF8013D for ; Fri, 26 Jul 2024 16:10:58 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 6322CF8013D Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=MITWT61G Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-427d2cc1c4eso15603265e9.1 for ; Fri, 26 Jul 2024 07:10:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1722003057; x=1722607857; darn=alsa-project.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=vEkK+be/9njUC3Is9y04g3ij2793OMGUHZjC8ZIJXBo=; b=MITWT61Gom133Q1iGu0u1dt0gMi1vzmF3iE27UD9tDlbqXjYhQ62KJGQTzwcYTc7Ai QNldHqAZtybJ7MfJPlyyINzb6S1QpV6wszzQaNA/7geUAMDyFyhYjfa538B4PqIIcyrZ mccBLoLLZDUhr8VdaFG6ZEsnqallIgveV1KRH6jO5xOSwYj4GoZW3ofwsnOX370uflRX Zs5/T3AdmwrX24Tvk6scm60G9AmVQeJNHlUy9tBL6+2C3iPDgbL85qcgPrw8v8G4Hndk 8DBjii5VRnsfo0pKuU8uKaqqh8EnJmtF3pWmU1q3C2dn46ww93Vc0oNsKK7UZE36+ieG qSAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722003057; x=1722607857; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vEkK+be/9njUC3Is9y04g3ij2793OMGUHZjC8ZIJXBo=; b=kbJD/J6w9Gytv2bqsNQQIwt1hJb1+5JNWywQWb7l8vkjIU29BJZF3XWLcDDxdyi6hl NGGGQShtDfQ4XwQBg2RfhGoYSfNbjlTFYo3PLdqGS/okn9cz32lpMsGkkRCQpu4hYxjE V6m0gufCnoF+UNp6eVxK144TbbvOPJ775Xwpx6nq1XTKsQo1sK2Id046afOeErjYERIH htIx2Y0M239jOzeROuZrXNBIj845+veenx4ckJNcrgUHMOWHK69EJ+piY8QPNhYYqQ0p hr2f2aQWJULG81p7om9iKqs/lRVMAm28BU9BvPI9krGtDruGfl0a/fpp4YbrF6mjFqQe WMcg== X-Forwarded-Encrypted: i=1; AJvYcCXLfjnYLDImWxGX719/cmBkzhVyDPx7R1rMmobCVhnxQt63aqIdg/0w2gBnS9ATmQKrMsP35Hp+T0tNLQuwX3XbnQcfaQdVUT7mzL8= X-Gm-Message-State: AOJu0YxQeJ+H4fw1i3Hdc/56eOGlp3HuksHBiIItzgXnn12yI1N4iuRk nN30zTyCCHjA1ofeJHxlS583epE23BNQkh19bJ9Hd1BxwmW4VJT1FocTM7vKDn0= X-Google-Smtp-Source: AGHT+IFV/ZpujOQQuNU4y5xUkqHK9TT5v4LwDRDBL4tAqj/tx/FvrWYNs9CZlkMnnbNmp4SxPWDCKQ== X-Received: by 2002:a05:600c:45d0:b0:426:6945:75b8 with SMTP id 5b1f17b1804b1-4280579e92cmr43011845e9.31.1722003057369; Fri, 26 Jul 2024 07:10:57 -0700 (PDT) Received: from [127.0.1.1] ([178.197.219.137]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427f941352asm120841115e9.41.2024.07.26.07.10.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 07:10:56 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 26 Jul 2024 16:10:41 +0200 Subject: [PATCH 1/6] ASoC: codecs: wcd937x-sdw: Correct Soundwire ports mask MIME-Version: 1.0 Message-Id: <20240726-asoc-wcd-wsa-swr-ports-genmask-v1-1-d4d7a8b56f05@linaro.org> References: <20240726-asoc-wcd-wsa-swr-ports-genmask-v1-0-d4d7a8b56f05@linaro.org> In-Reply-To: <20240726-asoc-wcd-wsa-swr-ports-genmask-v1-0-d4d7a8b56f05@linaro.org> To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Mohammad Rafi Shaik , Prasad Kumpatla , Srinivas Kandagatla , Neil Armstrong , Banajit Goswami , Pierre-Louis Bossart , Krzysztof Kozlowski Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, linux-arm-msm@vger.kernel.org X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1998; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=U0iQgUf77isNWPz5wSO/QalnZ8ymeec3WHS6WdettZs=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmo65oM7TrQ4WPQo4XevW2lOaGA4R95dKCpZlv6 wW46Z1aQP+JAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZqOuaAAKCRDBN2bmhouD 1/fvEACZejwshy7ORBUx21bbMgVsL7J/sztl10qJqNBoJeYs/gzMUsbENWm5JgO41XERX3/pfSo njQhapIsqRFLzlnen+Ok8TM/VRFoJUcXy5ttXSSOeSg/VRqNXO3op1XZQVgQkthRMruMwLtpQfv p7Ioldc0W1i2+muv17N+dtEVTsiVqQHDeMxTLZyUehIqIh0ujJG3Epa/uY+L49uSDoDKmpDPfQN Kb+BGzsuOCNeSorxevLNxmXad8la64bfdRXcxA29XsM5dht0wps8ECiIa4UEJRKowxISObJp/Wi ssDC4gmOguXoqxa/d1b7jCpx+6CnGgAWr85xitDbo0u/eJcBtJJuabta0yinmIHEjs34mRAae6X IT4p8mC7im5Ci/ErNcqoSwu1P2KrF0Hj3NyhrKBQ0UKUfgl1KyBk5xVHpLXEq4lLP4hpJMM+pZI XXKqLLfLc9owJQYBlFp0i/E4pq8xUpQOPTUAPBDnwoPe9tG0LXpApktVOEbv1EOCkMcelM1MitR zx6dHe1tFQ4WrJxFcx50DYUrsg3AVxtgH0HHPNC3w3Uy3ymLQc9RMGR7eTML5ZuqbMFf1gtzMjG R7VzVUxbGQomk/JoXeagI4n3whtWwoR3JUgTD3Bkx6oIpEqJHsIUYcdbaKuNM9S4TuyGGxPartk vl9HRMjVQGz3lGw== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Message-ID-Hash: MCRNXUU3A3BZCFJTKVUIBXW55NGD644Q X-Message-ID-Hash: MCRNXUU3A3BZCFJTKVUIBXW55NGD644Q X-MailFrom: krzysztof.kozlowski@linaro.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Device has up to WCD937X_MAX_TX_SWR_PORTS (or WCD937X_MAX_SWR_PORTS for sink) number of ports and the array assigned to prop.src_dpn_prop and prop.sink_dpn_prop has 0..WCD937X_MAX_TX_SWR_PORTS-1 elements. On the other hand, GENMASK(high, low) creates an inclusive mask between , so we need the mask from 0 up to WCD937X_MAX_TX_SWR_PORTS-1. Theoretically, too wide mask could cause an out of bounds read in sdw_get_slave_dpn_prop() in stream.c, however only in the case of buggy driver, e.g. adding incorrect number of ports via sdw_stream_add_slave(). Fixes: c99a515ff153 ("ASoC: codecs: wcd937x-sdw: add SoundWire driver") Signed-off-by: Krzysztof Kozlowski --- Not adding Cc-stable because I don't think the issue can lead to real out-of-bounds read. --- sound/soc/codecs/wcd937x-sdw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/wcd937x-sdw.c b/sound/soc/codecs/wcd937x-sdw.c index 3abc8041406a..0c33f7f3dc25 100644 --- a/sound/soc/codecs/wcd937x-sdw.c +++ b/sound/soc/codecs/wcd937x-sdw.c @@ -1049,7 +1049,7 @@ static int wcd9370_probe(struct sdw_slave *pdev, pdev->prop.lane_control_support = true; pdev->prop.simple_clk_stop_capable = true; if (wcd->is_tx) { - pdev->prop.source_ports = GENMASK(WCD937X_MAX_TX_SWR_PORTS, 0); + pdev->prop.source_ports = GENMASK(WCD937X_MAX_TX_SWR_PORTS - 1, 0); pdev->prop.src_dpn_prop = wcd937x_dpn_prop; wcd->ch_info = &wcd937x_sdw_tx_ch_info[0]; pdev->prop.wake_capable = true; @@ -1062,7 +1062,7 @@ static int wcd9370_probe(struct sdw_slave *pdev, /* Start in cache-only until device is enumerated */ regcache_cache_only(wcd->regmap, true); } else { - pdev->prop.sink_ports = GENMASK(WCD937X_MAX_SWR_PORTS, 0); + pdev->prop.sink_ports = GENMASK(WCD937X_MAX_SWR_PORTS - 1, 0); pdev->prop.sink_dpn_prop = wcd937x_dpn_prop; wcd->ch_info = &wcd937x_sdw_rx_ch_info[0]; } From patchwork Fri Jul 26 14:10:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 814585 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 06127C3DA49 for ; Fri, 26 Jul 2024 14:12:03 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 1D163E82; Fri, 26 Jul 2024 16:11:51 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 1D163E82 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1722003121; bh=cGgEjpzzxGI973pctJv1X1Xqrenmzkw5jm4bI9/CPUs=; h=From:Date:Subject:References:In-Reply-To:To:Cc:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=KcuKKgrsyb8/vrblte1hmapd6ZKhyQNBUw41UVPzsOI2YuoRYaueO75tnlmnar45C aQ3d83eRLxiZ3SrFPhLP1aKBq3QCuE0Ml9DsFfzrLbzcXQypyvwp+j6CfJYJLMIAco shsVN1lkysksjcqCoX8zWwXeKLp25wH2VC+KyDbA= Received: by alsa1.perex.cz (Postfix, from userid 50401) id D7559F805E5; Fri, 26 Jul 2024 16:11:15 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id CFAF9F805E9; Fri, 26 Jul 2024 16:11:14 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 31357F805AC; Fri, 26 Jul 2024 16:11:09 +0200 (CEST) Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 661FDF801F5 for ; Fri, 26 Jul 2024 16:10:59 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 661FDF801F5 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=rv2tmP6Q Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-427d2c8c632so15552075e9.2 for ; Fri, 26 Jul 2024 07:10:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1722003059; x=1722607859; darn=alsa-project.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=kTGsbAfRUm3WZ5fb53jExCzdO/XEBE/ZTI+TszbFHcE=; b=rv2tmP6QiZMnh2bvphSZbeAnkgBcwkgM1PdYOwuXsy2oMFe+n8tLC5o2LpcgLQwJpM 2NDPGmKGFfoKI3MOji9yJ1W+Pe47GnoR5qVFLfnsz9ecqj4C/XjkS+Wv9nMAA8/J1D7t p1ONGBWw2twrCee+1C3mapDc33AqH3hSGjG9Iq2GxPTMZGt+dBTbX/awu2/cnPGMqK2G NMVEwiDtTX3DlXSTi4ghr36aYJCaGOwz5G83BaSxI6sOZ/y0SmK4mwi+ec0eSwf+p+Ds gk9JPLOgAxPRjwlXm7PcVOFIwuVcpv/0VkWZwPBQWtHRRzmpQzzEN8ILa9aR1b0EmCsn vsTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722003059; x=1722607859; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kTGsbAfRUm3WZ5fb53jExCzdO/XEBE/ZTI+TszbFHcE=; b=r7Vfj5LdWKjVT9nGSX3eHEgcAV8OCwHe1cT9HM6Zy2m+5va2lk8RQL0gpKxLQHhDiW CXo0DHzAhB7C5xn9vyMDtdJYRDybwnqWfjrNIFjHPWF7k1k7xJdc7l0WbTb4zdm+aDJe RVp2NyoSWTg0HEMNmD8yKDviH+3l+6XZCQc1y5sXyy/2dcV9XAxyLrvUxBikYH5GqgYE jhHCWFc0QbO3zgdiewj37hQ3/FvHFX8O8zVDPRpDbib8R6BAfCjNMYlTON2DaVlW2VxM XGguvXahix7pLXYkSVGRs8253atleY12VHq4S8BCANZpFZiyD5FGvxHXBFV19S+X5gj3 n1Og== X-Forwarded-Encrypted: i=1; AJvYcCUuFZ10nAaC4RVl5Hr1zQnnVaeUEfjM0Cg0yebNW3Hcxqo35P/wtjm/eN0D5hLXZkH5ww6xgd391YfJpff9Cl+PXHUtwZuKufk/8s0= X-Gm-Message-State: AOJu0YwZjlWQrRePvJLRX44YtSUK+EBRFapjKDrP15lX46WV0yMy+39Z L8fLHL99aJ5phjJjUrziEzxN2stMFChEjSAPHQDqFWepikgHbuvpH8R1Q+V2zOs= X-Google-Smtp-Source: AGHT+IFz/JUl+8u/JK2MqcXdpWEoos3z2kzWUCjz3VughnmpNQSqc2rMtp7GCgrM4Xlo9AdJw/qt2A== X-Received: by 2002:a05:600c:5253:b0:426:6320:7ddf with SMTP id 5b1f17b1804b1-42806bfe266mr35213265e9.35.1722003058921; Fri, 26 Jul 2024 07:10:58 -0700 (PDT) Received: from [127.0.1.1] ([178.197.219.137]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427f941352asm120841115e9.41.2024.07.26.07.10.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 07:10:58 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 26 Jul 2024 16:10:42 +0200 Subject: [PATCH 2/6] ASoC: codecs: wcd938x-sdw: Correct Soundwire ports mask MIME-Version: 1.0 Message-Id: <20240726-asoc-wcd-wsa-swr-ports-genmask-v1-2-d4d7a8b56f05@linaro.org> References: <20240726-asoc-wcd-wsa-swr-ports-genmask-v1-0-d4d7a8b56f05@linaro.org> In-Reply-To: <20240726-asoc-wcd-wsa-swr-ports-genmask-v1-0-d4d7a8b56f05@linaro.org> To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Mohammad Rafi Shaik , Prasad Kumpatla , Srinivas Kandagatla , Neil Armstrong , Banajit Goswami , Pierre-Louis Bossart , Krzysztof Kozlowski Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, linux-arm-msm@vger.kernel.org X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1776; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=cGgEjpzzxGI973pctJv1X1Xqrenmzkw5jm4bI9/CPUs=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmo65pRGgV5B1JytKHlbz6JcNxoIZORTr8B+r6k 1jeQWWl6hWJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZqOuaQAKCRDBN2bmhouD 15dOD/9vCxKIo8VXq63ApLgbGCqko0MTCPw7y8OqbfI6J7s/NmZYrKzQ/Giyked/yjhq88hfeDs /RgAzAEvfZDgX2gBzrp5kdyXpudEXxJje5tyKU+CVkRrV2VD7eX25Ffs4+ecdvv9sIK75G48OX7 c//034fCz8FAPfACs1ME0OphEyX3rH7y74bMuDIZjUS02lt7wZ+EHZfEdf202e7Nj0WFg8RL+uj RIzDibfyrF6AKyzk8gg+taa42qLJwcw0CgjHCWzvk2bEEnJ8XZ1uYZnXIN3d1BaKDp+jte46aT8 vPYiQKGciYt0habUV9R7GWkKnEEp9MMmZ7NO1UmOG17oALbMjZ6bFFLk4qjlDlZTIrKH2UiOx4s nh8nB+OvGcvHarLpE8zWQt25mN80ziz6ECGGKUHrOucr7A6v8KgdKRGecYqZGB8H7q9ymJrKPtw MBFt3alHXQSitx4eQxWePlb4k9XZdtBj2gvfzYjEcRrhQyLOfbVNWnQqIAgD6vBDm9bXgO8a3d4 LFlkOKmtA7iQi6MZ262xykI/maLj+BD5R/27gnZQa+MLAOQyr51RAFSKjxUoQ506+3BMSOcnHKu hgLTmA0b01zEIxmHsqxSPr5Nz+N4Mbu9HIGTX5qOg+99eZFGhzh7MIgc5WUYJRDnXThdrv5JxoC F7LCmf/cGx29Emw== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Message-ID-Hash: NWF2LA7OX634HIDY7FW4WJHRHCTKNESX X-Message-ID-Hash: NWF2LA7OX634HIDY7FW4WJHRHCTKNESX X-MailFrom: krzysztof.kozlowski@linaro.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Device has up to WCD938X_MAX_SWR_PORTS number of ports and the array assigned to prop.src_dpn_prop and prop.sink_dpn_prop has 0..WCD938X_MAX_SWR_PORTS-1 elements. On the other hand, GENMASK(high, low) creates an inclusive mask between , so we need the mask from 0 up to WCD938X_MAX_SWR_PORTS-1. Theoretically, too wide mask could cause an out of bounds read in sdw_get_slave_dpn_prop() in stream.c, however only in the case of buggy driver, e.g. adding incorrect number of ports via sdw_stream_add_slave(). Fixes: 16572522aece ("ASoC: codecs: wcd938x-sdw: add SoundWire driver") Signed-off-by: Krzysztof Kozlowski --- Not adding Cc-stable because I don't think the issue can lead to real out-of-bounds read. --- sound/soc/codecs/wcd938x-sdw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/wcd938x-sdw.c b/sound/soc/codecs/wcd938x-sdw.c index c995bcc59ead..7da8a10bd0a9 100644 --- a/sound/soc/codecs/wcd938x-sdw.c +++ b/sound/soc/codecs/wcd938x-sdw.c @@ -1252,12 +1252,12 @@ static int wcd9380_probe(struct sdw_slave *pdev, pdev->prop.lane_control_support = true; pdev->prop.simple_clk_stop_capable = true; if (wcd->is_tx) { - pdev->prop.source_ports = GENMASK(WCD938X_MAX_SWR_PORTS, 0); + pdev->prop.source_ports = GENMASK(WCD938X_MAX_SWR_PORTS - 1, 0); pdev->prop.src_dpn_prop = wcd938x_dpn_prop; wcd->ch_info = &wcd938x_sdw_tx_ch_info[0]; pdev->prop.wake_capable = true; } else { - pdev->prop.sink_ports = GENMASK(WCD938X_MAX_SWR_PORTS, 0); + pdev->prop.sink_ports = GENMASK(WCD938X_MAX_SWR_PORTS - 1, 0); pdev->prop.sink_dpn_prop = wcd938x_dpn_prop; wcd->ch_info = &wcd938x_sdw_rx_ch_info[0]; } From patchwork Fri Jul 26 14:10:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 814784 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 B0E2CC3DA49 for ; Fri, 26 Jul 2024 14:13:31 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id D1A6AE82; Fri, 26 Jul 2024 16:13:19 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz D1A6AE82 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1722003209; bh=dP7UEMsz7e5SQeBIvoJx2Y/Pic6CV31hwYtlba9OL/E=; h=From:Date:Subject:References:In-Reply-To:To:Cc:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=G6pQQcoyvRJe+w4lZxFEqPsHoKeBZ7a4fOe3pwkxfwdlnXV1zx0A6biE2TKDFerw3 MbkM5kiP+PAj3Y05CASEM2OzUCi2z3tNuJOCmU2lky0K7Xd+SVIZSN3eJyeBIrxnhk 0yREhj92TKo2QUrptX81A2iwZ8A+09izTcPIAbQk= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 85825F80579; Fri, 26 Jul 2024 16:12:58 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 78BECF805BB; Fri, 26 Jul 2024 16:12:58 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 35559F8057A; Fri, 26 Jul 2024 16:12:55 +0200 (CEST) Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 54A09F8026D for ; Fri, 26 Jul 2024 16:11:01 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 54A09F8026D Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=zJVciAV9 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-427d8f1f363so16262225e9.2 for ; Fri, 26 Jul 2024 07:11:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1722003061; x=1722607861; darn=alsa-project.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=wq5Zwrj0wwcriRSju7UpectgcbI2N6emEEV2p6g72bY=; b=zJVciAV9xoFu4SLoVEprLr0m5f7CV36+yAlzUbIEOJAPeChLuaktNEOXhl8GIG0cUw ubxFHW4RtUvKOtxlipv+GChR1y2CL6WkF1wUgJf1v+CyQgJoJSLPIho0OkEQ9OhZYJNd yM7IKEXzYSQjxRrProHE5oBAUrJcpZq3s+l+NphF7kk4Txi0gzB15Trftn9ktbvWLdjC H6HUodg2fI+T7cypnfWFPK5pZPBPEF4M2NLl40QZ6HgxK8HXeGghtOzk9Q9BkM8wr+b7 UBZB/MheMGdobKH0y9day1XL2EQaHsNrr2CUXD1sC7aniS44DLCO0s+1/e8k5X77vsw7 l2AQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722003061; x=1722607861; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=wq5Zwrj0wwcriRSju7UpectgcbI2N6emEEV2p6g72bY=; b=i1dg4S2VjTqoLQ/7zu7tshuzRHeIqyTQJzAMnJQOI4HQLCHNrDInDz6vFVolOzkX1k BLpCp1ouW6k2BK6DnjmQXY9WzKtOZxx/ehQi6V7jl29Ru/ZYGxgoIV0JiNdTum5w/25/ n4Xj4KFIz3vZhj65y3wbjTpnjC+gtM/NeP1RPK+fm3ItVAEBPIK9F8/jVFDyKz/tfboU 9kG6jjWgL76eJprs/56xlzJ82DpU+2BX0Bh1Opua6s8yXoq/ISmPivUIM0U4JTeNnm5k lyLtjFraq65wBHQuugxATN4HWxVN5cRGw6sp46BJ32TpSeIQEkJ/ZLqzRxR84QlqoXkT SSdQ== X-Forwarded-Encrypted: i=1; AJvYcCUuQ+xBq03Dm+sKkg/TqxCHpiGxMUb27uHLnyAef/wM93ehp3LbCAdXBuJpDG8to8Rfm+H+2TTQBGJuHM3YwejQmQgwaD8JznsjDes= X-Gm-Message-State: AOJu0Ywi2b3KCnSHO71N+JkuOgTV1vKXuP2kVvD9GsDD/H5FjHxUZAJX t+WbRDzvaZbg/sFuVcepw/+uyDnOxObisNX7F7lsb6O88OzMkAGj0/929qgT1X8= X-Google-Smtp-Source: AGHT+IEG7AI5NN6YZ75+21NHmNdxvxhxO5Szstl2Ms6b99fP/MAH4f9xbyIPABZDEYOTNcVmNiXk9Q== X-Received: by 2002:a05:600c:3b87:b0:425:7974:2266 with SMTP id 5b1f17b1804b1-42806bd9f52mr39504875e9.24.1722003060682; Fri, 26 Jul 2024 07:11:00 -0700 (PDT) Received: from [127.0.1.1] ([178.197.219.137]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427f941352asm120841115e9.41.2024.07.26.07.10.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 07:11:00 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 26 Jul 2024 16:10:43 +0200 Subject: [PATCH 3/6] ASoC: codecs: wcd939x-sdw: Correct Soundwire ports mask MIME-Version: 1.0 Message-Id: <20240726-asoc-wcd-wsa-swr-ports-genmask-v1-3-d4d7a8b56f05@linaro.org> References: <20240726-asoc-wcd-wsa-swr-ports-genmask-v1-0-d4d7a8b56f05@linaro.org> In-Reply-To: <20240726-asoc-wcd-wsa-swr-ports-genmask-v1-0-d4d7a8b56f05@linaro.org> To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Mohammad Rafi Shaik , Prasad Kumpatla , Srinivas Kandagatla , Neil Armstrong , Banajit Goswami , Pierre-Louis Bossart , Krzysztof Kozlowski Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, linux-arm-msm@vger.kernel.org X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1877; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=dP7UEMsz7e5SQeBIvoJx2Y/Pic6CV31hwYtlba9OL/E=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmo65qRbZcLLRSFDbSoF0d0nw+PnV31kip12ewV IsrK0K2QvOJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZqOuagAKCRDBN2bmhouD 15q/D/93LrXG6IqxDSqzRNmqwo2E/ibyo4QxN+fHgz4wRiqe0TlnGGeEQ+gxtN/TsToXPtd14uQ KsnEb7dGNIRHFGSGUnLB6k+n6OSaIPy/1L5YoiXcLbiWJJyBvzexvmE2kYckW7bBn820xkFNOqm iZk/vRMqxFoq33FNv5JpRqufH+Icg21of5p9NIuYgDT/C9SOUGiOl0kzRn7XMnZDMwW8c1/jkpq 5gI7Hg7mzfdABuXkenHnQq7phecWnB+ip+MJfFhjQ4bDImdcvIy9PRY/1qi1brwy+ofE7mb+aIs YufA3koh/4r+90fO9XyRVTOYtEWhbsncegZ0Mc5UiOngqgCkMO/7OMh6BHNnJH71Q8qh08t3v7J aQJAR3DbMiwVYep3/GnS4VzdzPG92SwjznHisLCgMMwBF9vCZnzue1/N3dLip9I10C2O/cmRMas C4y5aP/lVKJjKVzuPANynpmAS0uR1uvOQdbJ3qo/HvHgfABrIiC/AeZjPqdnnGF9DaOTl+CZL65 YhtnBlSv3xvc59opcNjQBWH2aZlMW+NNhj/Y51fqm+OhXsuvBIm+18fV+5hbMhouDABvpc5SBBq VUvYNShK+k6XncLytZh5zYSqGEnCa3TRqwYgNXjF1tu6SUg+DcmdbVUC65YT5Irn4klnHrZIt0R 0Uu946k19b4UFAw== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Message-ID-Hash: 3AH47CKMBLIMGIDBW254KMNDGGVKHYBX X-Message-ID-Hash: 3AH47CKMBLIMGIDBW254KMNDGGVKHYBX X-MailFrom: krzysztof.kozlowski@linaro.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Device has up to WCD939X_MAX_TX_SWR_PORTS (or WCD939X_MAX_RX_SWR_PORTS for sink) number of ports and the array assigned to prop.src_dpn_prop and prop.sink_dpn_prop has 0..WCD939X_MAX_TX_SWR_PORTS-1 elements. On the other hand, GENMASK(high, low) creates an inclusive mask between , so we need the mask from 0 up to WCD939X_MAX_TX_SWR_PORTS-1. Theoretically, too wide mask could cause an out of bounds read in sdw_get_slave_dpn_prop() in stream.c, however only in the case of buggy driver, e.g. adding incorrect number of ports via sdw_stream_add_slave(). Fixes: be2af391cea0 ("ASoC: codecs: Add WCD939x Soundwire devices driver") Signed-off-by: Krzysztof Kozlowski --- Not adding Cc-stable because I don't think the issue can lead to real out-of-bounds read. --- sound/soc/codecs/wcd939x-sdw.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sound/soc/codecs/wcd939x-sdw.c b/sound/soc/codecs/wcd939x-sdw.c index 94b1e99a3ca0..fca95777a75a 100644 --- a/sound/soc/codecs/wcd939x-sdw.c +++ b/sound/soc/codecs/wcd939x-sdw.c @@ -1453,12 +1453,12 @@ static int wcd9390_probe(struct sdw_slave *pdev, const struct sdw_device_id *id) pdev->prop.lane_control_support = true; pdev->prop.simple_clk_stop_capable = true; if (wcd->is_tx) { - pdev->prop.source_ports = GENMASK(WCD939X_MAX_TX_SWR_PORTS, 0); + pdev->prop.source_ports = GENMASK(WCD939X_MAX_TX_SWR_PORTS - 1, 0); pdev->prop.src_dpn_prop = wcd939x_tx_dpn_prop; wcd->ch_info = &wcd939x_sdw_tx_ch_info[0]; pdev->prop.wake_capable = true; } else { - pdev->prop.sink_ports = GENMASK(WCD939X_MAX_RX_SWR_PORTS, 0); + pdev->prop.sink_ports = GENMASK(WCD939X_MAX_RX_SWR_PORTS - 1, 0); pdev->prop.sink_dpn_prop = wcd939x_rx_dpn_prop; wcd->ch_info = &wcd939x_sdw_rx_ch_info[0]; } From patchwork Fri Jul 26 14:10:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 814583 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 15155C3DA4A for ; Fri, 26 Jul 2024 14:13:50 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 4B761E0F; Fri, 26 Jul 2024 16:13:38 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 4B761E0F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1722003228; bh=Wl+tDBuyQMsKe2NwpZXMc/8shVbTUViF+5tNnWhiufg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=HDkNvzM6ARaZ8jMOzKgyHIeYyEu4GRmcqDQgp8cdlU2T9gnsWNhfNt3to2+Tlw3BD n1julLb6NGsGoTPCMcseD3DhkgOfCTbGqiK4KfyXhQJLzsO73smzY/cb7zy7N5ed6f sHm5Pif24N7EsNE6Fkw0zCdTlrelkUBStz5Chs0c= Received: by alsa1.perex.cz (Postfix, from userid 50401) id B1825F805E2; Fri, 26 Jul 2024 16:13:03 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 0E5B3F805E4; Fri, 26 Jul 2024 16:13:03 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 628D9F80482; Fri, 26 Jul 2024 16:12:57 +0200 (CEST) Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id F13E6F800AE for ; Fri, 26 Jul 2024 16:11:03 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz F13E6F800AE Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=s42/3qmS Received: by mail-lj1-x233.google.com with SMTP id 38308e7fff4ca-2ef2d582e31so15211371fa.2 for ; Fri, 26 Jul 2024 07:11:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1722003063; x=1722607863; darn=alsa-project.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=Brvms8JhmsVbDZotcc6ApH8ZnBoz//VNsdwEXVDTRv8=; b=s42/3qmSQAdtPnJSbxEnqXJdsMN6u3vjKsn0xeFjFPaa0jl/+zpCffGjIkvhasfAy4 rt0i6Fcf+/qEhaw3Kd4VEmJqd4x1v5TrmrEVwWWrhA3EjHmG1w3IcTPdPQkqhKfkBRAe siRiJJC5YWJVeoDuZBpiN9pohWDuoFqzcLK32wUIpIFC2efOlJOluTgg6GKh/f9R2p6V KzpVUDWHHgntnBU9Jqnhfmz0JHVWx7qnlaywJWZPCZqNRQ4qLYMyCFp15bFok0+ahHWB ayXk7SWR/gQHKzABDrSER1+I1XTnXyAM0VLueEUGqmZJVyniqGFpvz1pi2W/qT2FfjZj DwKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722003063; x=1722607863; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Brvms8JhmsVbDZotcc6ApH8ZnBoz//VNsdwEXVDTRv8=; b=TCSSeU1kKIVcyZVn/yK7vn3LYcg9wsxIHpIyZtR12o00aPRab17nFqVHxaLopPsPZK tcfvXgeQwxx046yk7d0uO5I04B+bdrfV6Lj0YhEgxRB1w5ALGjxOtAunDi8vE6//sLzp im7l8gDm1Nvhb1hrEwykR41Ob2ldqB5ecVHQMV5ngSPzF8OOwhrMip+sOHu4L8YPzcSH CvmOiKH18f0qzVG7YdFpX/O7HH9I6HQkuO088QKb8LejDx8fkCAdfJwOOkDQq2MADere tcLlvLlCNPh/9htgH8IZADxaQ/w182vI6zypkZnC9I44ASy3cZv1Sjytkjrs1dXdOUsQ vvWg== X-Forwarded-Encrypted: i=1; AJvYcCW6YC/baBITpz8CUleKWM1f0qSKMoiZOcOoOPydyTTfNn+018EuEiiDkepCwqRWXPzfsDz4+FrJL0BiiehFfHjRzR0YjYxbbTgt+H0= X-Gm-Message-State: AOJu0YymnT4CwRkc6+8vPm9u8JrSR8PTjX++TXBCV8CjryWFZnKMucll NlUnUWQLaBzfYhic2LO5SBO4TlX7sNmaHs6w5uDMb4fVJ/COlXjel2/+kMruvzM= X-Google-Smtp-Source: AGHT+IHoY8KGYJY7FAM0r57X/ZlrB/uyZh8XEYKyFteHSxqoB7xOthPewnXbTiP333EoAA8ogqWMIg== X-Received: by 2002:a2e:7209:0:b0:2ef:564c:9b66 with SMTP id 38308e7fff4ca-2f03dbe906bmr35474471fa.30.1722003062486; Fri, 26 Jul 2024 07:11:02 -0700 (PDT) Received: from [127.0.1.1] ([178.197.219.137]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427f941352asm120841115e9.41.2024.07.26.07.11.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 07:11:02 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 26 Jul 2024 16:10:44 +0200 Subject: [PATCH 4/6] ASoC: codecs: wsa881x: Correct Soundwire ports mask MIME-Version: 1.0 Message-Id: <20240726-asoc-wcd-wsa-swr-ports-genmask-v1-4-d4d7a8b56f05@linaro.org> References: <20240726-asoc-wcd-wsa-swr-ports-genmask-v1-0-d4d7a8b56f05@linaro.org> In-Reply-To: <20240726-asoc-wcd-wsa-swr-ports-genmask-v1-0-d4d7a8b56f05@linaro.org> To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Mohammad Rafi Shaik , Prasad Kumpatla , Srinivas Kandagatla , Neil Armstrong , Banajit Goswami , Pierre-Louis Bossart , Krzysztof Kozlowski Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, linux-arm-msm@vger.kernel.org X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1526; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=Wl+tDBuyQMsKe2NwpZXMc/8shVbTUViF+5tNnWhiufg=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmo65rhZpKPZg3tmFrHEHfD9UhC5sv0LQAvnb3T NdSB7BEB1+JAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZqOuawAKCRDBN2bmhouD 15JFD/0ST4V7oPsF2QmExiXjWppFCmdT+Au0ltznI674n979jfy3w7dDoF/hrPIbQN4GGQDNbN9 S3cVrNumBB3oxJlQhf8SD3JJSXK36Ex9XQqnlMPH81jl/OK2mbo9ohD1yl6uzKct/Ml02cEfQHI igpQwBFOpxgMg2QjGBjtZcE4iLyLiXlKbU53oTM2F9UEPpIUA9t4ibtjo1Q+kOH2ksZGut6U1+L 0IbIqM680Uzoz1gryxUSmsV2anr5Q16aXrSTzWPm2BYSvY9zCR7NIgOS9ZQA9Zvd1TvOUTqo5eg ryRpbnWzJ8t8BLKWupkqB+Kb1BYtqHcq8SaCM61uHyHoacuNZPwEKuVMMbCZVucPqi4G4m3LrZy urGvc6TRVsX5kOacMTT6LGATUkVlBA16jZGGkPbMD8fYi/pgJmMnIr4/i7gBZLzdC3oJxYM3f1w qfhjXpy5vSzIb7mvtytSDckrttVaI24rKbjNG/uq3xChVzmPpGJrqkjqHaxv4+UQ2xuL2yWkoXB PbNY5pDT4v+hcStu0NPuHGRxqqvFRrE7LIPNpAdDP4dSBgqmHh0SaBp234mSXmiinjliKVGCGeK XjzSrDy1t10bol85r0IbmGUtrKRc1KSa/9B73nJIlze+Y6iTSUeQN9UhUJitOacfQIv1/HcwI76 0g6reVierLFUesQ== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Message-ID-Hash: HFCPQEZXW7Q5HY7FDGWC7ZZGQ3PDQ3DQ X-Message-ID-Hash: HFCPQEZXW7Q5HY7FDGWC7ZZGQ3PDQ3DQ X-MailFrom: krzysztof.kozlowski@linaro.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Device has up to WSA881X_MAX_SWR_PORTS number of ports and the array assigned to prop.sink_dpn_prop has 0..WSA881X_MAX_SWR_PORTS-1 elements. On the other hand, GENMASK(high, low) creates an inclusive mask between , so we need the mask from 0 up to WSA881X_MAX_SWR_PORTS-1. Theoretically, too wide mask could cause an out of bounds read in sdw_get_slave_dpn_prop() in stream.c, however only in the case of buggy driver, e.g. adding incorrect number of ports via sdw_stream_add_slave(). Fixes: a0aab9e1404a ("ASoC: codecs: add wsa881x amplifier support") Signed-off-by: Krzysztof Kozlowski --- Not adding Cc-stable because I don't think the issue can lead to real out-of-bounds read. --- sound/soc/codecs/wsa881x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/codecs/wsa881x.c b/sound/soc/codecs/wsa881x.c index 0478599d0f35..fb9e92f08d98 100644 --- a/sound/soc/codecs/wsa881x.c +++ b/sound/soc/codecs/wsa881x.c @@ -1152,7 +1152,7 @@ static int wsa881x_probe(struct sdw_slave *pdev, wsa881x->sconfig.frame_rate = 48000; wsa881x->sconfig.direction = SDW_DATA_DIR_RX; wsa881x->sconfig.type = SDW_STREAM_PDM; - pdev->prop.sink_ports = GENMASK(WSA881X_MAX_SWR_PORTS, 0); + pdev->prop.sink_ports = GENMASK(WSA881X_MAX_SWR_PORTS - 1, 0); pdev->prop.sink_dpn_prop = wsa_sink_dpn_prop; pdev->prop.scp_int1_mask = SDW_SCP_INT1_BUS_CLASH | SDW_SCP_INT1_PARITY; pdev->prop.clk_stop_mode1 = true; From patchwork Fri Jul 26 14:10:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 814783 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 21257C3DA4A for ; Fri, 26 Jul 2024 14:14:07 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 4105CE85; Fri, 26 Jul 2024 16:13:55 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 4105CE85 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1722003245; bh=Vu+vQdTFKWsQq9i9w0o9ZFa+ZQrVAJEgITfkg5lDM4Y=; h=From:Date:Subject:References:In-Reply-To:To:Cc:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=dV9AFHbMzFJI8aezqqDMNtVV4CCjeD6TVOmwYwN4P6jzNDI7d6ZNFrvAN6NSFZzN8 5C8p3DBgIVA1Lb8VH80xiN8RY/0/3c2Zq2CQX6QMHNPgHN2Wy50FK1LwONf/WqKKuE RzgKKqOuC+/nYNhgDTPvzF1mnggSXL7lRsPZy38M= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 91C75F805E4; Fri, 26 Jul 2024 16:13:05 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 33842F80602; Fri, 26 Jul 2024 16:13:05 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 973DDF805B3; Fri, 26 Jul 2024 16:12:59 +0200 (CEST) Received: from mail-wm1-x333.google.com (mail-wm1-x333.google.com [IPv6:2a00:1450:4864:20::333]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 8B99CF80579 for ; Fri, 26 Jul 2024 16:11:05 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 8B99CF80579 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=p2kc2g/c Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-42809d6e719so8885565e9.3 for ; Fri, 26 Jul 2024 07:11:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1722003064; x=1722607864; darn=alsa-project.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=nnPQ2n6JhiYWWn9VeOeK/rEp99NPC+ELvUYPMv+J6Iw=; b=p2kc2g/cLcfUofTTANdXOZLRd8RxD6UpohdNlNdJWIt0BwnGk9YkC07KfReObqKLtN 5grSsF12FpZ44fGw+12naSWgakTIQVyNSgIjeJ75mpV5KLkd/tlmtLkXquFMafQlKbM8 SguhZ8uCPOu4Pkf+48pTtl3gtl7Y2Yghhm+EJI6uDphRD+6FSUFBq1x2alRIvKmedyX4 H43zvpU3SO33IUAFMGdQXk508Idd74z8/ZeTdEncSDFCld8CCRpEX9JvPyj4zA+UjkaO 3g0G7HNzirlOkx2sTCXGx8g5Om8w6w10y8VsqjLSvSqmmZg9mgTu/CYyKXjwBlRln0g3 +UWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722003064; x=1722607864; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nnPQ2n6JhiYWWn9VeOeK/rEp99NPC+ELvUYPMv+J6Iw=; b=m0CtbaNvmo3kAQ32bJHr7VrACNR0bzL1eSjV8pHY/I0oyCw4gS+IkbkXsFmhDwLwnZ G1jZjBNl/k0nW6OUgD58P7+n+FDOawTMkVxA3OGWaDEvEHsHlSMmZ1ii61sGIqE3pT+s ofT4rQAgldt1pC0wyTn9hH6OXvvae+KY3AwMi1WXg3n6O4ioIfNOfZqsLzpMt3K7GTek 1DLf75XWAU1jh8g4gDovTAXlFV79czwkVA6cb6QF7vhXUdNHVNr7GzZHXnn72BJE8nY9 fuLtUu/cEJuK9Ys397DS7DxpVH716UfXBDaLjzgFRUuYdwhNrA9JLMNN134FVgJxEeUc mJhA== X-Forwarded-Encrypted: i=1; AJvYcCU2mbl+JR73i0HT1knyxbWJNNLAa0XWpoeJT1Njun5k8oD1EDQCnGHjvR3Rm4AB+z947TlNqr3PR4/UgD9FL8YbCX+l9RhkqT5Ohos= X-Gm-Message-State: AOJu0YyM7rv+cScRBlHvpo4HS4gZQpYiQMjnyMUkjqXyPokq4cJKKsgr Cxx8QTP3ExsXshfCHGMTt34hADxRSGsLedicSj+DoLzLByrh5u3/KjezQyHNN0s= X-Google-Smtp-Source: AGHT+IFEX4rzg7NrNx6gbQi2pw9HHCL43584sSMR3P82rbrDcYIFr+PaqQ5QJ29wTGiIy5vcKmx21g== X-Received: by 2002:a05:600c:4712:b0:426:58cb:8ca3 with SMTP id 5b1f17b1804b1-428057104eamr39404725e9.21.1722003063990; Fri, 26 Jul 2024 07:11:03 -0700 (PDT) Received: from [127.0.1.1] ([178.197.219.137]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427f941352asm120841115e9.41.2024.07.26.07.11.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 07:11:03 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 26 Jul 2024 16:10:45 +0200 Subject: [PATCH 5/6] ASoC: codecs: wsa883x: Correct Soundwire ports mask MIME-Version: 1.0 Message-Id: <20240726-asoc-wcd-wsa-swr-ports-genmask-v1-5-d4d7a8b56f05@linaro.org> References: <20240726-asoc-wcd-wsa-swr-ports-genmask-v1-0-d4d7a8b56f05@linaro.org> In-Reply-To: <20240726-asoc-wcd-wsa-swr-ports-genmask-v1-0-d4d7a8b56f05@linaro.org> To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Mohammad Rafi Shaik , Prasad Kumpatla , Srinivas Kandagatla , Neil Armstrong , Banajit Goswami , Pierre-Louis Bossart , Krzysztof Kozlowski Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, linux-arm-msm@vger.kernel.org X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1494; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=Vu+vQdTFKWsQq9i9w0o9ZFa+ZQrVAJEgITfkg5lDM4Y=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmo65sdY4HV/1FoN5HkK5c6lQNXwdRdwBIMLNys QrDcxPsPziJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZqOubAAKCRDBN2bmhouD 1zCID/4viT8zslptT+J+Wyj3J9niHRv30fzKO8dyhhocsvtCsFJ42+NDmGPkTmHOOub3SxgLP9p CVa180tqGAVdwWlFCbFSGFPYzMsITwNnSS60fIwtqBcEbCToxyMQf8OwPX+nSeyzUUiU6iYYzqU FWcLRTupCcUfpDXsMPS5BKsnQFpjrnem3hTIMFgofs+kPHsElcmNMaGzrgoMiyQ/kQSy2DFI95U JD2yXtUfnhAQbof1PmfMA8g0rl2Z1jin2Xj6GqYUHvjT1ULI6VUs+5DL8VI5fsx3cz1V47XSKok wtUly+RB3YL630VU4tfMS6acALC/0bOv64GLuXLgGcdftot+Bueb69WzVF7Y1CdAv8YpL4+7+tJ QWGM41WCQVRW24EvCoOWPDLybVAQPUqUG4NYsFY2uokPc5QeB/w/hAprlCgIggY/YMsYj699004 X12s2MmtS7wnEiiV2o4X7qdb3LxvRXdHRw4Vh0kmlxSL1IHljB2JVRN0icjSa1NLBoeYtZsrycU NmiutNzyT0q7S4++eUxqmN+Xw/q5D7Wck+1cHxXWxtnI4Y8k+w02fykXMRsVWtqe58SU4MqZU9t xE8/kWlSaXC9a7CDDVpvLXaWXjaeJbp87KFkyy0tLZvi8HeVs8HrNAz6medqWhwmgRAXUUeX0Ws WxDpoYEDH8Zyauw== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Message-ID-Hash: QZXD2OPT6VOHECRNZJPPAB34QD7W3KRI X-Message-ID-Hash: QZXD2OPT6VOHECRNZJPPAB34QD7W3KRI X-MailFrom: krzysztof.kozlowski@linaro.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Device has up to WSA883X_MAX_SWR_PORTS number of ports and the array assigned to prop.sink_dpn_prop has 0..WSA883X_MAX_SWR_PORTS-1 elements. On the other hand, GENMASK(high, low) creates an inclusive mask between , so we need the mask from 0 up to WSA883X_MAX_SWR_PORTS-1. Theoretically, too wide mask could cause an out of bounds read in sdw_get_slave_dpn_prop() in stream.c, however only in the case of buggy driver, e.g. adding incorrect number of ports via sdw_stream_add_slave(). Fixes: 43b8c7dc85a1 ("ASoC: codecs: add wsa883x amplifier support") Signed-off-by: Krzysztof Kozlowski --- Not adding Cc-stable because I don't think the issue can lead to real out-of-bounds read. --- sound/soc/codecs/wsa883x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/codecs/wsa883x.c b/sound/soc/codecs/wsa883x.c index d0ab4e2290b6..3e4fdaa3f44f 100644 --- a/sound/soc/codecs/wsa883x.c +++ b/sound/soc/codecs/wsa883x.c @@ -1406,7 +1406,7 @@ static int wsa883x_probe(struct sdw_slave *pdev, WSA883X_MAX_SWR_PORTS)) dev_dbg(dev, "Static Port mapping not specified\n"); - pdev->prop.sink_ports = GENMASK(WSA883X_MAX_SWR_PORTS, 0); + pdev->prop.sink_ports = GENMASK(WSA883X_MAX_SWR_PORTS - 1, 0); pdev->prop.simple_clk_stop_capable = true; pdev->prop.sink_dpn_prop = wsa_sink_dpn_prop; pdev->prop.scp_int1_mask = SDW_SCP_INT1_BUS_CLASH | SDW_SCP_INT1_PARITY; From patchwork Fri Jul 26 14:10:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Krzysztof Kozlowski X-Patchwork-Id: 814584 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 5604FC3DA49 for ; Fri, 26 Jul 2024 14:12:33 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 78BCAE64; Fri, 26 Jul 2024 16:12:21 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 78BCAE64 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1722003151; bh=vYWYuVN4lK3XkrzlF4N+aA8raJCbc8inqKOksPmsXIE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=N6AT3KsUumFuMAviIkfVJuJtwTHkGAGoHUaBgRsifpPsLdM1z0KVLSCAngA89wH3e s+ChRIdBLA/nEhqd0fH/dj77qlEGTrzr0OCqNG2m1rUC18Rf6B7v8DiOCAcxvgYD4F V01P0GOXhpyR0W5V8BbYKAaX15+VnXcCQUgzTgVY= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 4C808F8061C; Fri, 26 Jul 2024 16:11:21 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id ECE26F80620; Fri, 26 Jul 2024 16:11:20 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id C7A2EF805E3; Fri, 26 Jul 2024 16:11:15 +0200 (CEST) Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 614EDF8057A for ; Fri, 26 Jul 2024 16:11:06 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 614EDF8057A Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=pOAcHobS Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-428035c0bb2so11928315e9.1 for ; Fri, 26 Jul 2024 07:11:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1722003065; x=1722607865; darn=alsa-project.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=zm4i9m/ncQZPuov6nCVEVOfcxXDmdJCtPoFsZxzq7VE=; b=pOAcHobSyz+Qhdkd0ZCLOWL6eV2shncqca6/lMyOuI5p3Q+5HKgt8zOfeNoajgDOpR iT3s9+sw2c9nnrepdxT9+Rv2SWN3mqDyQCpLMIo9c2fn68TX5LEqqn0Q3oijBaaY/YZu Ir0tdAeHEQAyBly73x9RW88ZC5Gxnx8hl6wrRpaHlPg7eanCS7gziTBHm0oeerwG1uEz OCuVrY+sXOOL66FCRczTPGtCiRRUUQzmXL2J+KJ8N8h77PX6OTveNEhJgovaDSn97+/e rtWMK+8yFaMX6fP9Cef7OipbLWuRjXDnL6YIKmX9jhNaJKQsgR+4OLJeqPJDTSltfLmX WBsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722003065; x=1722607865; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zm4i9m/ncQZPuov6nCVEVOfcxXDmdJCtPoFsZxzq7VE=; b=oGN3Fl7OQHab6OZ5HQLs0qH2l0rgVGVttBxdgOSXt9xyyhnctxaZ653TFDyuaN4yi/ r56Es5FbeHBnuTMJCDUp6zf6s3e49jnwoz2qGrhGGJkPE2VOE7ert+srj8SBnobQBir4 ffxGUmqFjsWoycFcc5igyx7lvq+0RNs4UBLboBdAG04NM7ZX0Hsl4vUN56PoAY1nnDa8 mspz7NLKcTxd11NFzfhL4sDyy7T14a6UW+4EHIWWh/Vnl2bUcKLpW2FZmPF+ouoH+Vwi 1LTHy6uXAkVPRuam6Qaf/aRj4GgMUqJLEx+C+JYKX9t95TlIgiyE8pd2gsLFOgYCSiYU aBIg== X-Forwarded-Encrypted: i=1; AJvYcCUCm4uk5vKLscRV5p9YLAmkl/GlfOG3Pv08IdvqHRtza1aGCj1oJPuUqhtiCsiJEEA/Vd58U8ZNEpnt28eoInvzXO36mgDWsKtrt4g= X-Gm-Message-State: AOJu0Yxihl9OQQ6udOp+rOyqhZ0sN9Rc29jS59tdHMpu/EmTm3Jl7hSX GQmpRd8JKTCxsB56eYzkNNEy8b5v8QyiTCWKJJQy7LG01IK/QYvPyhmQnMlI1r4= X-Google-Smtp-Source: AGHT+IHwl9iv5umoPhExYwiCZKYi87nvMtqxmxK8Rx49dM71Q/xYQD0kJO7Hzb+m82Le5VpchJQRlA== X-Received: by 2002:a05:600c:5247:b0:426:526f:4a1f with SMTP id 5b1f17b1804b1-42803b5b181mr45562735e9.16.1722003065313; Fri, 26 Jul 2024 07:11:05 -0700 (PDT) Received: from [127.0.1.1] ([178.197.219.137]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427f941352asm120841115e9.41.2024.07.26.07.11.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jul 2024 07:11:04 -0700 (PDT) From: Krzysztof Kozlowski Date: Fri, 26 Jul 2024 16:10:46 +0200 Subject: [PATCH 6/6] ASoC: codecs: wsa884x: Correct Soundwire ports mask MIME-Version: 1.0 Message-Id: <20240726-asoc-wcd-wsa-swr-ports-genmask-v1-6-d4d7a8b56f05@linaro.org> References: <20240726-asoc-wcd-wsa-swr-ports-genmask-v1-0-d4d7a8b56f05@linaro.org> In-Reply-To: <20240726-asoc-wcd-wsa-swr-ports-genmask-v1-0-d4d7a8b56f05@linaro.org> To: Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Mohammad Rafi Shaik , Prasad Kumpatla , Srinivas Kandagatla , Neil Armstrong , Banajit Goswami , Pierre-Louis Bossart , Krzysztof Kozlowski Cc: linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, linux-arm-msm@vger.kernel.org X-Mailer: b4 0.14.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1508; i=krzysztof.kozlowski@linaro.org; h=from:subject:message-id; bh=vYWYuVN4lK3XkrzlF4N+aA8raJCbc8inqKOksPmsXIE=; b=owEBbQKS/ZANAwAKAcE3ZuaGi4PXAcsmYgBmo65te5MyhCVdZRhQoHqqUXph8EfgHYbDMktc+ pR/3JMeV2eJAjMEAAEKAB0WIQTd0mIoPREbIztuuKjBN2bmhouD1wUCZqOubQAKCRDBN2bmhouD 17QID/9o+ExG1syoZx5GLY0VzNCNteL6E5cuNOrA+OdQ1Nwtug1RHqQ17IoqY4nYjtU1xZuKl2i eU7iEHYb5Ak2H9DHF0jbUsWP7ymH9YOY1WsPCQ5Pe2bNj7iJpru18vvrFABFVrqP1bMjZt37vUb Okr+pWTx0kPweMewQCs8jwl2uzQh1dYoh+mutI3sZ1bZLXDD0RM+db37/KQU2Ptrqn28XU+pVIR i0svhkxEOoSQUgLAGwQXviUnOLHFB57YjBlwIh6bZ9B26xMEWDKsWVrIvwoxny5crwDJHPxskUS KGe6PlEErlhXGeDYueBPkTgNsAb5JGWGeL16VpeqVXKBu1N/xZKT7lHHk1cT7bQuYlC6GoDu77d sQzT/MM0h6aWxFF46cKn71HA5/7+Mf9v3Y6X5Oifc0lj6G87IAHxTIFmA0xaFXvMMOubh8HYDVW Q/PvTuMQKp6Pn0OD5Q182HtBc5VJYmmS2+SNAxqbPX57XKCjrzNaFOrVe+4QZp1do9y+ztGF1fJ ymixiwT3tNPclmBqOXqGvaik23plgrnrOde+GRei6PivJtCkBo+a1dnOoEWOkOVI7RzjdxVWi0q AUaQ3YXZuTLyzGaS4vALPi2g8flrO3ev5qKxZ4nLyJlXxUPqEXO6bssiPuO8RkfBf5yrbyfY/1B 3fDQ1WwNDYRRw2g== X-Developer-Key: i=krzysztof.kozlowski@linaro.org; a=openpgp; fpr=9BD07E0E0C51F8D59677B7541B93437D3B41629B Message-ID-Hash: TLZ3WM5BVKCQPRZRII63NVAGNE4AKFHR X-Message-ID-Hash: TLZ3WM5BVKCQPRZRII63NVAGNE4AKFHR X-MailFrom: krzysztof.kozlowski@linaro.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.9 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Device has up to WSA884X_MAX_SWR_PORTS number of ports and the array assigned to prop.sink_dpn_prop has 0..WSA884X_MAX_SWR_PORTS-1 elements. On the other hand, GENMASK(high, low) creates an inclusive mask between , so we need the mask from 0 up to WSA884X_MAX_SWR_PORTS-1. Theoretically, too wide mask could cause an out of bounds read in sdw_get_slave_dpn_prop() in stream.c, however only in the case of buggy driver, e.g. adding incorrect number of ports via sdw_stream_add_slave(). Fixes: aa21a7d4f68a ("ASoC: codecs: wsa884x: Add WSA884x family of speakers") Signed-off-by: Krzysztof Kozlowski --- Not adding Cc-stable because I don't think the issue can lead to real out-of-bounds read. --- sound/soc/codecs/wsa884x.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/codecs/wsa884x.c b/sound/soc/codecs/wsa884x.c index d17ae17b2938..89eb5e03a617 100644 --- a/sound/soc/codecs/wsa884x.c +++ b/sound/soc/codecs/wsa884x.c @@ -1895,7 +1895,7 @@ static int wsa884x_probe(struct sdw_slave *pdev, WSA884X_MAX_SWR_PORTS)) dev_dbg(dev, "Static Port mapping not specified\n"); - pdev->prop.sink_ports = GENMASK(WSA884X_MAX_SWR_PORTS, 0); + pdev->prop.sink_ports = GENMASK(WSA884X_MAX_SWR_PORTS - 1, 0); pdev->prop.simple_clk_stop_capable = true; pdev->prop.sink_dpn_prop = wsa884x_sink_dpn_prop; pdev->prop.scp_int1_mask = SDW_SCP_INT1_BUS_CLASH | SDW_SCP_INT1_PARITY;