Received: by 2002:a05:7412:a9a3:b0:f9:327e:43ab with SMTP id o35csp20465rdh; Mon, 18 Dec 2023 03:09:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IGCBtCvyeH56dEjLDP9k7lSHI2/jSbbugtzZQoypu8wqZ+MFbXLLZS/Pk9VcjPUNacetvI8 X-Received: by 2002:a17:906:21d:b0:a23:59ea:1065 with SMTP id 29-20020a170906021d00b00a2359ea1065mr595266ejd.55.1702897750561; Mon, 18 Dec 2023 03:09:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702897750; cv=none; d=google.com; s=arc-20160816; b=jh3EO7+ShlCPB2znwsbqTkXTPUO4Hfa5SdVaOieNbUyOD2kBmjJRefeB4lg4yttG28 wSDOS7afNhcUEUW/qel3LBNVLPywClGxk+UYB//Dh6KHPs/7D7QxCzaSCVw+h/dqtfYm dMh7VH3hDl/3RNrhmYhlY1sLpfBb3YI1wIvbeEcuZYc4/Io+peRluHA4sz/3ueRJplNa 4ceoL4LdOaPgrf71n+tEPX0q+Yxd4lJbiTH6RWGOTV/XEqAsowWlyOsJiB108xgJYLA+ NEcP4x8rsWsB8/YbAr/eAQPP1+eoi16oTXTPtunwpfebRvfIlgzoTWO4o+oVfB0K7ujL KWig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=4AQLJNbHXm9bw9mH1g4ChmY8Tt43IgcTpCwr8V+S95I=; fh=NxdYLwuN/ZwbzqfLX5yBbM1qlaLg5Atw0qZtKiMGA20=; b=XyRm1H5pWiyOVW+QyvnIfmLpdYg+aKNyINjcZW4xW7rDF1QLWIvtLmYuNZ6tjpuRm1 PTaEso8sBv+aJCyxgNDVHLqYxuKme+G/HLJApVcPX5yjUZyTTqodI7i1eucT0M/eIwzK CouJNnmK/AdHdIk3fCuHrG6OIt4QHvQ+XmsJjFCEOxr5Jmhocec7kIIvVoWwOVfy+wp5 w+wGyaPIxG54E4WdAy7OzQEJKICPg9xV/7RYtIcgTeH5ws91+eycArrJt/KnQtn1a7EA JbHMRhr2P35UHMV6vHp3/hgc35FUHO1dpnnUT6kraRHe8XroFzzXKB6WBEJrImk33hwK zfuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=kaRcdsjr; spf=pass (google.com: domain of linux-kernel+bounces-3414-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3414-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id p12-20020a17090628cc00b00a1db94ef71fsi9732819ejd.862.2023.12.18.03.09.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 03:09:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-3414-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=kaRcdsjr; spf=pass (google.com: domain of linux-kernel+bounces-3414-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-3414-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 488DE1F237CF for ; Mon, 18 Dec 2023 11:09:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8837A1A702; Mon, 18 Dec 2023 11:08:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="kaRcdsjr" X-Original-To: linux-kernel@vger.kernel.org Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 807A118E1B for ; Mon, 18 Dec 2023 11:08:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-54744e66d27so15543a12.0 for ; Mon, 18 Dec 2023 03:08:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1702897684; x=1703502484; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=4AQLJNbHXm9bw9mH1g4ChmY8Tt43IgcTpCwr8V+S95I=; b=kaRcdsjr/daU9csfk49B6e7YkDEeXe+8daoUSl4stDbgvAq4TgAR3sOUDvc/CUxE5S ur65bsf/zjpu243JziAXJ47BqFENyXH5LIqSmodfPRUIkNdYlwQdpKi6qoEOV12feCZ2 A9yKaHjw+6aPlwlH8KvMWJz8czYH3h7ofYXBEy96YX3NpLRZJUa59GVW30Pl1/+InOrR 1WNaEDuCyMi7p/smItqL/TBPlZJwriR85LaYuQ/dxZ/XSVPq2szfczY4rWMXS/3Y2ZKJ b2mhH0X6Qa7RBxkx4ttWijfMego3zCFRVuP9tlMRyWVTkcmM2RTNma6RLMUWI1X3axtQ cHMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702897684; x=1703502484; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4AQLJNbHXm9bw9mH1g4ChmY8Tt43IgcTpCwr8V+S95I=; b=jgTJbZTlh22Sx5qkA+eaWJW8a4oqmQgb8Or95h4RH/4rJnFdYAAm2BZzuHv9TMSAkm 5fEvCHr1mzxeXZ3U/dYrMXyQKUR3Cf/yOuy4y62InQhoLLblU6r3q6BfV0NmuFZkqh3E jCPB+U2koZcbQp8/BWiJVqGBm9vSKRthqaLWCaRvKWVTzjFSuBqJdrrD6UlHniHyx1oB H407S5ZcMUSEwTWWCEhgT/YsFYz1yzL/iXoeSTsDoOvSeySlhpIhsSEvF0fY4WMXbopC b/Xru7eD1UHgusWUJ2vgg0x4Biof2fXI6hEb/ip4tVzIYrgtuXThTIlfy3ecdO6yHXL4 6z6A== X-Gm-Message-State: AOJu0YyxR4NZEURqnx0fd6eYc6+g+B4c3Cx/t/KCxz/iH9EOStAz3pFo pm0DznLWSis7EMs6mbfJqUJQ6U2KdYHnvcENcazncl0hbj5GP9Pnl0CPNuNQqw== X-Received: by 2002:a50:cdc6:0:b0:551:9870:472 with SMTP id h6-20020a50cdc6000000b0055198700472mr275515edj.1.1702897684321; Mon, 18 Dec 2023 03:08:04 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231218084252.7644-1-zhangyiqun@phytium.com.cn> In-Reply-To: <20231218084252.7644-1-zhangyiqun@phytium.com.cn> From: Eric Dumazet Date: Mon, 18 Dec 2023 12:07:50 +0100 Message-ID: Subject: Re: [PATCH] xfrm: Use spin_lock_bh() in xfrm_input() To: Zhang Yiqun Cc: steffen.klassert@secunet.com, herbert@gondor.apana.org.au, davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Mon, Dec 18, 2023 at 9:43=E2=80=AFAM Zhang Yiqun wrote: > > This patch is to change spin_lock() into spin_lock_bh(), which can > disable bottem half in calling. If we leave this as spin_lock(), > it may stuck in a deadlock, because the callback in bottem half in > crypto driver will also call xfrm_input() again. > > Signed-off-by: Zhang Yiqun When was the bug added ? We need a FIxes: tag. Also a stack trace to show the deadlock (or lockdep complaint ) would be needed as well. > --- > net/xfrm/xfrm_input.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/net/xfrm/xfrm_input.c b/net/xfrm/xfrm_input.c > index bd4ce21d76d7..f4cd46d73b1e 100644 > --- a/net/xfrm/xfrm_input.c > +++ b/net/xfrm/xfrm_input.c > @@ -581,7 +581,7 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be= 32 spi, int encap_type) > } > > lock: > - spin_lock(&x->lock); > + spin_lock_bh(&x->lock); > > if (unlikely(x->km.state !=3D XFRM_STATE_VALID)) { > if (x->km.state =3D=3D XFRM_STATE_ACQ) > @@ -607,7 +607,7 @@ int xfrm_input(struct sk_buff *skb, int nexthdr, __be= 32 spi, int encap_type) > goto drop_unlock; > } > > - spin_unlock(&x->lock); > + spin_unlock_bh(&x->lock); > > if (xfrm_tunnel_check(skb, x, family)) { > XFRM_INC_STATS(net, LINUX_MIB_XFRMINSTATEMODEERRO= R); This patch is not correct anyway. There are five places in xfrm_input() where x->lock is either locked or unlocked. Please tell us how this was tested. Thanks.