From 00a2f9f8be6f5a2b32b0cfa4ac2dacaa16b53520 Mon Sep 17 00:00:00 2001 From: maxv Date: Mon, 9 Apr 2018 11:35:22 +0000 Subject: [PATCH] Add KASSERT. The input point expects struct ether_header to be there. Now, I'm wondering whether it can be triggered by L2 encapsulation protocols - they may not provide a contiguous area. --- sys/net/if_ethersubr.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c index 0077021352d7..88d3e82e33d0 100644 --- a/sys/net/if_ethersubr.c +++ b/sys/net/if_ethersubr.c @@ -1,4 +1,4 @@ -/* $NetBSD: if_ethersubr.c,v 1.261 2018/04/09 11:05:59 maxv Exp $ */ +/* $NetBSD: if_ethersubr.c,v 1.262 2018/04/09 11:35:22 maxv Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -61,7 +61,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.261 2018/04/09 11:05:59 maxv Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.262 2018/04/09 11:35:22 maxv Exp $"); #ifdef _KERNEL_OPT #include "opt_inet.h" @@ -588,6 +588,7 @@ ether_input(struct ifnet *ifp, struct mbuf *m) KASSERT(!cpu_intr_p()); KASSERT((m->m_flags & M_PKTHDR) != 0); + KASSERT(m->m_len >= sizeof(*eh)); if ((ifp->if_flags & IFF_UP) == 0) { m_freem(m);