Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2652226pxa; Mon, 17 Aug 2020 15:34:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwZ7rO/qD5FuMGlqFiC01H/Ofb22k5wfWGSQF5vBaCo/ehAILYxrce+j/1Vz28BKLefe6fk X-Received: by 2002:aa7:de09:: with SMTP id h9mr16862914edv.277.1597703647492; Mon, 17 Aug 2020 15:34:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597703647; cv=none; d=google.com; s=arc-20160816; b=a0kri7lFhVYildIuGWL3caBX0knWzPSRWEh/MKJakYAuwrl3EORypE6q6qvC8T7rmu b+kylyWqVjjY/JplGyq/ZLyN3ftkXuYCFr8M8immo756yd1jDEXG4dr8zUK6IlGK6MlW 58lcenxk+r89qcahk5RFlDx7O0vd7jedoftCmxCbIjTOKqCDGAjFxmByfckFQ7Lc6VYw tnCDc7t2bco+h93JmGEfSAFtemjhI1rfZq1iTJ81UehE+xpb2pAKSLkc1r9oFA04p2lm 7x4zg4eFNcyHfqqC+sm1QOXCi8ZQns06GXzxEOfjjr5pjn4JIhLS3XWTDj0sNhE/rbAP HyfA== 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=TLl2Vv34p6RUQXIF4SfGJtVz26MBkwlrx3afWihyR7g=; b=Nyl1Oy1H5Dd4op0eeXCC61hdCGxt/66qLwRca2EUWw/USQ3wOz7njSwavgx/jgqGQU oWzQfkJadbOTDSHruS+K8KZHdygsA+hbAi5a5+P30ZmxPQyDkzSdWOzFMAImc3KdkrEj o3s8ckbP8WDlHkG4SMMn/8HsFn7X/0L+c36X88R76WcFlil2sJ2rbL0IZGFVilfjsSix wsL6EAnl/9YKPuM7OgSFse121zt10tOwRdLVOcSAf/xK/AJ/zG3ZchrdRP1u+F/WmBa3 bQld6vV/lN9BKze3Bu/6lUuAci785bRIRHCrie2lMnqJytK4NR876AK/WE/dOUS+iLL1 eX0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0TCwxEav; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bv14si12689223ejb.249.2020.08.17.15.33.42; Mon, 17 Aug 2020 15:34:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0TCwxEav; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389354AbgHQRIh (ORCPT + 99 others); Mon, 17 Aug 2020 13:08:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:37854 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388573AbgHQQKu (ORCPT ); Mon, 17 Aug 2020 12:10:50 -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 8EAFB20658; Mon, 17 Aug 2020 16:10:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597680650; bh=j6itLwYHs4h1ELFjdN0Ed7FTwV28jLzTzu64XBJ+iL4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0TCwxEav7tookZI4pmwQPyzzRIgSTmRbp4pxVlmNKyU9LK3r69GhKzfs9SetZST3N vXr96kXCAogCk0pyz8aGBkU/DDNwzag0z2mxQ8/HUZLuLZUpPxHqLyxLVrLMkvjelf Bw6RDOsB83JsqbhdjiBIH6y3RZ13K9dFcihtr1R0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mikulas Patocka , Herbert Xu Subject: [PATCH 5.4 260/270] crypto: cpt - dont sleep of CRYPTO_TFM_REQ_MAY_SLEEP was not specified Date: Mon, 17 Aug 2020 17:17:41 +0200 Message-Id: <20200817143808.769592297@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143755.807583758@linuxfoundation.org> References: <20200817143755.807583758@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mikulas Patocka commit 9e27c99104707f083dccd3b4d79762859b5a0614 upstream. There is this call chain: cvm_encrypt -> cvm_enc_dec -> cptvf_do_request -> process_request -> kzalloc where we call sleeping allocator function even if CRYPTO_TFM_REQ_MAY_SLEEP was not specified. Signed-off-by: Mikulas Patocka Cc: stable@vger.kernel.org # v4.11+ Fixes: c694b233295b ("crypto: cavium - Add the Virtual Function driver for CPT") Signed-off-by: Herbert Xu Signed-off-by: Greg Kroah-Hartman --- drivers/crypto/cavium/cpt/cptvf_algs.c | 1 + drivers/crypto/cavium/cpt/cptvf_reqmanager.c | 12 ++++++------ drivers/crypto/cavium/cpt/request_manager.h | 2 ++ 3 files changed, 9 insertions(+), 6 deletions(-) --- a/drivers/crypto/cavium/cpt/cptvf_algs.c +++ b/drivers/crypto/cavium/cpt/cptvf_algs.c @@ -200,6 +200,7 @@ static inline int cvm_enc_dec(struct abl int status; memset(req_info, 0, sizeof(struct cpt_request_info)); + req_info->may_sleep = (req->base.flags & CRYPTO_TFM_REQ_MAY_SLEEP) != 0; memset(fctx, 0, sizeof(struct fc_context)); create_input_list(req, enc, enc_iv_len); create_output_list(req, enc_iv_len); --- a/drivers/crypto/cavium/cpt/cptvf_reqmanager.c +++ b/drivers/crypto/cavium/cpt/cptvf_reqmanager.c @@ -133,7 +133,7 @@ static inline int setup_sgio_list(struct /* Setup gather (input) components */ g_sz_bytes = ((req->incnt + 3) / 4) * sizeof(struct sglist_component); - info->gather_components = kzalloc(g_sz_bytes, GFP_KERNEL); + info->gather_components = kzalloc(g_sz_bytes, req->may_sleep ? GFP_KERNEL : GFP_ATOMIC); if (!info->gather_components) { ret = -ENOMEM; goto scatter_gather_clean; @@ -150,7 +150,7 @@ static inline int setup_sgio_list(struct /* Setup scatter (output) components */ s_sz_bytes = ((req->outcnt + 3) / 4) * sizeof(struct sglist_component); - info->scatter_components = kzalloc(s_sz_bytes, GFP_KERNEL); + info->scatter_components = kzalloc(s_sz_bytes, req->may_sleep ? GFP_KERNEL : GFP_ATOMIC); if (!info->scatter_components) { ret = -ENOMEM; goto scatter_gather_clean; @@ -167,7 +167,7 @@ static inline int setup_sgio_list(struct /* Create and initialize DPTR */ info->dlen = g_sz_bytes + s_sz_bytes + SG_LIST_HDR_SIZE; - info->in_buffer = kzalloc(info->dlen, GFP_KERNEL); + info->in_buffer = kzalloc(info->dlen, req->may_sleep ? GFP_KERNEL : GFP_ATOMIC); if (!info->in_buffer) { ret = -ENOMEM; goto scatter_gather_clean; @@ -195,7 +195,7 @@ static inline int setup_sgio_list(struct } /* Create and initialize RPTR */ - info->out_buffer = kzalloc(COMPLETION_CODE_SIZE, GFP_KERNEL); + info->out_buffer = kzalloc(COMPLETION_CODE_SIZE, req->may_sleep ? GFP_KERNEL : GFP_ATOMIC); if (!info->out_buffer) { ret = -ENOMEM; goto scatter_gather_clean; @@ -421,7 +421,7 @@ int process_request(struct cpt_vf *cptvf struct cpt_vq_command vq_cmd; union cpt_inst_s cptinst; - info = kzalloc(sizeof(*info), GFP_KERNEL); + info = kzalloc(sizeof(*info), req->may_sleep ? GFP_KERNEL : GFP_ATOMIC); if (unlikely(!info)) { dev_err(&pdev->dev, "Unable to allocate memory for info_buffer\n"); return -ENOMEM; @@ -443,7 +443,7 @@ int process_request(struct cpt_vf *cptvf * Get buffer for union cpt_res_s response * structure and its physical address */ - info->completion_addr = kzalloc(sizeof(union cpt_res_s), GFP_KERNEL); + info->completion_addr = kzalloc(sizeof(union cpt_res_s), req->may_sleep ? GFP_KERNEL : GFP_ATOMIC); if (unlikely(!info->completion_addr)) { dev_err(&pdev->dev, "Unable to allocate memory for completion_addr\n"); ret = -ENOMEM; --- a/drivers/crypto/cavium/cpt/request_manager.h +++ b/drivers/crypto/cavium/cpt/request_manager.h @@ -62,6 +62,8 @@ struct cpt_request_info { union ctrl_info ctrl; /* User control information */ struct cptvf_request req; /* Request Information (Core specific) */ + bool may_sleep; + struct buf_ptr in[MAX_BUF_CNT]; struct buf_ptr out[MAX_BUF_CNT];