git: 8707cb19e681 - main - if_vxlan(4): Check the size of data available in mbuf before using them

From: Kristof Provost <kp_at_FreeBSD.org>
Date: Fri, 30 Sep 2022 11:58:54 UTC
The branch main has been updated by kp:

URL: https://cgit.FreeBSD.org/src/commit/?id=8707cb19e68128c181477d87f960182c14e15f12

commit 8707cb19e68128c181477d87f960182c14e15f12
Author:     Zhenlei Huang <zlei.huang@gmail.com>
AuthorDate: 2022-09-30 07:55:29 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2022-09-30 07:56:15 +0000

    if_vxlan(4): Check the size of data available in mbuf before using them
    
    PR:             261711
    Reviewed by:    kp
    Differential Revision:  https://reviews.freebsd.org/D36794
---
 sys/net/if_vxlan.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/sys/net/if_vxlan.c b/sys/net/if_vxlan.c
index 6c9a3d7e3095..cba2ba4b0a16 100644
--- a/sys/net/if_vxlan.c
+++ b/sys/net/if_vxlan.c
@@ -2849,6 +2849,12 @@ vxlan_input(struct vxlan_socket *vso, uint32_t vni, struct mbuf **m0,
 		return (ENOENT);
 
 	ifp = sc->vxl_ifp;
+	if (m->m_len < ETHER_HDR_LEN &&
+	    (m = m_pullup(m, ETHER_HDR_LEN)) == NULL) {
+		*m0 = NULL;
+		error = ENOBUFS;
+		goto out;
+	}
 	eh = mtod(m, struct ether_header *);
 
 	if ((ifp->if_drv_flags & IFF_DRV_RUNNING) == 0) {