Print this page
4596 Callers of ip_srcid_find_id() need to be more careful

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/inet/tcp/tcp.c
          +++ new/usr/src/uts/common/inet/tcp/tcp.c
↓ open down ↓ 16 lines elided ↑ open up ↑
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
  24   24   * Copyright (c) 2011, Joyent Inc. All rights reserved.
  25   25   * Copyright (c) 2011 Nexenta Systems, Inc. All rights reserved.
  26   26   * Copyright (c) 2013 by Delphix. All rights reserved.
       27 + * Copyright 2014, OmniTI Computer Consulting, Inc. All rights reserved.
  27   28   */
  28   29  /* Copyright (c) 1990 Mentat Inc. */
  29   30  
  30   31  #include <sys/types.h>
  31   32  #include <sys/stream.h>
  32   33  #include <sys/strsun.h>
  33   34  #include <sys/strsubr.h>
  34   35  #include <sys/stropts.h>
  35   36  #include <sys/strlog.h>
  36   37  #define _SUN_TPI_VERSION 2
↓ open down ↓ 1539 lines elided ↑ open up ↑
1576 1577                   * compatibility with SunOS 4.x.
1577 1578                   * Update the T_CONN_REQ (sin/sin6) since it is used to
1578 1579                   * generate the T_CONN_CON.
1579 1580                   */
1580 1581                  dstaddr = htonl(INADDR_LOOPBACK);
1581 1582                  *dstaddrp = dstaddr;
1582 1583          }
1583 1584  
1584 1585          /* Handle __sin6_src_id if socket not bound to an IP address */
1585 1586          if (srcid != 0 && connp->conn_laddr_v4 == INADDR_ANY) {
1586      -                ip_srcid_find_id(srcid, &connp->conn_laddr_v6,
1587      -                    IPCL_ZONEID(connp), tcps->tcps_netstack);
     1587 +                if (!ip_srcid_find_id(srcid, &connp->conn_laddr_v6,
     1588 +                    IPCL_ZONEID(connp), B_TRUE, tcps->tcps_netstack)) {
     1589 +                        /* Mismatch - conn_laddr_v6 would be v6 address. */
     1590 +                        return (EADDRNOTAVAIL);
     1591 +                }
1588 1592                  connp->conn_saddr_v6 = connp->conn_laddr_v6;
1589 1593          }
1590 1594  
1591 1595          IN6_IPADDR_TO_V4MAPPED(dstaddr, &connp->conn_faddr_v6);
1592 1596          connp->conn_fport = dstport;
1593 1597  
1594 1598          /*
1595 1599           * At this point the remote destination address and remote port fields
1596 1600           * in the tcp-four-tuple have been filled in the tcp structure. Now we
1597 1601           * have to see which state tcp was in so we can take appropriate action.
↓ open down ↓ 60 lines elided ↑ open up ↑
1658 1662          /*
1659 1663           * Interpret a zero destination to mean loopback.
1660 1664           * Update the T_CONN_REQ (sin/sin6) since it is used to
1661 1665           * generate the T_CONN_CON.
1662 1666           */
1663 1667          if (IN6_IS_ADDR_UNSPECIFIED(dstaddrp))
1664 1668                  *dstaddrp = ipv6_loopback;
1665 1669  
1666 1670          /* Handle __sin6_src_id if socket not bound to an IP address */
1667 1671          if (srcid != 0 && IN6_IS_ADDR_UNSPECIFIED(&connp->conn_laddr_v6)) {
1668      -                ip_srcid_find_id(srcid, &connp->conn_laddr_v6,
1669      -                    IPCL_ZONEID(connp), tcps->tcps_netstack);
     1672 +                if (!ip_srcid_find_id(srcid, &connp->conn_laddr_v6,
     1673 +                    IPCL_ZONEID(connp), B_FALSE, tcps->tcps_netstack)) {
     1674 +                        /* Mismatch - conn_laddr_v6 would be v4-mapped. */
     1675 +                        return (EADDRNOTAVAIL);
     1676 +                }
1670 1677                  connp->conn_saddr_v6 = connp->conn_laddr_v6;
1671 1678          }
1672 1679  
1673 1680          /*
1674 1681           * Take care of the scope_id now.
1675 1682           */
1676 1683          if (scope_id != 0 && IN6_IS_ADDR_LINKSCOPE(dstaddrp)) {
1677 1684                  connp->conn_ixa->ixa_flags |= IXAF_SCOPEID_SET;
1678 1685                  connp->conn_ixa->ixa_scopeid = scope_id;
1679 1686          } else {
↓ open down ↓ 2798 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX