Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1911403imu; Thu, 24 Jan 2019 04:13:19 -0800 (PST) X-Google-Smtp-Source: ALg8bN4mDPGCL5RpU4gGHXzpusLwtKXHwOfIwlYauaITGvZb/H0FbZDhm5e0c+clq5mPJhR2At2h X-Received: by 2002:a63:f241:: with SMTP id d1mr5749803pgk.2.1548331999250; Thu, 24 Jan 2019 04:13:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548331999; cv=none; d=google.com; s=arc-20160816; b=BYGCexwy3hxr43qccVtl9I5+WzQVRpwkIU1l7Ogl/JDn8cwBdy4F2I6kedlHWhlN16 reXwqHQdvFgEnt0aHwJpDkY+v+g2EE2kgKRjSehhsTtwgNAEDExkcuhl4yh2zZLibau0 oUnVdW6JxR2Oe1EBxX2p+Hje826saTnKlFK0D6EF27aR+QKLt93+48kPI7pDQ5RNbjUE 7y0DJmSiGwoqrIquSh8vyfrkhRU581zPJ3+yc08VSM/3sVgoYuwPMTkqYvJCOlHtne8o yVVWnAdVMMy3bXQFNZljho0KkWRQLhZL84tYn5N7xzLR7KOvUrmAPvJ3VIaNQn3NyOlD VRxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=e7C6zUR07TLT9ym38kesf+PfYGHS00+KJqk/gsJOPwA=; b=hEl2I5FO7SM3kqLIzpo7u6ZOQ7W6PMRRixN67I0mtU1wwoCL1w7NnFdPLJrV6VVhQ+ +QE+a6egH+wzbNn9TaoAlIOVaTxn/Vn6JGgQD8CoB9Tq3tI/eQ7z2zUX9zka3tGPSyf2 M80hP+oV3iiBx3NWeqmvYih+Zdu3yEdrXBK3RU+M5uYuCQrDeEEfhukcai58ex7B/qy4 4KSTocnOo2pigCDJeb8RhIY3HKlqQqWsvXTW++xDBOoPhJhOe+/LCZdtV3g7U+J1V224 4Bl04daxQoYd96rLN8sUz7xTyyoxIFzDaVgAGgZK8N7kA4h1ZLt2CnaHUzVIqPuE9Nn8 aHTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KeJi9ktC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 z128si7586369pgb.372.2019.01.24.04.13.00; Thu, 24 Jan 2019 04:13:19 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=KeJi9ktC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-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 S1727798AbfAXMLh (ORCPT + 99 others); Thu, 24 Jan 2019 07:11:37 -0500 Received: from mail-io1-f67.google.com ([209.85.166.67]:46188 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727548AbfAXMLg (ORCPT ); Thu, 24 Jan 2019 07:11:36 -0500 Received: by mail-io1-f67.google.com with SMTP id s8so4482468iob.13 for ; Thu, 24 Jan 2019 04:11:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=e7C6zUR07TLT9ym38kesf+PfYGHS00+KJqk/gsJOPwA=; b=KeJi9ktC73hG0Edi7qu7Tmvvn/boBH9yI43KQGl/d7UDP2uzWDvDimjGv+cul9CoKW UPAzcpbWYE1HxIr9dz4iTvWqrkB5MoQGvBlFuAozh3t3JVWLw7lD8MG5kATzd9cYcVHk YN8LJ5i1uETsG7w5QQpYEMgpOtg5JO/8CsGlA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=e7C6zUR07TLT9ym38kesf+PfYGHS00+KJqk/gsJOPwA=; b=gY712KnvN9Mgob3rCB4F0DzbNzZJl8yFs1gLpcPQNClNZxZPAgyuzOn5iKL4dUf9uL wYkdEUzopu7MRyqP3TwN6Cw/8xoauLAlBVRrfL3u88ubWwzBtV7jb8KJOBqa6Fqxrc3y iT+tiBz8D8MLRETzZwlxI3Ru23hqVLzrXLRMF1fc9XdKq1WdPnOF5a5dYrOOpvYSZF2N MbPg0KUGKUbLPaFToLIkk812WrdJ6MvYD/j7r+M7PYpQaMUMiOq76YXx9+xxmsYqiLdZ r/KNB1G9wgH0R1N34wh5xr97qok9yXHlLDEm5hIeR8PDZCmSeoFJDqxdBJszFfcyyo9D GfPg== X-Gm-Message-State: AHQUAuY7AU0iwyXIt9hdoqqJQFrVIETSf6Z8qiakNoiuHBwlisjSQ1l2 4aIgdhggw1Vtv+kDDbO9fBcKggwWwjlCyaH/WgFPvA== X-Received: by 2002:a5e:c206:: with SMTP id v6mr3814134iop.60.1548331895362; Thu, 24 Jan 2019 04:11:35 -0800 (PST) MIME-Version: 1.0 References: <20190123224926.250525-1-ebiggers@kernel.org> <20190123224926.250525-8-ebiggers@kernel.org> In-Reply-To: <20190123224926.250525-8-ebiggers@kernel.org> From: Ard Biesheuvel Date: Thu, 24 Jan 2019 13:11:23 +0100 Message-ID: Subject: Re: [RFC/RFT PATCH 07/15] crypto: arm64/aes-neonbs - fix returning final keystream block To: Eric Biggers Cc: "open list:HARDWARE RANDOM NUMBER GENERATOR CORE" , Herbert Xu , Linux Kernel Mailing List , "Jason A . Donenfeld" , stable Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 23 Jan 2019 at 23:52, Eric Biggers wrote: > > From: Eric Biggers > > The arm64 NEON bit-sliced implementation of AES-CTR fails the improved > skcipher tests because it sometimes produces the wrong ciphertext. The > bug is that the final keystream block isn't returned from the assembly > code when the number of non-final blocks is zero. This can happen if > the input data ends a few bytes after a page boundary. In this case the > last bytes get "encrypted" by XOR'ing them with uninitialized memory. > > Fix the assembly code to return the final keystream block when needed. > > Fixes: 88a3f582bea9 ("crypto: arm64/aes - don't use IV buffer to return final keystream block") > Cc: # v4.11+ > Cc: Ard Biesheuvel > Signed-off-by: Eric Biggers Reviewed-by: Ard Biesheuvel > --- > arch/arm64/crypto/aes-neonbs-core.S | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/arch/arm64/crypto/aes-neonbs-core.S b/arch/arm64/crypto/aes-neonbs-core.S > index e613a87f8b53..8432c8d0dea6 100644 > --- a/arch/arm64/crypto/aes-neonbs-core.S > +++ b/arch/arm64/crypto/aes-neonbs-core.S > @@ -971,18 +971,22 @@ CPU_LE( rev x8, x8 ) > > 8: next_ctr v0 > st1 {v0.16b}, [x24] > - cbz x23, 0f > + cbz x23, .Lctr_done > > cond_yield_neon 98b > b 99b > > -0: frame_pop > +.Lctr_done: > + frame_pop > ret > > /* > * If we are handling the tail of the input (x6 != NULL), return the > * final keystream block back to the caller. > */ > +0: cbz x25, 8b > + st1 {v0.16b}, [x25] > + b 8b > 1: cbz x25, 8b > st1 {v1.16b}, [x25] > b 8b > -- > 2.20.1.321.g9e740568ce-goog >