Received: by 2002:a5b:505:0:0:0:0:0 with SMTP id o5csp3413ybp; Thu, 3 Oct 2019 09:22:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqzMNcASxlGvolsL0vKD6pzWG8XqPBp4R+Qm6SYuRcdLRHZSjLFHudywssR73a9GRoKcm26/ X-Received: by 2002:a17:906:4d08:: with SMTP id r8mr8495133eju.283.1570119732843; Thu, 03 Oct 2019 09:22:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570119732; cv=none; d=google.com; s=arc-20160816; b=00ZtveCeNS7GiBB3t1bFQV2HAoEP9dYjc2P6HOKRLZGt/FW0tFJNCRzSZmq/br0pBW TL3ncBdF2wftN6jawTMsfrpu/PCJHq5VK48xc7ZoBJmRFb4+gMFoTWU/7YEIZSGkCih2 NogLENKyCkjHBvqB6c/des2tHZLynlna3nn0p7XaEN0pO12Ck769ZOD2J1hVzUnKzyIe pTYL8zBYEtmfyD+Jn/xlqZgj/yc2t5B7QQ2eaQiZhzpVE9V+qPcLeVyaP9IPLxAqblBN 4RHmLj9GSXbcvaK0YPqoAunac2GMLyGBx8SiKVyXKojFzoo3S7qW21XKu+EC/OccT8tb U/LQ== 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=Jly3UJhv15el0mSwyHmGQOdGD/JkaOqFx6v06OfbrC4=; b=Da0CpBw0XG6wq4Afk+3+uBe4HZS81pWN5EiBIOXxAy0UlTQR0A62k3tR91BBntay4P NciiGdJP8WKdpfycMJ4qgKGk945BNBX4JhMXVoOyQ+vGcF+g736OjxpwXE6ADnnzxEsN y2VKtIgtXfdjjdxIAUOO+nKJ64BBeVb1sSaVeTV+1Sopf4zYKlkpKQZpQKJ2VhOveQL/ eE+Hb7FTos0XFnhLEpyrDaLXxsOYJW9Q8VnR56OWKnpdVDyzIraERkVF8QSeX+b8Vm/9 ACgW+XUURpG1rwtkMEZTngL3+RBKISwlVi6+2Z73DUhgsYgEGZ/eQy+mUTa665gj4Jhf BhAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=l6DpmpDo; 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 j35si2048894eda.144.2019.10.03.09.21.47; Thu, 03 Oct 2019 09:22:12 -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=l6DpmpDo; 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 S2389557AbfJCQUM (ORCPT + 99 others); Thu, 3 Oct 2019 12:20:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:47520 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389835AbfJCQUH (ORCPT ); Thu, 3 Oct 2019 12:20:07 -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 3746A222CB; Thu, 3 Oct 2019 16:20:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1570119606; bh=s7x370y95jXHCMWBXfaRjHHLe9MY1QprAjrHw4KTmss=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=l6DpmpDo2P2J1H08zhYTF9pb5nB9ZSRh76T6FRMKQo1bthEXSXQKxefXXl7akS25G yenkYfeaU4Bpon02CHqY1AYcZOxGvYZ5Gfp1cTMsHBwKVUHNchBb855rD53exEKTl6 Wesn1Rm8La0tulYe2uI9W5Wr0FzJsGY4CAA09Eto= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Harald Freudenberger , Vasily Gorbik , Sasha Levin Subject: [PATCH 4.19 128/211] s390/crypto: xts-aes-s390 fix extra run-time crypto self tests finding Date: Thu, 3 Oct 2019 17:53:14 +0200 Message-Id: <20191003154515.944746287@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20191003154447.010950442@linuxfoundation.org> References: <20191003154447.010950442@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: Harald Freudenberger [ Upstream commit 9e323d45ba94262620a073a3f9945ca927c07c71 ] With 'extra run-time crypto self tests' enabled, the selftest for s390-xts fails with alg: skcipher: xts-aes-s390 encryption unexpectedly succeeded on test vector "random: len=0 klen=64"; expected_error=-22, cfg="random: inplace use_digest nosimd src_divs=[2.61%@+4006, 84.44%@+21, 1.55%@+13, 4.50%@+344, 4.26%@+21, 2.64%@+27]" This special case with nbytes=0 is not handled correctly and this fix now makes sure that -EINVAL is returned when there is en/decrypt called with 0 bytes to en/decrypt. Signed-off-by: Harald Freudenberger Signed-off-by: Vasily Gorbik Signed-off-by: Sasha Levin --- arch/s390/crypto/aes_s390.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/s390/crypto/aes_s390.c b/arch/s390/crypto/aes_s390.c index 8ff7cb3da1cba..2bc189187ed40 100644 --- a/arch/s390/crypto/aes_s390.c +++ b/arch/s390/crypto/aes_s390.c @@ -585,6 +585,9 @@ static int xts_aes_encrypt(struct blkcipher_desc *desc, struct s390_xts_ctx *xts_ctx = crypto_blkcipher_ctx(desc->tfm); struct blkcipher_walk walk; + if (!nbytes) + return -EINVAL; + if (unlikely(!xts_ctx->fc)) return xts_fallback_encrypt(desc, dst, src, nbytes); @@ -599,6 +602,9 @@ static int xts_aes_decrypt(struct blkcipher_desc *desc, struct s390_xts_ctx *xts_ctx = crypto_blkcipher_ctx(desc->tfm); struct blkcipher_walk walk; + if (!nbytes) + return -EINVAL; + if (unlikely(!xts_ctx->fc)) return xts_fallback_decrypt(desc, dst, src, nbytes); -- 2.20.1