Module Name:    src
Committed By:   maxv
Date:           Mon Jan 15 12:17:05 UTC 2018

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

Log Message:
Fix a bug in the VLAN path: there's an inverted logic, the mbuf needs to
be bigger than struct ether_vlan_header, not smaller.

Meanwhile add a KASSERT in the LLC path.


To generate a diff of this commit:
cvs rdiff -u -r1.253 -r1.254 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.253 src/sys/net/if_ethersubr.c:1.254
--- src/sys/net/if_ethersubr.c:1.253	Mon Jan 15 11:57:27 2018
+++ src/sys/net/if_ethersubr.c	Mon Jan 15 12:17:05 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_ethersubr.c,v 1.253 2018/01/15 11:57:27 maxv Exp $	*/
+/*	$NetBSD: if_ethersubr.c,v 1.254 2018/01/15 12:17:05 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.253 2018/01/15 11:57:27 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ethersubr.c,v 1.254 2018/01/15 12:17:05 maxv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -699,7 +699,7 @@ ether_input(struct ifnet *ifp, struct mb
 		 * just being used to store the priority.  Extract the ether
 		 * type, and if IP or IPV6, let them deal with it.
 		 */
-		if (m->m_len <= sizeof(*evl) &&
+		if (m->m_len >= sizeof(*evl) &&
 		    EVL_VLANOFTAG(evl->evl_tag) == 0) {
 			etype = ntohs(evl->evl_proto);
 			ehlen = sizeof(*evl);
@@ -843,11 +843,13 @@ ether_input(struct ifnet *ifp, struct mb
 			return;
 		}
 	} else {
+		KASSERT(ehlen == sizeof(*eh));
 #if defined (LLC) || defined (NETATALK)
-		if (m->m_len < ehlen + sizeof(struct llc)) {
+		if (m->m_len < sizeof(*eh) + sizeof(struct llc)) {
 			goto dropanyway;
 		}
 		l = (struct llc *)(eh+1);
+
 		switch (l->llc_dsap) {
 #ifdef NETATALK
 		case LLC_SNAP_LSAP:
@@ -873,10 +875,10 @@ ether_input(struct ifnet *ifp, struct mb
 				    sizeof(aarp_org_code)) == 0 &&
 				    ntohs(l->llc_snap_ether_type) ==
 				    ETHERTYPE_AARP) {
-					m_adj( m, sizeof(struct ether_header)
+					m_adj(m, sizeof(struct ether_header)
 					    + sizeof(struct llc));
 					aarpinput(ifp, m); /* XXX */
-				    return;
+					return;
 				}
 
 			default:

Reply via email to