Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp596915img; Fri, 22 Mar 2019 04:51:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqxcHh74af4gmE4z/XTnNfCy/cY6mw2tNo61Ii+Dt9Bbni/RNPZtwGg+GFsn290bZa/H/8Yu X-Received: by 2002:a17:902:a40d:: with SMTP id p13mr8921289plq.144.1553255471887; Fri, 22 Mar 2019 04:51:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553255471; cv=none; d=google.com; s=arc-20160816; b=s1kBl/SUIb9Jr52HgkpGFzvQb6uOR958WzsIaSMfo6HJZMe28UN77YBx51iDawj/wK cXNKIiTHTs0SiPmAac9E92a4CzsGcOc/AenTvHS3AdNphCqVMWWJd2LkU7gaPCBy4of1 QT/YxQBzsOWtaMEPerXDGFXi+cHBz52SI+1P9iTc627z3tBWJ8PThv5BeH/hOc/bdukI qPL0Pc852n6kOrrmS8BNkCgfSD5nYRY7hdteHAePnxVBc2t8o/r8bmwjoABzRFbrZl8X HCYPPYJEu6t30utmUu6cxAvMDC+47fBR7+pGeU6Ig81OmLG/3Uwvv7aNfNZgRQFNXllp zkFg== 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=c4r7H8d1mI+hAHhQY0h8JkvzN4wIGRUrZlhwdTVZNQE=; b=pnzld9/rMION09zPJb41BGeHX4PO4382GTah1K2ct41RmvTmjgrbZc/f77b6JN47w+ VKJUKohwVzb+GN5POF0k/iORjqVuqcqt5SjfRk0kHAB60tb+UWFeF8zyxCdpjdjO6AOm 2+yg4U+pFwwvHZjcQAppiZxOPv6IDYvyukeIrSwXkWaw5oXAqUX6a768MB/9yR6kNmvI 5CSWA7kvTrzk2/Z/TTBf90z06RZJSFHWbOHs9++RYN/anE2691JzRaNMo+Hw3DozpA++ C++IQEYxENP3PHGR2AAQ91r0yQwZ0k+oM/m5meLZJrmePnoPr3W9mXpJS3oUDK0WLXHS osPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Tgq5o5km; 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 h127si6709102pfb.213.2019.03.22.04.50.56; Fri, 22 Mar 2019 04:51:11 -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=Tgq5o5km; 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 S1732597AbfCVLuN (ORCPT + 99 others); Fri, 22 Mar 2019 07:50:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:53918 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732330AbfCVLuJ (ORCPT ); Fri, 22 Mar 2019 07:50:09 -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 9297F20850; Fri, 22 Mar 2019 11:50:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553255409; bh=foEC0qubLHMRy4OwNaYm9PUGpzCS43PkmOBS1b/3jAI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Tgq5o5km+rA+lDQjR53Jw/1QCB4MNWZYq8RViTeN6u6QcN6mcjTCbiZxMjy8z24Xm NoWToxqPSroW2WUC+zLXZ0+kI0ExGBumUMuRx2b2RXrcLnapW9v8DSfXvJ0rDISO5t wIDCOLSztss02ZhrkquYZ0bFIHrZlQEeM+D6POmE= 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.14 074/183] crypto: arm64/crct10dif - revert to C code for short inputs Date: Fri, 22 Mar 2019 12:15:02 +0100 Message-Id: <20190322111247.098040254@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190322111241.819468003@linuxfoundation.org> References: <20190322111241.819468003@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.14-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;