Received: by 10.223.185.116 with SMTP id b49csp1115297wrg; Fri, 23 Feb 2018 12:11:20 -0800 (PST) X-Google-Smtp-Source: AH8x224zF8vujBHquyPanZRloi38+gF3E7XMSQLHfS6ETMHwt7Zee7QDAOyQnsSNDuCWL5hhNCN2 X-Received: by 10.98.242.6 with SMTP id m6mr2835884pfh.230.1519416680101; Fri, 23 Feb 2018 12:11:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519416680; cv=none; d=google.com; s=arc-20160816; b=Ef4trJCroSMIvOQFJM8YJUpiSqnI8WAQLcDdGdzSoay5csuYdxnh2c1tyAghiegVP5 X8mhBG8hR8CQx4Um2RPDjmKFdOUP2TVaLtZI9PTgmYAr+yT8ZYuJvXRtVTOw4/svlIY+ 3u8eRtvDONeVHWsYKcX/FlQJQGRQV2hWjOWjEIV91na0GqukKK2gMpsg6Ldcb3unqUv5 FAhMJvx9LCHdTMb7smnhUFLt8FaeiFobtLOnxuaZaiB9ehyg6ByopIKkimAUOywC1bK1 wB1A7vh2NdUyObkSVUYJIocuukm8/tb7wA/xEAwKyB5bsL50IfMRt7o6ynSZPZpqFOIO nqIw== 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=l5tmCNOCL5ZPF8FZIxxcFUCMUVdA31MRxUkmbTMW7eo=; b=ybztGKFmPm6sQVgOCDUl33BUEjikIH3fhvP1TQ7IQ/c8Foo1brFlQegSqizBDVARWn O3mWFCLHRahhQSL8mP68+jlPDkdzhHQLSWXabq8j375R3kxNusdSmihZXWc7d8M0r6te pcMHUBCm59YCvHBhCYExiPd1O3NPaXsnKGg/PDjO63MLVRdU0xw7ymcN6uV7xxYk9zoj x8rsSMYptCadpzBlb8Nz6CMWkyG+v2ayK8FUjUdQgb1agRXJNV1dv/7yNuW77FxBi+ZK ckuQ+lpUqrF0w+SJenuGhYqAvsbdKC7WpQYOTocF8BCUvY1S2JyJVkkyQdtqRxbOTGYe Hivg== 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 i10-v6si2254540plr.670.2018.02.23.12.11.05; Fri, 23 Feb 2018 12:11:20 -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 S933268AbeBWUJu (ORCPT + 99 others); Fri, 23 Feb 2018 15:09:50 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:41392 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932991AbeBWSmK (ORCPT ); Fri, 23 Feb 2018 13:42:10 -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 0CC30707; Fri, 23 Feb 2018 18:42:09 +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.4 193/193] crypto: s5p-sss - Fix kernel Oops in AES-ECB mode Date: Fri, 23 Feb 2018 19:27:06 +0100 Message-Id: <20180223170356.654413380@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180223170325.997716448@linuxfoundation.org> References: <20180223170325.997716448@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.4-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 | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) --- a/drivers/crypto/s5p-sss.c +++ b/drivers/crypto/s5p-sss.c @@ -401,16 +401,21 @@ static void s5p_aes_crypt_start(struct s uint32_t aes_control; int err; unsigned long flags; + 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; else if (dev->ctx->keylen == AES_KEYSIZE_256) @@ -440,7 +445,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, req->src); s5p_set_dma_outdata(dev, req->dst);