From nobody Thu Oct 06 15:48:54 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4MjwpZ5YrVz4dskL; Thu, 6 Oct 2022 15:48:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (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 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4MjwpZ4kYVz3Pw0; Thu, 6 Oct 2022 15:48:54 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1665071334; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=mLMRCtTHOOODilw0zcLhCAqDEOvivPr3WVIquTlZMsw=; b=l8hNiZQMG4NCCj9DbDKjKFoo6/SUedKb1l3qT587hG9QMP2IZiG9oaXW0Pzvpd4eA1PI1+ nIQ3453ITaDOdDc/Y4OY+d/teOOmXdyYFnwTb0pjFrMCIsJsPq3RdXjWzkGnYhBAlelNaa NEFCxpSQ5u+YGDv41e7JVckq+drULkBEQfRnCFxGzlOtHLOJ0k149TAN5LWBcr+c/C+Fr2 v3Z6WudSjml0zDbtM24eUZUQc1pKySjVu/uMXbOW9pXluX9xtnS0AHchPpm3EmyhTnSyCF 6HRuQhoWlUIj3gFBE2/ARHswtpqitX5IpZ8iIGtLmzMF5kpuCap/TUCbnWHEKQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4MjwpZ3m1PzHtv; Thu, 6 Oct 2022 15:48:54 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 296Fmshs080005; Thu, 6 Oct 2022 15:48:54 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 296FmsFx080004; Thu, 6 Oct 2022 15:48:54 GMT (envelope-from git) Date: Thu, 6 Oct 2022 15:48:54 GMT Message-Id: <202210061548.296FmsFx080004@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kristof Provost Subject: git: 4f756295e0e3 - main - if_ovpn: ensure we're in net_epoch when calling ovpn_encap() List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: kp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 4f756295e0e3ac5a9c2b3a6a3bfda6e7a61a560f Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1665071334; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=mLMRCtTHOOODilw0zcLhCAqDEOvivPr3WVIquTlZMsw=; b=jTHmS6nBiheJ7rPuHtLyMRVf4qaSwO7n7xJSn4Qx7MwGkljcTzyPkv3c7lI3X3ExxWcJDv ACOK5mQ5RsvD4Ucqzipe8vqfA81wq6LBY3hnh7f3dkgMLiHlUkdLD3oPMSshx/Lw4ZpXSL MamEUmjcT1PklZVvOKZAj2y997/4ZhvZlLtHGag5D5kaSygxnnO9lbZARCdqPj0ZEHUbWf VqV+SBiy5BBxobvQoBW1l3La6dQJTAvjqzrMjRu3JTjnm2A4nBitlpsQqWiQZZW3lbdpom xeSY5uekG5YIgzDxXZcUBuUiEcb5+/f3ioL0AxbbpENu0JR8g5y6EfcP8y6dSg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1665071334; a=rsa-sha256; cv=none; b=xl+leQUNz9OebikwMgSQXwEDlozfK+WNamXXaP1W2u9uCGTvcXAt/vPVnRhxnXOcSIDap/ Xl0zQ7g1+uB3pNq+qwZtkqCv/IfGBEbUNPwvqSXRv+Y7LFlLVU5TWCu1CooVKTS9jKScAm HcUUSIFmowdOjZ5uqMSgNWEanW/44sh+45YzZhVg/qqfIJEqThcjmNbYEEr1vUOtk7qW9l L4LXA26lsjEio0zF8sXEIJs3dhraXVJAycLwIv3AsSDOmO6wjgl1f17+bFmxCHKY2qcO3C czL4DUotkaNvhE2Y0hjSwBLu7qH0is1xGZ6q7nYbRdBNDj4epR2eNl/3hdL6Og== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=4f756295e0e3ac5a9c2b3a6a3bfda6e7a61a560f commit 4f756295e0e3ac5a9c2b3a6a3bfda6e7a61a560f Author: Kristof Provost AuthorDate: 2022-10-06 15:01:47 +0000 Commit: Kristof Provost CommitDate: 2022-10-06 15:42:12 +0000 if_ovpn: ensure we're in net_epoch when calling ovpn_encap() If the crypto callback is asynchronous we're no longer in net_epoch, which ovpn_encap() (and ip_output() it calls) expect. Ensure we've entered the epoch. Do the same thing for the rx path. Sponsored by: Rubicon Communications, LLC ("Netgate") --- sys/net/if_ovpn.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sys/net/if_ovpn.c b/sys/net/if_ovpn.c index ed0ff178972f..16def82c6071 100644 --- a/sys/net/if_ovpn.c +++ b/sys/net/if_ovpn.c @@ -1378,6 +1378,7 @@ ovpn_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data) static int ovpn_encrypt_tx_cb(struct cryptop *crp) { + struct epoch_tracker et; struct ovpn_kpeer *peer = crp->crp_opaque; struct ovpn_softc *sc = peer->sc; struct mbuf *m = crp->crp_buf.cb_mbuf; @@ -1391,6 +1392,7 @@ ovpn_encrypt_tx_cb(struct cryptop *crp) return (0); } + NET_EPOCH_ENTER(et); CURVNET_SET(sc->ifp->if_vnet); MPASS(crp->crp_buf.cb_type == CRYPTO_BUF_MBUF); @@ -1403,6 +1405,7 @@ ovpn_encrypt_tx_cb(struct cryptop *crp) } CURVNET_RESTORE(); + NET_EPOCH_EXIT(et); crypto_freereq(crp); ovpn_peer_release_ref(peer, false); @@ -1419,6 +1422,7 @@ ovpn_finish_rx(struct ovpn_softc *sc, struct mbuf *m, int ret __diagused; OVPN_RASSERT(sc); + NET_EPOCH_ASSERT(); /* Replay protection. */ if (V_replay_protection && ! ovpn_check_replay(key->decrypt, seq)) { @@ -1488,6 +1492,7 @@ ovpn_find_key(struct ovpn_softc *sc, struct ovpn_kpeer *peer, static int ovpn_decrypt_rx_cb(struct cryptop *crp) { + struct epoch_tracker et; struct ovpn_softc *sc = crp->crp_opaque; struct mbuf *m = crp->crp_buf.cb_mbuf; struct ovpn_kkey *key; @@ -1546,7 +1551,9 @@ ovpn_decrypt_rx_cb(struct cryptop *crp) m_adj_decap(m, sizeof(struct udphdr) + sizeof(struct ovpn_wire_header)); + NET_EPOCH_ENTER(et); ovpn_finish_rx(sc, m, peer, key, ntohl(ohdr->seq), _ovpn_lock_trackerp); + NET_EPOCH_EXIT(et); OVPN_UNLOCK_ASSERT(sc); CURVNET_RESTORE();