Skip to content

Commit

Permalink
if_ovpn: ensure it's safe to modify the mbuf
Browse files Browse the repository at this point in the history
PR:		280036
Reviewed by:	ae
MFC after:	1 week
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D46529
  • Loading branch information
kprovost committed Sep 5, 2024
1 parent a9ac25d commit 5644e2c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions sys/net/if_ovpn.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 5644e2c

Please sign in to comment.