Path: blob/main/website/static/security/patches/EN-08:02/tcp.patch
18096 views
Index: sys/netinet/tcp.h1===================================================================2RCS file: /home/ncvs/src/sys/netinet/tcp.h,v3retrieving revision 1.404diff -p -u -I__FBSDID -I$FreeBSD -r1.40 tcp.h5--- sys/netinet/tcp.h 25 May 2007 21:28:49 -0000 1.406+++ sys/netinet/tcp.h 18 Jun 2008 05:36:20 -00007@@ -78,6 +78,8 @@ struct tcphdr {89#define TCPOPT_EOL 010#define TCPOLEN_EOL 111+#define TCPOPT_PAD 0 /* padding after EOL */12+#define TCPOLEN_PAD 113#define TCPOPT_NOP 114#define TCPOLEN_NOP 115#define TCPOPT_MAXSEG 216Index: sys/netinet/tcp_output.c17===================================================================18RCS file: /home/ncvs/src/sys/netinet/tcp_output.c,v19retrieving revision 1.141.2.320diff -p -u -I__FBSDID -I$FreeBSD -r1.141.2.3 tcp_output.c21--- sys/netinet/tcp_output.c 5 Dec 2007 10:37:17 -0000 1.141.2.322+++ sys/netinet/tcp_output.c 18 Jun 2008 05:36:21 -000023@@ -1280,12 +1280,16 @@ tcp_addoptions(struct tcpopt *to, u_char24for (mask = 1; mask < TOF_MAXOPT; mask <<= 1) {25if ((to->to_flags & mask) != mask)26continue;27+ if (optlen == TCP_MAXOLEN)28+ break;29switch (to->to_flags & mask) {30case TOF_MSS:31while (optlen % 4) {32optlen += TCPOLEN_NOP;33*optp++ = TCPOPT_NOP;34}35+ if (TCP_MAXOLEN - optlen < TCPOLEN_MAXSEG)36+ continue;37optlen += TCPOLEN_MAXSEG;38*optp++ = TCPOPT_MAXSEG;39*optp++ = TCPOLEN_MAXSEG;40@@ -1298,6 +1302,8 @@ tcp_addoptions(struct tcpopt *to, u_char41optlen += TCPOLEN_NOP;42*optp++ = TCPOPT_NOP;43}44+ if (TCP_MAXOLEN - optlen < TCPOLEN_WINDOW)45+ continue;46optlen += TCPOLEN_WINDOW;47*optp++ = TCPOPT_WINDOW;48*optp++ = TCPOLEN_WINDOW;49@@ -1308,6 +1314,8 @@ tcp_addoptions(struct tcpopt *to, u_char50optlen += TCPOLEN_NOP;51*optp++ = TCPOPT_NOP;52}53+ if (TCP_MAXOLEN - optlen < TCPOLEN_SACK_PERMITTED)54+ continue;55optlen += TCPOLEN_SACK_PERMITTED;56*optp++ = TCPOPT_SACK_PERMITTED;57*optp++ = TCPOLEN_SACK_PERMITTED;58@@ -1317,6 +1325,8 @@ tcp_addoptions(struct tcpopt *to, u_char59optlen += TCPOLEN_NOP;60*optp++ = TCPOPT_NOP;61}62+ if (TCP_MAXOLEN - optlen < TCPOLEN_TIMESTAMP)63+ continue;64optlen += TCPOLEN_TIMESTAMP;65*optp++ = TCPOPT_TIMESTAMP;66*optp++ = TCPOLEN_TIMESTAMP;67@@ -1355,7 +1365,7 @@ tcp_addoptions(struct tcpopt *to, u_char68optlen += TCPOLEN_NOP;69*optp++ = TCPOPT_NOP;70}71- if (TCP_MAXOLEN - optlen < 2 + TCPOLEN_SACK)72+ if (TCP_MAXOLEN - optlen < TCPOLEN_SACKHDR + TCPOLEN_SACK)73continue;74optlen += TCPOLEN_SACKHDR;75*optp++ = TCPOPT_SACK;76@@ -1386,9 +1396,15 @@ tcp_addoptions(struct tcpopt *to, u_char77optlen += TCPOLEN_EOL;78*optp++ = TCPOPT_EOL;79}80+ /*81+ * According to RFC 793 (STD0007):82+ * "The content of the header beyond the End-of-Option option83+ * must be header padding (i.e., zero)."84+ * and later: "The padding is composed of zeros."85+ */86while (optlen % 4) {87- optlen += TCPOLEN_NOP;88- *optp++ = TCPOPT_NOP;89+ optlen += TCPOLEN_PAD;90+ *optp++ = TCPOPT_PAD;91}9293KASSERT(optlen <= TCP_MAXOLEN, ("%s: TCP options too long", __func__));949596