Source-Changes-HG archive

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

[src/trunk]: src/sys/netinet Fix KASSERT in tcp_input



details:   https://anonhg.NetBSD.org/src/rev/6b3189ec2c5c
branches:  trunk
changeset: 824805:6b3189ec2c5c
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Mon Jun 19 10:04:23 2017 +0000

description:
Fix KASSERT in tcp_input

inp can be NULL when receiving an IPv4 packet on an IPv4-mapped IPv6
address. In that case KASSERT(sotoinpcb(so) == inp) always fails.

Should fix PR kern/52304 (at least it fixes the same panic as the
report)

diffstat:

 sys/netinet/tcp_input.c |  12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diffs (33 lines):

diff -r 8ff8254e2930 -r 6b3189ec2c5c sys/netinet/tcp_input.c
--- a/sys/netinet/tcp_input.c   Mon Jun 19 09:49:07 2017 +0000
+++ b/sys/netinet/tcp_input.c   Mon Jun 19 10:04:23 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tcp_input.c,v 1.357 2017/04/20 08:46:07 ozaki-r Exp $  */
+/*     $NetBSD: tcp_input.c,v 1.358 2017/06/19 10:04:23 ozaki-r 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 2017/04/20 08:46:07 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tcp_input.c,v 1.358 2017/06/19 10:04:23 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1835,7 +1835,13 @@
                                        switch (af) {
 #ifdef INET
                                        case AF_INET:
-                                               KASSERT(sotoinpcb(so) == inp);
+                                               /*
+                                                * 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(



Home | Main Index | Thread Index | Old Index