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=1796263681; b=EwqfOYLUp5lG6sRAZ2d/cdtqWDzqIcg6kzohEondPaGR4COThkRLKBGeGx7JpvAToskr /crj3ICHWYFd8Upawej8WLf2Loq6zmu/gUMWfrt16ZSfbQzthI3qe7g8Y3hWbMj5VxTnQ R/ETcTYG86Aj0bY1dfe0o0+UQaurgWgvAvJKJP2PH0WYFtUakxvutzLYlGvWG/tqMPDol Hb1KNELeVcLnl82lvh2+hjpCmkop6UmXky6QXK3jjCMkpJOsWyCTCOSGhvJAuDNOjMuAx tCQd1RHBaDbE1eOq7Q5KOgQ4k0q4OyAerX2a+/EdsxXwn7d0hzGz8eQQuUEz6vzdIew== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796263681; 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=Nv4bBI2nQTnAQa7VVyNNtpM5P6KUCDHBGIEl1IvOK2c=; b=ZZh6Pd/t/5zbeeRGSHPzXZCfOi/XxWY56EhdtZwpv24/o5T+RfI34i46M7Ei/qBQKo/k sRZi1dMRKfZ0HBSFFsRcOHei5DCEJWUruFCR+XZUPvoR4aQZpn/5tqy4E5cRQ++St4w9V m/PIiQmaZ9ITjarID1GxbWXbh+Lxt74lPmkPteRfar8AonJd3Tpic5yK2MTPfWxp7G1bS 0vgGSHOdeXlvg6aY9sjnLxyMBRPIJ4S2N3mvTTsjOAjGfEKN8wWn8qFxXfgh7QvZqFeHJ pzM2LJGSPE3OPcgN7E4CuJ86ZYYbHR4Dsefqd6dd4fWL5RnKJdEHPxNdkUmHXnlJhfQ== 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=0SwaIp3z; 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 A913F606A330 for ; Thu, 3 Dec 2026 02:08:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A913F606A330 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=0SwaIp3z Received: by mail-pl1-f177.google.com with SMTP id d9443c01a7336-2f0458cc9easo107019705ad.3 for ; Wed, 02 Dec 2026 18:08:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796263680; x=1796868480; 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=Nv4bBI2nQTnAQa7VVyNNtpM5P6KUCDHBGIEl1IvOK2c=; b=0SwaIp3zdF4hbxI3eaby7B7e6Dbk+tTcZRkfRhFiIsiqMDNVd2mZTDW6O7yrmqPmBl y8lyw+y/IA5+y6kYcvwWWm66HZXtKrntf3LcEXbIzttvVtyMIxyMFn79AsbNJD1zqf+V wZpNTAQ6NnBoAXRzZp02OADT9+MJ4baVJovy/EHBiiAQ6bv3m8TZh3Wj78rvKa9wrehz xzGzHNiec8OX7AuGrNyhDOPvbuzZiPSOFJ6mOBzMoDj2km11rHS7ruyxhK5hPVq910Yh mbnQOVpnJ8FMS3cUj9glx/qRH3SyJFNToAPb6GboB9slFcBn4wrVoErH6v8ZuO3AIzxJ WVoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796263680; x=1796868480; 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=Nv4bBI2nQTnAQa7VVyNNtpM5P6KUCDHBGIEl1IvOK2c=; b=FOHuV8V+LzrIlrexuNYEshirEolzYE9bQF6rp1ObNC399RE3/mVUL7d99/aSE3JSNe +mhl+UwbvlMlG9VpjV2rDisOxZ4U6vq+eJlxkqDSa0/NTla5LlAG1IG5edjz/Lg1fzzE Le3FPwM8830KtHgbBYtVIG2KE6/kZ/LzgiwTtSM+DRAsGl9XDInCvAZ2N3dAxku27qPf kLfrtw2ClSZKQ2KNwkEpBSayUgC8bqnozn9q+nbI7UnrLC9nnmCq0N9NV52oJl/7GhdN YmtSniYuAr8HH2ug5k7GV0UegCYUhJ1Xi+38OH3q1m2jrPs0MLYYg1Irzx+IrpDvLjAW ++VQ== X-Gm-Message-State: APuU4Z/sZFfFC6zyaF1YVUNZ8Yf9XDZNsSGEZJViiiWg8aFt+YKFoMob Lmp7KlpX99dYYS2GY02KwdiCzLeCWxQzjWW1591jWwC1ZRHrwIV8ePCt X-Gm-Gg: AZFdTZc9aabhorWyZCeq45kHPy7VRmM+g7cZfZuXgr2/UEYfspkdWci7Z1F+mTl/FCm 63RtnL6oqf9w12pWojjvI9SwXrgj4jq/D/PtFFoPeMl1jbrM0LvFynF4o8L3a2FgR4BC8jmVXlu NeKFpke/1MCHX5ZClm0CRxP19Ef4aFYdj9Si63dUgZpeWjdQSADOzW9d3DxZiPAqab+NgNhpoMP EXsbErDsRpG/KKjXu4m6TgfLvGDMr3VQQlKZm9SwdV1SoXU9C+AV4eOFsl1yPHDLJR6NPJJgBID 3mgJrZC9+kHDoK05MDkpnN2CJ/3S6Jc+YzEmJpnXrWBuIzOq4CpChUY0Ci18zxM3VrSmuSKgFku OkqL0sHIaGXhseN3e30PH8pmfR/Nvh+e+/xL68jXTlXvaJWuW9ahoKyi8yOZkZyldrUVkafn8WH tM0q/zWiXbw1TRSqVUEnCyhXr9OMQit00vUpL5sCRRrvBy2GPqZxZD8wnzVHru8HKpDhYzFBrll DSEadpeyYuKJIZ+NRpqyMbQQ3JjScvdW67YYvAWhxUtgTCywpc7DjGXDNlaJtIEO6hmEDXVN3Vn 8DlXcTSgWB6GgsGtPrQsWda7J6DU8yv3EhHP8Zddmnel5JgygJmgXhF9F9/DcEKryS5+ckr9lZU S8wwAxtlgqo90It0Z3mugAEaFwP/+f3vrFkF9RK9EYOadhM5qEFbZAm9jrieGa88jiGGKNa6tSd YnMQ== X-Received: by 2002:a17:903:19cb:b0:2ed:101c:480a with SMTP id d9443c01a7336-2f03f1c007dmr464920865ad.37.1796263679933; Wed, 02 Dec 2026 18:07:59 -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.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2026 18:07:59 -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 7/8] crypto: cesa - do not step empty hash operations on the non-TDMA path Date: Wed, 2 Dec 2026 18:07:32 -0800 Message-ID: <20261203020733.260995-8-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), mv_cesa_ahash_std_step() trims each step of a non-final update to whole blocks and leaves the partial tail for the next request. mv_cesa_ahash_std_process() asks for another step as long as source bytes are left, so when an update fills its last SRAM-sized step exactly and fewer than a block's worth of bytes remain, it steps once more: that step trims its data to nothing and starts a zero-length MAC operation, which corrupts the hash state. Multi-part hashes whose update ends that way are wrong, one-shot digests are not affected. Once less than a block is left on a non-final request, complete it and leave the remaining bytes to the cache, as for the last step. Fixes: f63601fd616a ("crypto: marvell/cesa - add a new driver for Marvell's CESA") Cc: stable@vger.kernel.org Signed-off-by: Rosen Penev --- drivers/crypto/marvell/cesa/hash.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/marvell/cesa/hash.c b/drivers/crypto/marvell/cesa/hash.c index 6fcd78427b71..b51315cd01df 100644 --- a/drivers/crypto/marvell/cesa/hash.c +++ b/drivers/crypto/marvell/cesa/hash.c @@ -297,10 +297,23 @@ static int mv_cesa_ahash_std_process(struct ahash_request *req, u32 status) { struct mv_cesa_ahash_req *creq = ahash_request_ctx(req); struct mv_cesa_ahash_std_req *sreq = &creq->req.std; + unsigned int left; - if (sreq->offset < (req->nbytes - creq->cache_ptr)) + if (creq->last_req) { + if (sreq->offset < (req->nbytes - creq->cache_ptr)) + return -EINPROGRESS; + return 0; + } + + /* + * Less than a block left: keep it in the cache for the next request + * rather than stepping a zero-length operation. + */ + left = req->nbytes - sreq->offset; + if (left >= CESA_MAX_HASH_BLOCK_SIZE) return -EINPROGRESS; + creq->cache_ptr = left; return 0; } -- 2.56.1