From patchwork Tue Jan 15 13:43:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 155667 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4907440jaa; Tue, 15 Jan 2019 05:44:23 -0800 (PST) X-Google-Smtp-Source: ALg8bN7FACxq0ujTNeyEPAV0tcAEflqMVEbkn+XUw0bWS212+CImBLFthkkZ6To2oyj2XPzyqRjg X-Received: by 2002:a63:cd4c:: with SMTP id a12mr4023729pgj.252.1547559863241; Tue, 15 Jan 2019 05:44:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547559863; cv=none; d=google.com; s=arc-20160816; b=fI4Sb98DOJTYK/fiyQwsqw5NwLUU3HTTavRTEe7CTwyj0HeurRbXdYeNZTCPNhJ/Po 6npSqs8+5Jkd6RQvv6/cxQ6Aj0rAR/RstZJKlnn3kWZ9A6hEUT4DoJlkfzpCC4kK4CST cuK5YnaryVmsoCYDjmd1PgzvXwRuIbEhDXlKHpOh2gfpa4+tb03ODnr6/lJx/rvfEoMB WuENVgdN6NSIyYhFws/CnNrCnZH7vn/NADWzCKMmNRLfglC8yG0yZhEfSHssVW2G0ZKQ OkVGt5sXRgfnMSIrkGgeGS01pk/VW95+2fOpXx5tjI1lN1iFC5GSuwitmk9d+5J47I10 f8bg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=kQ6Bs3LgW8JMojGuX1e7BnS3H+dwKIpQz9Z7XRKrZaQ=; b=0+0aPaFb71bJCvVr+Pqr72FDDYwL4FGzuOkbbvo8QSN3WSVkxwsRzLqqmRSicMudqL hfMVV6yL1IivKOC0P+IomhFWVK6sXfsTDEtm5XFVC5kgXFo35mDoT7NotSUsSoOcKUZd 3IBqi6fE3xjYJhvlhhXin9HyjynQTRKtbA6ibvA5T6VQJbdbKLByoc+AuRLhe6DbRYRb tNRQJsOWNizIHudAmjitKKww5odNk4UYfNZUhg4IZhx5QI8TsnBsvqJhaii+LPQAGlKw RSjMszlRDCndrOcbSgUWn23pNJBBtk4Jetrvs81kO9ykM7kulhVCJt+iKvzUvmZGZ13g h4ng== 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 11si3257793pgy.408.2019.01.15.05.44.22; Tue, 15 Jan 2019 05:44:23 -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 S1729861AbfAONni (ORCPT + 31 others); Tue, 15 Jan 2019 08:43:38 -0500 Received: from foss.arm.com ([217.140.101.70]:50726 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729844AbfAONng (ORCPT ); Tue, 15 Jan 2019 08:43:36 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1773915AB; Tue, 15 Jan 2019 05:43:36 -0800 (PST) Received: from e110176-lin.kfn.arm.com (e110176-lin.kfn.arm.com [10.50.4.178]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 55E1A3F70D; Tue, 15 Jan 2019 05:43:34 -0800 (PST) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" Cc: Hadar Gat , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/7] crypto: ccree: improve error handling Date: Tue, 15 Jan 2019 15:43:11 +0200 Message-Id: <20190115134318.28712-2-gilad@benyossef.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190115134318.28712-1-gilad@benyossef.com> References: <20190115134318.28712-1-gilad@benyossef.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hadar Gat pass the returned error code to the higher level functions Signed-off-by: Hadar Gat Signed-off-by: Gilad Ben-Yossef --- drivers/crypto/ccree/cc_buffer_mgr.c | 74 +++++++++++++--------------- 1 file changed, 35 insertions(+), 39 deletions(-) -- 2.20.1 diff --git a/drivers/crypto/ccree/cc_buffer_mgr.c b/drivers/crypto/ccree/cc_buffer_mgr.c index dd948e1df9e5..32d2df36ced2 100644 --- a/drivers/crypto/ccree/cc_buffer_mgr.c +++ b/drivers/crypto/ccree/cc_buffer_mgr.c @@ -511,10 +511,8 @@ int cc_map_cipher_request(struct cc_drvdata *drvdata, void *ctx, /* Map the src SGL */ rc = cc_map_sg(dev, src, nbytes, DMA_BIDIRECTIONAL, &req_ctx->in_nents, LLI_MAX_NUM_OF_DATA_ENTRIES, &dummy, &mapped_nents); - if (rc) { - rc = -ENOMEM; + if (rc) goto cipher_exit; - } if (mapped_nents > 1) req_ctx->dma_buf_type = CC_DMA_BUF_MLLI; @@ -528,12 +526,11 @@ int cc_map_cipher_request(struct cc_drvdata *drvdata, void *ctx, } } else { /* Map the dst sg */ - if (cc_map_sg(dev, dst, nbytes, DMA_BIDIRECTIONAL, - &req_ctx->out_nents, LLI_MAX_NUM_OF_DATA_ENTRIES, - &dummy, &mapped_nents)) { - rc = -ENOMEM; + rc = cc_map_sg(dev, dst, nbytes, DMA_BIDIRECTIONAL, + &req_ctx->out_nents, LLI_MAX_NUM_OF_DATA_ENTRIES, + &dummy, &mapped_nents); + if (rc) goto cipher_exit; - } if (mapped_nents > 1) req_ctx->dma_buf_type = CC_DMA_BUF_MLLI; @@ -1078,10 +1075,8 @@ static int cc_aead_chain_data(struct cc_drvdata *drvdata, &areq_ctx->dst.nents, LLI_MAX_NUM_OF_DATA_ENTRIES, &dst_last_bytes, &dst_mapped_nents); - if (rc) { - rc = -ENOMEM; + if (rc) goto chain_data_exit; - } } dst_mapped_nents = cc_get_sgl_nents(dev, req->dst, size_for_map, @@ -1235,11 +1230,10 @@ int cc_map_aead_request(struct cc_drvdata *drvdata, struct aead_request *req) } areq_ctx->ccm_iv0_dma_addr = dma_addr; - if (cc_set_aead_conf_buf(dev, areq_ctx, areq_ctx->ccm_config, - &sg_data, req->assoclen)) { - rc = -ENOMEM; + rc = cc_set_aead_conf_buf(dev, areq_ctx, areq_ctx->ccm_config, + &sg_data, req->assoclen); + if (rc) goto aead_map_failure; - } } if (areq_ctx->cipher_mode == DRV_CIPHER_GCTR) { @@ -1299,10 +1293,8 @@ int cc_map_aead_request(struct cc_drvdata *drvdata, struct aead_request *req) (LLI_MAX_NUM_OF_ASSOC_DATA_ENTRIES + LLI_MAX_NUM_OF_DATA_ENTRIES), &dummy, &mapped_nents); - if (rc) { - rc = -ENOMEM; + if (rc) goto aead_map_failure; - } if (areq_ctx->is_single_pass) { /* @@ -1386,6 +1378,7 @@ int cc_map_hash_request_final(struct cc_drvdata *drvdata, void *ctx, struct mlli_params *mlli_params = &areq_ctx->mlli_params; struct buffer_array sg_data; struct buff_mgr_handle *buff_mgr = drvdata->buff_mgr_handle; + int rc = 0; u32 dummy = 0; u32 mapped_nents = 0; @@ -1405,18 +1398,18 @@ int cc_map_hash_request_final(struct cc_drvdata *drvdata, void *ctx, /*TODO: copy data in case that buffer is enough for operation */ /* map the previous buffer */ if (*curr_buff_cnt) { - if (cc_set_hash_buf(dev, areq_ctx, curr_buff, *curr_buff_cnt, - &sg_data)) { - return -ENOMEM; - } + rc = cc_set_hash_buf(dev, areq_ctx, curr_buff, *curr_buff_cnt, + &sg_data); + if (rc) + return rc; } if (src && nbytes > 0 && do_update) { - if (cc_map_sg(dev, src, nbytes, DMA_TO_DEVICE, - &areq_ctx->in_nents, LLI_MAX_NUM_OF_DATA_ENTRIES, - &dummy, &mapped_nents)) { + rc = cc_map_sg(dev, src, nbytes, DMA_TO_DEVICE, + &areq_ctx->in_nents, LLI_MAX_NUM_OF_DATA_ENTRIES, + &dummy, &mapped_nents); + if (rc) goto unmap_curr_buff; - } if (src && mapped_nents == 1 && areq_ctx->data_dma_buf_type == CC_DMA_BUF_NULL) { memcpy(areq_ctx->buff_sg, src, @@ -1435,7 +1428,8 @@ int cc_map_hash_request_final(struct cc_drvdata *drvdata, void *ctx, /* add the src data to the sg_data */ cc_add_sg_entry(dev, &sg_data, areq_ctx->in_nents, src, nbytes, 0, true, &areq_ctx->mlli_nents); - if (cc_generate_mlli(dev, &sg_data, mlli_params, flags)) + rc = cc_generate_mlli(dev, &sg_data, mlli_params, flags); + if (rc) goto fail_unmap_din; } /* change the buffer index for the unmap function */ @@ -1451,7 +1445,7 @@ int cc_map_hash_request_final(struct cc_drvdata *drvdata, void *ctx, if (*curr_buff_cnt) dma_unmap_sg(dev, areq_ctx->buff_sg, 1, DMA_TO_DEVICE); - return -ENOMEM; + return rc; } int cc_map_hash_request_update(struct cc_drvdata *drvdata, void *ctx, @@ -1470,6 +1464,7 @@ int cc_map_hash_request_update(struct cc_drvdata *drvdata, void *ctx, struct buffer_array sg_data; struct buff_mgr_handle *buff_mgr = drvdata->buff_mgr_handle; unsigned int swap_index = 0; + int rc = 0; u32 dummy = 0; u32 mapped_nents = 0; @@ -1514,21 +1509,21 @@ int cc_map_hash_request_update(struct cc_drvdata *drvdata, void *ctx, } if (*curr_buff_cnt) { - if (cc_set_hash_buf(dev, areq_ctx, curr_buff, *curr_buff_cnt, - &sg_data)) { - return -ENOMEM; - } + rc = cc_set_hash_buf(dev, areq_ctx, curr_buff, *curr_buff_cnt, + &sg_data); + if (rc) + return rc; /* change the buffer index for next operation */ swap_index = 1; } if (update_data_len > *curr_buff_cnt) { - if (cc_map_sg(dev, src, (update_data_len - *curr_buff_cnt), - DMA_TO_DEVICE, &areq_ctx->in_nents, - LLI_MAX_NUM_OF_DATA_ENTRIES, &dummy, - &mapped_nents)) { + rc = cc_map_sg(dev, src, (update_data_len - *curr_buff_cnt), + DMA_TO_DEVICE, &areq_ctx->in_nents, + LLI_MAX_NUM_OF_DATA_ENTRIES, &dummy, + &mapped_nents); + if (rc) goto unmap_curr_buff; - } if (mapped_nents == 1 && areq_ctx->data_dma_buf_type == CC_DMA_BUF_NULL) { /* only one entry in the SG and no previous data */ @@ -1548,7 +1543,8 @@ int cc_map_hash_request_update(struct cc_drvdata *drvdata, void *ctx, cc_add_sg_entry(dev, &sg_data, areq_ctx->in_nents, src, (update_data_len - *curr_buff_cnt), 0, true, &areq_ctx->mlli_nents); - if (cc_generate_mlli(dev, &sg_data, mlli_params, flags)) + rc = cc_generate_mlli(dev, &sg_data, mlli_params, flags); + if (rc) goto fail_unmap_din; } areq_ctx->buff_index = (areq_ctx->buff_index ^ swap_index); @@ -1562,7 +1558,7 @@ int cc_map_hash_request_update(struct cc_drvdata *drvdata, void *ctx, if (*curr_buff_cnt) dma_unmap_sg(dev, areq_ctx->buff_sg, 1, DMA_TO_DEVICE); - return -ENOMEM; + return rc; } void cc_unmap_hash_request(struct device *dev, void *ctx, From patchwork Tue Jan 15 13:43:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 155661 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4906830jaa; Tue, 15 Jan 2019 05:43:45 -0800 (PST) X-Google-Smtp-Source: ALg8bN4Eir/5j0ICUCuZf+vxyuky/Jy/85vC60TambCjNe/QBdLbgbqVDPbBgQPKZwciRYRdbOCZ X-Received: by 2002:a17:902:7201:: with SMTP id ba1mr4172749plb.105.1547559824993; Tue, 15 Jan 2019 05:43:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547559824; cv=none; d=google.com; s=arc-20160816; b=UgbF1JiUJO4m3sWsmKwBfgo3ep8ojjDH/okvKItDSjfm53lGP2SJLUxgw5YGh/NjiZ yAxaed5crU2E8YwW670DplmlcdWnswpyXF6FzvtiUNkilUz/SRvxioNnkERa1TP94ZyA 7NtXpzd5x7sHE20d4Lh57rpa89aOKonokJ4fT38W/ci+WE1Ht2GG8IboDGEMyhAUhGpN CvaC6PF3qQpTY7n4uxurWoKvSkvblBS23lCrlSeBaI6OwYprDv1qCFtJBFNjF0g2+Fuq e9FvuOvY0Sz87TWOWz/g58l8Z8sU77o9cnKfYqxiF1vol4rmgodxFAp60MpJZVYPFPn2 O82g== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=qC1Casu27NFS6or0Ka1NITjp0xAjlYvECFcNRcq9Fmc=; b=NSLuYq1DDwYPR2Bz9dsAJHdxTJXcTz5DB/SNeG93u1M95ID9co+6s2F8sLANSiRYkH qeaxKyPbOo2R9dA82B6srjCwHlaY4AGDMwYzLIqo2shFMFrneS0ujVQ/b3lxN8AMzQ5y 7UTqkwdH2UejRHhMtXsI7SVI5UCNy6BOm98RQX/NyBiMmH8epTnRgJt+mvQ1C0lMvA/5 jHTmiY4LlHcPuMJt92CGl+zg8GYh/sRfIOGprp/QAi/RBSntSysbiFspZpoyARHuDcwM 4Dv/ClqjaQ35v9WmlflZ46wHBTMAQ2eV9/fv3hfB7RZE9+PkN5r52xu0ulV6pNNRAhm5 SoWw== 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 f17si3240163pgj.208.2019.01.15.05.43.44; Tue, 15 Jan 2019 05:43:44 -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 S1729892AbfAONnn (ORCPT + 31 others); Tue, 15 Jan 2019 08:43:43 -0500 Received: from foss.arm.com ([217.140.101.70]:50746 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729245AbfAONnl (ORCPT ); Tue, 15 Jan 2019 08:43:41 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4F843A78; Tue, 15 Jan 2019 05:43:41 -0800 (PST) Received: from e110176-lin.kfn.arm.com (e110176-lin.kfn.arm.com [10.50.4.178]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 905783F70D; Tue, 15 Jan 2019 05:43:39 -0800 (PST) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" Cc: Hadar Gat , stable@vger.kernel.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/7] crypto: ccree: fix free of unallocated mlli buffer Date: Tue, 15 Jan 2019 15:43:13 +0200 Message-Id: <20190115134318.28712-4-gilad@benyossef.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190115134318.28712-1-gilad@benyossef.com> References: <20190115134318.28712-1-gilad@benyossef.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hadar Gat In cc_unmap_aead_request(), call dma_pool_free() for mlli buffer only if an item is allocated from the pool and not always if there is a pool allocated. This fixes a kernel panic when trying to free a non-allocated item. Cc: stable@vger.kernel.org Signed-off-by: Hadar Gat Signed-off-by: Gilad Ben-Yossef --- drivers/crypto/ccree/cc_buffer_mgr.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) -- 2.20.1 diff --git a/drivers/crypto/ccree/cc_buffer_mgr.c b/drivers/crypto/ccree/cc_buffer_mgr.c index 237a87a57830..0ee1c52da0a4 100644 --- a/drivers/crypto/ccree/cc_buffer_mgr.c +++ b/drivers/crypto/ccree/cc_buffer_mgr.c @@ -614,10 +614,10 @@ void cc_unmap_aead_request(struct device *dev, struct aead_request *req) hw_iv_size, DMA_BIDIRECTIONAL); } - /*In case a pool was set, a table was - *allocated and should be released - */ - if (areq_ctx->mlli_params.curr_pool) { + /* Release pool */ + if ((areq_ctx->assoc_buff_type == CC_DMA_BUF_MLLI || + areq_ctx->data_buff_type == CC_DMA_BUF_MLLI) && + (areq_ctx->mlli_params.mlli_virt_addr)) { dev_dbg(dev, "free MLLI buffer: dma=%pad virt=%pK\n", &areq_ctx->mlli_params.mlli_dma_addr, areq_ctx->mlli_params.mlli_virt_addr); From patchwork Tue Jan 15 13:43:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 155665 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4907083jaa; Tue, 15 Jan 2019 05:44:02 -0800 (PST) X-Google-Smtp-Source: ALg8bN7GpMfCKLNuaQ2w52gPWJ+MWI6YU5URXTLEv1Sot4R6552mQa6gZy3bwYy2vwWXSf1zbUIF X-Received: by 2002:a63:3e05:: with SMTP id l5mr3745641pga.96.1547559842192; Tue, 15 Jan 2019 05:44:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547559842; cv=none; d=google.com; s=arc-20160816; b=wbgf/N/d0/IJ7VxZtgsRhhY+zb26XLFZgx/jFu1wm0FOxTirkqo3OSyjl6lPCrCAbc MsLxp+Sohhhz10Kh8ciDDWL8qlNefsRK5tVj24XTI3YeG621Et0iXCyxmbEmliv18mfH Kf8/WzAcE88zaaRxdyFO5021A2vnOS01Yg1YTSWlt+jTzl9NAvBLJ0ylvSQOIa4BSCtR b8gcW+m+rAP/TIh6taKXF7QaEB028VSoMVoUdWa9mKLejF579xmFat06zuxTWrtDGYu8 BX6cDaunIutj/zgKFVkFqpEh6rU1XimqmIJhmwj33q8kPL/jzLUjnEZ/msb8EW9aqXi4 fm3w== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=YMkA2O+1SjXE7a0G/vCnA6dYImm8sYTUf2i8Pj/htP8=; b=EE+TrI70IYwHpxn//3O4Oz9HAEzDDGdh+8JLrdNqZ8/2wT53lSpfKlRx1nZqN3VGfr gCPAAy+lQNUoUd1gXEnae081X7386VD/CHc7YGLIX5RuEOogpRKN7QHcCfVb59H7ux2E PDqWihxlz0MHKwXy7LTDKGDqJNYKFKrL+Eaj5nKrukWWLocFTAVHrmMQNGyjFfLFU3O0 1rg1dQqb16dZJwIXtJKFHG30RBThsy7gibVvaclz1DfvxIOLSkmn/vv/QkEjol8VyRRZ WMlzBbgh9Nag80opxrfh8ejKFqle6/+Vp0oAFyQbwMFBXLTmoCuuzs9xbp4DaY8EIcT8 WmQg== 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 l17si2945844pfd.236.2019.01.15.05.44.01; Tue, 15 Jan 2019 05:44:02 -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 S1729924AbfAONnu (ORCPT + 31 others); Tue, 15 Jan 2019 08:43:50 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:50760 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729901AbfAONnq (ORCPT ); Tue, 15 Jan 2019 08:43:46 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4A3EFA78; Tue, 15 Jan 2019 05:43:46 -0800 (PST) Received: from e110176-lin.kfn.arm.com (e110176-lin.kfn.arm.com [10.50.4.178]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BEA853F70D; Tue, 15 Jan 2019 05:43:44 -0800 (PST) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" Cc: stable@vger.kernel.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/7] crypto: ccree: unmap buffer before copying IV Date: Tue, 15 Jan 2019 15:43:15 +0200 Message-Id: <20190115134318.28712-6-gilad@benyossef.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190115134318.28712-1-gilad@benyossef.com> References: <20190115134318.28712-1-gilad@benyossef.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We were copying the last ciphertext block into the IV field for CBC before removing the DMA mapping of the output buffer with the result of the buffer sometime being out-of-sync cache wise and were getting intermittent cases of bad output IV. Fix it by moving the DMA buffer unmapping before the copy. Signed-off-by: Gilad Ben-Yossef Fixes: 00904aa0cd59 ("crypto: ccree - fix iv handling") Cc: --- drivers/crypto/ccree/cc_cipher.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) -- 2.20.1 diff --git a/drivers/crypto/ccree/cc_cipher.c b/drivers/crypto/ccree/cc_cipher.c index cc92b031fad1..98ea53524250 100644 --- a/drivers/crypto/ccree/cc_cipher.c +++ b/drivers/crypto/ccree/cc_cipher.c @@ -652,6 +652,8 @@ static void cc_cipher_complete(struct device *dev, void *cc_req, int err) unsigned int ivsize = crypto_skcipher_ivsize(sk_tfm); unsigned int len; + cc_unmap_cipher_request(dev, req_ctx, ivsize, src, dst); + switch (ctx_p->cipher_mode) { case DRV_CIPHER_CBC: /* @@ -681,7 +683,6 @@ static void cc_cipher_complete(struct device *dev, void *cc_req, int err) break; } - cc_unmap_cipher_request(dev, req_ctx, ivsize, src, dst); kzfree(req_ctx->iv); skcipher_request_complete(req, err); From patchwork Tue Jan 15 13:43:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gilad Ben-Yossef X-Patchwork-Id: 155664 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp4907039jaa; Tue, 15 Jan 2019 05:43:59 -0800 (PST) X-Google-Smtp-Source: ALg8bN6Ug7C4T1NUkk0TY8/VsByua3gWjyPeorQ5/lngfh84eONiMZevUjv//30X2ooWnbm7L5IO X-Received: by 2002:a62:be0c:: with SMTP id l12mr4026939pff.51.1547559839385; Tue, 15 Jan 2019 05:43:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547559839; cv=none; d=google.com; s=arc-20160816; b=bSqost6cSfHVRdohOEsLo7Wu1AnB0C00SmZkxmZR0gwCXl4u79aAiFRRCJeY0LBrKW fhA3tt3Kj0nR7XacA30nstxwf0eGenj0u1RsTIWuYvpAO30DowC7nxWVrIIcCOl5zVJ8 C5HKpXxQfVQUVtE5fTvl82IoZGF5a6V5/kJa4Q5J7FKuXO/LSMtUKmpM2J43LhxnKPQX zjpuB2ip3ZV1CTaajmsPg3PaCTPYubt4/NpxRVJAH6m4N5gDZq276yBHw6AnFOZRBi9A tHrXjc/sP2Vuk4ZImnFdpbDo0xdOT7+uxI5rAZ0UBtzD1H7eTq4skEvZvj0qf3EmF/u4 pSJg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from; bh=OLWGgWUAXV4+NRnPf2nYT9l1zhiwjTptWj5S11i8zNk=; b=hstcOfxpeF53unXQiK0N1ckK9m5pAR5ZMaznP3RQY4KWgQIBI1WBijpvGjmYSu4Mds H0yU+5j53nZ/HpFvl1/tqO5Y+enU06BKXlnA2IgTOAm6nqW8gCCQRtlNyhMWf0HygdC8 +86d5PAScCSnk93LZWmn0h74FgMTfo3zKYvxBRQGxRRMlZNOqXyEXsPu9QoeBxDqt6X3 xUY8jKnEUBVbtzQz5CFDxhsnhDH5fw0Yf48aFowcGzl/5oczvZdZk5a8DUfbfswScYNW 6JNaekdpMG5drD9IWUK4R0N1xt1R8VGTNqQ4bQ+/lwRTTb0zAPvwGXMjmBk9+XqtScqK nLMw== 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 l17si2945844pfd.236.2019.01.15.05.43.59; Tue, 15 Jan 2019 05:43:59 -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 S1729943AbfAONnw (ORCPT + 31 others); Tue, 15 Jan 2019 08:43:52 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:50768 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729245AbfAONns (ORCPT ); Tue, 15 Jan 2019 08:43:48 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8E2F3EBD; Tue, 15 Jan 2019 05:43:48 -0800 (PST) Received: from e110176-lin.kfn.arm.com (e110176-lin.kfn.arm.com [10.50.4.178]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 421483F70D; Tue, 15 Jan 2019 05:43:47 -0800 (PST) From: Gilad Ben-Yossef To: Herbert Xu , "David S. Miller" Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 6/7] crypto: ccree: shared irq lines are not a bug Date: Tue, 15 Jan 2019 15:43:16 +0200 Message-Id: <20190115134318.28712-7-gilad@benyossef.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190115134318.28712-1-gilad@benyossef.com> References: <20190115134318.28712-1-gilad@benyossef.com> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The ccree driver was logging an error if it got an interrupt but HW indicated nothing to do as might happen if sharing an irq line. Remove the error as this is normal and we already have a debug print for the IRR register value. Signed-off-by: Gilad Ben-Yossef --- drivers/crypto/ccree/cc_driver.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.20.1 diff --git a/drivers/crypto/ccree/cc_driver.c b/drivers/crypto/ccree/cc_driver.c index 8ada308d72ee..e75fbe7a8f84 100644 --- a/drivers/crypto/ccree/cc_driver.c +++ b/drivers/crypto/ccree/cc_driver.c @@ -103,10 +103,10 @@ static irqreturn_t cc_isr(int irq, void *dev_id) /* read the interrupt status */ irr = cc_ioread(drvdata, CC_REG(HOST_IRR)); dev_dbg(dev, "Got IRR=0x%08X\n", irr); - if (irr == 0) { /* Probably shared interrupt line */ - dev_err(dev, "Got interrupt with empty IRR\n"); + + if (irr == 0) /* Probably shared interrupt line */ return IRQ_NONE; - } + imr = cc_ioread(drvdata, CC_REG(HOST_IMR)); /* clear interrupt - must be before processing events */