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: 13742822 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 39C174C8D for ; Fri, 26 Jul 2024 14:10:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722003060; cv=none; b=QKQVEmFXnONRrOAzS/JsWktBTZ7HGJLvQ6P7Qp7TEyMN/T9tfAyg+KMZFUG4nNBfKJ03RK0pwOGfwojqedvxogB3rP5EDSRg6mlsJxuhMi26Hk+O99EbVlI8EWXc9260OC0UbxdmPbZSnNrxVYBopwOtcJ8/zwqfF2VS1PJoaW8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722003060; c=relaxed/simple; bh=U0iQgUf77isNWPz5wSO/QalnZ8ymeec3WHS6WdettZs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=dyosAF4sIou0KM0R+iYdKm60vnqPUfw2m8x4GU7o9WkbhmtSVW5+mx7JJA6lIGmZuSSoQu98EHrEbhrQ936jZKqxMFZOsf0q5k9esuLzjfa2mfD8XLyzt4wc9raxFLlPKLZ77Yc+D7pvM0bJnxp6ODnCEMjQLuhmQNzNVL33xq4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=ALCVqZPz; arc=none smtp.client-ip=209.85.128.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="ALCVqZPz" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-42793fc0a6dso15704825e9.0 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=vger.kernel.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=ALCVqZPzjQ7Dn0u2cgQa9zAwxf8ZZ+aJFmNknjQyum6Cm3bXlyIXeeGs3OdwtwQ3ST Sqa6QferPSzs7am+Kf5afxWV4c8mTTEOL7kypiV/Q3J0/HjhD46iH2x52uU/a4/i4mtX hDATLep18wBYCNJttR/GmRNUe5B6AEfEa86I+0e3PuNB6fminA+PW39uSOAuH5zyCg+T 7dWTHlqJ+YLb2iW0ZSFRhAwCkfpE9EcM7O1yeeTd7M4zVweTnZqU7oPMohogn3x+fBPD CtWXt5e7xfgm5pMrIbCnB0vJupPU7K3LKjkx9tFVLTL1VMQi+EylJ6cc6fHD/n3se1mR M2gw== 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=N2K7PaUlW9BNgxRk5eGX7qyFW3+7M4gNfm1CYKgoVDly8ELoqo50PjJdyrFnjSvNED rTzZ9BoZwwv0IJUTqTxLZlt5q6w3DtFTfGxgSEUXiR9nnJtxGVfzveo09Qu8GDLunBxV 3LmZsD50vVL6JZTqQjQJgN1JaPI88/W1FsTb39lka8VmnOhd2+iUO7RHAixYg7XAmtxL DWdfXxwVB4eSrzpeRShj8lG000dzBWzibg5SN0q9/PbXVJs7ZcMYYdcdNpIk2AZ4Mtg8 bxkqc06oOLJbl8rKXqYkdRMIl7snEiM/OQ6usY5xUqVZsAwpv9Fz9sZJWjXkT5N4bYx6 EV2Q== X-Gm-Message-State: AOJu0Yx99IEoNmHgwi9550WVD6IM1/SwCeyVJxXB+VQNJlmhTGy5vI1J /Q4g3h9VAqDMkJLzlZgbj5gB+80jnE+MYtdrfiZTsvByEaZ80KQ7Dd847Qn/h44= 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 Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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: 13742823 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A454EB673 for ; Fri, 26 Jul 2024 14:11:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722003062; cv=none; b=LIm1p4zQGOSePdxWb2otUul9OGRIzp8s7feZZaQhzlYudiToB5QGs3/3507S4itNYtVv9QoMkmFQ3ZsSOosNpLYyQvzTKFGt2rkURYa8CHM84v+9fyyHIDN3QMBoxix0bPWVVDJWTmpSiZv2u5GnsbxlDSUobCshwu2P47OD8fw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722003062; c=relaxed/simple; bh=cGgEjpzzxGI973pctJv1X1Xqrenmzkw5jm4bI9/CPUs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=JZIdKNc1M/bsf+vY+q9cHx0D3xkXKvF0TDKrl8jCgWZ4Zme3vLYL/UwKg6M0yqWb5n7Nv56rcfDO/1bK+act9md8K8zLbUQRP2bSWGSdR4kY71FDjhYL0bjkX3i0cEKjtDhgG87uQcdZkkcnds7vtwGyqrtxhOy9Pr/HRk3Ep+E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=M83Rsn7z; arc=none smtp.client-ip=209.85.128.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="M83Rsn7z" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-4280c493719so5540985e9.3 for ; Fri, 26 Jul 2024 07:11:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1722003059; x=1722607859; darn=vger.kernel.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=M83Rsn7zZwZCX83qbij7qoBpsyFsLhWEL+xk+iUQS4Qsp2A+N3dBkewHJjLGmIUn/x Anv3HRDysxHEFpMHjF2aEKtN9znYS5Z23QWbQeaDrtRcHawVqhbO++mgLNh3fj90m37v uRNg6w7hWwIFj6WHeJiiJuFJ1Z8KNo2k2nLG/p1M5+twMDSCUiJJ6kQJST4Ob5JD1n4Q PXcLgCLpKjbdu5/+5b4ko7xzN8Zk3XdJZxTtxvzNWhi7SpxCLP0y8k8Jrd6lKV91w0Wr GqoJawioIpvmKjNADqFN/YndQcBcqrl6OqD+/tUDKzJYaexugzzrqVfqKkFGg4zGmLDq /frA== 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=h47qtoga0pSgzZ+fB2b2XoN22+fo1mZ1qIYwiaRFsNBEwpmRR9UDIJkuB4iyqy3ki0 eGKIP9SXqQc9tWxRD2SDOWd7UF/XSfGKbEG7xKIdx5S3lIjEIpRJn9HqOCLOPvL2qTdL Aecjg486RJIzJg3yuMqtQDy7i8eN9Et5aXgFQRQzLwbDFdaYvC+HeCVsjfudWSIaNSrU hncvd/jPc8a+zpjqH2Uw6flNGZQ7udjU0BxNeY/tqVY1EGmTUMNAFfi9IBjQGjmxLhXx f06M2N0pltYfASgihTy80OGGpvzl0LHmPeih2u3I0VKiAZYNnJXFblgIX2EQ+nstux4N +blw== X-Gm-Message-State: AOJu0YwsMrRyYpYd3RHADf5oN6ZRqjddB5NVK5J0qkIv0elWjhx9F5gM nr6IVMnNSpFV9ffcI8lmlnT0G/bfnHXF3WDFfJiwtvXLNkqDJqZPDy8aEZX+7rs= 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 Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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: 13742824 Received: from mail-wm1-f45.google.com (mail-wm1-f45.google.com [209.85.128.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5B3A110A19 for ; Fri, 26 Jul 2024 14:11:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722003064; cv=none; b=ucGbKFTkzKC9w+H1irgCxNwm56GTatJkxpLY/JuuFUnDN2bB4HTDG5Cca8gmfE+VDtQy1axyGk/3S76o0ayQ7BkwoXZ12CyhG775QQq6/pg6/jZoe+S3+dGemHxHF5QgOoulHO+3YP4YrWiMsVWYqpn0ZHSFV5DiD8np1jQ4stU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722003064; c=relaxed/simple; bh=dP7UEMsz7e5SQeBIvoJx2Y/Pic6CV31hwYtlba9OL/E=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=AzeX7V/+2qTcNtuZpPXzugvm/1/mZ6qaWz/lYEBixmRACg/E9B/LlNRE0sy07dooMFXsNW9WpV+zk1yy6sT1yl9+yVk8bkZ6si4mVLbS759Y5vOH6jDvNOL3bZsUCc9A3jMhDf2+oseR00y+OGn1NNFMEbwdUXuw031AiDt7wHA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=T8tlNpIh; arc=none smtp.client-ip=209.85.128.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="T8tlNpIh" Received: by mail-wm1-f45.google.com with SMTP id 5b1f17b1804b1-427b9dcbb09so16247805e9.3 for ; Fri, 26 Jul 2024 07:11:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1722003061; x=1722607861; darn=vger.kernel.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=T8tlNpIhJSFJ2tkUsbRhEjDU5OYi/ZG+4qhIsF8TrXR2re2sEV/hsGSejB2XtYFiMw nHFLBCUQIFAC3P04vZ9RV8lUsQ+J/SXmuq4a1k6SJV6Fs25hUHVSCqesCMcZAcOMhc10 OxTVvUaxawJhhsjKpRsJtWeEHozDZ669LtEtY0cDgjBAmS7Sc+C8xen3ZdPpUY/5Kbx4 g2fciMcIQL9NJuOvQgiCls4/2bs1EXRMio90YAnXGLdat0TNxKagjbMPwNZ6RS7qu3e8 PfKM+sCZCYhVOqxWBpsl6UaXeP4aiCSFXhB5/EnDusreQC+LybrG5RxMr4Nr+uvt77w2 1aKQ== 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=aqgk72fuki9wvqF2OBtsgHm4FlMZz2EXzesu1V4wS4Xsb7AGZ0d1W3Dq4l13g3T2mn 0JTrFy0cJ3BVThRm0SA7oGERUU8n5AMZ3o3ntya5KX7lAr8a/gcr3eC/h8nSwnWUWKPg aPXXDkJ/WQjOQ/N7ib8gCMmNeeeJ+JtJgAZrtmlIL/W6ucsmlXkKWXPZdLi7+AnK6bKL 74/a8VhumM0xBs16KyaGYrAn3ybUBvflcsVwlQ0VxAHEFR2bitodHviKMI6mjhbQZsAs fn0a1L0VTKu4tS1EBdM7Ffa27VJwQlofAtvbAK46Tlf6U7ejj3xYtym9Iqhex8gC4k2l Ct7g== X-Gm-Message-State: AOJu0YyYxB18N+8DFyGI3MrQPhOIcko835wFRo6bbcQFa2rPznqkOvZZ +Uslh9McknF5bdlj7bTiB7CiJz6VVLdODMpHWKtXGd5cPNkwaiALDKwVJTv7z58= 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 Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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: 13742825 Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com [209.85.208.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 931EB17BDC for ; Fri, 26 Jul 2024 14:11:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722003066; cv=none; b=OB4ad5k7H4aySChHU35xVgUAB7AubvqnTMkVj99+dCrYQ/2pNQC05nVhvxhBS/v4+/Vq2s4I7uUhigPXf0E8veASQqiciU26a7I0ghJ4Px9CM1TdpwrzboCzQI55v3jvvQUeneQtK4uFlukYX11WIiE6o6Wnr8ORJKKFXwEmFQc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722003066; c=relaxed/simple; bh=Wl+tDBuyQMsKe2NwpZXMc/8shVbTUViF+5tNnWhiufg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Hv4mBUaLBPCtJWLSesXIZ+5ZFRPUmiUP38XsK3cje0dExOJoDJ9+oOHs5O6FfEEJx4Rx/u5H3TbzmY3s+npH/4oWREpG0UqMyOiSAtjs65FvGLdFeD0wmB7TpLV4HoyZj+sZPUR0LENfAB5SiK8jR0I0EsslaAbE8l9DEF1N4uE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=T8ZMbcaT; arc=none smtp.client-ip=209.85.208.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="T8ZMbcaT" Received: by mail-lj1-f174.google.com with SMTP id 38308e7fff4ca-2f035ae1083so16344611fa.3 for ; Fri, 26 Jul 2024 07:11:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1722003063; x=1722607863; darn=vger.kernel.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=T8ZMbcaTDFDAb1M7njuK8aj40JAft/Vhu5gvyZTqQkLQB7dLUN9bemklA9of8k506e 1aZcBdUWT8+SQiSuNzi2W/0vNAp7Ergw92vd7+bnxCKQVnncAk6rs4zWmIe42de/jKYx hPOuQ0n0juOwF5eZkn2SIH/CkRr+39QvirbPehl3WHsj8a3COqZsLdQz8WNQy6oymZAs wk0N+Swzfvl98vMzs4IQL5+im/0hgQEAFT/YxCz38cbvV6bszugHYy2mcpyuD3Q4/5Z9 16roi37Xz7PH4QZmn32spkKLJQ/Icg0BOLJ+xLKTacvOr+Fpuvio/iiaeOfVLZyG2ERv b5Bg== 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=G2JzM7coNAlDClo4nXp1nPKfNlj21vUmaLTdcaOBeyY4XGzFY4q2pgW9OpCbJlA4qK 0vwZPt4SYNOtLviWXeu5FumrG6sO6qpTurqtOJA0jK5a8dbjx0JSxFlM4jO20yDSSreG iHxnQgP5EdJ8PwmrMF+Eq9hnLpYj8nAJnltqaiAgKrWHbBKc9R3aLDNXaSma66YKgfWE EUvD1q68gv9jeyEjaKpAFO9mG0O5A3BArXvUbgKPLmHCGTTb1DFD9x5sb3l2CjEfi4J0 EzFXrNXYLUTlgI2ramZNAKA9Ix6A6DAjOPzTQ7ZjC5YdkuRpcrWsPog2fx+h0sh52qDj s1hw== X-Gm-Message-State: AOJu0Yzn74qo4Yxc7kG6IjZnGmr1NlibnS93N0gm2xQdMfHkprROs4wj ol8mu3io55KWPmwgmjBsP217Xtt0MbB+h49DBljIZcP1hqMAcpj7qNPEMJHzgsI= 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 Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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: 13742826 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A45E51CA96 for ; Fri, 26 Jul 2024 14:11:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722003067; cv=none; b=CRU2mKYRbj61QrDS9LdyJi0Wc8bcqrIq8vOXd1JTW6BU7IADnS15cRnMbLTIsHY0y6NcbeWzLObOQeQ/glEhaObnEWQLP+zte98SeRuCkOCNbMjiFYY0CTybSRfzfGn8Q/Ek31mS+F9t/Guk+g28LOcDP4PipO7GpBIZgXPSLxI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722003067; c=relaxed/simple; bh=Vu+vQdTFKWsQq9i9w0o9ZFa+ZQrVAJEgITfkg5lDM4Y=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=YUtWxWyNEA80nQ0oxWK4p56jE7RgXF0hm1a1FMbOguZEZjCY4/4vonPUDK32OTAR+AbILVvFBWiL3KvahlzaaJyRICIkRYlb8Ic1eW0UCpEkRGosgKDFr/tmrFPc1Vo4xP5KxA5sWGgkljPTzwjDhnKP5VxZT1or1aDi6LXgng8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=gIu6kCSi; arc=none smtp.client-ip=209.85.128.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="gIu6kCSi" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-4280854e236so12196515e9.2 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=vger.kernel.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=gIu6kCSiQ2jaCwqted0ryUzMZMm0U0QUedqdo5D/x9S4EhAmFFCjtkn+MhIIXIMeGS nEJagepm/TsRISe0VEvpeAnXxvGB2GeAr4UuzvzG5YfcRArnvJ6ascGHBsd2ZXVIul2d FE1A9Yyg44UkiVPtAeGJJ0Rcoko3nrnkWgZbQCtq8qTpaEFoQTYN08QuxH/BlgeaiE0L xstesxH/XJ1p40dN4eDZZHyzHg8HvSFxHF9c6pXtVgl8f9jFEgPMrk5d6qwfeIRRIdnc uIyhhV3x5m5iIclrVQ+H69blbXQqn7O7ZtXXVGA6WO36w36N70PE/aQ8gXl8Hy3RokCe 0Qeg== 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=leLzs/HVTUKbqElNCSpJyT9Y5nIeLZ41FGvXGwGgPbCw8mU5GeQyzRQbKPuAAAqMgf 0s2+dqH7uZgd8AvXQs13xXTHkJ7MA9yb4U46YSdOAfyMjfJE+Wb1bFOeVGlo5v2vOE4e HoAB8z0t3r7PidxZZFqng3nlxFWnOr0tE1IE2rlMPp4MtmM8ZE5ZQDzkrhKVF9Hly0q9 IYPRCDyAUQduX43sPnbm1/Ou6BCzjzr4HKamfgDa0EuuIOzcClLppIT5eqDpVgMDo7bF s3lT/3aHxNWoPu/GGj6lBMAubTP9bgChGO0wHiF9To8vEsFDMwSawXYFujuEvyBbGbEA T3Vg== X-Gm-Message-State: AOJu0Yw7dRSSSX8kGZaV8oS8wujl5Cw+hxPAHI+6xFTNECx0RiSBWjIz ue4gd6VpRHaGSx6KOmCdS50OUQCX1IpcBv+LeiH9phaFT8v4serqXVXLC2O6rU0= 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 Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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: 13742827 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CAC54BA42 for ; Fri, 26 Jul 2024 14:11:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722003068; cv=none; b=iVoY1yxwC/Nw3U/qozLRHAucKVK23X6dla/E/Cfo/VuDxgFanX0u9S4KtsvprTjsFiS9YB8jXW7oeIN3Uh5sVQTzidtIQNnE40LyT+TD6JiUu3GgkwoCxEoNEJdHAsJk/fboFprJgHmCZjce0+YqoRIzoOnKIK82snLkOw8DifY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722003068; c=relaxed/simple; bh=vYWYuVN4lK3XkrzlF4N+aA8raJCbc8inqKOksPmsXIE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=H/FbwQ/oN9pmDD0x/Qszrh3Ij1o7W3g4uasKekYeld3Xg06/dwT2KWMMiPUwF1az/Wf1m6Ps568rS2Xn8/cE5Phyhjx8DyxDK/JUB2ccaHCccnBFHu1QRjruHxWHlUO7nfnAjHmcLmddYpjvs3fuR4FCz4x8VVaCcMP6du4I8Zw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=BXFfClDl; arc=none smtp.client-ip=209.85.128.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="BXFfClDl" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-4280c55e488so3955235e9.0 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=vger.kernel.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=BXFfClDlHaDjbaV+jhg+EztBMz3iP926ns3sAeX1qJFGouN5CjlY9NBUqJ2QSkWtAA KQ+KFbDbr2uUtmxvyC7SBE9kSZ6GuWXgRFFmQnv5e0XD3NViQlxDqRmwYIy21NkieHLa Xf+7IGH6ltgqgHPZrTQhZ5HNIkaL7JYdMG6knwZjsXjtCd6d7tJArZ5D5Ilt0/LKGNO6 SLuM7b3RspAxGEYbL6NL2gyUrxXUWR64sO3BGCgc55iGj1tGhKZHv1/yIUQpUE2forB4 sxKbdg/3WRQe9pJt/I2kCdkasyqYu2E7uuWsWVGQBGCv5rDkbrgQjEaOk7CpV3ywqBpB 0cTg== 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=aSzzvC9bO6LAWrvuvY3CujhR3u4mOR1SJfRZAPC2DBkfcRaMR4bPPuyM9lZP9q63Zj lOoBdA64vpncjHRbN8imZvUUCggjtyyxh+XraZMDz5FD41lKYnH5g8lXmdZaGTgUrlU6 BvQxQvGt1GLIbuK18Bc+BPeYUklUD2Nyd3Td98WghaqXWf3fl+JFCQeMqD9y2wzu+cnQ Ktzur03//7LlBf3S4nEhged3ZE6GOviu5QVkvnpUGRRMo2G9WOA0E1PUwwtChAUWHSv9 LETrYCWP51FfSnSGA9fI5+9aGsang5QAlBbTklloek0ChX/X4moGMP8bxR3OZArUomCG +4Iw== X-Gm-Message-State: AOJu0Yxv9GiaTdjFmyyZLQl+eHFyIBf3fE7cKGGEXy2xNV3J0gQDA6BP NBlC4qXzhBlEgJnrvJ5pmc3dK2TTzc+vEnko6hlvIk85vJdpJ5mnpDpUHBdbu8E= 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 Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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;