From patchwork Thu Feb 13 15:21:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 231402 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B7C1CC2BA83 for ; Thu, 13 Feb 2020 15:49:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8F99D20661 for ; Thu, 13 Feb 2020 15:49:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581608972; bh=Dgrwx/JC4sa0jfa3IwWsSW9puRlLOOtDFySxIgxoPhs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=iPAw+HseVoEKaJ38tRB3jVdbwqMeb0fM2WVN3Y+SN+bFHCL/rWVxbc5T2GrH5qwnH r6FgBLkHSmzTR3NrHhHPiPC63puvm4hy42t6fONZKpEUo18WdThJ23ayuffW9ZOfAH i9j/3OaZ67+DNY5cH0ouWb/NN9bHW5b/faanMd7I= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728678AbgBMPt2 (ORCPT ); Thu, 13 Feb 2020 10:49:28 -0500 Received: from mail.kernel.org ([198.145.29.99]:47008 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729237AbgBMP0p (ORCPT ); Thu, 13 Feb 2020 10:26:45 -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 ABEC824685; Thu, 13 Feb 2020 15:26:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581607604; bh=Dgrwx/JC4sa0jfa3IwWsSW9puRlLOOtDFySxIgxoPhs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1HLrbVVFt6r2HOQqmhQL2ppYt+9yCipnxBGXrRq05+izXMS9v4+3B7JAZkW+ehD4h EsqN2PTc7gfYlt6x6svBmKSDEdVrgaV41df8i+0Ion53iHE8GC4nDrygAFDauGyY+U t3tmYwSxCsI5MHwzO4K9Vre6OBNQ5tWAqIKE7YAs= 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 4.19 43/52] crypto: atmel-sha - fix error handling when setting hmac key Date: Thu, 13 Feb 2020 07:21:24 -0800 Message-Id: <20200213151827.802990585@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200213151810.331796857@linuxfoundation.org> References: <20200213151810.331796857@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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 @@ -1921,12 +1921,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)