From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796387677; b=3C6VnsND6NNok1mrr2BFZLHk7O1HTtgxtorUmiWuqmyXWA0JMmtju//kjw+K+pU919aD wK66PzWxGNI16jOvpuNCyG+KGgyySAaBiWqLZytXuRQMhqXPcTHr29mTT8u8dgKZa0AFn qwNpj1oLz1IZYSGKLJ3wQ0V/0W2UznmLih0N1NOcv/VgprqV183gXzAi/UJ+I2P0BIqM1 m19zKmt9F6/6FXP7FuaoYXoxw58OszhHk/FBjcDZyFfFOr8Nfpn/+NMei+yaIJTDTO2g6 GX0CxQTDknmro8QwBdgkRUh8Iy8hIFDNSQHgkbSbhLt0AOyGmDl4GmgCQUDJzwIGm+g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796387677; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=IzgDqgMAe7iAno0UmjsyrBb0KtaXEhTipr/20NgC8g4=; b=WPB4P1ubByPg6+5IHl4J7Ut8YldzxI6IJOYeIY4O2ZL5SxaPTqAl/dCxrSgJgaMa1cyw iQF3ZlwlI3IoBtzKu2xYQJUZL/udkDo/gqtxSiCjQufIjrDs9IAUR5uHQzKMFNMlEAgEq 9ieAq87rgL+MdUWWAKxgiqqQi6Izv98NMuLuGHywyBw2LsrtQOtJtWpXQjaTcVFrcB6o9 mV3U2LVOw9u5BFWT30b5yA+P1ZjH2rCOfiflmrR2NtGAi0jm+QMbZN2EuMp+1JU5hnQlD h+8jGEGxEHy9Dee21GXWg4gIL3vFrYPvw6qeBBuDpUQv0aNYM3jjdR8qtYU2qYZ9Oag== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=r93w5uBU; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 111AC606A322; Fri, 4 Dec 2026 12:34:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=r93w5uBU Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7EC231F0092C; Fri, 4 Dec 2026 12:34:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796387676; bh=IzgDqgMAe7iAno0UmjsyrBb0KtaXEhTipr/20NgC8g4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=r93w5uBUFXUWCQ0z5sl5EcwxIiLbuk+jVxAous31YFbzFf88v08J2qH+1IDd9F1j6 HiK4vmvq108ycSHf/f4Q9A8xANP4kvGrajDvMDr/uyg/9SP7PkFV1gYvIvB7VqI6m2 Al+TYVT4RbYZAAwPOdwKxlm50b6/VdlTN8vHgdR4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, sashiko-bot@kernel.org, Linus Walleij , Frank Li , Vinod Koul , Sasha Levin Subject: [PATCH 6.1 0344/1059] dmaengine: ste_dma40: Fix logical channel bounds check Date: Fri, 4 Dec 2026 18:57:55 +0900 Message-ID: <20261204100653.178046412@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Linus Walleij [ Upstream commit 57938e0c2a24f9f792fe9f611391ef6b58d1aa21 ] d40_validate_conf() checks the raw dev_type against num_log_chans, but d40_allocate_channel() derives the lookup_log_chans index as either 2 * dev_type or 2 * dev_type + 1. Validate the dev_type against the derived logical channel index limit so channel allocation cannot write past lookup_log_chans. Fixes: 26955c07dcf3 ("dmaengine: ste_dma40: Amalgamate DMA source and destination channel numbers") Reported-by: sashiko-bot@kernel.org Closes: https://lore.kernel.org/dmaengine/20260618051539.15E201F000E9@smtp.kernel.org/ Assisted-by: LLM Signed-off-by: Linus Walleij Reviewed-by: Frank Li Link: https://patch.msgid.link/20260927-dma40-fixes-v7-19-89f595e8851d@kernel.org Signed-off-by: Vinod Koul Signed-off-by: Sasha Levin --- drivers/dma/ste_dma40.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c index 15f55802e8036..e5260139f5da4 100644 --- a/drivers/dma/ste_dma40.c +++ b/drivers/dma/ste_dma40.c @@ -1843,15 +1843,26 @@ static int d40_validate_conf(struct d40_chan *d40c, { int res = 0; bool is_log = conf->mode == STEDMA40_MODE_LOGICAL; + bool invalid_dev_type = conf->dev_type < 0; if (!conf->dir) { chan_err(d40c, "Invalid direction.\n"); res = -EINVAL; } - if ((is_log && conf->dev_type > d40c->base->num_log_chans) || - (!is_log && conf->dev_type > d40c->base->num_phy_chans) || - (conf->dev_type < 0)) { + if (!invalid_dev_type && is_log) { + int max_dev_type; + + if (conf->dir == DMA_DEV_TO_MEM) + max_dev_type = DIV_ROUND_UP(d40c->base->num_log_chans, 2); + else + max_dev_type = d40c->base->num_log_chans / 2; + + invalid_dev_type = conf->dev_type >= max_dev_type; + } + + if (invalid_dev_type || + (!is_log && conf->dev_type > d40c->base->num_phy_chans)) { chan_err(d40c, "Invalid device type (%d)\n", conf->dev_type); res = -EINVAL; } -- 2.53.0