From patchwork Fri Jul 3 09:06:39 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ralf Lici X-Patchwork-Id: 5083 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:1887:b0:869:83bc:8c48 with SMTP id r7csp1842836max; Fri, 3 Jul 2026 02:07:21 -0700 (PDT) X-Forwarded-Encrypted: i=2; AFNElJ/Y3cj248BIg682nwwCClV31+CbF45yC4956A5lzIl/AoIide7awLCWANDez6ZzYf9x5uZR3Zm1d7s=@openvpn.net X-Received: by 2002:a05:6808:3501:b0:497:cfda:3c0f with SMTP id 5614622812f47-497e1dfdf4dmr2502222b6e.29.1783069640872; Fri, 03 Jul 2026 02:07:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1783069640; cv=none; d=google.com; s=arc-20260327; b=hC4RJr01NtjHZry6gqS+GRHrhNlMTNDanvi/jddHuJ6VMCh/jG4MdQUYkj6Bjti6C7 dT+RRqZic8pJbusxmSDpXf/rY8DnBRKzJy61hudmLaxKATKSyj4+3VVeD7oJZw7QDEGO OuFNUVrdDrIKEXw9t70SIHzqIbi9r1w9b2v406cyjNETtccLLESHa/oPMt+9RoDJlg51 h/Ypd5bmvhL+1QE8Mn7M4CNLp2c55TOo7M2ndmecEogAGJ/1IqNX19s6wYJmv/MmTErK KewBCgddpOEtwcJ8IDSa5266KFXj5uBv6hdvgWRobVpIfRiQUZb5NbtGya5KACBbTJnp 9ecA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:message-id:date:to:from:dkim-signature:dkim-signature :dkim-signature:dkim-signature; bh=vl7WpkuzhiAlguUN4z42FflQm8zssfcXTYXPvG8LKJI=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=OziyCQUnFjwnl+DZ4nkNMYSi8FkBSy3lH7RlMLKhhc1C4Melpihqj5cfezilDry/vz hHpq21CFChAbVryT0YfEYBgo/5e6cGJ9y5CvtgCZVTPtbQnydnOyHgxCpKxoLw6E8DIo +yHoVDY51UwvLf9WEdnmcfXgXxCG1gw2rhdUMOAlp6YGtO6GRQsEQY/FiZVdSbDGEw4U 9ZVfynzaesqJ8FzijTF13V/5HGXoecVTr7AgMt98v0KwP8NgVRbtLr+jY2ZVSJ8DE/kh /no/3Ux+Ge9wVSr7Or69wuszBH4jNDtsJFSvwRe/T5BiIdV714GXw0aYpql/AJ9Ia8dy 594Q==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=fYlx4YaJ; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=B2k6aoxz; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b="Nosg/fv2"; dkim=neutral (body hash did not verify) header.i=@mandelbit.com header.s=MBO0001 header.b=A1du04q5; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id 5614622812f47-497d1d1ba1csi3611907b6e.126.2026.07.03.02.07.20 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Jul 2026 02:07:20 -0700 (PDT) Received-SPF: pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=fYlx4YaJ; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=B2k6aoxz; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b="Nosg/fv2"; dkim=neutral (body hash did not verify) header.i=@mandelbit.com header.s=MBO0001 header.b=A1du04q5; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Subject:MIME-Version:Message-ID:Date:To:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Owner; bh=vl7WpkuzhiAlguUN4z42FflQm8zssfcXTYXPvG8LKJI=; b=fYlx4YaJ0ITMbKrJX5YBUE2BOw Ovg6vAanh/7E/Wxc4VOj8wU8K+fUW/MpEiesM4HcSWL3+FBBl8AQqBvuaQLKUDwi6+ZcGodo5teHV SvKAPAZus9mMX4iqZhwPU12h6+Dhkxez1+kTPcW6Aq99Xp0DB8JqVBhxHfqTsAmZMGDk=; Received: from [127.0.0.1] (helo=sfs-ml-3.v29.lw.sourceforge.com) by sfs-ml-3.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1wfZrb-0000ll-22; Fri, 03 Jul 2026 09:07:11 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-3.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1wfZrY-0000lc-26 for openvpn-devel@lists.sourceforge.net; Fri, 03 Jul 2026 09:07:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:Message-ID: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=8wVVWjRto61+Opgk9ZT+IXb/xnVsQIN2zZU+I0gZtGU=; b=B2k6aoxzqeWpYXfCZw0jgEw5Ej vwv+mup+HGrX01RUOrRncAcV7jhRM1oYboKLvN+JaIicTnR+mboDj57xf+Q/4P8h81ouL2tNeKXaT aMEzzsFFPTyFbDGOKVZ4Epb1Q5mN6pFMzyxsVF3XA8oNWLchVXEx0IE9mnWlQv9nWp4o=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Subject:Cc:To:From :Sender:Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=8wVVWjRto61+Opgk9ZT+IXb/xnVsQIN2zZU+I0gZtGU=; b=N osg/fv2Dz0eJD70E9t818y0gRhzAtvJ76O5SDFK0VRDo4Muu9OHzxynVA6C5gGcLyYyV/JC3WxcRJ kiZwdAqLNRokAPYFNqrWQRd3GVEo2Vbl/cXaQbUNu1Z4IfSHhia+Yn44GtA6QAfZ06hN9oTsOOQ43 rwdNEnJmrZm/aFOc=; Received: from mout-b-106.mailbox.org ([195.10.208.46]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1wfZrW-0007dx-OL for openvpn-devel@lists.sourceforge.net; Fri, 03 Jul 2026 09:07:08 +0000 Received: from smtp202.mailbox.org (smtp202.mailbox.org [IPv6:2001:67c:2050:b231:465::202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-b-106.mailbox.org (Postfix) with ESMTPS id 4gs7DG689HzDsYs; Fri, 3 Jul 2026 11:06:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandelbit.com; s=MBO0001; t=1783069614; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=8wVVWjRto61+Opgk9ZT+IXb/xnVsQIN2zZU+I0gZtGU=; b=A1du04q5KP7386lIcVRFr0LAtoaQzw6rCzv5cO7vnZX/khCZzPUFZor6nUkLCJ4DBoraQV W0hlRihgrGTDBMIiL6WTP7/66jQVhcAmZyFyUo7md/sEQeK/G/tnNwMNW1lDH2otbJzBu4 fMs9vx8mlR1kI4fcLmW5Yzv8G9in5KwEKBthEDyBN7536wjsPb3hYK0Xssyn03Wf9UxwqB KDu8svy2pD8n/mtB1Rm3ir85RHGRX85HPXklte28s+mcSuYBFBliTZsAHBiyS/77uEizU9 spqeS75flJOBSj1D4p4mGZP0mfoY21LsaTUPhL7l3vDso6BEVaCHoh+qLuCnxg== Authentication-Results: outgoing_mbo_mout; dkim=none; spf=pass (outgoing_mbo_mout: domain of ralf@mandelbit.com designates 2001:67c:2050:b231:465::202 as permitted sender) smtp.mailfrom=ralf@mandelbit.com From: Ralf Lici To: openvpn-devel@lists.sourceforge.net Date: Fri, 3 Jul 2026 11:06:39 +0200 Message-ID: <567de7a9371ce72b0632158799dd11bb543cae08.1783068961.git.ralf@mandelbit.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 4gs7DG689HzDsYs X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "sfi-spamd-2.hosts.colo.sdot.me", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Crypto completion callbacks release both key slot and peer references. The peer reference pins the netdev. Once ovpn_peer_put drops the last reference, netdev unregistration and module removal can com [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [195.10.208.46 listed in wl.mailspike.net] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-Headers-End: 1wfZrW-0007dx-OL Subject: [Openvpn-devel] [PATCH ovpn net v2 1/2] ovpn: release key slot before peer in crypto callbacks X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: 1869684031875439212 X-GMAIL-MSGID: 1869684031875439212 Crypto completion callbacks release both key slot and peer references. The peer reference pins the netdev. Once ovpn_peer_put drops the last reference, netdev unregistration and module removal can complete on another CPU while the callback is still running. The subsequent ovpn_crypto_key_slot_put can then schedule an RCU callback backed by module text after ovpn_cleanup rcu_barrier has already run. The callback can later execute in freed module memory. Release the key slot first, while the peer reference still blocks teardown, and drop the peer reference as the last action. Fixes: 8534731dbf2d ("ovpn: implement packet processing") Signed-off-by: Ralf Lici --- New patch added in v2. drivers/net/ovpn/io.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/ovpn/io.c b/drivers/net/ovpn/io.c index a6b777a9c2d9..9671ee6bea9b 100644 --- a/drivers/net/ovpn/io.c +++ b/drivers/net/ovpn/io.c @@ -204,10 +204,10 @@ void ovpn_decrypt_post(void *data, int ret) ovpn_dev_dstats_rx_dropped(peer->ovpn->dev); kfree_skb(skb); drop_nocount: - if (likely(peer)) - ovpn_peer_put(peer); if (likely(ks)) ovpn_crypto_key_slot_put(ks); + if (likely(peer)) + ovpn_peer_put(peer); } /* RX path entry point: decrypt packet and forward it to the device */ @@ -302,10 +302,10 @@ void ovpn_encrypt_post(void *data, int ret) err: if (unlikely(skb)) ovpn_dev_dstats_tx_dropped(peer->ovpn->dev); - if (likely(peer)) - ovpn_peer_put(peer); if (likely(ks)) ovpn_crypto_key_slot_put(ks); + if (likely(peer)) + ovpn_peer_put(peer); kfree_skb(skb); }