Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2094210ybl; Thu, 30 Jan 2020 11:15:11 -0800 (PST) X-Google-Smtp-Source: APXvYqxCA+lOLX7T2Mtb7eNR1YtZ/oHX1IMLnpMMhtzoEwpyT3WkINA9oz7qIvv/0pS6/Rjm3Sj8 X-Received: by 2002:a05:6830:1185:: with SMTP id u5mr4388930otq.147.1580411711644; Thu, 30 Jan 2020 11:15:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580411711; cv=none; d=google.com; s=arc-20160816; b=vgkjRiisYDaljIFVHO7qBaYbpozz1frM0NV7F3+Xs9fbPeQoVm1OeZfyHwviWH9COs YxQ3TXeDpfOJPjYIOiHpz3ixFSQ4J+WTy8GyFCDgy8xKkkOMd4wGvk7mP/7uzT/6RZsD R4bFRz2qiPY5vV1Ip1izax74tA2JU55RPiL1oBwnzcnW9izja6ZTzqQI5x7F8XQpkght OpKQ6IW9LSeu4RxbiJfYdmDgBuWt1N0y//FzqPu7luenPSbvssM3sgLmDfP5x61YnhVC CpA+0J2YOyeGAaHmGMt8Zu1yYQSzfnrZlogRFSPJGMnitQearBa8Js98mKp7beLifJLE M1Wg== 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=CN3KS6VFrH038jfh+Cx0R7oBmpo6V81gH85T1zQvUK4=; b=AnvpF8l2Qsf3QI5lgFM+USHPfBUiDi8+gu+o7LIa6SSMg7Zasc9aswLxbeMelpvUA1 N/jaDt6bLONXwpFiiXFF/nr+tTO6er0WgdzRi6HktMq7LtuAD2ctoDLoOCJVXnO1aB8s Swtqw9ZQgyEoI7HrFlREnbDc75VplUee8yJh2Pl3n4pGJ0et8E2YvyAISMtSQtHJb1oj w1pCUZOL7OfiD11LmT6k1WgHjdlZUnCnE0Dy+/Etpza75cia/S3HRy9Dq8i6GqkNX5sw z61U39RSB82RDxyMdoHKQihMFO5gml9BQrKalzXXTxr1CArF6m862xpzzVVErYwQ4Zku UyNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=mRvNfCvO; 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 z73si3265203oia.40.2020.01.30.11.15.00; Thu, 30 Jan 2020 11:15:11 -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=@kernel.org header.s=default header.b=mRvNfCvO; 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 S1730186AbgA3Slb (ORCPT + 99 others); Thu, 30 Jan 2020 13:41:31 -0500 Received: from mail.kernel.org ([198.145.29.99]:49410 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730170AbgA3Sl2 (ORCPT ); Thu, 30 Jan 2020 13:41:28 -0500 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 7577A2082E; Thu, 30 Jan 2020 18:41:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580409687; bh=bGoDS0mBgh3I4daVnCZ7k2qTbcUa8RGgkJZ9QH04wi4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mRvNfCvOhxJhcltJAlWf5khuKitrNTbaMK/ET8f0c5zfAEYtM/5NqhLZ4JgViSdOu i4jBHf1q6nJ+gfXQv+jiR3/XEAyHQTH1z1axfYzJw7psQzt3nRQ+DmGztL+aO8PR7R xm8A6szOBPi6q+tzIT+8E+2MDSm8wpCR6Cm/q61s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Erhard Furtner , Ard Biesheuvel , Michael Ellerman , Daniel Axtens , Herbert Xu Subject: [PATCH 5.5 51/56] crypto: vmx - reject xts inputs that are too short Date: Thu, 30 Jan 2020 19:39:08 +0100 Message-Id: <20200130183618.075735523@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200130183608.849023566@linuxfoundation.org> References: <20200130183608.849023566@linuxfoundation.org> User-Agent: quilt/0.66 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 From: Daniel Axtens commit 1372a51b88fa0d5a8ed2803e4975c98da3f08463 upstream. When the kernel XTS implementation was extended to deal with ciphertext stealing in commit 8083b1bf8163 ("crypto: xts - add support for ciphertext stealing"), a check was added to reject inputs that were too short. However, in the vmx enablement - commit 239668419349 ("crypto: vmx/xts - use fallback for ciphertext stealing"), that check wasn't added to the vmx implementation. This disparity leads to errors like the following: alg: skcipher: p8_aes_xts encryption unexpectedly succeeded on test vector "random: len=0 klen=64"; expected_error=-22, cfg="random: inplace may_sleep use_finup src_divs=[66.99%@+10, 33.1%@alignmask+1155]" Return -EINVAL if asked to operate with a cryptlen smaller than the AES block size. This brings vmx in line with the generic implementation. Reported-by: Erhard Furtner Link: https://bugzilla.kernel.org/show_bug.cgi?id=206049 Fixes: 239668419349 ("crypto: vmx/xts - use fallback for ciphertext stealing") Cc: Ard Biesheuvel Cc: stable@vger.kernel.org # v5.4+ Signed-off-by: Michael Ellerman [dja: commit message] Signed-off-by: Daniel Axtens Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- drivers/crypto/vmx/aes_xts.c | 3 +++ 1 file changed, 3 insertions(+) --- a/drivers/crypto/vmx/aes_xts.c +++ b/drivers/crypto/vmx/aes_xts.c @@ -84,6 +84,9 @@ static int p8_aes_xts_crypt(struct skcip u8 tweak[AES_BLOCK_SIZE]; int ret; + if (req->cryptlen < AES_BLOCK_SIZE) + return -EINVAL; + if (!crypto_simd_usable() || (req->cryptlen % XTS_BLOCK_SIZE) != 0) { struct skcipher_request *subreq = skcipher_request_ctx(req);