Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/net Fix a bug in the VLAN path: there's an inverted logi...



details:   https://anonhg.NetBSD.org/src/rev/9da937ec8aec
branches:  trunk
changeset: 829044:9da937ec8aec
user:      maxv <maxv%NetBSD.org@localhost>
date:      Mon Jan 15 12:17:05 2018 +0000

description:
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.

diffstat:

 sys/net/if_ethersubr.c |  14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diffs (55 lines):

diff -r 7a4602d44b78 -r 9da937ec8aec sys/net/if_ethersubr.c
--- a/sys/net/if_ethersubr.c    Mon Jan 15 11:57:27 2018 +0000
+++ b/sys/net/if_ethersubr.c    Mon Jan 15 12:17:05 2018 +0000
@@ -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 @@
                 * 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 @@
                        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 @@
                                    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:



Home | Main Index | Thread Index | Old Index