From nobody Thu Sep 05 09:00:27 2024 X-Original-To: dev-commits-src-main@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 4WztcD0x1Jz5W16k; Thu, 05 Sep 2024 09:00:28 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WztcD0QgNz4mT0; Thu, 5 Sep 2024 09:00:28 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1725526828; 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=vpweC052vZ3IzGv78oaNaW3AfrQqhpt/j9Rvax+rnaI=; b=NKYGcSpTOSoktDm9kkIsS9hTuPatKuuP9dfH7Q2VI7IXqCBJujD4fM2tfIaBknoVQJgtg6 APT3Xe+WfbzGUeQ2rmkej7j2lZp66hj2mqeC4RIJK2Rb8UXb1KPQsNGQCriPN0D8BDyHUW EKW1k8YPkobaIA/9IYeRt/Zosmm5teXRdORWRhvz1g75YD74OGvTxJzkUrHqkMPToBXuyS B0g644ZYtW25wXnmUUrTslgnsC8qg+UlaLpdbCXWAzmpFA1vD7hhVRzL9ASAmBY2WgbtGh Acd0e2GftduzS6jfE4szbe+0t66Gxz3FhT3GDWGAuR4GFvG/nIK0K+4Fv75zmQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1725526828; a=rsa-sha256; cv=none; b=a6p68+O9BvSTewVMVTjPI2Z2odSBEQXa9yIBHSZ393guBvisBQNsdmUel27RrBtZuIsLoh CDgds2ne1Akt/hU2MNol9Yqa4P6HepM2KwxYHxrfYY/XFaOJYyPxGQtIueq3ho6RgBuci8 TkxnGe+1dJA6MT0h4qAfhslS0JLCKO4QWGIweaFao9bhOEhLS4daQS9mrAx0u+OV95vM7n YVjDbDBo3cGMXiOW42RMrS8cQ3rqlAbLGGaXHDO4QjT4XGjuYKz5R2XyzWX7kvr7qQcTBe 7jctBQ4O/3Oa7nAEHcdolVyeWcHrPxgZYaOAtb76cQCPv6LqoqAynZ2qbdJZ1w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1725526828; 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=vpweC052vZ3IzGv78oaNaW3AfrQqhpt/j9Rvax+rnaI=; b=Py7NIfKqe/Gdg93+t+S6J7SYDTqZDRRZo2Zq+/Nb/7aHpuQWGwDgGbrTBUnEw+k0+2c3eZ zj0ymnHf9LSDyMM4GFK32erD5o881AD71z2URq1huvC3IchiNsmLxqgTaXl68DFFdYh4Yq TY09mgkiXf9iLAo3tvArntL0ory9+3KM0OTT3fE3qX0al9NzszPTjwkMxP+P3ctpNNhYHV FwxQDfEWKtPdhe9I+qXwrVF3EyvOBFxU6UCWUv0aHMjuq2Of7RSre42GYapdVr7bw/fxmz iZ5ZtosX4ki10PlUZS0elIcXLtb49SOXJd9eXQy02JYckejeBuSe8DYUnxLtSA== 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 4WztcC6RV9z12Wq; Thu, 5 Sep 2024 09:00:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 48590RQJ083423; Thu, 5 Sep 2024 09:00:27 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 48590RHp083420; Thu, 5 Sep 2024 09:00:27 GMT (envelope-from git) Date: Thu, 5 Sep 2024 09:00:27 GMT Message-Id: <202409050900.48590RHp083420@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: 5644e2c6d47c - main - if_ovpn: ensure it's safe to modify the mbuf List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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: 5644e2c6d47c6113a61ab7fc0776b7227677656a Auto-Submitted: auto-generated The branch main has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=5644e2c6d47c6113a61ab7fc0776b7227677656a commit 5644e2c6d47c6113a61ab7fc0776b7227677656a Author: Kristof Provost AuthorDate: 2024-09-04 12:54:23 +0000 Commit: Kristof Provost CommitDate: 2024-09-05 08:59:31 +0000 if_ovpn: ensure it's safe to modify the mbuf PR: 280036 Reviewed by: ae MFC after: 1 week Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D46529 --- sys/net/if_ovpn.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sys/net/if_ovpn.c b/sys/net/if_ovpn.c index f6f640a65f61..ee097cfa24b3 100644 --- a/sys/net/if_ovpn.c +++ b/sys/net/if_ovpn.c @@ -2115,6 +2115,12 @@ ovpn_output(struct ifnet *ifp, struct mbuf *m, const struct sockaddr *dst, sc = ifp->if_softc; + m = m_unshare(m, M_NOWAIT); + if (m == NULL) { + OVPN_COUNTER_ADD(sc, lost_data_pkts_out, 1); + return (ENOBUFS); + } + OVPN_RLOCK(sc); SDT_PROBE1(if_ovpn, tx, transmit, start, m); @@ -2233,6 +2239,12 @@ ovpn_udp_input(struct mbuf *m, int off, struct inpcb *inp, M_ASSERTPKTHDR(m); + m = m_unshare(m, M_NOWAIT); + if (m == NULL) { + OVPN_COUNTER_ADD(sc, nomem_data_pkts_in, 1); + return (true); + } + OVPN_COUNTER_ADD(sc, transport_bytes_received, m->m_pkthdr.len - off); ohdrlen = sizeof(*ohdr) - sizeof(ohdr->auth_tag);