Module Name:    src
Committed By:   maxv
Date:           Mon Apr  9 16:14:11 UTC 2018

Modified Files:
        src/sys/net: if_ethersubr.c

Log Message:
Replace KASSERTMSG by a real check. L2 encapsulation protocols (at least
L2TP) don't ensure the LLC is there, and in !DIAGNOSTIC configurations
m_copydata will crash. Tested with L2TP.


To generate a diff of this commit:
cvs rdiff -u -r1.262 -r1.263 src/sys/net/if_ethersubr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/net/if_ethersubr.c
diff -u src/sys/net/if_ethersubr.c:1.262 src/sys/net/if_ethersubr.c:1.263
--- src/sys/net/if_ethersubr.c:1.262	Mon Apr  9 11:35:22 2018
+++ src/sys/net/if_ethersubr.c	Mon Apr  9 16:14:11 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ethersubr.c,v 1.262 2018/04/09 11:35:22 maxv Exp $	*/
+/*	$NetBSD: if_ethersubr.c,v 1.263 2018/04/09 16:14:11 maxv Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -61,7 +61,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.262 2018/04/09 11:35:22 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.263 2018/04/09 16:14:11 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -759,8 +759,10 @@ ether_input(struct ifnet *ifp, struct mb
 	case ETHERTYPE_SLOWPROTOCOLS: {
 		uint8_t subtype;
 
-		KASSERTMSG((m->m_pkthdr.len >= sizeof(*eh) + sizeof(subtype)),
-		    "too short slow protocol packet");
+		if (m->m_pkthdr.len < sizeof(*eh) + sizeof(subtype)) {
+			m_freem(m);
+			return;
+		}
 
 		m_copydata(m, sizeof(*eh), sizeof(subtype), &subtype);
 		switch (subtype) {

Reply via email to