Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 76BDBC4742C for ; Mon, 16 Nov 2020 13:54:58 +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 A9899222B9 for ; Mon, 16 Nov 2020 13:54: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="tQA0ha1l"; 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="uhrUcNEK" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A9899222B9 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+linux-arm-kernel=archiver.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=oS2M0tETvgsn6sKIaumjbpNxTSy0HCXn5zLlYs4oRS0=; b=tQA0ha1l4u3/gIHRDYnujIxvir LfO03wZf1iIklBJ5mUFP6tWOJxF5fWV5xntMY9Q2CRVrRUDCw0qKMJMZc7lWLZhPbHEBPG/s4OQ1r vs5H16L/Cx0HK8Z4qLcMQEe7m+/NmvLeNq9sIzNo4XkNs5OJ4mtjFmvn9IC5Es7/AShv6ZNc83+zz m0Hb0LHxPKERHIP+0bLShOyXNz/TH8V3CYgN6B/SP48lZbQsDn+Xr2bczZLWHxQcKxz/2pM1Vs02n QxBk+TwEL3MoCQiC/sT7QJbb/JqRD2MF62V+cpnAnTYLPJRs/h3S8BuUhhqrVqw2tMIX7DNd919V0 JmCpjhJw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1keexi-0004AZ-1t; Mon, 16 Nov 2020 13:54:30 +0000 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1keexe-00049M-UG for linux-arm-kernel@lists.infradead.org; Mon, 16 Nov 2020 13:54:28 +0000 Received: by mail-pf1-x443.google.com with SMTP id c20so14183857pfr.8 for ; Mon, 16 Nov 2020 05:54:26 -0800 (PST) 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=+A359lF42tZa73dPiOWZxYbdDHUjaoA4SP1/TVC6kqw=; b=uhrUcNEKOBNJHazYbkL0/WF/jWRl6a4lPtR5yUmS/9ZGu9nIeJeSBAYW7AixeYsajJ MdTINMXr78JkR3QHYkXVFW6bU/3iPm5GOEoxaIBRV34IVfhMC3DOPR2d5Ij1wyOFHxw7 SSIcAwr0NphdpCzUpdzlLNuimTIpEcRFEmh/FA5qPhCTPu4xUNW7VYhvfJykv/9jV4Pa +y2GKPkUqDCS/I2AYrEUDrv6LpFFe/iBpLAPRTF2wTaUP0kYvhfFKCrAoMR3WucUC5UJ unoa8iDF+ShqImnC7uASDcgwnvpRL3fhpyjSjNysN6bM6c12EhXhdAGpHyPP5wWYRlFT OoAw== 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=+A359lF42tZa73dPiOWZxYbdDHUjaoA4SP1/TVC6kqw=; b=IVh87KzATjJlcPeowQj6TYr8M0ctbcbwHyyPtB+iTgQr83YboWliqODa7Y6Z2qUm5d XqPPjT3cL/Wt0OInQSmobz99qXfjpm+JWbkgsLSmJDbBr1llGR7MaV51U4M0Y1GPZY6w yBzgxqBpDJx+2UQCj712hYqhNuJEpk3MTSxSfIHrRCpszxe40PUXrzeiPvFhIE/zbxMN dS5l3+PIFdGzFgdP/oyTeH3Djt0QI5ZI81ul333n7D9PNX/wSpBsWs8T4O664iCKPzJ+ PsgeSIELrXZ44R7tKcacjg0MZ/5DqqEOw9RzNzRB+OP81Afbpk70A63XFC/FiBKPS7Vb l5Pw== X-Gm-Message-State: AOAM5311snkQ1Id1Uv4GKfWE7tLF74SY6eeHLkk3QLx4CR36XTqkaI5d tCYaHJS7Es4Y3yP1lM1SMoRtgg== X-Google-Smtp-Source: ABdhPJx7zPBrpHujwVU2oFB8zrUqJuJFYi0hZX7sx2UK8bvDlOvTG38tK788gR3212Yjzqoa2hpXLg== X-Received: by 2002:a63:4759:: with SMTP id w25mr12628446pgk.414.1605534864664; Mon, 16 Nov 2020 05:54:24 -0800 (PST) Received: from localhost.localdomain ([163.172.76.58]) by smtp.googlemail.com with ESMTPSA id u22sm15864031pgf.24.2020.11.16.05.54.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Nov 2020 05:54:24 -0800 (PST) From: Corentin Labbe To: arnd@arndb.de, davem@davemloft.net, herbert@gondor.apana.org.au, jernej.skrabec@siol.net, mripard@kernel.org, wens@csie.org Subject: [PATCH v3 2/7] crypto: sun4i-ss: checking sg length is not sufficient Date: Mon, 16 Nov 2020 13:53:40 +0000 Message-Id: <20201116135345.11834-3-clabbe@baylibre.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201116135345.11834-1-clabbe@baylibre.com> References: <20201116135345.11834-1-clabbe@baylibre.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201116_085427_139197_57E0CDB3 X-CRM114-Status: GOOD ( 16.18 ) 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: linux-kernel@vger.kernel.org, stable@vger.kernel.org, linux-sunxi@googlegroups.com, Corentin Labbe , linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The optimized cipher function need length multiple of 4 bytes. But it get sometimes odd length. This is due to SG data could be stored with an offset. So the fix is to check also if the offset is aligned with 4 bytes. Fixes: 6298e948215f2 ("crypto: sunxi-ss - Add Allwinner Security System crypto accelerator") Cc: Signed-off-by: Corentin Labbe --- drivers/crypto/allwinner/sun4i-ss/sun4i-ss-cipher.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-cipher.c b/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-cipher.c index 19f1aa577ed4..4dd736ee5a4d 100644 --- a/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-cipher.c +++ b/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-cipher.c @@ -186,12 +186,12 @@ static int sun4i_ss_cipher_poll(struct skcipher_request *areq) * we can use the SS optimized function */ while (in_sg && no_chunk == 1) { - if (in_sg->length % 4) + if (in_sg->length % 4 || !IS_ALIGNED(in_sg->offset, sizeof(u32))) no_chunk = 0; in_sg = sg_next(in_sg); } while (out_sg && no_chunk == 1) { - if (out_sg->length % 4) + if (out_sg->length % 4 || !IS_ALIGNED(out_sg->offset, sizeof(u32))) no_chunk = 0; out_sg = sg_next(out_sg); } -- 2.26.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel