From patchwork Mon May 20 12:14:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 164613 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp224991ili; Mon, 20 May 2019 05:29:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqxBEqyW2zvuGaGb6Ji+f9k7HvcSGJlxm8LglCXk7B2Z3XXB3j6aaFhnpf+K2wlBM1h9WCfQ X-Received: by 2002:a63:7c6:: with SMTP id 189mr74873381pgh.247.1558355357525; Mon, 20 May 2019 05:29:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558355357; cv=none; d=google.com; s=arc-20160816; b=vMQc+vYP4hGlIik2zdQtFX1mqmXGs9CzfnpAuIvlWyARlHErVuvfVPP4alPcNY14m6 WIg8LrmJY7TIbyp7ow4bZexDHUkYiHwy7oe162bHS3w5yCcYmB4Y5LvZwLs3FNz8uN5D EWAEEnj9ca1aYnMzrts7o24/PfKJ6ck9EyBAPL4tprHf5fY8/7uPUqBEcAt2/Qwp2K4F EI41C/Cu4xurBbPc5KJKwO3qnwGXYcDfsTsWTikcm9AOMTA1M2iJ2a2dYCZxQxxmA0wY otOi7tvPTxsV+PVyayiWzwc0UPIvuQKtVhX9+pA1/6B/zWsY9eAV2+XLWLkmDYDwS29N VWvw== 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=4hi58WDdbOUM/9kH+6aekOTXYHooTdZi2b7xGvjqVXg=; b=y//0c2rzUNfXZuISOPsYdBYYw41BJ/CZigCq8UgiE+dVNzqEivhqqJ2Jeg2tj4WgSL OfOvfU4lkyO81Qmv2xzmF6scjwKLZj+0mfdeWiDDN8kxksijNNGl2/tuHcltsXmj0IpD rEUyGJJAh9avLxh0bPe/nkC6qhhX6crGmzKzCS4qosXCh+xshkMXNT7pqFQw3lXSnrFn W6a5h+vHMCCKOdf3Vw4YT+wDn0IRR02BS0D/uP5mEQSFDZkH+sm8orDb2wm7tEUIzYwg 3vYVOYtu1KiE5rqzSMQIFZBFhXyjR7RLyRHEbm0gzC3YfFGVg/Lt1BF/ayXvnPPB6dfU FdFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=yTWndb4k; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 g21si17864787pgb.313.2019.05.20.05.29.17; Mon, 20 May 2019 05:29:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-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=yTWndb4k; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389264AbfETM3P (ORCPT + 14 others); Mon, 20 May 2019 08:29:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:45272 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389843AbfETM3O (ORCPT ); Mon, 20 May 2019 08:29:14 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 8E98820645; Mon, 20 May 2019 12:29:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558355354; bh=jS18uhjhZFB0J7GPa296xwoUoszjtacB5vvBJtErWs8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yTWndb4kDopFDVLmcwB1PffqwKgstb5BW6Gt484s9Xp9p7OHdCGTCnZKPQhnR7dVT 4+MiNy0qYHq6biWFMtZo62hX9dHu6OPFj/WHsASWuMIf6CnzgKprqgI0M1jBXIYIaj MJng72E+DGPzBrL8HmiL7ZXX3jvdc1wH8BuA15cw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Gilad Ben-Yossef , Herbert Xu Subject: [PATCH 5.0 060/123] crypto: ccree - dont map MAC key on stack Date: Mon, 20 May 2019 14:14:00 +0200 Message-Id: <20190520115248.773914614@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190520115245.439864225@linuxfoundation.org> References: <20190520115245.439864225@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: Gilad Ben-Yossef commit 874e163759f27e0a9988c5d1f4605e3f25564fd2 upstream. The MAC hash key might be passed to us on stack. Copy it to a slab buffer before mapping to gurantee proper DMA mapping. Signed-off-by: Gilad Ben-Yossef Cc: stable@vger.kernel.org # v4.19+ Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- drivers/crypto/ccree/cc_hash.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) --- a/drivers/crypto/ccree/cc_hash.c +++ b/drivers/crypto/ccree/cc_hash.c @@ -69,6 +69,7 @@ struct cc_hash_alg { struct hash_key_req_ctx { u32 keylen; dma_addr_t key_dma_addr; + u8 *key; }; /* hash per-session context */ @@ -730,13 +731,20 @@ static int cc_hash_setkey(struct crypto_ ctx->key_params.keylen = keylen; ctx->key_params.key_dma_addr = 0; ctx->is_hmac = true; + ctx->key_params.key = NULL; if (keylen) { + ctx->key_params.key = kmemdup(key, keylen, GFP_KERNEL); + if (!ctx->key_params.key) + return -ENOMEM; + ctx->key_params.key_dma_addr = - dma_map_single(dev, (void *)key, keylen, DMA_TO_DEVICE); + dma_map_single(dev, (void *)ctx->key_params.key, keylen, + DMA_TO_DEVICE); if (dma_mapping_error(dev, ctx->key_params.key_dma_addr)) { dev_err(dev, "Mapping key va=0x%p len=%u for DMA failed\n", - key, keylen); + ctx->key_params.key, keylen); + kzfree(ctx->key_params.key); return -ENOMEM; } dev_dbg(dev, "mapping key-buffer: key_dma_addr=%pad keylen=%u\n", @@ -887,6 +895,9 @@ out: dev_dbg(dev, "Unmapped key-buffer: key_dma_addr=%pad keylen=%u\n", &ctx->key_params.key_dma_addr, ctx->key_params.keylen); } + + kzfree(ctx->key_params.key); + return rc; } @@ -913,11 +924,16 @@ static int cc_xcbc_setkey(struct crypto_ ctx->key_params.keylen = keylen; + ctx->key_params.key = kmemdup(key, keylen, GFP_KERNEL); + if (!ctx->key_params.key) + return -ENOMEM; + ctx->key_params.key_dma_addr = - dma_map_single(dev, (void *)key, keylen, DMA_TO_DEVICE); + dma_map_single(dev, ctx->key_params.key, keylen, DMA_TO_DEVICE); if (dma_mapping_error(dev, ctx->key_params.key_dma_addr)) { dev_err(dev, "Mapping key va=0x%p len=%u for DMA failed\n", key, keylen); + kzfree(ctx->key_params.key); return -ENOMEM; } dev_dbg(dev, "mapping key-buffer: key_dma_addr=%pad keylen=%u\n", @@ -969,6 +985,8 @@ static int cc_xcbc_setkey(struct crypto_ dev_dbg(dev, "Unmapped key-buffer: key_dma_addr=%pad keylen=%u\n", &ctx->key_params.key_dma_addr, ctx->key_params.keylen); + kzfree(ctx->key_params.key); + return rc; } From patchwork Mon May 20 12:14:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 164614 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp225687ili; Mon, 20 May 2019 05:30:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqwcWIFXUCjiNzMy7j3MA/18zgI0JbFOfXH9XPlfICY5N4AOm6SxW4Uo5IEx8raVkoXdFQ3Q X-Received: by 2002:a63:fd52:: with SMTP id m18mr75515704pgj.267.1558355400662; Mon, 20 May 2019 05:30:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558355400; cv=none; d=google.com; s=arc-20160816; b=n7BfrJ7HERWn9ukAYG0ItNPf3AVVv+1w3c+1IV/n24aH+k449NQYjiksa4AgUjTkqG Uu+b/g0UeuEWUW/itaqvIM40jaxpJm+UmASFpHpjyaEAGozi/dy0xMdEwBwk9nG150GX Zme5Vxlp7AxBRf0ukw7lQydZXsH4kr8EDJBC6nnH5NZ6780By+gaIGB3TyvqmjTA5eoZ mSJbsKUuRRGoGhqFbiZx2NlPoAi0tTeFsPdW2sxrLjlli+bq5yKrBO7L98u6olZic4YN b4S5I6ysoHCtFxjSplUZdK+dW1la6fDAFlCwvoSr6fkK+12ObSGdmcwQqqMl5ivO+aYk dXcg== 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=ARw5OkX8RrRkC62uBGX0tw06kUtIzZt2Zd6J4Z/scf4=; b=qEUiWT+XbaOKkVw7bh+lqYbqF84VNsZ5EGs9OPY69stazq4T5hKxHON6F/XH0UqFjW QdFi5nI+gES0wFUEdkBxKoxdNy1nvWIXNcJ+I812feTCt/A72rbU2vQ5dEgs2m7QYiy5 QvQqpxy6l0DQat94hR/mr28Xq0UfxhtV25IGNf4P1veprZZ08h49vnCfolGqL98pn2Pw TD3AiwK4/62BHnBkh7pWVjgX6RFjMOM4ohIQyT3HpdVku5/N800kaRctOJkcemBgPeRn KqGhHBEOgoO0f/UlX1iaN0RGfRr+DctiKN8qUL/w5rDOGcuGzk7z72RUrRO3UKldKYFi aekg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=DZz3Ba05; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 186si18145232pfc.247.2019.05.20.05.30.00; Mon, 20 May 2019 05:30:00 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-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=DZz3Ba05; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389975AbfETM37 (ORCPT + 14 others); Mon, 20 May 2019 08:29:59 -0400 Received: from mail.kernel.org ([198.145.29.99]:46120 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390007AbfETM35 (ORCPT ); Mon, 20 May 2019 08:29:57 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 2CDAE20645; Mon, 20 May 2019 12:29:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558355396; bh=2TRMfZDviT4+xoulx6yedoRHajY+kmB/koE91teu8Ro=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DZz3Ba05G4fCi7W/CN8xH764Ed663rTGo9pxsATVcKGu/rJ06dtmxQIOPdmcH1f4f N2nxACrhOTvCXNbtqokg23Vii1ZrzhbN7/GlyDmEpxCMslXa/Ld/QRID9ItO9nvzrA 0XXp9DsGunVDLfCR4mVXu47qWdZk2Y8cLN2sV3Cg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Gilad Ben-Yossef , Herbert Xu Subject: [PATCH 5.0 062/123] crypto: ccree - dont map AEAD key and IV on stack Date: Mon, 20 May 2019 14:14:02 +0200 Message-Id: <20190520115248.925921091@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190520115245.439864225@linuxfoundation.org> References: <20190520115245.439864225@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: Gilad Ben-Yossef commit e8662a6a5f8f7f2cadc0edb934aef622d96ac3ee upstream. The AEAD authenc key and IVs might be passed to us on stack. Copy it to a slab buffer before mapping to gurantee proper DMA mapping. Signed-off-by: Gilad Ben-Yossef Cc: stable@vger.kernel.org # v4.19+ Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- drivers/crypto/ccree/cc_aead.c | 11 ++++++++++- drivers/crypto/ccree/cc_buffer_mgr.c | 15 ++++++++++++--- drivers/crypto/ccree/cc_driver.h | 1 + 3 files changed, 23 insertions(+), 4 deletions(-) --- a/drivers/crypto/ccree/cc_aead.c +++ b/drivers/crypto/ccree/cc_aead.c @@ -424,7 +424,7 @@ static int validate_keys_sizes(struct cc /* This function prepers the user key so it can pass to the hmac processing * (copy to intenral buffer or hash in case of key longer than block */ -static int cc_get_plain_hmac_key(struct crypto_aead *tfm, const u8 *key, +static int cc_get_plain_hmac_key(struct crypto_aead *tfm, const u8 *authkey, unsigned int keylen) { dma_addr_t key_dma_addr = 0; @@ -437,6 +437,7 @@ static int cc_get_plain_hmac_key(struct unsigned int hashmode; unsigned int idx = 0; int rc = 0; + u8 *key = NULL; struct cc_hw_desc desc[MAX_AEAD_SETKEY_SEQ]; dma_addr_t padded_authkey_dma_addr = ctx->auth_state.hmac.padded_authkey_dma_addr; @@ -455,11 +456,17 @@ static int cc_get_plain_hmac_key(struct } if (keylen != 0) { + + key = kmemdup(authkey, keylen, GFP_KERNEL); + if (!key) + return -ENOMEM; + key_dma_addr = dma_map_single(dev, (void *)key, keylen, DMA_TO_DEVICE); if (dma_mapping_error(dev, key_dma_addr)) { dev_err(dev, "Mapping key va=0x%p len=%u for DMA failed\n", key, keylen); + kzfree(key); return -ENOMEM; } if (keylen > blocksize) { @@ -542,6 +549,8 @@ static int cc_get_plain_hmac_key(struct if (key_dma_addr) dma_unmap_single(dev, key_dma_addr, keylen, DMA_TO_DEVICE); + kzfree(key); + return rc; } --- a/drivers/crypto/ccree/cc_buffer_mgr.c +++ b/drivers/crypto/ccree/cc_buffer_mgr.c @@ -560,6 +560,7 @@ void cc_unmap_aead_request(struct device if (areq_ctx->gen_ctx.iv_dma_addr) { dma_unmap_single(dev, areq_ctx->gen_ctx.iv_dma_addr, hw_iv_size, DMA_BIDIRECTIONAL); + kzfree(areq_ctx->gen_ctx.iv); } /* Release pool */ @@ -664,19 +665,27 @@ static int cc_aead_chain_iv(struct cc_dr struct aead_req_ctx *areq_ctx = aead_request_ctx(req); unsigned int hw_iv_size = areq_ctx->hw_iv_size; struct device *dev = drvdata_to_dev(drvdata); + gfp_t flags = cc_gfp_flags(&req->base); int rc = 0; if (!req->iv) { areq_ctx->gen_ctx.iv_dma_addr = 0; + areq_ctx->gen_ctx.iv = NULL; goto chain_iv_exit; } - areq_ctx->gen_ctx.iv_dma_addr = dma_map_single(dev, req->iv, - hw_iv_size, - DMA_BIDIRECTIONAL); + areq_ctx->gen_ctx.iv = kmemdup(req->iv, hw_iv_size, flags); + if (!areq_ctx->gen_ctx.iv) + return -ENOMEM; + + areq_ctx->gen_ctx.iv_dma_addr = + dma_map_single(dev, areq_ctx->gen_ctx.iv, hw_iv_size, + DMA_BIDIRECTIONAL); if (dma_mapping_error(dev, areq_ctx->gen_ctx.iv_dma_addr)) { dev_err(dev, "Mapping iv %u B at va=%pK for DMA failed\n", hw_iv_size, req->iv); + kzfree(areq_ctx->gen_ctx.iv); + areq_ctx->gen_ctx.iv = NULL; rc = -ENOMEM; goto chain_iv_exit; } --- a/drivers/crypto/ccree/cc_driver.h +++ b/drivers/crypto/ccree/cc_driver.h @@ -170,6 +170,7 @@ struct cc_alg_template { struct async_gen_req_ctx { dma_addr_t iv_dma_addr; + u8 *iv; enum drv_crypto_direction op_type; }; From patchwork Mon May 20 12:14:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 164630 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp242418ili; Mon, 20 May 2019 05:45:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqzlCshyBlzX+Kc1OOdR1LjjMDLU9L19NBMJw+TvPPJ8zJB686MdTuKhqsjVXdz1MpgQsEKw X-Received: by 2002:a63:db4e:: with SMTP id x14mr60070645pgi.119.1558356343847; Mon, 20 May 2019 05:45:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558356343; cv=none; d=google.com; s=arc-20160816; b=SRq2gkGYax3YABvD+QkUq6w7Pfoqfv2lSTvU8+mvca/4xloiYMPWEgxGg96zW6aNfd vZhn/8A/l/D+t9x9vXnt1BIu21Cdun6TETJLVyrnJ0cIxNDe5sPqjDHXivd+scGw3nXW HT7Yu6dC6dw5Rro1ZyGCmlhogkIdYBqnpLslPVRHirhGlirzvZp5gpnF8F35/cNENCxp fkdYgWxCysSfI7sORzE19XNhDslwmlH9xIvy+zlCpvmha6CQ4f18Dz8vbzd3XoBa5gxH 8XTamz/Gl3iFBOZ085V20hFA8W4E17FkS9yVdE/vtKN8n/PTUF3AFQqXhPFDKwSyLpfz dUog== 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=7VDXYu1Vil/45PCSSpHKBrSUhZb+7wVJ3dTnv4Vglp8=; b=Ogt1KlbryzIEedEboUL3quOmA29QJqXqR76WIhWNEWHxEm6Dp2pMF9n6B0D1tW7uYj 0JoTQMcZg2EcoTG2ZzXKojp93t6MitsUFMyuMODUxMddg/4DXb6wYYiGWk1P8Ope6xcs QzDc1faFVxvbdeBdx8UZjBXIgcQCINoKXeg77TGK9tjtlCBMWBoLTIT91pxMmpwDnh89 nRqgTPhGgTlTsH2oWhGavwkXBDnGWIaQt2T8FpEipw/TwxYtjyDbvKN0jvm7sFAnPt+v nQ/VOQUSQCFzq+/LS27R87S+pRebzyh/w195KT5RRUrUYeGuMmTonolqTG0q1Z2Xb5mb AxBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HSizXNwL; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 e11si12396932pgv.569.2019.05.20.05.45.42; Mon, 20 May 2019 05:45:43 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-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=HSizXNwL; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390032AbfETMmg (ORCPT + 14 others); Mon, 20 May 2019 08:42:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:46178 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390010AbfETM37 (ORCPT ); Mon, 20 May 2019 08:29:59 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 F1D9220675; Mon, 20 May 2019 12:29:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558355399; bh=Uw0pF31YOHlAKBRVzNCneThPQgBmKK3R8VVsUrLP+AI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HSizXNwLMrzv5tjiYYDJltPfFOAkrCLVw1zWp/Oq77qZ5wFjbZxTG2cO+7MqiCBBG 5ffHJHv0FxNf11C/oNNlPCqK+Fp1zQi1kS22gYAYcsCm60eBuYK35UwGYtg85d8iiW BM5ug6FOvLyeK3DAnEBtOcAUmKQjgm3+eEdz1SrU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ofir Drang , Gilad Ben-Yossef , Herbert Xu Subject: [PATCH 5.0 063/123] crypto: ccree - pm resume first enable the source clk Date: Mon, 20 May 2019 14:14:03 +0200 Message-Id: <20190520115248.994423542@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190520115245.439864225@linuxfoundation.org> References: <20190520115245.439864225@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: Ofir Drang commit 7766dd774d80463cec7b81d90c8672af91de2da1 upstream. On power management resume function first enable the device clk source to allow access to the device registers. Signed-off-by: Ofir Drang Signed-off-by: Gilad Ben-Yossef Cc: stable@vger.kernel.org # v4.19+ Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- drivers/crypto/ccree/cc_pm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/drivers/crypto/ccree/cc_pm.c +++ b/drivers/crypto/ccree/cc_pm.c @@ -42,14 +42,15 @@ int cc_pm_resume(struct device *dev) struct cc_drvdata *drvdata = dev_get_drvdata(dev); dev_dbg(dev, "unset HOST_POWER_DOWN_EN\n"); - cc_iowrite(drvdata, CC_REG(HOST_POWER_DOWN_EN), POWER_DOWN_DISABLE); - + /* Enables the device source clk */ rc = cc_clk_on(drvdata); if (rc) { dev_err(dev, "failed getting clock back on. We're toast.\n"); return rc; } + cc_iowrite(drvdata, CC_REG(HOST_POWER_DOWN_EN), POWER_DOWN_DISABLE); + rc = init_cc_regs(drvdata, false); if (rc) { dev_err(dev, "init_cc_regs (%x)\n", rc); From patchwork Mon May 20 12:14:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 164615 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp225835ili; Mon, 20 May 2019 05:30:05 -0700 (PDT) X-Google-Smtp-Source: APXvYqyjLVyJi3cbEY/YtzaP/mmJqR2v7hWmTzObcMlIMJdjIR+BW72Y2ZMwkf1GasgQbStHDLRY X-Received: by 2002:a62:7d10:: with SMTP id y16mr80044851pfc.116.1558355405507; Mon, 20 May 2019 05:30:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558355405; cv=none; d=google.com; s=arc-20160816; b=06OZoveWS1IvKusTL+Vb+SiCIW9zBJlFvqQGHATXBisFcZOSa6s30SWjubC4F8VpRT 58pso4z4Q1t1fzqlqNdULmbiumMV0FiiQHomuuIAfkDfOhNtXj6EBA2bEVA4dLutw5LD Hxq9Yv5aY4BxBjn/wL/IPXXXU25GjhBJDZyUl4CvSlLJyBVP3VWc64LOWNNr4jcGGURq 61UIpGU1C9XrCsrulBFysQ7khTLCk4xW8E0onRbKxIgEkZp3URFhNJgClPdhYuCjmzBA 3pagZ+8MavVlUS/Gq0XCeNe8D79x8UzuVIkxErYgKclHlXePYrR50puA7Px/pXUMuEmV UOOw== 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=MQsQd7JjODRrsK+dQeyghBZyBB4P818m4ncJkixtdw8=; b=fy4ScDegl6PWQOO1oirG2VNT1jayfarU3c0ObQK8Bg6J298r1C/ABT4BKM6af6/wlr SFfH4ErDcOOhtNu8Zq4vghVTkgP6/3l9sjmgBle+MPV6j+HuPCuuWKUm7oTIW5VUqI7/ EpaTUQkjdG7I+S1v0YI6MQuGW1L8mKuIXPm/TGrvSpQBLfEBxcKYhUzc0japvTmdFuMU iDT0VFwcB2ARe+fEDl/6a2HT5EOsan/kehOYTkh9vKDrMTDCu2eA+vDHXgGmbVyR+TS6 sCU6X0rAkBZrVcT1yYBa4hC7b3PyRxkeaQdU3aQOJN2wF8onmiFgdiUFkDs/flMueRJb /baA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UTYN4nPT; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 186si18145232pfc.247.2019.05.20.05.30.05; Mon, 20 May 2019 05:30:05 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-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=UTYN4nPT; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390007AbfETMaD (ORCPT + 14 others); Mon, 20 May 2019 08:30:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:46274 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390019AbfETMaC (ORCPT ); Mon, 20 May 2019 08:30:02 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 96FDD20645; Mon, 20 May 2019 12:30:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558355402; bh=N9QFeO4yQVMQCWzkv0CVm3igV/vAF6zg1t8BEEZGIbY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UTYN4nPTb3+TFBbaPSImEcS2aed5ThrLf2/uU/EKJU5ow83PFZrq+fia7916yXczw MU2Ew7UCDsLK37W9T/awlSJ5iBPR2tbJ5GVhSnlGmoinNsWtj/BHDaMtm6RajtuWyF MRez9lFPlWZDR1Do1BBwJplPY02vCkR1Q7noaQQU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ofir Drang , Gilad Ben-Yossef , Herbert Xu Subject: [PATCH 5.0 064/123] crypto: ccree - HOST_POWER_DOWN_EN should be the last CC access during suspend Date: Mon, 20 May 2019 14:14:04 +0200 Message-Id: <20190520115249.067751301@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190520115245.439864225@linuxfoundation.org> References: <20190520115245.439864225@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: Ofir Drang commit 3499efbeed39d114873267683b9e776bcb34b058 upstream. During power management suspend the driver need to prepare the device for the power down operation and as a last indication write to the HOST_POWER_DOWN_EN register which signals to the hardware that The ccree is ready for power down. Signed-off-by: Ofir Drang Signed-off-by: Gilad Ben-Yossef Cc: stable@vger.kernel.org # v4.19+ Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- drivers/crypto/ccree/cc_pm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/crypto/ccree/cc_pm.c +++ b/drivers/crypto/ccree/cc_pm.c @@ -25,13 +25,13 @@ int cc_pm_suspend(struct device *dev) int rc; dev_dbg(dev, "set HOST_POWER_DOWN_EN\n"); - cc_iowrite(drvdata, CC_REG(HOST_POWER_DOWN_EN), POWER_DOWN_ENABLE); rc = cc_suspend_req_queue(drvdata); if (rc) { dev_err(dev, "cc_suspend_req_queue (%x)\n", rc); return rc; } fini_cc_regs(drvdata); + cc_iowrite(drvdata, CC_REG(HOST_POWER_DOWN_EN), POWER_DOWN_ENABLE); cc_clk_off(drvdata); return 0; } From patchwork Mon May 20 12:14:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 164616 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp225903ili; Mon, 20 May 2019 05:30:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqz4lF5oYXykTNXfpiqgkxydbAamQ+h/719y/9xsXatpKS1+SMI9L0vLlMsyrGDWi1X+7knw X-Received: by 2002:a65:520b:: with SMTP id o11mr20948965pgp.184.1558355409533; Mon, 20 May 2019 05:30:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558355409; cv=none; d=google.com; s=arc-20160816; b=wes73KXDvEcvAa8PvtCgHdySErW+koVpH1/thwwIW5U4bRMrZGQIp0SgByN2bTuN5h MOrpGy5alivg2Wa0QzRG5Be+YKa/qtpJxMKuBULSLlmyuz4bfN/gbQen6qusFUctU1T5 LDDT0bbGtmfd3KmMPgFOqdHY1jJ4W4qihIWosxrENe8JMysdiODfMiB8zHNiAjgyiGtv z9p5kTAP1lj7+4dbjceIUjFQ0+5UH5EM/LsdZDz+Y8/NbvHhFPodXuGj1N7PbqKD+cen DKmDCKT/p2JYfxv2nhwjVAvqBvwoHaIf61h2eOV/f+J4uF7IYQY2Q0eE6IBCOZ0zvacx BfQg== 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=Bsr5lnxGn3aaW5Bh5tHhpU2uotZZ/yJORIJIhWro+k8=; b=cNEXhPbXY0h+P4ZV17Y8Evwtb5k9bbCs2o1ybuI5VmTEfg73tJc8jEQn41A4kaV3IW 43tOHtQ0+OXnWp5eHs7XgVA79h3iOznmeDf0o0HkuYA2S8tx8EQg8Wb8380mGfMtjw+l e5GUUCqK3Jr6X7a2IqMleH1R8CtsfOKgZ2Fm7c14q4auSGdquA9SgXd/rJt+vIEOfx2y QNLzpUwtoriGrj60wFPWeSjRqLUYPv/0JrvzJTaBY7xDha67pfDeuBkVOYjLL+kTQC9c 87tzjJyjQfKQGgRby87EksxZmUzoJr9+6/bF8RrNeaI0dILBWypJ9h01QpgSX+C8dxD0 bUHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=j6oMMwDJ; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 186si18145232pfc.247.2019.05.20.05.30.09; Mon, 20 May 2019 05:30:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-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=j6oMMwDJ; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390034AbfETMaI (ORCPT + 14 others); Mon, 20 May 2019 08:30:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:46370 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390030AbfETMaH (ORCPT ); Mon, 20 May 2019 08:30:07 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 C881320645; Mon, 20 May 2019 12:30:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558355407; bh=evbFVzhLxEg4SbCoKYUaCDJhdyPgsuUfMr8WxKWYoSI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j6oMMwDJCsz00d/YmJS4GtQjDApvoHtByj0eb8BzAbRMSHn1DW62LMfEyCdV2445l ITngMtbWcvGmgpOxWKSp0KtFbS9UH6gO1LKh8jvVQhLrScmy2sNNvfKTerh3NbL1ay ZyMrmXPlWGuKIVChIr9OidrxKk+dB1yN+AcixNBk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ofir Drang , Gilad Ben-Yossef , Herbert Xu Subject: [PATCH 5.0 066/123] crypto: ccree - handle tee fips error during power management resume Date: Mon, 20 May 2019 14:14:06 +0200 Message-Id: <20190520115249.216173085@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190520115245.439864225@linuxfoundation.org> References: <20190520115245.439864225@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: Ofir Drang commit 7138377ce10455b7183c6dde4b2c51b33f464c45 upstream. in order to support cryptocell tee fips error that may occurs while cryptocell ree is suspended, an cc_tee_handle_fips_error call added to the cc_pm_resume function. Signed-off-by: Ofir Drang Signed-off-by: Gilad Ben-Yossef Cc: stable@vger.kernel.org # v4.19+ Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- drivers/crypto/ccree/cc_pm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/crypto/ccree/cc_pm.c +++ b/drivers/crypto/ccree/cc_pm.c @@ -11,6 +11,7 @@ #include "cc_ivgen.h" #include "cc_hash.h" #include "cc_pm.h" +#include "cc_fips.h" #define POWER_DOWN_ENABLE 0x01 #define POWER_DOWN_DISABLE 0x00 @@ -50,12 +51,13 @@ int cc_pm_resume(struct device *dev) } cc_iowrite(drvdata, CC_REG(HOST_POWER_DOWN_EN), POWER_DOWN_DISABLE); - rc = init_cc_regs(drvdata, false); if (rc) { dev_err(dev, "init_cc_regs (%x)\n", rc); return rc; } + /* check if tee fips error occurred during power down */ + cc_tee_handle_fips_error(drvdata); rc = cc_resume_req_queue(drvdata); if (rc) {