From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.180 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796263678; b=JuKyCaeMoLcP9l5gdt57ahCmkCY4rHHHohfViUg92tBjmGxXfz3XUNqzgtkgoxsFD8ec bKKcYXdQpeX7gF0aHlnOuuFMUjQeZuYVgfwFQzjjT5QetfdmdhpX1VyUbTeXqYYJrlZME xDTQuwkimthv9jZLHgm9dZ15GTtR7Fftk/iGFTA/jl1iiXWaGGyaqUJYzCJhwqQBq8fU9 sBaRBOjhvQ2t+21K/L+YNnEkMPUjPYTiwtNVkRl06/ztOO83c8+BJ+2QcSgPKKttpk2gw 1WnKlRn+PKszoLTYM4Tbkldh4HwrEe6LGWdDQnTYxORdzxk/kWTld26IQ1/Lqa4IePQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796263678; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=+Us9tpfzzDLDdkUkSziqd+1j2O6M4UZEsHL8trtds4k=; b=Nf3S+WQAiC54pNDa8vjK7/KRB9SLOZlqnfzOpZz4UZiCZGnnPweUoRrfvLaYeulIhG6f 0SeG6xcpAsH2/4F5PcSFjU+gK8iWH3QuDYH48cDXjB6BU4lr8ialYPA8BUU7ktqngxFwA 7hcclBzbPWhk4lOMsj16snLNANe01tivdsbPYxbWbZMJ3jEvYbmzsXdvHcXIf7sPi/qK1 jwUslSZa6AHrM25DXYTOrmOjb97N5P5iFCni5iOk0njR7A1xRkAEPooQxTtIg0irwOCFI IoSxxju8+L3Ot7oYwlfMr7Hy/LPE8MaGPocudTWOvbVd9Y4PUGT+WhjUXE3yFQHEojQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=FFCn7bms; arc=none smtp.remote-ip=209.85.214.180 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3B9C0606A32D for ; Thu, 3 Dec 2026 02:07:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 3B9C0606A32D Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=FFCn7bms Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-2f04ad2c46dso81923125ad.2 for ; Wed, 02 Dec 2026 18:07:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796263677; x=1796868477; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=+Us9tpfzzDLDdkUkSziqd+1j2O6M4UZEsHL8trtds4k=; b=FFCn7bmsrdnbjsK/llpO5Z1CnM+rq78JXFoWelrB4yB3zGS/O/qA3z1aFlYGTAZBSF iElSpl3u1O1oS1wrOqgTSUGYM+AzZFvZsBFfj/pM8Nl70Bc/vuqZjhfjVTarARJsevCa 0EQj0930ji1E2/JbEHW2/8BbvJ5Y+F+xzav/AZUSmegzg9sG9McWxl7ouVDNTi+O04BX tIBL7Jfu1g7ahHVtowIM3G0oO9BONspGHKdqPFeJ4xF2qwcACSoTawmTkl3qpZfF1CwG j8Yr7YsPjsRAj3tphEfmQWpALKGq0uhM2VQM6wH/6q+/2wABjgQPWNDt1PtPuEZM+0so 4ZYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796263677; x=1796868477; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=+Us9tpfzzDLDdkUkSziqd+1j2O6M4UZEsHL8trtds4k=; b=i5Tv1hywAH6o8o/H5Yez980WMNCfE4jDAyVpf19QGh74OcTxpvCm9AySx+oXqXCNFA fOIXlvmAbLOpiakks4jCxf8oo/EvvmdS0F/BrkpihEyy5mzQs+77SyETdPmPsEa7aE6f ZE0wMAWitzujFrhgwO03fNqLhUrM14qBtcYg9Wit8iHKbuOJ5hNfrEgNmyYtQyb4PgIm c3zdrZsYM2n0ghnDW9ATVLBkEIWE4jCSUzHC3/veWEpHHYKrXtMQGLuod666+D+WVaj8 xEOiKSZ2mOS/PI1E/u6noGN4VzOY7FwUPxbxAnNmmFPEvnzoG1Mf+WjFq3F6otWJWOov RFAQ== X-Forwarded-Encrypted: i=1; AL+hErHwanst3cjShzWeuHNZHrrphXsM93CIclLMIWoVEGmCP/JXmEskRzQmNzG1A1rmcrxD/r0J10Jh07Jjn70=@vger.kernel.org X-Gm-Message-State: APuU4Z+OTpZbPePLcTsibYratVZ2Xze8gloK4fZPoaWOPJRODBgJLC/E ilzRMeRWMyWHKZ0VY7TYt4yGZii3C0cXrdMFj2gmmYsIDOQ65xZ1IUZw X-Gm-Gg: AZFdTZd/XHm5b/KbO9B1UQpAgpLdB9hE4VoOQeSOnW+1979Dno1ktD4hJQ76p4rpN5n PO2sILZj6Jbaeo4IU4mYrL4j9bla4mxXHSC/xyBsHfhyPgnY7xH8GawEXT1xZkM72g+Qk7bFBSR TQKBh5oGx+cBdiHouMMS6H58dqCDhrxLzq4nf9AHAxVBw5dEE4iUL5YF3EpAPSWpS8EUQi9fvg5 6SSk84nI/MODG8zEf6NOmoeHPKslRFfAZo7MmGZSOBLvMNg+zlqsYdV7qxL+1yZjEmNuqZgm7bh XBmzOBn0ANnj1dFhMBQC9ZIae8Q5X8P47wsZSBhMVoRrL4HZQf08jNMAB/OiE5IWUet/9qjtVvE xPJDjcEIdAg2PjJGwOTCkcgruNeVr8QVHUAZI65DYnByPjDJzrzCqdrS8HcrAtQd4NFBdunexiO /ap4Gr8XltmjBWTmkJ90CT8rdzzWPpL/IN++o1UGsbL6PtYDrM7HTgRAoPYYBZEeXOdje5ZnXIs 2W30GJseviKvKCqr2s25qwvU5NDFZ1Yz6X6J9ojrqKJgfl0KnuFHd23D1PJM0WFSdgTOxgg3oqv 6mUIl250ESqi2moiHAKvvJB3l1vhL8GCoH/4gtN5t8oZ1nL1eO2jTiQe9BC1XVX3JppHOscLU5I kZdf8hpO1RYaay64HYzm5MnDWUC4gwwtgBKWt6D4vlK2/fzSfYMIJb1SlpSzb0RG2TPjkfFOEm2 EXENI= X-Received: by 2002:a17:902:ef05:b0:2ef:f645:da1f with SMTP id d9443c01a7336-2f03f17d1c8mr288035845ad.14.1796263677364; Wed, 02 Dec 2026 18:07:57 -0800 (PST) Received: from ryzen.lan ([2601:644:8000:37f::e34]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2f0b58fce71sm157752485ad.45.2026.12.02.18.07.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2026 18:07:56 -0800 (PST) From: Rosen Penev To: Srujana Challa , Bharat Bhushan , Herbert Xu , "David S. Miller" , Rosen Penev , Boris Brezillon , Arnaud Ebalard , Russell King , Romain Perier , linux-crypto@vger.kernel.org Cc: stable@vger.kernel.org Subject: [PATCH v2 5/8] crypto: cesa - keep the chained IV on the non-TDMA cipher path Date: Wed, 2 Dec 2026 18:07:30 -0800 Message-ID: <20261203020733.260995-6-rosenp@gmail.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261203020733.260995-1-rosenp@gmail.com> References: <20261203020733.260995-1-rosenp@gmail.com> X-Mailing-List: linux-crypto@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 On engines without TDMA (Orion), a cipher request longer than the SRAM payload is processed in several steps, and for CBC the engine leaves the IV for the next step in the SRAM context area. Since commit 2786cee8e50b ("crypto: marvell - Move SRAM I/O operations to step functions"), mv_cesa_skcipher_std_step() copies the whole operation, original IV included, to SRAM at the start of every step, before the copy further down that rightly writes the full operation for the first step only and just the descriptor afterwards. Every step after the first therefore restarts from the request IV, and every CBC request longer than 1920 bytes (with the default 2 KiB SRAM) gives a wrong result. Drop the redundant copy. Tested on an Armada 385 (WRT3200ACM) with TDMA disabled in a test build, against the software implementations: CBC-AES and CBC-3DES results were wrong for 77% of random lengths up to 8192 bytes, i.e. all of those over 1920 bytes, and correct for all of about 38000 after. ECB was always correct. Fixes: 2786cee8e50b ("crypto: marvell - Move SRAM I/O operations to step functions") Cc: stable@vger.kernel.org Signed-off-by: Rosen Penev --- drivers/crypto/marvell/cesa/cipher.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/crypto/marvell/cesa/cipher.c b/drivers/crypto/marvell/cesa/cipher.c index 3fe0fd9226cf..fb9ea9623746 100644 --- a/drivers/crypto/marvell/cesa/cipher.c +++ b/drivers/crypto/marvell/cesa/cipher.c @@ -91,11 +91,11 @@ static void mv_cesa_skcipher_std_step(struct skcipher_request *req) size_t len = min_t(size_t, req->cryptlen - sreq->offset, CESA_SA_SRAM_PAYLOAD_SIZE); + /* + * The op is copied to SRAM below, in full for the first chunk only: + * later chunks must keep the IV the engine chained there. + */ mv_cesa_adjust_op(engine, &sreq->op); - if (engine->pool) - memcpy(engine->sram_pool, &sreq->op, sizeof(sreq->op)); - else - memcpy_toio(engine->sram, &sreq->op, sizeof(sreq->op)); len = mv_cesa_sg_copy_to_sram(engine, req->src, creq->src_nents, CESA_SA_DATA_SRAM_OFFSET, len, -- 2.56.1