From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.214.177 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796263678; b=urvfVceewX+i5cHWMEBNC1ODsatgXnyCCfv1X0rOAJugy+fNK2vx22kMF3D+hl6x+c4q kMtWZpYHjC+xgbjNg1FEBT93hM4C1UZdypdVPmLakY1rEQGhxGnGhPXg+cisZPbl5RsUm 9hNF7H6RJvOfQuF4JgpuFkubKjiY1dGCuxFo2NZ4CPmpi4ZTF3fB7yPye34kBGp1XDVKj klJo/HkbUz3tfKMO84c3lNCDXrCwjyA4CdGn/D1zavDO7TstwyDYKkMWJBVP7ozrAMLIP Q+U48nHMyOLOszYcb4wfw9iWVuv4Tozd0d8rMQeLZ0MnGwy9ncCpQ5s8yHzIlJFuBag== 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-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=AN4byKZR4/ovZqKhtzZWfJuzuquNfd2XpO7k8CRuItXvV4abx5rJJugO2kHFaCXRhhYi vDVn6AYvxOQXFaq00wG5CKIHbRBype6Lr/h1KCfNJtq9u01IHuDIbcFK40RNOVgQyv2p5 DKwWfOeov3QlqTCW2A3EFsTfklju4RnEtx2wZmePiGexUNUWTRh8o6+/h5U1gprFNNqvU V0ICWGIXrYPtfHdJSf0/u9Yzln+ADTad4fMiMLckHC+lUUwWTG12sp9IKUPGoozcGNFqz PQoPBCtZHp0LXq6Xn9xtH88INiX5WsDSdEtw62A8YYCyJvXWXFCosz0mO3YgOBSpAHA== 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.177 Received: from mail-pl1-f177.google.com (mail-pl1-f177.google.com [209.85.214.177]) (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 2DAEF606A32F for ; Thu, 3 Dec 2026 02:07:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2DAEF606A32F 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-f177.google.com with SMTP id d9443c01a7336-2f041f88577so75094335ad.1 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=01/d0vTaQIudu7DJZ9EUQllEiuMHHkJhumhIN6JHEddW8V0tR3u0MJxrnG/ExA9jJ3 ti2XI4+ADXTUH9D5UkQS9mQTVGtJZ59uwMeeNShArj+5CEICm5yvQaNS9wymodtq4UbC +HPjL4vFmJy6ekSBVEHw+DvjWwFI8SgHVPZmFgVTvSUzub6YojwtfMtqtW2H1k2l/7RS jlg/gSlOsr2D/IEiaXWcgdTWh/Lp1fT5i5X5UgBYNczve+r61wWlaz4/73lvYbK+Z5Gu o5gJb/yanNrZKqkPle/1i+/KGM0c7Yq+rMwwpFvCEmV8d60LBaD5fN7rl4SdyF6oMitX CGvg== X-Gm-Message-State: APuU4Z8rzgjKBYfqcwj5HohVqWbAVlFqhXKBwdDZvExwNG2544ANBphH 41Fxbk4xD1SIKeCCFuEDLQ90dP4ohaP9eg3Vfr9/ITOLAvWRBKH1r+Me X-Gm-Gg: AZFdTZelL0l8iZMmcx4MdySZo50l46LthTvSTbvq/Mb5CGmkO0buLp/AXRvuDH8pFSh eF4Ds8BscX6RSvpjuq7TsjkMGesI5KzfnPH5I3zLisWJ0FjrrUvaiWn2oaS0Ct7WeII/ADn64zH zcdL/bYs0TN3AOroocn2ABgz5atgw1rsYwpVksM8at2rxjZTs8nLBneOJhRiydshMlxyMdCWzfW fp4pyyOsX9rVRa+vxcptAX6rqFfSZmITh6wQgBEYpLpMhHNS3m4lnLDxBUvBbQqESjnkH8/HuQW FY0oGQEytB2eGE1y3FNWHXgQPt61Eea4tzSFZYPYNU2leNBRS8xiytsgd3ngdiAFh24PUAgyM+7 beUWI3GBoBMx+afYYCrg030U8aah+jXkVeUcQr1YBTSOJuifTeIZkgOMMWkMb9Yn/eMrxD4AH6r P4UqKaCCLvLWBN+9ZxTNhp3ii8+GWq75idUtYsAb1iCGCe2z/nko5XcaX5lOO6dOdsMTzYn6W+3 uayn+aJ2hTxKmkpEIR/mdTXcS/M98ai1hoe+pbwZPGsWsEPLivIQGUwrs/Q0z2KFnrhdP555003 Lxk1yPPjNlW/9ZKIw3NxzJ564mnMsDGrPA0DI/p1ufb1BDL8AnCMUYM2MI2krWL5n3aeShvsdRK +d2nkoYO6Jh/bPmjU9/uApSKA/XB0erEqThEAdx1JRfYteKZV4k7oMA4yunEo/eoDkGK0S2ZGEP 9tvgw= 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: 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 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