Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp608282img; Fri, 22 Mar 2019 05:05:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqz23ujn8aVXSb7LFBlwZRn7SoQc2wJ5Y7I8MMo7qJpgmkBvxOHtyzSMxDf/itdT+nWG2weh X-Received: by 2002:aa7:82d7:: with SMTP id f23mr8861375pfn.114.1553256315109; Fri, 22 Mar 2019 05:05:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553256315; cv=none; d=google.com; s=arc-20160816; b=ndHKQ5FpTfG2novCG0XtM47Ivrkl4Fpd8p/RmPod9VvUaKxnBM5BhoMWAhtqLGfV2R IErX64xkhOhZb4jcKg7MWZEKC5mLzObtfrBoGKH3zCpBse7Lbk5OL3rRNc25PYiMAj0I kiRok8L4Lj5D16Wj5B7Km2ae/KvCj0mBxeSoOCM7QjsHoOicfEt3gyvPWXlSGd2jLCmG Ldq3HLr2FIO11nE/wVXXU7aGvbLUefzQb7wZ1JutT8dRHOMDPkVRKyuW9VC0wGzr+wyk YYXgPVnqzyedqma2V/S1XOiHltacqX9Fj0A1AF1vZHGUI4a4scjSXv2TbQl577gBTvnF RNBg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=+Hyfsy2FE8vQVlGZq8EoMKlaFL24D5bIHXZVrn6+kIo=; b=NYciddmoxst8ePQzmquRIGQzYyAOLTYbpmBABIP0Bb5q5lZxTY0qJiDoZ+6p1JWUuP 8/IcKWnCHk/3t+gLyLi1GatJTzO7XZvFFNWLJHIqVEQHfCoJ24bBRWRk7oOf9NjWYLnP OdHByEtB98oJ4+eQH5R+VpO/OY31cRcty9L3nhOiT+f0E/kWHCMtIWqphhuGaz104l7S 6N/4s5SQxbbAGh7+zM5XM9+BmSNrVJtLReZKNgyDnHRk4q3XZGxx0tFg+Jd6tjnQrRYE KVfbZE6RgTBiOUZAIYALinMyR9qL/ITLl24SrprIqe+qVEfucp1uAvMwgMDiPfhlMtzR OqJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bpVjew5J; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g127si6521156pgc.313.2019.03.22.05.04.59; Fri, 22 Mar 2019 05:05:15 -0700 (PDT) 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=@kernel.org header.s=default header.b=bpVjew5J; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388551AbfCVMDl (ORCPT + 99 others); Fri, 22 Mar 2019 08:03:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:42052 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388542AbfCVMDi (ORCPT ); Fri, 22 Mar 2019 08:03:38 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id BF0CA204FD; Fri, 22 Mar 2019 12:03:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553256218; bh=0JO1CB0UsKwNA92DiPqRCRKQpuu5Lo9vMPeXTCRyLXc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bpVjew5JJ5Jzqxg8TacXJezY8gwAWm3qUl3TtYUgn/RvsrK2o/17K4h4unXT3xcsz UKA8iI8no3Mhc/DmLpRgZP+OCTYgEorffrXuIUBuHyfPPDQPUjDd2figgz2d3Z1juB 7qVgJ+Hlo/VbnyoVEeMG+Bt9AddwnGkvRtErrnQQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Biggers , Ard Biesheuvel , Herbert Xu Subject: [PATCH 4.19 126/280] crypto: arm64/crct10dif - revert to C code for short inputs Date: Fri, 22 Mar 2019 12:14:39 +0100 Message-Id: <20190322111315.890633255@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190322111306.356185024@linuxfoundation.org> References: <20190322111306.356185024@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ard Biesheuvel commit d72b9d4acd548251f55b16843fc7a05dc5c80de8 upstream. The SIMD routine ported from x86 used to have a special code path for inputs < 16 bytes, which got lost somewhere along the way. Instead, the current glue code aligns the input pointer to 16 bytes, which is not really necessary on this architecture (although it could be beneficial to performance to expose aligned data to the the NEON routine), but this could result in inputs of less than 16 bytes to be passed in. This not only fails the new extended tests that Eric has implemented, it also results in the code reading past the end of the input, which could potentially result in crashes when dealing with less than 16 bytes of input at the end of a page which is followed by an unmapped page. So update the glue code to only invoke the NEON routine if the input is at least 16 bytes. Reported-by: Eric Biggers Reviewed-by: Eric Biggers Fixes: 6ef5737f3931 ("crypto: arm64/crct10dif - port x86 SSE implementation to arm64") Cc: # v4.10+ Signed-off-by: Ard Biesheuvel Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- arch/arm64/crypto/crct10dif-ce-glue.c | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) --- a/arch/arm64/crypto/crct10dif-ce-glue.c +++ b/arch/arm64/crypto/crct10dif-ce-glue.c @@ -36,26 +36,13 @@ static int crct10dif_update(struct shash unsigned int length) { u16 *crc = shash_desc_ctx(desc); - unsigned int l; - if (unlikely((u64)data % CRC_T10DIF_PMULL_CHUNK_SIZE)) { - l = min_t(u32, length, CRC_T10DIF_PMULL_CHUNK_SIZE - - ((u64)data % CRC_T10DIF_PMULL_CHUNK_SIZE)); - - *crc = crc_t10dif_generic(*crc, data, l); - - length -= l; - data += l; - } - - if (length > 0) { - if (may_use_simd()) { - kernel_neon_begin(); - *crc = crc_t10dif_pmull(*crc, data, length); - kernel_neon_end(); - } else { - *crc = crc_t10dif_generic(*crc, data, length); - } + if (length >= CRC_T10DIF_PMULL_CHUNK_SIZE && may_use_simd()) { + kernel_neon_begin(); + *crc = crc_t10dif_pmull(*crc, data, length); + kernel_neon_end(); + } else { + *crc = crc_t10dif_generic(*crc, data, length); } return 0;