From patchwork Mon Sep 25 15:07:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gonglei \(Arei\)" X-Patchwork-Id: 726758 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 40227CE7A96 for ; Mon, 25 Sep 2023 15:07:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232405AbjIYPHQ convert rfc822-to-8bit (ORCPT ); Mon, 25 Sep 2023 11:07:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229647AbjIYPHP (ORCPT ); Mon, 25 Sep 2023 11:07:15 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86989101; Mon, 25 Sep 2023 08:07:09 -0700 (PDT) Received: from kwepemd200001.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4RvR2Z3LZZzNnmH; Mon, 25 Sep 2023 23:03:18 +0800 (CST) Received: from dggpemm500006.china.huawei.com (7.185.36.236) by kwepemd200001.china.huawei.com (7.221.188.2) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.1258.23; Mon, 25 Sep 2023 23:07:07 +0800 Received: from dggpemm500006.china.huawei.com ([7.185.36.236]) by dggpemm500006.china.huawei.com ([7.185.36.236]) with mapi id 15.01.2507.031; Mon, 25 Sep 2023 23:07:06 +0800 From: "Gonglei (Arei)" To: Herbert Xu , "linux-crypto@vger.kernel.org" , Halil Pasic CC: Marc Hartmayer , "Michael S. Tsirkin" , Jason Wang , "virtualization@lists.linux-foundation.org" , "linux-kernel@vger.kernel.org" , "pizhenwei@bytedance.com" Subject: [PATCH] crypto: virtio-crypto: call finalize with bh disabled Thread-Topic: [PATCH] crypto: virtio-crypto: call finalize with bh disabled Thread-Index: AdnvwZyqMOU4LXJLQHSIVFGYJFXR5Q== Date: Mon, 25 Sep 2023 15:07:06 +0000 Message-ID: <1914739e2de14ed396e5674aa2d4766c@huawei.com> Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.174.149.11] MIME-Version: 1.0 X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Doing ipsec produces a spinlock recursion warning. This is due to not disabling BH during crypto completion function. Fixes: 59ca6c93387d3 ("virtio-crypto: implement RSA algorithm") Reported-by: Halil Pasic Signed-off-by: Gonglei --- drivers/crypto/virtio/virtio_crypto_akcipher_algs.c | 3 ++- drivers/crypto/virtio/virtio_crypto_skcipher_algs.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/crypto/virtio/virtio_crypto_akcipher_algs.c b/drivers/crypto/virtio/virtio_crypto_akcipher_algs.c index 2621ff8a9376..19e2898977d3 100644 --- a/drivers/crypto/virtio/virtio_crypto_akcipher_algs.c +++ b/drivers/crypto/virtio/virtio_crypto_akcipher_algs.c @@ -61,8 +61,9 @@ static void virtio_crypto_akcipher_finalize_req( vc_akcipher_req->src_buf = NULL; vc_akcipher_req->dst_buf = NULL; virtcrypto_clear_request(&vc_akcipher_req->base); - + local_bh_disable(); crypto_finalize_akcipher_request(vc_akcipher_req->base.dataq->engine, req, err); + local_bh_enable(); } static void virtio_crypto_dataq_akcipher_callback(struct virtio_crypto_request *vc_req, int len) diff --git a/drivers/crypto/virtio/virtio_crypto_skcipher_algs.c b/drivers/crypto/virtio/virtio_crypto_skcipher_algs.c index 23c41d87d835..661c1102583e 100644 --- a/drivers/crypto/virtio/virtio_crypto_skcipher_algs.c +++ b/drivers/crypto/virtio/virtio_crypto_skcipher_algs.c @@ -566,9 +566,10 @@ static void virtio_crypto_skcipher_finalize_req( AES_BLOCK_SIZE, 0); kfree_sensitive(vc_sym_req->iv); virtcrypto_clear_request(&vc_sym_req->base); - + local_bh_disable(); crypto_finalize_skcipher_request(vc_sym_req->base.dataq->engine, req, err); + local_bh_enable(); } static struct virtio_crypto_algo virtio_crypto_algs[] = { {