Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 16 Jan 2024 14:29:19 +0000
From:      bugzilla-noreply@freebsd.org
To:        bugs@FreeBSD.org
Subject:   [Bug 276363] if_wg: Fix a code bug in calculate_padding() although impossible to hit
Message-ID:  <bug-276363-227-Zn8vbjsdEv@https.bugs.freebsd.org/bugzilla/>
In-Reply-To: <bug-276363-227@https.bugs.freebsd.org/bugzilla/>
References:  <bug-276363-227@https.bugs.freebsd.org/bugzilla/>

next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D276363

--- Comment #1 from Aaron LI <aly@aaronly.me> ---
Well, after testing, I found 'pkt->p_mtu' is actually 0 for keepalive packe=
ts;
however, those packets also have a zero length, so calculate_padding() didn=
't
cause any real problems.

I suggest the following new patch:

--- if_wg.c.orig        2023-10-12 09:06:16.983637264 +0800
+++ if_wg.c     2024-01-16 22:25:04.878629478 +0800
@@ -1461,8 +1461,11 @@ calculate_padding(struct wg_packet *pkt)
 {
        unsigned int padded_size, last_unit =3D pkt->p_mbuf->m_pkthdr.len;

-       if (__predict_false(!pkt->p_mtu))
-               return (last_unit + (WG_PKT_PADDING - 1)) & ~(WG_PKT_PADDIN=
G -
1);
+       /* Keepalive packets don't set p_mtu, but also have a zreo length. =
*/
+       if (__predict_false(pkt->p_mtu =3D=3D 0)) {
+               padded_size =3D (last_unit + (WG_PKT_PADDING - 1)) &
~(WG_PKT_PADDING - 1);
+               return padded_size - last_unit;
+       }

        if (__predict_false(last_unit > pkt->p_mtu))
                last_unit %=3D pkt->p_mtu;

--=20
You are receiving this mail because:
You are the assignee for the bug.=



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-276363-227-Zn8vbjsdEv>