Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2654261pxa; Mon, 17 Aug 2020 15:37:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwHM/s0BTJ0tLwAcLP8D5mMEp2oBCs8AN254EubyjxoErIdvMX9d/1sE4Th2kT+PSsPdYyE X-Received: by 2002:a17:906:c1d7:: with SMTP id bw23mr18066523ejb.315.1597703844016; Mon, 17 Aug 2020 15:37:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597703844; cv=none; d=google.com; s=arc-20160816; b=K6JsOGG5FarY7OeZSb7e/1ir9do9KfHirifVP8itWRxDKiavusFmzmjY4/yMIm7/FQ gceHP+5O1f05bQONvApSWH60xFeDypMeUcVS6ba33WNl+Poj+Uykcug2z+3i0JnHieuZ IbCUQfPxdJhpUTIwL7jDlt1FXRtrxZ7SAZgHALQh7QjueKjwlA2/Pb7dl4pqsU373Ibz 4zGTG2LdMMsG8DFQl7pzWA5+4STlvlU4sYV4uGLhlmuvGYs/nKuoSU2Q4nRYLnJqZrbs ZaegbgmcGGYC/xoEFbzstLPIVxW5r0kR70rVWU7Nr1F3nF2K2j4zbxtDTjBPjXp/PXVk bWJQ== 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=x5SG7/+f+HxYEobi1dI4CC0mJQoJHiWdwrHKPdY5R4A=; b=wE2oR9dhwLL5jKQHFnI3pgS/SuWctzC0nlTUNf+qV8wrrc6y1fXSd+4m/Jk+vGOcTp YN+VTRx+irKYk0wEaj8wmDakxsT27RyHoaaOl6/IkpwAfeSFiyJ7In82RvM2CY9Bhm3F mXMKmgcT0gJAJr8FoTTe61InVlIaO6M0dOyw80aSTceTFiDb/VPHPRt5aV+LSbOsmOSd GcZeAFxodr/Uqs4R8uBYKPZoVH1WShvlEhdkLSyHN/oq1Oaz2upZDj9dlXJRWbVvdafm 0/RUv1Jb9qQkh8KgDtyFTc6oRlsPMDEdSubtwTTqe6ePq7Mq4NZHXXBKvd5q2fgogxjs Yvhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HelnaL+R; 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 t22si11923565ejy.466.2020.08.17.15.37.00; Mon, 17 Aug 2020 15:37:24 -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=HelnaL+R; 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 S2387960AbgHQRht (ORCPT + 99 others); Mon, 17 Aug 2020 13:37:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:55382 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731131AbgHQQRN (ORCPT ); Mon, 17 Aug 2020 12:17:13 -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 9F1CC207DE; Mon, 17 Aug 2020 16:16:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597681011; bh=6DHbHLVvao1IOlB/zt8+RprsouiSiHG/qkIEQ1H8n/k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HelnaL+RM3F+4oac+7zzOXqQzpWhQYkd2nAIkz6E16dTP33/swpCKKIvti3KgG6pN m0DQ5okmutpx8D4pIEOGElderr+qI0bXRwy/VhHJIsc+beDtxfU72JtN76wyOyQcCU RhVYEfBP5nri/AsGh0FX/8k1pb+aCSHNZ+GHGv84= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mikulas Patocka , Herbert Xu Subject: [PATCH 4.19 148/168] crypto: cpt - dont sleep of CRYPTO_TFM_REQ_MAY_SLEEP was not specified Date: Mon, 17 Aug 2020 17:17:59 +0200 Message-Id: <20200817143741.059298855@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143733.692105228@linuxfoundation.org> References: <20200817143733.692105228@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 @@ -205,6 +205,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 @@ -136,7 +136,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; @@ -153,7 +153,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; @@ -170,7 +170,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; @@ -198,7 +198,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; @@ -434,7 +434,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; @@ -456,7 +456,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 @@ -65,6 +65,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];