Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp616686img; Fri, 22 Mar 2019 05:14:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqzGi9eDhDBYCc0K+GA6kJwnCIdrw9vTXdafrsqxBZojIeWI6QaVxqw/E+Vz78uVa4ASZKRU X-Received: by 2002:a17:902:2a03:: with SMTP id i3mr9527186plb.229.1553256847813; Fri, 22 Mar 2019 05:14:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553256847; cv=none; d=google.com; s=arc-20160816; b=ewBerjhTRaG/BLggXBycJp6aqJLWxslsnHwo+/quPkLSvOlFI/WYjKd3UAWSyzM6A3 vqpFXn2JjTVauvX4NItDayc8nspfkorHMQsAWfB45Qe7uVYqKqbrniFlrkLyahK/BZEJ DdniqEMAEQyEbkmvG7DgMqaFCsddP5k4w+FSADOWe3NvMIMz43iDs7vP1JJ+S+Euhs+j C5zv5LAtvELw/Pl4bByhiW9BD9MmPo5nEcxvWUCneK7tCoVKQqD/1yAAjK1rdYIKVwyZ ED8HEbDMMBB05d7crOZOX1H+0FxV1xd62xDBcNg1zV9Dh8b/NjM/NLs65M4bBG5zJKy1 AL1A== 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=lygTPth2JPWXmFK5SiPt2wrz+w/7Vlcr4NoYSV3DbTI=; b=fMGe5D7ym86h5XZTjiNT6zwvn0EjNmo/Prer5lIm0+vx2il4wn7qWtxQDmcImAcOpp SJ6mH6yhCkFGuwsOihzKXY304EvJplcflxD4tbE8dAjmVykPNsGgiJuRfFKrEzjwIcrL uJ+N94DEuIxuUSyyWTUsAyAp9lLa2AC+TOwIXWaA5orOM6mQcAEI/87p4InAb8dNSy5r hwO1XvuQPUgNsx9WGyLXq3enlS84gFBzbG4QcDfk3OyPIe9EZWhq9JbDqWDNkT+c7vc7 sL0c9zFBa5Ht4y6UnPTui4PM5C5X1JhStFUqVLpbL1oeSMQJunmLu9jjayzG+xlUQErB wvtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FDcUbYYp; 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 p87si6526430pfa.48.2019.03.22.05.13.52; Fri, 22 Mar 2019 05:14:07 -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=FDcUbYYp; 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 S2389747AbfCVMNV (ORCPT + 99 others); Fri, 22 Mar 2019 08:13:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:51560 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389446AbfCVMNT (ORCPT ); Fri, 22 Mar 2019 08:13:19 -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 6A07E2082C; Fri, 22 Mar 2019 12:13:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553256798; bh=5ijW2TygqGamYHO6y/LTo4KgIc0uUKs31b3gskNQB20=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FDcUbYYp6EHaEgM9j/DqtgsSbyz3YS229uWVeg4aMX1zKkVYC5OKniqk6lsH5uPz3 sSA0nX02nxmSH8/aUDZBI7Fg98kstZqWn2wcHQyiFBRmSgg8+oTJhc/9T4sv3bDyaC 8SVQnsy4VXJjG+2Giilt6d4mMOBuNN639FERCWn8= 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 5.0 040/238] crypto: arm64/crct10dif - revert to C code for short inputs Date: Fri, 22 Mar 2019 12:14:19 +0100 Message-Id: <20190322111300.751457459@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190322111258.383569278@linuxfoundation.org> References: <20190322111258.383569278@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 5.0-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 @@ -39,26 +39,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;