if_wg.c: Zero Padding Missing MTU Check
Zixu Wu <[email protected]>
| Newsgroups | gmane.os.openbsd.bugs |
|---|---|
| Message-ID | <[email protected]> |
Zero padding shouldn't cause the packet size to go beyond MTU.
diff --git a/sys/net/if_wg.c b/sys/net/if_wg.c
index 0641c4b5ba9..90ef5b808a0 100644
--- a/sys/net/if_wg.c
+++ b/sys/net/if_wg.c
@@ -1592,6 +1592,9 @@ wg_encap(struct wg_softc *sc, struct mbuf *m)
peer = t->t_peer;
plaintext_len = WG_PKT_WITH_PADDING(m->m_pkthdr.len);
+ if (m->m_pkthdr.len <= t->t_mtu && plaintext_len > t->t_mtu) {
+ plaintext_len = t->t_mtu;
+ }
padding_len = plaintext_len - m->m_pkthdr.len;
out_len = sizeof(struct wg_pkt_data) + plaintext_len +
NOISE_AUTHTAG_LEN;