Module Name:    src
Committed By:   martin
Date:           Fri Mar 30 11:17:19 UTC 2018

Modified Files:
        src/sys/netinet [netbsd-8]: tcp_input.c

Log Message:
Pull up following revision(s) (requested by maxv in ticket #662):

        sys/netinet/tcp_input.c: revision 1.383 (via patch)

Revert rev1.183 (2003).

It was intended as an optimization, but it increases the attack surface:

the IPsec policy is not enforced on RST packets when the socket is in the
LISTEN state, and an (unauthenticated) attacker could jam the connection
between two IPsec hosts by sending RST packets between the client's SYN
and ACK packets.

Discussed with ozaki-r@.


To generate a diff of this commit:
cvs rdiff -u -r1.357.4.2 -r1.357.4.3 src/sys/netinet/tcp_input.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/netinet/tcp_input.c
diff -u src/sys/netinet/tcp_input.c:1.357.4.2 src/sys/netinet/tcp_input.c:1.357.4.3
--- src/sys/netinet/tcp_input.c:1.357.4.2	Sat Oct 21 19:43:54 2017
+++ src/sys/netinet/tcp_input.c	Fri Mar 30 11:17:19 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: tcp_input.c,v 1.357.4.2 2017/10/21 19:43:54 snj Exp $	*/
+/*	$NetBSD: tcp_input.c,v 1.357.4.3 2018/03/30 11:17:19 martin Exp $	*/
 
 /*
  * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
@@ -148,7 +148,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.357.4.2 2017/10/21 19:43:54 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.357.4.3 2018/03/30 11:17:19 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1475,16 +1475,12 @@ findpcb:
 		}
 #if defined(IPSEC)
 		if (ipsec_used) {
-			if (inp &&
-			    (inp->inp_socket->so_options & SO_ACCEPTCONN) == 0
-			    && ipsec4_in_reject(m, inp)) {
+			if (inp && ipsec4_in_reject(m, inp)) {
 				IPSEC_STATINC(IPSEC_STAT_IN_POLVIO);
 				goto drop;
 			}
 #ifdef INET6
-			else if (in6p &&
-			    (in6p->in6p_socket->so_options & SO_ACCEPTCONN) == 0
-			    && ipsec6_in_reject(m, in6p)) {
+			else if (in6p && ipsec6_in_reject(m, in6p)) {
 				IPSEC_STATINC(IPSEC_STAT_IN_POLVIO);
 				goto drop;
 			}
@@ -1520,9 +1516,7 @@ findpcb:
 			goto dropwithreset_ratelim;
 		}
 #if defined(IPSEC)
-		if (ipsec_used && in6p
-		    && (in6p->in6p_socket->so_options & SO_ACCEPTCONN) == 0
-		    && ipsec6_in_reject(m, in6p)) {
+		if (ipsec_used && in6p && ipsec6_in_reject(m, in6p)) {
 			IPSEC6_STATINC(IPSEC_STAT_IN_POLVIO);
 			goto drop;
 		}
@@ -1830,39 +1824,6 @@ findpcb:
 				}
 #endif
 
-#if defined(IPSEC)
-				if (ipsec_used) {
-					switch (af) {
-#ifdef INET
-					case AF_INET:
-						/*
-						 * inp can be NULL when
-						 * receiving an IPv4 packet on
-						 * an IPv4-mapped IPv6 address.
-						 */
-						KASSERT(inp == NULL ||
-						    sotoinpcb(so) == inp);
-						if (!ipsec4_in_reject(m, inp))
-							break;
-						IPSEC_STATINC(
-						    IPSEC_STAT_IN_POLVIO);
-						tp = NULL;
-						goto dropwithreset;
-#endif
-#ifdef INET6
-					case AF_INET6:
-						KASSERT(sotoin6pcb(so) == in6p);
-						if (!ipsec6_in_reject(m, in6p))
-							break;
-						IPSEC6_STATINC(
-						    IPSEC_STAT_IN_POLVIO);
-						tp = NULL;
-						goto dropwithreset;
-#endif /*INET6*/
-					}
-				}
-#endif /*IPSEC*/
-
 				/*
 				 * LISTEN socket received a SYN
 				 * from itself?  This can't possibly

Reply via email to