Received: by 10.223.185.116 with SMTP id b49csp1040298wrg; Fri, 23 Feb 2018 10:49:51 -0800 (PST) X-Google-Smtp-Source: AH8x227crRq9+9ZxziPT66NuCYPOzPXFylHhlc9yWNUTunMzGL8h1hYQ5fNR15BHDNuwCBax/y5J X-Received: by 10.101.80.132 with SMTP id r4mr2153107pgp.185.1519411791527; Fri, 23 Feb 2018 10:49:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519411791; cv=none; d=google.com; s=arc-20160816; b=Fd0sCAVF3rdf9RGgyFazqvwdf6e5dDocso5tdMbHvEenQP2stYysKb3CDWzQAjLb7F NufAs14EGLMDuCNEg0XiIdQVYGbTc3MVCHakja5ynohQ5stXeLhri+fYIFTke2dS2ydg 41rrAiybRWyCq6Q96rQYL84sepE356Bi/VtO70qbKg6AXEyJvBs8bNY1326bmLm+UyjZ Y/Ic/PwQvIMGwB0cRqe5UjF/9uJ61eoHHJko3z65HUpr/Mnbl0KYBMahduaBMnDaJAPL NU6Wmcuv1BNe2hLuX7aKyCMtY/Uqg9+0HroycYm7ufCdoC+nvVq1Y28nrf1rG+F5tylA /ecg== 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=iNa7WMsRJL+x5K85d3g9ha9ufWGQuQz5IwwjmIzejxA=; b=r68oCVrUGOrTFU6aTka5aR9c0GeEiganoxxvWPZ4+ShPuO+t3rD5dxqzxq3Vv8T1ee JQjopczeq3RCmyUTKUcvE8VA0nX8wzgHGcwWyD6PXgISX9ZgeP5mtu0zLO5UTquu3RbH IxadJn4JzrrtIRYn5ghrJLK5rcyJtIW03XzYiKCpVvMVmB5hK0snFEXqK7tL31+iaN4P wv4Dz05oyT/jGwQPol4SWI1K1MXsYJMso2uDUJYiE37eDtOOV333qsl1LtztchR6bTPQ 7Y2yKTE+f/dCBlVMb4+rsYA7NR/qusv/sfCIYyOaFyXXMuSHPwvID4hvL68sTGS9YPw/ TygA== 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 b10-v6si2129678plz.484.2018.02.23.10.49.37; Fri, 23 Feb 2018 10:49:51 -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 S934473AbeBWSs5 (ORCPT + 99 others); Fri, 23 Feb 2018 13:48:57 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:45098 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933827AbeBWSs4 (ORCPT ); Fri, 23 Feb 2018 13:48:56 -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 7C9931104; Fri, 23 Feb 2018 18:48:55 +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.9 145/145] crypto: s5p-sss - Fix kernel Oops in AES-ECB mode Date: Fri, 23 Feb 2018 19:27:31 +0100 Message-Id: <20180223170743.408530272@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180223170724.669759283@linuxfoundation.org> References: <20180223170724.669759283@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.9-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 @@ -542,15 +542,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; @@ -581,7 +587,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);