Print this page
9832 Original bug discovered as 9560 has friends IPv4 packets coming in as IPv6 creating chaos

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/io/mac/mac_util.c
          +++ new/usr/src/uts/common/io/mac/mac_util.c
↓ open down ↓ 12 lines elided ↑ open up ↑
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  /*
  22   22   * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
       23 + * Copyright 2018 Joyent, Inc.
  23   24   */
  24   25  
  25   26  /*
  26   27   * MAC Services Module - misc utilities
  27   28   */
  28   29  
  29   30  #include <sys/types.h>
  30   31  #include <sys/mac.h>
  31   32  #include <sys/mac_impl.h>
  32   33  #include <sys/mac_client_priv.h>
↓ open down ↓ 451 lines elided ↑ open up ↑
 484  485          uint16_t length;
 485  486          uint_t  ehdrlen;
 486  487          uint8_t *whereptr;
 487  488          uint8_t *nexthdrp;
 488  489          ip6_dest_t *desthdr;
 489  490          ip6_rthdr_t *rthdr;
 490  491          ip6_frag_t *fraghdr;
 491  492  
 492  493          if (((uchar_t *)ip6h + IPV6_HDR_LEN) > endptr)
 493  494                  return (B_FALSE);
 494      -        ASSERT(IPH_HDR_VERSION(ip6h) == IPV6_VERSION);
      495 +        /*
      496 +         * NOTE: Version-check failure here may cause mismatched IP versions
      497 +         * to propagate ENOBUFS in some callers, instead of letting the
      498 +         * packet reach the appropriate IP input function, where version check
      499 +         * errors are logged & counted.
      500 +         */
      501 +        if (IPH_HDR_VERSION(ip6h) != IPV6_VERSION)
      502 +                return (B_FALSE);
 495  503          length = IPV6_HDR_LEN;
 496  504          whereptr = ((uint8_t *)&ip6h[1]); /* point to next hdr */
 497  505  
 498  506          if (fragp != NULL)
 499  507                  *fragp = NULL;
 500  508  
 501  509          nexthdrp = &ip6h->ip6_nxt;
 502  510          while (whereptr < endptr) {
 503  511                  /* Is there enough left for len + nexthdr? */
 504  512                  if (whereptr + MIN_EHDR_LEN > endptr)
↓ open down ↓ 602 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX