From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) (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 0534037996B for ; Wed, 29 Apr 2026 15:18:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.67 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777475890; cv=none; b=tbiDIq1zeAqizgNGlgz6B5HDfGl9Vo7GtXh5KGLbXWM15W432rVAl83Q6E1dSaSemzrJN12IH31GJ7QjjiUsYsEfvwLTZ59+KMVXYlpEr0Cir7/iHQZ83HDI/3atWGV0fdSvllqq0odjTAXRLm6o4RyR1v33qHgIWIZ+/MUVgVc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777475890; c=relaxed/simple; bh=IcSgz7CPtBhFf1K8izNXcbPchRtKjVsJDl/ciso75PU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fR/WUjof2rDHhHtxMFHkGQLkAP8e1Iev+kO4mxF7cbRoAX1+AEB+dDWmRLg5xB1g4xCCDJR2SzzT7otC5sEZNcMPJRLXV3HQJRWe3t6bwK36w28iEuiR59h60WpIlXH2LS36bQeHbj/gXruJudBJt0BZXt7k9HgILZ1p0TjRCf8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ovn.org; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.128.67 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ovn.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f67.google.com with SMTP id 5b1f17b1804b1-488a14c31eeso105948025e9.0 for ; Wed, 29 Apr 2026 08:18:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777475887; x=1778080687; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=wI/PIcTVy7eu/PfacjAoItlkhWbBUZ77v7uqcAyLoWE=; b=J8rUQ82Ys7jPBPuv2eKZtEPpt6XbiMQq+JSReW+5w/D3BCJKIiAJpPIXr0fCgrrcRJ 0utijMrFDFNX9I31p1CISLrU3dDPuXmqtACkdMAF4ixt+FcTFs9PUmLBf4DmwxD+Fkk5 XdVr2R+yhXNpLIsA+yCGB8W945CB/hS0TZgOXID/iumcbjraGPpC4tUfsGVhEuLDYI4v q+l1vM2e3kWXYlkwpuNI8bHaPZtUTRnC5sy3fYBMgflaOq7L7NNXKV2ZHOC9YcDhzh23 kSjFLyw0CjtJ1LyAB74fKszzNk1ZYUZrFyiWi2JAIfIODXc3IAqHNqlTQDmdrYePQqds hs1w== X-Forwarded-Encrypted: i=1; AFNElJ/R3IxGZPLDkvNIjrNs+dHM4L6U2J9eC0g+pyfWexL3XHP0mz/fwp5Xuv34Jp3sfkHgUll+sr57Kw+vhg4=@vger.kernel.org X-Gm-Message-State: AOJu0YwQ7g4Qil0JRKU6reFORBfZsdmw9q2D/dz5pyeTVAcCOsYGTY52 sElcDsQokM5s4qXsE0vS7HIUKTqB4mZQGzNa9ofXT0aOQNWlFmfAI83W X-Gm-Gg: AeBDiesszBw7eJ4Qay8GRpvoIzCDAmx5ck7nyVy5nj6oCcb+kEonVwPdYbuEcn2vVYA RE+lL3PwqHVyUjCt5Sd+1fD8WJQ2g4JqXxUxNJRQ4CdxPIatBIQptRX6H4rZnLAn6kugjQg0zfD fHeL1kj1IsfQ7DguM11FIs4f67/rhvYzdJAyu2s+RE241mJQTwZH5HmNwYuSZ7YDAcn1rkVZ58/ LCBOjcbVI/hB16AoReB3NHF7xMwzZr7M46v/Xpl4y1j9aEl0+wSHKiZ9zRGvxGXipubChg3aNKj l8IrcWwVBPLns9tKeIIaJEm9Feq1c57zCHeVVQArb99XVUYwTbszkfjxVlEYIl8AhBqgx0A3v2o 08RDj7IfMZ/ZpogoWzGGO2ilITd93cpu8oCRJswpcRKJYPxI19x9eKyQ8YUQwRh7cKvkWtwMiIc s27NLmcx71bLDx9T1jb57xyrjDpp1v8uxuF9xUZGkCXxl1MgTd2O/QRBsTNiCmPppqGRcBTA== X-Received: by 2002:a05:600c:1396:b0:48a:5565:ec3d with SMTP id 5b1f17b1804b1-48a77b1b85fmr132416975e9.22.1777475887157; Wed, 29 Apr 2026 08:18:07 -0700 (PDT) Received: from im-t490s.redhat.com (89-24-32-159.nat.epc.tmcz.cz. [89.24.32.159]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48a7c2d3811sm32358165e9.3.2026.04.29.08.18.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Apr 2026 08:18:06 -0700 (PDT) From: Ilya Maximets To: netdev@vger.kernel.org Cc: Aaron Conole , Eelco Chaudron , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Shuah Khan , Yuan Tan , Yang Yang , dev@openvswitch.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Ilya Maximets , stable@vger.kernel.org Subject: [PATCH net 1/2] openvswitch: vport: fix self-deadlock on release of tunnel ports Date: Wed, 29 Apr 2026 17:16:36 +0200 Message-ID: <20260429151756.4157670-2-i.maximets@ovn.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260429151756.4157670-1-i.maximets@ovn.org> References: <20260429151756.4157670-1-i.maximets@ovn.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit vports are used concurrently and protected by RCU, so netdev_put() must happen after the RCU grace period. So, either in an RCU call or after the synchronize_net(). The rtnl_delete_link() must happen under RTNL and so can't be executed in RCU context. Calling synchronize_net() while holding RTNL is not a good idea for performance and system stability under load in general, so calling netdev_put() in RCU call is the right solution here. However, when the device is deleted, rtnl_unlock() will call netdev_run_todo() and block until all the references are gone. In the current code this means that we never reach the call_rcu() and the vport is never freed and the reference is never released, causing a self-deadlock on device removal. Fix that by moving the rcu_call() before the rtnl_unlock(), so the scheduled RCU callback will be executed when synchronize_net() is called from the rtnl_unlock()->netdev_run_todo() while the RTNL itself is already released. Fixes: 6931d21f87bc ("openvswitch: defer tunnel netdev_put to RCU release") Cc: stable@vger.kernel.org Signed-off-by: Ilya Maximets --- net/openvswitch/vport-netdev.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/net/openvswitch/vport-netdev.c b/net/openvswitch/vport-netdev.c index 12055af832dc0..a1df551e915bc 100644 --- a/net/openvswitch/vport-netdev.c +++ b/net/openvswitch/vport-netdev.c @@ -196,9 +196,13 @@ void ovs_netdev_tunnel_destroy(struct vport *vport) */ if (vport->dev->reg_state == NETREG_REGISTERED) rtnl_delete_link(vport->dev, 0, NULL); - rtnl_unlock(); + /* We can't put the device reference yet, since it can still be in + * use, but rtnl_unlock()->netdev_run_todo() will block until all + * the references are released, so the RCU call must be before it. + */ call_rcu(&vport->rcu, vport_netdev_free); + rtnl_unlock(); } EXPORT_SYMBOL_GPL(ovs_netdev_tunnel_destroy); -- 2.53.0