Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp684424ybv; Thu, 13 Feb 2020 07:43:55 -0800 (PST) X-Google-Smtp-Source: APXvYqwjzgvb1yudw54yOqNLIbVjRuzCyLhfln06xxcqTPa35QZb5GYjtUfuH27Aqj9ecCS5GLnK X-Received: by 2002:a05:6808:312:: with SMTP id i18mr3453010oie.44.1581608635611; Thu, 13 Feb 2020 07:43:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581608635; cv=none; d=google.com; s=arc-20160816; b=va5gUNLu8ss5ZggvaQlVBukKppLhV9y2+gj73GsfVes/avi2YukEIxJC6XJ3f/AMSi /PHAvYNyrhclAJBV2Y6lkafaNsStaGIoj3kEs1Z/4i7tnEiiSij7yjr36DW8I0zT9Zao pS/TED1clCYqSCVCQiYosmlCbaEnf7eOwoc5F7UsGWkhoM0eKK0uYd9sSE0ZyZa4e9SS TnTucFl477H3NO0C/dQD01MuNg/WxEelDQTtPGg68NKRI+uMoWsgKNcUVj70tt/3AL1h xHWniunZBXpRNm7JmT4SR+byAM3Qjb4r8cQLkY9guuHYCn5RmjCrczp2QHF7BAQdqIHf 5jQg== 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=xeZ2OD0UXE32Pb2DpuOe2J4DbPz5XN1SSxvD0RxU+PE=; b=fwVZ+Qz/Os2u8ouj6p6rLQgkP+ghlbEXs3XB9fqGmcc37b3q5xmiHnZfGkTT7HztNr eEAQmjAxIsa4CFJVh6hWC9glrQXhrRz3zBWykAuvVcnx2cYwJsw3XiwUWl143cdQzJBF Xlh9MvhQGLqxqvYi3pgdNKLxXKr7ubXP1iAF9Cwhfy/rOtvO+A9WdIropKf0BdQSs+ew 8fZzMLLWyvz4oozEabJXO37tpDmAfNhbpPhR7h75VVq9vMrvp/VlNzjMMwWTu5NS0HGN 5DmFElBdzsMS5j1FZw9EeVZ5Wy78nL+/KJJ1vwpXbFKWkyzWiIQDj+kCfe4yK8Dge8uh UhuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=WSceo7h8; 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 t3si1322886oth.247.2020.02.13.07.43.43; Thu, 13 Feb 2020 07:43:55 -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=WSceo7h8; 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 S1729505AbgBMPng (ORCPT + 99 others); Thu, 13 Feb 2020 10:43:36 -0500 Received: from mail.kernel.org ([198.145.29.99]:53140 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728412AbgBMP1x (ORCPT ); Thu, 13 Feb 2020 10:27:53 -0500 Received: from localhost (unknown [104.132.1.104]) (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 9757F218AC; Thu, 13 Feb 2020 15:27:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581607672; bh=Y7tj7PSZoyNOv58hg+6UOtynPKMg5y4iPeSa/ueM9To=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WSceo7h8Un/a+AD7PCxqjK/1O8WftM0lGth5g+ui7/pVK3mBADqKsY2GScIdlilYW GdT8k9CvKgkkJDKyHZTZwN2vnXOvKyGLAgYhIr7ZOualdMyvDvVrQGw9YNIuSU+8Qk gxORHny6QgunwH//Vl8A6nsGbtrReAohgnrBZfhw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nicolas Ferre , Alexandre Belloni , Ludovic Desroches , Eric Biggers , Tudor Ambarus , Herbert Xu Subject: [PATCH 5.4 79/96] crypto: atmel-sha - fix error handling when setting hmac key Date: Thu, 13 Feb 2020 07:21:26 -0800 Message-Id: <20200213151908.944131584@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200213151839.156309910@linuxfoundation.org> References: <20200213151839.156309910@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 b529f1983b2dcc46354f311feda92e07b6e9e2da upstream. HMAC keys can be of any length, and atmel_sha_hmac_key_set() can only fail due to -ENOMEM. But atmel_sha_hmac_setkey() incorrectly treated any error as a "bad key length" error. Fix it to correctly propagate the -ENOMEM error code and not set any tfm result flags. Fixes: 81d8750b2b59 ("crypto: atmel-sha - add support to hmac(shaX)") Cc: Nicolas Ferre Cc: Alexandre Belloni Cc: Ludovic Desroches Signed-off-by: Eric Biggers Reviewed-by: Tudor Ambarus Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- drivers/crypto/atmel-sha.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) --- a/drivers/crypto/atmel-sha.c +++ b/drivers/crypto/atmel-sha.c @@ -1918,12 +1918,7 @@ static int atmel_sha_hmac_setkey(struct { struct atmel_sha_hmac_ctx *hmac = crypto_ahash_ctx(tfm); - if (atmel_sha_hmac_key_set(&hmac->hkey, key, keylen)) { - crypto_ahash_set_flags(tfm, CRYPTO_TFM_RES_BAD_KEY_LEN); - return -EINVAL; - } - - return 0; + return atmel_sha_hmac_key_set(&hmac->hkey, key, keylen); } static int atmel_sha_hmac_init(struct ahash_request *req)