Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp406838pxb; Wed, 3 Mar 2021 06:22:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJwwBktbLK1Z+AEBsGU5xhgwKkz47yBBUZvZDvD6bFIwtBmJYTZ/ZYnMzYtv0Iejc/8v5rle X-Received: by 2002:a17:907:c05:: with SMTP id ga5mr4348678ejc.380.1614781360641; Wed, 03 Mar 2021 06:22:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614781360; cv=none; d=google.com; s=arc-20160816; b=Xj4PJNjdNT/XL76/5AFXdDyuixHMCaku4uQ3uyVxibtjlA6C9HpVi4XK2GkiluxlTP KQzbFcUIwKooxErVuh4007taWKfbaCjSFRCDjqtWu5W31eCF1OwNxWEPnBZvl3Vc33+f zZgglNbfpdtXejSZlZLG6oiYs5oBshj1+XTXNjlv+kP09L3m3u31lKQ2hWSowVhQ3E9Y G7fdO6Jgm+woPWDm7zZlJCmQCaC61hXsWswcwFhPkqhHoBl0MB721ozAikj95z86vV3L wjbPBLY8Qb6VOQYBTgL3XnEw6fUm9ag9rgKg+AuArJl1zcFNv/70107M6iN8ybllRPn7 Afog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ziXpeqYcsHQRM1TFuYDBWCYxnaWSM6I9PidvVJ01wCA=; b=HHiAVRnVn7I7vO4BaC3sNiMTuvAmqObezYL1CZev0xn8v14zQVp8G0sVyDyBgCNqaY OBsz23OUlDaz537g6lq9/zNJHyYTadixlbSRlo7qlpWUcLa9YkLe5mPI1BhuRpr55ugk T5WGUd5wnjYDMKRGMuqLKc6RzkJE5HldmTfxRCaanaj9wxXZ2HfZtXS4hhOw5asZ4E3d BtsRfUXkLB59ME9ix+X8D3U4HmO+rlsjvdEnKkvGuKf8wcsUKY0keCayFUVLWYVC+btk 6MKLXvcuPcaBOprW1kueKMtEwRFV15/cP+7qhPLSYMpANLQQZGFFK8YvXPwIOq+smO/R ypWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=sPGYoWvo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m26si6420003edv.514.2021.03.03.06.21.43; Wed, 03 Mar 2021 06:22:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-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=@linuxfoundation.org header.s=korg header.b=sPGYoWvo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237322AbhCAVNw (ORCPT + 99 others); Mon, 1 Mar 2021 16:13:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:48196 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237971AbhCARNx (ORCPT ); Mon, 1 Mar 2021 12:13:53 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9B9A064F4A; Mon, 1 Mar 2021 16:44:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614617095; bh=wYYQUZI4Lv7Vc+6cscue2zINWcEHnylnQDKnVEuSZ/s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sPGYoWvomIdHbdds1GpwJ01eRnBUqz3vGiLRwjVdUMxwoqFUhuTL9v8CFeRzwWynQ FD655jHawvDJBz7wUfoBB1zDaZpqwDATi1/nMBZWZ8XyIh0WCE4BicfsRaPrCkjdSn b4gpcxxNarXslaPSk9BvFl2nLyQrRMMaskZ+iifE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Corentin Labbe , Herbert Xu Subject: [PATCH 4.19 201/247] crypto: sun4i-ss - checking sg length is not sufficient Date: Mon, 1 Mar 2021 17:13:41 +0100 Message-Id: <20210301161041.500045845@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161031.684018251@linuxfoundation.org> References: <20210301161031.684018251@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Corentin Labbe commit 7bdcd851fa7eb66e8922aa7f6cba9e2f2427a7cf upstream. 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 Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- drivers/crypto/sunxi-ss/sun4i-ss-cipher.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c +++ b/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c @@ -189,12 +189,12 @@ static int sun4i_ss_cipher_poll(struct s * we can use the SS optimized function */ while (in_sg && no_chunk == 1) { - if (in_sg->length % 4) + if ((in_sg->length | in_sg->offset) & 3u) no_chunk = 0; in_sg = sg_next(in_sg); } while (out_sg && no_chunk == 1) { - if (out_sg->length % 4) + if ((out_sg->length | out_sg->offset) & 3u) no_chunk = 0; out_sg = sg_next(out_sg); }