Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp625553pxk; Thu, 17 Sep 2020 11:39:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyHhvL5vVq1OY7DoHlhKr0Kd5yw1c4gBMHoOUhbHMjgeLuoi4aQbGr6cUdG3SlpLMQAAUX7 X-Received: by 2002:a17:906:3ac5:: with SMTP id z5mr20163478ejd.46.1600367961039; Thu, 17 Sep 2020 11:39:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600367961; cv=none; d=google.com; s=arc-20160816; b=k4PboJDS69e0Ecd7pfP6AfAOd6dmgXkgx0MzMHURUxqqf5Ni1evbJbSc8p22+gzRn1 C+0Bi66gVeSZ8Gy9w2UQyakeGaWjOkpQ3uBh9TVC/YoS0FYq4TPQUAvC3uavVX8W/C1D Inz9uQbJdl1GPl/sEOY+JXuZZ3uQQeibK1f+HT+m/t/dtE53FWJixl7lxjruJn5X+Wl5 gUR2vrIaPsF6c25YL4n4IWiLJZTO1QR0CURPCXomfG61+NphyzkhhWvjiM+QEjOX/kYm rMe6kJBc1qqDGcLuiB46cC8CLE8nVw2A9twhG5HC7iKvIW6AiEDGm9bp+p7HugrxRADO OVuw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=IhTFOXooJMFxAaaEHQf3e3fIzkNVzwZdrWDdh3u1EUQ=; b=V5q8i33WCumf4Q5bKcJ4kjUlBqLABVJaYH8+JbXYEyV5qUjMXd8b/KjdrN5pr79MYI 3VTY1UeIO/tXfZqdS/dDq7n8nMDD9fbYe3vVkordSnCD1SM+lQTjY7fGoYhMjFR+V+jm jmVMLARSLnYeuoxXrJdFQ7clN4KNwEIEVedKEkuFINEF3cWojsVnq6JdNXKi8o6ajdMv yyrDRFtCQOCtU4TZlCmaF4lBRj8m2Z1d0AhIxJ7VuUHwh8MidQMcjnW/DmgqCvyMQcWk 9i2hwCJ6MRqirKvL7WIKWGFD/QDESGQse5t0mOxbve6al4y1j9TNmA2vg/XhFlZp7Gp4 J1pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=Tc51Lgth; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t22si486657ejj.683.2020.09.17.11.38.57; Thu, 17 Sep 2020 11:39:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=Tc51Lgth; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726549AbgIQSiO (ORCPT + 99 others); Thu, 17 Sep 2020 14:38:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726587AbgIQSgL (ORCPT ); Thu, 17 Sep 2020 14:36:11 -0400 Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2CCCC06178B for ; Thu, 17 Sep 2020 11:36:10 -0700 (PDT) Received: by mail-wr1-x441.google.com with SMTP id o5so3094902wrn.13 for ; Thu, 17 Sep 2020 11:36:10 -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=IhTFOXooJMFxAaaEHQf3e3fIzkNVzwZdrWDdh3u1EUQ=; b=Tc51LgthYrtN/C0RNoGrtu6I9ssV8h9UwKdz0ft8yPntVgsb8RwIMw2tQjkL6VvUpx 3eWnFSDstKy+8h4FEmzSZWfBbdwSOxyvMAtKCO15lX8oQo0DLMpCcJMNkbzNdDP6KAi3 QJLSWItKrjv+Cm4ONO+v1GJ+LqrcYZVhQmFHXkhyR7kyAU2SCYQxnB4x0eSoWWZ3uiel 1g3XKPSUC1UWr6V9dk92C5vQKtCam+DPIaXUx+A2es6eobd/bm7rpS5BTk/1C2vUiO9U u2SfduQvAoDYEuIWH8kTUHfKZsnO/Z/9zSYmF07TWFeb8C0GQ6qEKJcYdgBjjtdcs0f4 w79A== 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=IhTFOXooJMFxAaaEHQf3e3fIzkNVzwZdrWDdh3u1EUQ=; b=jfc5oG0F1R1ZhJ+rB2LTfYjFq3xFJZC+QpiIJnl10Ka9HHkFEh9McFhKBjdwCHMGgQ w8Ai/URCbgdjofz5ZMInpL0XYgSyMSt7evLxWD9az1uM6TBXa9cfconpFKuyaDVVFN+M gBZGTpooqoQJKepe1M8Yayq6waRqUE/ddtzOxhW9105g8p6rufGALwiM37uqRklO8YR/ Gu8daLa2HB6ltYojSRCbATsUfrT0MNYRHIR9nRD0wVv+oa/81YKZzcxgH1wdt+82eg97 cgqKX9AMS7k0bvBM9eHnFKt3sjTrY9/Sz9snpwAM0jzdbFqUkRTph5tBmysRrig0Lklq Kx1Q== X-Gm-Message-State: AOAM533YWjHuCGueDgNRMz7mHhD/fC7/u7BDsO+eJmG+Wfs6V2drFteJ XejNKcjyvja9T51IZuqLGoXOmw== X-Received: by 2002:a5d:6cb1:: with SMTP id a17mr30001488wra.386.1600367769682; Thu, 17 Sep 2020 11:36:09 -0700 (PDT) Received: from localhost.localdomain ([51.15.160.169]) by smtp.googlemail.com with ESMTPSA id x16sm571901wrq.62.2020.09.17.11.36.08 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Sep 2020 11:36:09 -0700 (PDT) From: Corentin Labbe To: arnd@arndb.de, davem@davemloft.net, herbert@gondor.apana.org.au, mripard@kernel.org, wens@csie.org Cc: linux-arm-kernel@lists.infradead.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com, Corentin Labbe , stable@vger.kernel.org Subject: [PATCH 2/7] crypto: sun4i-ss: checking sg length is not sufficient Date: Thu, 17 Sep 2020 18:35:53 +0000 Message-Id: <1600367758-28589-3-git-send-email-clabbe@baylibre.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1600367758-28589-1-git-send-email-clabbe@baylibre.com> References: <1600367758-28589-1-git-send-email-clabbe@baylibre.com> Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.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 b92d175b5d2a..2614640231dc 100644 --- a/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-cipher.c +++ b/drivers/crypto/allwinner/sun4i-ss/sun4i-ss-cipher.c @@ -188,12 +188,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