From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D1749484235; Mon, 31 Aug 2026 14:07:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788185249; cv=none; b=TJJIZdSpSjs2VbBnfQbcHXOumP0rMjUZ3hSvmBjUx4bwXvleZu76Q+2SH65TK4ZYsIgS++/ukpivPtMJGbheZKzCTG86m12YEosuK+4/jNQxudgahwJRy94iMKhzyWxaGdbOQ7NoqoR9cnQuRfQ8NP4aQbvx9Kfsxi2eY+HvWc0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788185249; c=relaxed/simple; bh=5hi7diP1TQJoRCJ9ochdxk+tWkMLuePo5JeUlb28jBI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eSichcYLd8iWPlX4OQDgfcbQvU9UoLZ+zkQnFW3sjl2ZhbdUWVNy2M66j9Jr0gmxV7zm0/uelSHZ+do1FBeDup4KATxUP6opw2IZxJm379CsIdsBGRSCyqMu1cBbdlH4Sz7yAZ1IvldaSIms69TsJixIP0LtWGO05+HzbXvqOFs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=FP4ZjgRm; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="FP4ZjgRm" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 32EA71F000E9; Mon, 31 Aug 2026 14:07:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1788185248; bh=PBH71UhXmXDqRRwmn9UfC1TOghrYqUPn0fWSC0riUCM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=FP4ZjgRmeCUA7jLgL9KzxAviIbi6j40Fe7IMcHPc27aEdWhmk5+CMD6KASmEmce2q lj4xU4/kQ5MFOJ6SZK293Bqno0jKBkHPICar3xkAWtXE7I6Ph+4wDWnkELEH9922cj t8wPZM5QCvOlKB8Kqz4UIhg856Hl4s7tS42SBzjk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Thorsten Blum , Herbert Xu Subject: [PATCH 5.10 34/43] crypto: atmel-tdes - use scatterlist length before DMA mapping Date: Mon, 31 Aug 2026 15:35:42 +0200 Message-ID: <20260831133400.226641945@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260831133358.571886287@linuxfoundation.org> References: <20260831133358.571886287@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Thorsten Blum commit ba199bdaa80b09a7dd92f28751de7f3dbb06c510 upstream. Using sg_dma_len() is only valid after mapping the scatterlist with dma_map_sg(). However, atmel_tdes_crypt_start() uses it before mapping to compare input/output lengths and to compute the transfer count. Use the original scatterlist lengths before DMA mapping to avoid reading stale or uninitialized DMA lengths when CONFIG_NEED_SG_DMA_LENGTH=y. Drop the output scatterlist length in the fast path since it is equal to ->in_sg->length and does not change the transfer count. Fixes: 13802005d8f2 ("crypto: atmel - add Atmel DES/TDES driver") Fixes: 1f858040c2f7 ("crypto: atmel-tdes - add support for latest release of the IP (0x700)") Cc: stable@vger.kernel.org Signed-off-by: Thorsten Blum Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- drivers/crypto/atmel-tdes.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) --- a/drivers/crypto/atmel-tdes.c +++ b/drivers/crypto/atmel-tdes.c @@ -509,14 +509,13 @@ static int atmel_tdes_crypt_start(struct IS_ALIGNED(dd->out_sg->length, dd->ctx->block_size); fast = in && out; - if (sg_dma_len(dd->in_sg) != sg_dma_len(dd->out_sg)) + if (dd->in_sg->length != dd->out_sg->length) fast = 0; } if (fast) { - count = min_t(size_t, dd->total, sg_dma_len(dd->in_sg)); - count = min_t(size_t, count, sg_dma_len(dd->out_sg)); + count = min_t(size_t, dd->total, dd->in_sg->length); err = dma_map_sg(dd->dev, dd->in_sg, 1, DMA_TO_DEVICE); if (!err) {