Received: by 10.223.185.116 with SMTP id b49csp1054027wrg; Fri, 23 Feb 2018 11:04:10 -0800 (PST) X-Google-Smtp-Source: AH8x2246zGpJJh2bOL8WZKj9JRzk0V+tfGOpGLte/a6fgmGlqEs0k2r6KzTg8Mqsc7A6OOp+7EQD X-Received: by 2002:a17:902:4222:: with SMTP id g31-v6mr2522613pld.335.1519412650592; Fri, 23 Feb 2018 11:04:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519412650; cv=none; d=google.com; s=arc-20160816; b=jqVhziQWwEKdeo2t09bYLHTnGXZYqp1l2A0VC8RQmnpbHUJandz7rupnm5Lqkzqase 7+o1IYmU4NAl4wKUME/Te36ZNWxSzwF7W7OQ67KNFDbp08awR+e4kOTVvwBCldh1siUz R6cfKf9rdHsnnR5RPb2eO50EuVL4dI3WFv0tmVWOP66RDKJN2xGavqz/W7jsXfNzKvlv Dzgw75l5DGGbe4g5VkbyL0E8TTVtkDOvqdPaDJqpG5143Yn/upQ2V0TLl+tP/OTz02n9 oeOyC2OZPBs2SwIXqWi2NKmf9KVLiVorXodXnX8x/H/n6tzcb/NbpYCF7OXu9kF3z2Tv pwtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=m1lEcFy0EDSFQNF2Jy5DTnw8/DXP8g+c7gFvCakgqUM=; b=xHQk6rvv6go4GykxpadTWMvyZZVQMkH91q7zLrETRIFmZTmesmp9wKWd1Hpz+URDrB jiB/4oFlqOhz8HNrcH1lnFQkKqUVjhBvjNWEGaKjOvmrTf4JsthggKGIfv+rvjVnafjo BXT312JNMyKAWbXJU34fuXTulpP5Z4clAzfut06recVxLGZtgpmc2irbEMJ/LCFA+QsZ qR0fgUh2vWX6FKOaNU28WTD+lVEvLKyYhnj8kJ3Ces1fhg4Ogtva46Ap1lTBwlT2EnRj ogMRt+IYm9tGyoHlIyJeJtFhvg3WptRezZxig6PHJtE48w7vqe+FkqXRHhrqm4HHiOkD HOxw== ARC-Authentication-Results: i=1; mx.google.com; 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 e13-v6si2163626pln.750.2018.02.23.11.03.56; Fri, 23 Feb 2018 11:04:10 -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; 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 S935693AbeBWTCQ (ORCPT + 99 others); Fri, 23 Feb 2018 14:02:16 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:50674 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965664AbeBWS6r (ORCPT ); Fri, 23 Feb 2018 13:58:47 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 101D01183; Fri, 23 Feb 2018 18:58:46 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kamil Konieczny , Anand Moon , Krzysztof Kozlowski , Herbert Xu Subject: [PATCH 4.15 42/45] crypto: s5p-sss - Fix kernel Oops in AES-ECB mode Date: Fri, 23 Feb 2018 19:29:21 +0100 Message-Id: <20180223170722.083625911@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180223170715.197760019@linuxfoundation.org> References: <20180223170715.197760019@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Kamil Konieczny commit c927b080c67e3e97193c81fc1d27f4251bf4e036 upstream. In AES-ECB mode crypt is done with key only, so any use of IV can cause kernel Oops. Use IV only in AES-CBC and AES-CTR. Signed-off-by: Kamil Konieczny Reported-by: Anand Moon Reviewed-by: Krzysztof Kozlowski Tested-by: Anand Moon Cc: stable@vger.kernel.org # can be applied after commit 8f9702aad138 Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- drivers/crypto/s5p-sss.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) --- a/drivers/crypto/s5p-sss.c +++ b/drivers/crypto/s5p-sss.c @@ -1926,15 +1926,21 @@ static void s5p_aes_crypt_start(struct s uint32_t aes_control; unsigned long flags; int err; + u8 *iv; aes_control = SSS_AES_KEY_CHANGE_MODE; if (mode & FLAGS_AES_DECRYPT) aes_control |= SSS_AES_MODE_DECRYPT; - if ((mode & FLAGS_AES_MODE_MASK) == FLAGS_AES_CBC) + if ((mode & FLAGS_AES_MODE_MASK) == FLAGS_AES_CBC) { aes_control |= SSS_AES_CHAIN_MODE_CBC; - else if ((mode & FLAGS_AES_MODE_MASK) == FLAGS_AES_CTR) + iv = req->info; + } else if ((mode & FLAGS_AES_MODE_MASK) == FLAGS_AES_CTR) { aes_control |= SSS_AES_CHAIN_MODE_CTR; + iv = req->info; + } else { + iv = NULL; /* AES_ECB */ + } if (dev->ctx->keylen == AES_KEYSIZE_192) aes_control |= SSS_AES_KEY_SIZE_192; @@ -1965,7 +1971,7 @@ static void s5p_aes_crypt_start(struct s goto outdata_error; SSS_AES_WRITE(dev, AES_CONTROL, aes_control); - s5p_set_aes(dev, dev->ctx->aes_key, req->info, dev->ctx->keylen); + s5p_set_aes(dev, dev->ctx->aes_key, iv, dev->ctx->keylen); s5p_set_dma_indata(dev, dev->sg_src); s5p_set_dma_outdata(dev, dev->sg_dst);