Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2095878ybl; Thu, 30 Jan 2020 11:16:56 -0800 (PST) X-Google-Smtp-Source: APXvYqz5gt+4yaQyOd0UE1K6EdYa0UPdPGWTNNDz9RXLq9jde8eVL58Wz5ZZwX2GRydaLU1KmapM X-Received: by 2002:a05:6830:16d8:: with SMTP id l24mr4798425otr.268.1580411816052; Thu, 30 Jan 2020 11:16:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580411816; cv=none; d=google.com; s=arc-20160816; b=TPACrL7xCepZFUHpsvEbif732xq9UTdED5piaktti28bFDmcLAulJalbZhd87PlbwF oW75kVTa34WPw8RbZtZQgW8YNyk2uGvTJCHikJnOxh/I7r9iJ4CTTkL6byceNp/F2AHU Z3gkEpz3Erm0N6ZoPnVYLxEsHjdFcIERAlaPW92l1EQfAz7iEeGJ/U/pqTFaZMbGxN+P OP/FaP5zBl84hVcUFUohJqMiWmTHNKizBDu+c5gbEc+Q97f125LSueDbRqL5UrefdSLu LhM4i2yBC23w4jYzBfGURQ4yWtkbFh7S7MSaAPOLeogcPzazc5M5FZimY3wycWqls5Vy nBEQ== 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=m38Gvlfzulurzi9rFpjzPv0qVLDcWAnwqZ5NyjDa/N0=; b=BBidC0n0tqCzUHzuh/naDPJNtMrsXUNZ6XmDzQlXR9qjDkweTQ56IcT3W4dMLbpOiH A9RD9mxqytqkRfiTi48b+cnY1pd1dfQtRkuKSYnHUJ2aMaKFheFZxb2CrGqwUOllwJpY N7jlI+LMmG+kHZRUMLoLlCn5AA2WxTmrKP+7vxi95eHZUbs+1MrCcMB+LbM+5usdmpU3 gXasTTyodD8boT6xW8q949JRREMEP83IWG2tcVulUYYIjMsPiVGH64hh78j0rNZrOFi2 NhZynsUTHI4S2XuNos/QzsAjkYCLRtcVyvfkvOUWgtcVgXdrk4lyGyGO29XrI0CCMYCB HQaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hZjxlYtz; 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 j16si3561918otq.23.2020.01.30.11.16.43; Thu, 30 Jan 2020 11:16:56 -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=hZjxlYtz; 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 S1728036AbgA3Sm5 (ORCPT + 99 others); Thu, 30 Jan 2020 13:42:57 -0500 Received: from mail.kernel.org ([198.145.29.99]:51410 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730488AbgA3Smz (ORCPT ); Thu, 30 Jan 2020 13:42:55 -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 E0CAF2082E; Thu, 30 Jan 2020 18:42:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580409774; bh=QfnxMB0dgD92cegRD30p3lKsxzzu3pByATBZQ2NyotA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hZjxlYtzO1pD9GY7Wy8FnRrn3QffJ75SGwSrXrm96KU2b0bQ1xc4bekL1HtrrFOuF 63tbqsAC1DYz2R9RypC/FSeNiWkcgcFuQoUZvA7q7B3YjFovKpiJf6GzB/o3+6Bvo/ TYoQQdW2agWGHkSpbx3Dr74HHNSudoxG82IYNIqk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Atul Gupta , Eric Biggers , Herbert Xu Subject: [PATCH 5.4 027/110] crypto: chelsio - fix writing tfm flags to wrong place Date: Thu, 30 Jan 2020 19:38:03 +0100 Message-Id: <20200130183618.338563306@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200130183613.810054545@linuxfoundation.org> References: <20200130183613.810054545@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: Eric Biggers commit bd56cea012fc2d6381e8cd3209510ce09f9de8c9 upstream. The chelsio crypto driver is casting 'struct crypto_aead' directly to 'struct crypto_tfm', which is incorrect because the crypto_tfm isn't the first field of 'struct crypto_aead'. Consequently, the calls to crypto_tfm_set_flags() are modifying some other field in the struct. Also, the driver is setting CRYPTO_TFM_RES_BAD_KEY_LEN in ->setauthsize(), not just in ->setkey(). This is incorrect since this flag is for bad key lengths, not for bad authentication tag lengths. Fix these bugs by removing the broken crypto_tfm_set_flags() calls from ->setauthsize() and by fixing them in ->setkey(). Fixes: 324429d74127 ("chcr: Support for Chelsio's Crypto Hardware") Cc: # v4.9+ Cc: Atul Gupta Signed-off-by: Eric Biggers Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- drivers/crypto/chelsio/chcr_algo.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) --- a/drivers/crypto/chelsio/chcr_algo.c +++ b/drivers/crypto/chelsio/chcr_algo.c @@ -3194,9 +3194,6 @@ static int chcr_gcm_setauthsize(struct c aeadctx->mayverify = VERIFY_SW; break; default: - - crypto_tfm_set_flags((struct crypto_tfm *) tfm, - CRYPTO_TFM_RES_BAD_KEY_LEN); return -EINVAL; } return crypto_aead_setauthsize(aeadctx->sw_cipher, authsize); @@ -3221,8 +3218,6 @@ static int chcr_4106_4309_setauthsize(st aeadctx->mayverify = VERIFY_HW; break; default: - crypto_tfm_set_flags((struct crypto_tfm *)tfm, - CRYPTO_TFM_RES_BAD_KEY_LEN); return -EINVAL; } return crypto_aead_setauthsize(aeadctx->sw_cipher, authsize); @@ -3263,8 +3258,6 @@ static int chcr_ccm_setauthsize(struct c aeadctx->mayverify = VERIFY_HW; break; default: - crypto_tfm_set_flags((struct crypto_tfm *)tfm, - CRYPTO_TFM_RES_BAD_KEY_LEN); return -EINVAL; } return crypto_aead_setauthsize(aeadctx->sw_cipher, authsize); @@ -3289,8 +3282,7 @@ static int chcr_ccm_common_setkey(struct ck_size = CHCR_KEYCTX_CIPHER_KEY_SIZE_256; mk_size = CHCR_KEYCTX_MAC_KEY_SIZE_256; } else { - crypto_tfm_set_flags((struct crypto_tfm *)aead, - CRYPTO_TFM_RES_BAD_KEY_LEN); + crypto_aead_set_flags(aead, CRYPTO_TFM_RES_BAD_KEY_LEN); aeadctx->enckey_len = 0; return -EINVAL; } @@ -3328,8 +3320,7 @@ static int chcr_aead_rfc4309_setkey(stru int error; if (keylen < 3) { - crypto_tfm_set_flags((struct crypto_tfm *)aead, - CRYPTO_TFM_RES_BAD_KEY_LEN); + crypto_aead_set_flags(aead, CRYPTO_TFM_RES_BAD_KEY_LEN); aeadctx->enckey_len = 0; return -EINVAL; } @@ -3379,8 +3370,7 @@ static int chcr_gcm_setkey(struct crypto } else if (keylen == AES_KEYSIZE_256) { ck_size = CHCR_KEYCTX_CIPHER_KEY_SIZE_256; } else { - crypto_tfm_set_flags((struct crypto_tfm *)aead, - CRYPTO_TFM_RES_BAD_KEY_LEN); + crypto_aead_set_flags(aead, CRYPTO_TFM_RES_BAD_KEY_LEN); pr_err("GCM: Invalid key length %d\n", keylen); ret = -EINVAL; goto out;