From patchwork Thu Jan 24 16:33:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 156500 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp2165008jaa; Thu, 24 Jan 2019 08:33:56 -0800 (PST) X-Google-Smtp-Source: ALg8bN4qgcMv94G1rbi/jFpZT5U8Hb9BfQfRe9QZRCVSirPl89nU/rqcmgbA0p5yeAbwKRhMx9XB X-Received: by 2002:a17:902:4681:: with SMTP id p1mr7421430pld.184.1548347636852; Thu, 24 Jan 2019 08:33:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548347636; cv=none; d=google.com; s=arc-20160816; b=JAnzXhpivDsQQ/RpIzwO+Kz1zgECUF4CTa1V6DJr3PKZ2vG06VcHr5jPqGUQtUIK4a 8B/zf/95py+IppDN/TQBTlzsD0gGSQk9YcPKWfFl7uu7jSuyUfVijtOYgPlEMahzq02s yMsI1pf13oMcD7/5n4RT90K5EwX1cdSAsEdrxz/QYeo/d1qe8qPYplyhcX9D4hLemlvI uvMIIo52J9r1ZoAD3wWIDP6+uTgPz065XpbhcvbHNMauiDMdLH8x7Q3gkOpG2Tyk+Oi0 IP8el1YbdWNz4lHhxDWXhEHVMajV2gJDpuM7d5Oa6BJBPA+vQQeo3PekKF8KWf6FKVwQ //7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=G41sgJAH7cOGISzvmX0cU+gy3eCXCkMtDvUqIcUHa8o=; b=s8A3zFYFQNtDvQikfW09Tu0+aBjdP1xsNtTG5HxAKLWsJ8wTZcQ0BsFhFODPyzrvbb 8g94lFTJz5pLpinKUMRBgC0EbWIm3LdP39Sd5Iz4G8BA6FT111CwOmp547S6GjtCOPNO EUE/2EOhgPe8OAnI/5Qc6NTvAmcZvocYGV/ztQBF6018ZXf6P7UkHO4MoVzD/gs1LKLd 2+5eAg6AflNqYw/ii4Z42ZPtchXJHz+cp9cE9tlCsN8N1IY96S5IDwS76g7EjC8P3RdQ SsZDDY/fLIfAYeSZ7fe6NIqjDe77AQ9wG45IbMNrx3B6RlXG3Ld5PvUw6PTvC7CfWOos gk3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QCP0TruD; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c5si20261952pgq.434.2019.01.24.08.33.56; Thu, 24 Jan 2019 08:33:56 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QCP0TruD; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727740AbfAXQd4 (ORCPT + 3 others); Thu, 24 Jan 2019 11:33:56 -0500 Received: from mail-wm1-f67.google.com ([209.85.128.67]:40825 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727573AbfAXQdz (ORCPT ); Thu, 24 Jan 2019 11:33:55 -0500 Received: by mail-wm1-f67.google.com with SMTP id f188so3705689wmf.5 for ; Thu, 24 Jan 2019 08:33:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=G41sgJAH7cOGISzvmX0cU+gy3eCXCkMtDvUqIcUHa8o=; b=QCP0TruD5NqlWG78qRspIyKRhyZUDVgHDQI6xFIOtZOj1rVYG8KkE0iTaYViG+1TF+ lgTNQBFMdHW0ilDblDGlHSd2HFrTY0F44c2hg62rU689AVCNCgc6ez3g4AlDNqAb6FX7 5UhgeDBHb0H5+zuFslLxAva0WV+GbeRo3FTtA= 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:mime-version:content-transfer-encoding; bh=G41sgJAH7cOGISzvmX0cU+gy3eCXCkMtDvUqIcUHa8o=; b=b1pJDxdzO8VEIpeR3JRHIq3qhHclJiLhhFQ8hiTiaagMPco1NSn6t4GHB50zoFeshb Ut7Dq1nv/nWnNkgTZpxiU7rUaDzpslJ/B+Je8LGjQYqWnNBpsI2KmWXQmy9SHG15/qQc 44VdLjEE+cH8RwSsVYGnC2ttBRmJbdoRwai2M8I6stXSen5wFSlMibJAS0nmaG6pULNt Atiza89aivFTX4BWNkCuoHSUMv0MRMUtXmFEYRo33iPJ2LKSmpuOSrO400JnHPtkID+d p72QLAOZsNvNHozQnAFPRJ4dxXT2naU3iDEUCmtC5bCUKYQfw8fYpbjVZ4Ra3ohrUqbW dbtA== X-Gm-Message-State: AJcUukcPRiYT7L4G273Up/sjTOMZDFgaHQ+NZ16MbCg28HNnbe1ElnVD xk6k/EJbJ67Qj4zcD4gn1WBUHy8GM3HtXA== X-Received: by 2002:a1c:9cce:: with SMTP id f197mr3381997wme.135.1548347633691; Thu, 24 Jan 2019 08:33:53 -0800 (PST) Received: from localhost.localdomain (laubervilliers-657-1-83-120.w92-154.abo.wanadoo.fr. [92.154.90.120]) by smtp.gmail.com with ESMTPSA id t12sm99629069wrr.65.2019.01.24.08.33.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Jan 2019 08:33:52 -0800 (PST) From: Ard Biesheuvel To: linux-crypto@vger.kernel.org Cc: herbert@gondor.apana.org.au, ebiggers@kernel.org, Ard Biesheuvel Subject: [PATCH 2/3] crypto: arm64/aes-ccm - fix bugs in non-NEON fallback routine Date: Thu, 24 Jan 2019 17:33:46 +0100 Message-Id: <20190124163347.12653-3-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190124163347.12653-1-ard.biesheuvel@linaro.org> References: <20190124163347.12653-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Commit 5092fcf34908 ("crypto: arm64/aes-ce-ccm: add non-SIMD generic fallback") introduced C fallback code to replace the NEON routines when invoked from a context where the NEON is not available (i.e., from the context of a softirq taken while the NEON is already being used in kernel process context) Fix two logical flaws in the MAC calculation of the associated data. Reported-by: Eric Biggers Fixes: 5092fcf34908 ("crypto: arm64/aes-ce-ccm: add non-SIMD generic fallback") Signed-off-by: Ard Biesheuvel --- arch/arm64/crypto/aes-ce-ccm-glue.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) -- 2.20.1 diff --git a/arch/arm64/crypto/aes-ce-ccm-glue.c b/arch/arm64/crypto/aes-ce-ccm-glue.c index 68b11aa690e4..986191e8c058 100644 --- a/arch/arm64/crypto/aes-ce-ccm-glue.c +++ b/arch/arm64/crypto/aes-ce-ccm-glue.c @@ -125,7 +125,7 @@ static void ccm_update_mac(struct crypto_aes_ctx *key, u8 mac[], u8 const in[], abytes -= added; } - while (abytes > AES_BLOCK_SIZE) { + while (abytes >= AES_BLOCK_SIZE) { __aes_arm64_encrypt(key->key_enc, mac, mac, num_rounds(key)); crypto_xor(mac, in, AES_BLOCK_SIZE); @@ -139,8 +139,6 @@ static void ccm_update_mac(struct crypto_aes_ctx *key, u8 mac[], u8 const in[], num_rounds(key)); crypto_xor(mac, in, abytes); *macp = abytes; - } else { - *macp = 0; } } }