Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp5505426pxb; Mon, 7 Feb 2022 03:39:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJw6n5MoUDNA9U6LQEZjBeWdYmQ5U8gZWcl/hVLXfKVUuJgrp3U5lD2aM4I1LQd1omR+8k14 X-Received: by 2002:a17:902:f2c2:: with SMTP id h2mr1272863plc.2.1644233992594; Mon, 07 Feb 2022 03:39:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644233992; cv=none; d=google.com; s=arc-20160816; b=GtkS+wuq5dNM6xhbTWEJrgb8QlAexTopFFyn0BqytmrTrEHiQLDilM96i+ZEDG29D9 xWZEGUh6cQ3Ev8+Lu+8rsyCcQTVPopYEd+PywANN1y9ZDK4DDTWxZEIVTtfvfj1VoaqG D++zvb2kcwy2NOTiOnsWilvVZ9sIVutkVPjHS+j/DQBOSQdayCs5MKS1XtEECBnwsFJ2 hL2paveIaKINRTlExFCCRkBKAZ5rC27PgHbZIDYzFxUOQyU6Xkpi/t6K5JTyXV7EnPuc ugmy07PRUWATELbeNyfG6bfJWfxTFDIeGYgrq2QEC6Dc5GANiwGw1oqiCrSQG6HbP8Jn HAYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=W8usBoPeRR7PeUopf5YstHTfqdIT6ekV5U9+DPiPsuY=; b=oBykfiDzMw/V0/O3sewuI1KG0q8r+JrrXDKP9dqXiF1+uIXEmat5DKoIpgw7EGD/oh RnM8oTdFfKawsaduxkdTU6Ixl/dwwBMUpDPEb/kSyjEkNy4fGKJTLkOGbt6Pm9kmVX6n GrlHZUwBqoSJjsP1H2qVfBAu5BsQetHUbfeoznhLbmyZvtiXUFvo8oA0f5d7fDW22Aun i3mn7YrBMQYRQw+uB0Pb/Xggp46pT13zUM/0EOzpNim1H0I3Yjy+x29kTzrYtEkJmYO4 EDFUiTIJz2taXfHfT/PZQlb2xa8UI/OcJcM5EwJzo0QPo1MB7x7+SaFjUwe6CTg5Wfx1 4TrQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i10si10776896pla.449.2022.02.07.03.39.39; Mon, 07 Feb 2022 03:39:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379296AbiBEEDU (ORCPT + 99 others); Fri, 4 Feb 2022 23:03:20 -0500 Received: from helcar.hmeau.com ([216.24.177.18]:33954 "EHLO fornost.hmeau.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379299AbiBEEDT (ORCPT ); Fri, 4 Feb 2022 23:03:19 -0500 Received: from gwarestrin.arnor.me.apana.org.au ([192.168.103.7]) by fornost.hmeau.com with smtp (Exim 4.92 #5 (Debian)) id 1nGCI3-0001kj-W9; Sat, 05 Feb 2022 15:03:13 +1100 Received: by gwarestrin.arnor.me.apana.org.au (sSMTP sendmail emulation); Sat, 05 Feb 2022 15:03:11 +1100 Date: Sat, 5 Feb 2022 15:03:11 +1100 From: Herbert Xu To: Corentin Labbe Cc: davem@davemloft.net, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] crypto: engine: disable BH during completion Message-ID: References: <20220127133332.4011509-1-clabbe@baylibre.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220127133332.4011509-1-clabbe@baylibre.com> Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Thu, Jan 27, 2022 at 01:33:32PM +0000, Corentin Labbe wrote: > When doing iperf over ipsec with crypto hardware sun8i-ce, I hit some > spinlock recursion bug. > > This is due to crypto/crypto_engine not disabling BH when calling > completion function. > > Fixes: 735d37b5424b ("crypto: engine - Introduce the block request crypto engine framework") > Signed-off-by: Corentin Labbe > --- > crypto/crypto_engine.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/crypto/crypto_engine.c b/crypto/crypto_engine.c > index fb07da9920ee..b3844f6d98a3 100644 > --- a/crypto/crypto_engine.c > +++ b/crypto/crypto_engine.c > @@ -7,6 +7,7 @@ > * Author: Baolin Wang > */ > > +#include > #include > #include > #include > @@ -53,7 +54,9 @@ static void crypto_finalize_request(struct crypto_engine *engine, > dev_err(engine->dev, "failed to unprepare request\n"); > } > } > + local_bh_disable(); > req->complete(req, err); > + local_bh_enable(); Most other drivers call this function in softirq context. In general crypto API callback functions expect to be called in softirq context. So I think we should fix the driver to do the bh disable instead. However, it's probably a good idea to add a check in this spot to detect drivers that are calling this in the wrong context, e.g., lockdep_assert_in_softirq(). Thanks, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt