From patchwork Sun Sep 20 18:37:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin LABBE X-Patchwork-Id: 11788087 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DA7CD6CB for ; Sun, 20 Sep 2020 18:37:57 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A5A02207BB for ; Sun, 20 Sep 2020 18:37:57 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="PQik6zla"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=baylibre-com.20150623.gappssmtp.com header.i=@baylibre-com.20150623.gappssmtp.com header.b="pT0FFND6" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A5A02207BB Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=CnOVV5RBSo5mfnzwx++Pe3kTeZc1Izw4cbw32xCBUts=; b=PQik6zla8e7mRQmxcwukQcOLTU wiBc2zKgxr3HRRyXq+p2EtqzzUB83KkF3n+Xp5AtJpljnVluyoHNp1o42dPu6yZC54DphHSrVBOx9 B7fukfWtumiTyBhXkwoueZwe16UOt9Lv2/uMbdY7nPhhyI2CtYSvPBxHk8Dea0KOTPf7wzr0xz1nb maKasOkFN8Qbb6cJuzEOpCooNtKnaQAEdKqN2b/idzQkAiti1U0lsUAYrFOroSvyfW23uyeCfoL+g 62P1cng2fD+tUcZPptbLHDCp2/fe+K+6coW4gXk8Znm8q6hUDPVjVuTPd7uLVoOoM/WqFVzUWJXuk MvQzbvHg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kK4DJ-0006o7-T9; Sun, 20 Sep 2020 18:37:29 +0000 Received: from mail-wm1-x341.google.com ([2a00:1450:4864:20::341]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kK4DG-0006mn-9O for linux-arm-kernel@lists.infradead.org; Sun, 20 Sep 2020 18:37:27 +0000 Received: by mail-wm1-x341.google.com with SMTP id a9so10384517wmm.2 for ; Sun, 20 Sep 2020 11:37:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=jTdlzUzyc1hcRCjE509a2kDcbNHBKMDXHMkrLBJjCcg=; b=pT0FFND6nkoHYyotdgwU1JAtZKe+QpWMkWB0/vahBAzG/8Ld4jH7LOF+KhWyjcj83t 5Sx1nwXbpU0PNjl2Y003G0PYjPMwRiIqD5CYsm3Z0nBKnZ52AW5B3f5Hhj8p7itelMfp fvBatPUhYCOePXCZd1QIH91PiEHEvt+VDnDRsjG3ZauxunjMmzsJ+bmE99QNcPDxN6rS mKT67ZLBJo3J9fkL813BBeFdlQUanY2I2v07DKoQLz8k78j1GXzlghb79gZU2bah7KKg 4p4K2uuaQccbL2gIHbH3zwiC8/XjHX0tiV71d3nbLb9AJadcKfPh7hAuDZKn0Mj0E89F Hdqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=jTdlzUzyc1hcRCjE509a2kDcbNHBKMDXHMkrLBJjCcg=; b=Da81TqhP+yjBck/OsVIYWANmxSt2RvMqgqp7KAQyF4TDDdOnVKWEYMfIrJyqXzpdNC 6ydZRerJV7F5DPKbWbWDpJfY3efmHXbIbnPRIBkMmx3CEEavjqOkdpnVG8J0JLZOePdc SeU8XFChIPtTpgUGuy3S4N5Ozg63lXZz/C4hH6BydFokdD6WedTQF25ulRjoCn71LZfy hZoLHy0HDdmKgYBJW+ZD/Dfcf/Df4fgD4a+7NVkqVB/5D7O+qFsOKE6kMP78B8Q6J3oV WZCNu6IYAVyGf4bspMfSeFS4YydlOvqmRoBxuv/NvATxI58N6kytN28YC5ydHODtvxaY QIsQ== X-Gm-Message-State: AOAM5312mAL4ls5nIaK1EtqJtAP4zPmd49EEmGgz3DeuSpMOOskAy86I ZthZNZbaVOUhYCzqwFTq1uHjaQ== X-Google-Smtp-Source: ABdhPJznL0wnKPFRx+ll8rXF6fFCp51XOjtzRgf3arfEI4ScF5bVizdGKfVQJuxQR3n2Q1QXlekbrg== X-Received: by 2002:a05:600c:414b:: with SMTP id h11mr26441143wmm.20.1600627045206; Sun, 20 Sep 2020 11:37:25 -0700 (PDT) Received: from localhost.localdomain ([51.15.160.169]) by smtp.googlemail.com with ESMTPSA id e18sm16419841wrx.50.2020.09.20.11.37.24 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 20 Sep 2020 11:37:24 -0700 (PDT) From: Corentin Labbe To: arnd@arndb.de, davem@davemloft.net, herbert@gondor.apana.org.au, mripard@kernel.org, wens@csie.org Subject: [PATCH v2 1/7] crypto: sun4i-ss: linearize buffers content must be kept Date: Sun, 20 Sep 2020 18:37:12 +0000 Message-Id: <1600627038-40000-2-git-send-email-clabbe@baylibre.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1600627038-40000-1-git-send-email-clabbe@baylibre.com> References: <1600627038-40000-1-git-send-email-clabbe@baylibre.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200920_143726_349021_2B25DDBB X-CRM114-Status: GOOD ( 15.94 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:341 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Corentin Labbe , linux-sunxi@googlegroups.com, linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org When running the non-optimized cipher function, SS produce partial random output. This is due to linearize buffers being reseted after each loop. Fixes: 8d3bcb9900ca ("crypto: sun4i-ss - reduce stack usage") Signed-off-by: Corentin Labbe --- drivers/crypto/allwinner/sun4i-ss/sun4i-ss-cipher.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-cipher.c b/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-cipher.c index b72de8939497..b92d175b5d2a 100644 --- a/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-cipher.c +++ b/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-cipher.c @@ -163,6 +163,8 @@ static int sun4i_ss_cipher_poll(struct skcipher_request *areq) unsigned int todo; struct sg_mapping_iter mi, mo; unsigned int oi, oo; /* offset for in and out */ + char buf[4 * SS_RX_MAX];/* buffer for linearize SG src */ + char bufo[4 * SS_TX_MAX]; /* buffer for linearize SG dst */ unsigned int ob = 0; /* offset in buf */ unsigned int obo = 0; /* offset in bufo*/ unsigned int obl = 0; /* length of data in bufo */ @@ -233,8 +235,6 @@ static int sun4i_ss_cipher_poll(struct skcipher_request *areq) while (oleft) { if (ileft) { - char buf[4 * SS_RX_MAX];/* buffer for linearize SG src */ - /* * todo is the number of consecutive 4byte word that we * can read from current SG @@ -295,8 +295,6 @@ static int sun4i_ss_cipher_poll(struct skcipher_request *areq) oo = 0; } } else { - char bufo[4 * SS_TX_MAX]; /* buffer for linearize SG dst */ - /* * read obl bytes in bufo, we read at maximum for * emptying the device